Skip to content

Commit 0d896a8

Browse files
author
bors-servo
authored
Auto merge of #13996 - servo:about-blank, r=Ms2ger,jdm,asajeffrey,nox
Implement synchronous about:blank loading. Based on initial work by jdm in <#8600>. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13996) <!-- Reviewable:end -->
2 parents 9a45252 + 6075d0e commit 0d896a8

File tree

103 files changed

+552
-937
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+552
-937
lines changed

components/constellation/constellation.rs

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use rand::{Rng, SeedableRng, StdRng, random};
4242
use script_traits::{AnimationState, AnimationTickType, CompositorEvent};
4343
use script_traits::{ConstellationControlMsg, ConstellationMsg as FromCompositorMsg};
4444
use script_traits::{DocumentState, LayoutControlMsg, LoadData};
45-
use script_traits::{IFrameLoadInfo, IFrameSandboxState, TimerEventRequest};
45+
use script_traits::{IFrameLoadInfo, IFrameLoadInfoWithData, IFrameSandboxState, TimerEventRequest};
4646
use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, ScriptThreadFactory};
4747
use script_traits::{LogEntry, ServiceWorkerMsg, webdriver_msg};
4848
use script_traits::{MozBrowserErrorType, MozBrowserEvent, WebDriverCommandMsg, WindowSizeData};
@@ -914,11 +914,17 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
914914
}
915915
FromScriptMsg::ScriptLoadedURLInIFrame(load_info) => {
916916
debug!("constellation got iframe URL load message {:?} {:?} {:?}",
917-
load_info.parent_pipeline_id,
917+
load_info.info.parent_pipeline_id,
918918
load_info.old_pipeline_id,
919-
load_info.new_pipeline_id);
919+
load_info.info.new_pipeline_id);
920920
self.handle_script_loaded_url_in_iframe_msg(load_info);
921921
}
922+
FromScriptMsg::ScriptLoadedAboutBlankInIFrame(load_info, lc) => {
923+
debug!("constellation got loaded `about:blank` in iframe message {:?} {:?}",
924+
load_info.parent_pipeline_id,
925+
load_info.new_pipeline_id);
926+
self.handle_script_loaded_about_blank_in_iframe_msg(load_info, lc);
927+
}
922928
FromScriptMsg::ChangeRunningAnimationsState(pipeline_id, animation_state) => {
923929
self.handle_change_running_animations_state(pipeline_id, animation_state)
924930
}
@@ -1363,14 +1369,14 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
13631369
// will result in a new pipeline being spawned and a frame tree being added to
13641370
// parent_pipeline_id's frame tree's children. This message is never the result of a
13651371
// page navigation.
1366-
fn handle_script_loaded_url_in_iframe_msg(&mut self, load_info: IFrameLoadInfo) {
1372+
fn handle_script_loaded_url_in_iframe_msg(&mut self, load_info: IFrameLoadInfoWithData) {
13671373
let (load_data, window_size, is_private) = {
13681374
let old_pipeline = load_info.old_pipeline_id
13691375
.and_then(|old_pipeline_id| self.pipelines.get(&old_pipeline_id));
13701376

1371-
let source_pipeline = match self.pipelines.get(&load_info.parent_pipeline_id) {
1377+
let source_pipeline = match self.pipelines.get(&load_info.info.parent_pipeline_id) {
13721378
Some(source_pipeline) => source_pipeline,
1373-
None => return warn!("Script loaded url in closed iframe {}.", load_info.parent_pipeline_id),
1379+
None => return warn!("Script loaded url in closed iframe {}.", load_info.info.parent_pipeline_id),
13741380
};
13751381

13761382
// If no url is specified, reload.
@@ -1384,7 +1390,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
13841390
LoadData::new(url, None, None)
13851391
});
13861392

1387-
let is_private = load_info.is_private || source_pipeline.is_private;
1393+
let is_private = load_info.info.is_private || source_pipeline.is_private;
13881394

13891395
let window_size = old_pipeline.and_then(|old_pipeline| old_pipeline.size);
13901396

@@ -1396,20 +1402,65 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
13961402
};
13971403

13981404
// Create the new pipeline, attached to the parent and push to pending frames
1399-
self.new_pipeline(load_info.new_pipeline_id,
1400-
load_info.frame_id,
1401-
Some((load_info.parent_pipeline_id, load_info.frame_type)),
1405+
self.new_pipeline(load_info.info.new_pipeline_id,
1406+
load_info.info.frame_id,
1407+
Some((load_info.info.parent_pipeline_id, load_info.info.frame_type)),
14021408
window_size,
14031409
load_data,
14041410
load_info.sandbox,
14051411
is_private);
14061412

14071413
self.pending_frames.push(FrameChange {
1408-
frame_id: load_info.frame_id,
1414+
frame_id: load_info.info.frame_id,
14091415
old_pipeline_id: load_info.old_pipeline_id,
1410-
new_pipeline_id: load_info.new_pipeline_id,
1416+
new_pipeline_id: load_info.info.new_pipeline_id,
1417+
document_ready: false,
1418+
replace: load_info.info.replace,
1419+
});
1420+
}
1421+
1422+
fn handle_script_loaded_about_blank_in_iframe_msg(&mut self,
1423+
load_info: IFrameLoadInfo,
1424+
layout_sender: IpcSender<LayoutControlMsg>) {
1425+
let IFrameLoadInfo {
1426+
parent_pipeline_id,
1427+
new_pipeline_id,
1428+
frame_type,
1429+
replace,
1430+
frame_id,
1431+
is_private,
1432+
} = load_info;
1433+
1434+
let pipeline = {
1435+
let parent_pipeline = match self.pipelines.get(&parent_pipeline_id) {
1436+
Some(parent_pipeline) => parent_pipeline,
1437+
None => return warn!("Script loaded url in closed iframe {}.", parent_pipeline_id),
1438+
};
1439+
1440+
let script_sender = parent_pipeline.script_chan.clone();
1441+
1442+
let url = ServoUrl::parse("about:blank").expect("infallible");
1443+
Pipeline::new(new_pipeline_id,
1444+
frame_id,
1445+
Some((parent_pipeline_id, frame_type)),
1446+
script_sender,
1447+
layout_sender,
1448+
self.compositor_proxy.clone_compositor_proxy(),
1449+
is_private || parent_pipeline.is_private,
1450+
url,
1451+
None,
1452+
parent_pipeline.visible)
1453+
};
1454+
1455+
assert!(!self.pipelines.contains_key(&new_pipeline_id));
1456+
self.pipelines.insert(new_pipeline_id, pipeline);
1457+
1458+
self.pending_frames.push(FrameChange {
1459+
frame_id: frame_id,
1460+
old_pipeline_id: None,
1461+
new_pipeline_id: new_pipeline_id,
14111462
document_ready: false,
1412-
replace: load_info.replace,
1463+
replace: replace,
14131464
});
14141465
}
14151466

components/constellation/pipeline.rs

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ impl Pipeline {
165165
load_data: state.load_data.clone(),
166166
window_size: window_size,
167167
pipeline_port: pipeline_port,
168-
layout_to_constellation_chan: state.layout_to_constellation_chan.clone(),
169-
content_process_shutdown_chan: layout_content_process_shutdown_chan.clone(),
168+
content_process_shutdown_chan: Some(layout_content_process_shutdown_chan.clone()),
170169
layout_threads: PREFS.get("layout.threads").as_u64().expect("count") as usize,
171170
};
172171

@@ -254,23 +253,23 @@ impl Pipeline {
254253
state.window_size,
255254
state.prev_visibility.unwrap_or(true));
256255

257-
pipeline.notify_visibility();
258-
259256
Ok((pipeline, child_process))
260257
}
261258

262-
fn new(id: PipelineId,
263-
frame_id: FrameId,
264-
parent_info: Option<(PipelineId, FrameType)>,
265-
script_chan: Rc<ScriptChan>,
266-
layout_chan: IpcSender<LayoutControlMsg>,
267-
compositor_proxy: Box<CompositorProxy + 'static + Send>,
268-
is_private: bool,
269-
url: ServoUrl,
270-
size: Option<TypedSize2D<f32, PagePx>>,
271-
visible: bool)
272-
-> Pipeline {
273-
Pipeline {
259+
/// Creates a new `Pipeline`, after the script and layout threads have been
260+
/// spawned.
261+
pub fn new(id: PipelineId,
262+
frame_id: FrameId,
263+
parent_info: Option<(PipelineId, FrameType)>,
264+
script_chan: Rc<ScriptChan>,
265+
layout_chan: IpcSender<LayoutControlMsg>,
266+
compositor_proxy: Box<CompositorProxy + 'static + Send>,
267+
is_private: bool,
268+
url: ServoUrl,
269+
size: Option<TypedSize2D<f32, PagePx>>,
270+
visible: bool)
271+
-> Pipeline {
272+
let pipeline = Pipeline {
274273
id: id,
275274
frame_id: frame_id,
276275
parent_info: parent_info,
@@ -284,7 +283,11 @@ impl Pipeline {
284283
running_animations: false,
285284
visible: visible,
286285
is_private: is_private,
287-
}
286+
};
287+
288+
pipeline.notify_visibility();
289+
290+
pipeline
288291
}
289292

290293
pub fn exit(&self) {
@@ -424,6 +427,7 @@ impl UnprivilegedPipelineContent {
424427
control_chan: self.script_chan.clone(),
425428
control_port: self.script_port,
426429
constellation_chan: self.constellation_chan,
430+
layout_to_constellation_chan: self.layout_to_constellation_chan.clone(),
427431
scheduler_chan: self.scheduler_chan,
428432
bluetooth_thread: self.bluetooth_thread,
429433
resource_threads: self.resource_threads,
@@ -448,7 +452,7 @@ impl UnprivilegedPipelineContent {
448452
self.font_cache_thread,
449453
self.time_profiler_chan,
450454
self.mem_profiler_chan,
451-
self.layout_content_process_shutdown_chan,
455+
Some(self.layout_content_process_shutdown_chan),
452456
self.webrender_api_sender,
453457
self.prefs.get("layout.threads").expect("exists").value()
454458
.as_u64().expect("count") as usize);

components/layout_thread/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ impl LayoutThreadFactory for LayoutThread {
246246
font_cache_thread: FontCacheThread,
247247
time_profiler_chan: time::ProfilerChan,
248248
mem_profiler_chan: mem::ProfilerChan,
249-
content_process_shutdown_chan: IpcSender<()>,
249+
content_process_shutdown_chan: Option<IpcSender<()>>,
250250
webrender_api_sender: webrender_traits::RenderApiSender,
251251
layout_threads: usize) {
252252
thread::spawn_named(format!("LayoutThread {:?}", id),
@@ -278,7 +278,9 @@ impl LayoutThreadFactory for LayoutThread {
278278
layout.start();
279279
}, reporter_name, sender, Msg::CollectReports);
280280
}
281-
let _ = content_process_shutdown_chan.send(());
281+
if let Some(content_process_shutdown_chan) = content_process_shutdown_chan {
282+
let _ = content_process_shutdown_chan.send(());
283+
}
282284
});
283285
}
284286
}

components/layout_traits/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub trait LayoutThreadFactory {
4444
font_cache_thread: FontCacheThread,
4545
time_profiler_chan: time::ProfilerChan,
4646
mem_profiler_chan: mem::ProfilerChan,
47-
content_process_shutdown_chan: IpcSender<()>,
47+
content_process_shutdown_chan: Option<IpcSender<()>>,
4848
webrender_api_sender: webrender_traits::RenderApiSender,
4949
layout_threads: usize);
5050
}

0 commit comments

Comments
 (0)