mirror of
https://github.com/servo/servo.git
synced 2025-07-28 09:40:33 +01:00
Ensures that iframe navigation updates the parent iframe element subpage id.
This fixes the case of clicking a link in an iframe, going back, then clicking the link again.
This commit is contained in:
parent
5ce7d8accf
commit
06a79243a7
4 changed files with 40 additions and 0 deletions
|
@ -608,6 +608,16 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
// Set paint permissions correctly for the compositor layers.
|
// Set paint permissions correctly for the compositor layers.
|
||||||
self.revoke_paint_permission(prev_pipeline_id);
|
self.revoke_paint_permission(prev_pipeline_id);
|
||||||
self.send_frame_tree_and_grant_paint_permission();
|
self.send_frame_tree_and_grant_paint_permission();
|
||||||
|
|
||||||
|
// Update the owning iframe to point to the new subpage id.
|
||||||
|
// This makes things like contentDocument work correctly.
|
||||||
|
if let Some((parent_pipeline_id, subpage_id)) = pipeline_info {
|
||||||
|
let ScriptControlChan(ref script_chan) = self.pipeline(parent_pipeline_id).script_chan;
|
||||||
|
let (_, new_subpage_id) = self.pipeline(next_pipeline_id).parent_info.unwrap();
|
||||||
|
script_chan.send(ConstellationControlMsg::UpdateSubpageId(parent_pipeline_id,
|
||||||
|
subpage_id,
|
||||||
|
new_subpage_id)).unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_key_msg(&self, key: Key, state: KeyState, mods: KeyModifiers) {
|
fn handle_key_msg(&self, key: Key, state: KeyState, mods: KeyModifiers) {
|
||||||
|
|
|
@ -73,6 +73,7 @@ pub trait HTMLIFrameElementHelpers {
|
||||||
fn generate_new_subpage_id(self) -> (SubpageId, Option<SubpageId>);
|
fn generate_new_subpage_id(self) -> (SubpageId, Option<SubpageId>);
|
||||||
fn navigate_child_browsing_context(self, url: Url);
|
fn navigate_child_browsing_context(self, url: Url);
|
||||||
fn dispatch_mozbrowser_event(self, event_name: String, event_detail: Option<String>);
|
fn dispatch_mozbrowser_event(self, event_name: String, event_detail: Option<String>);
|
||||||
|
fn update_subpage_id(self, new_subpage_id: SubpageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
|
impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
|
||||||
|
@ -156,6 +157,10 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
|
||||||
event.fire(target);
|
event.fire(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_subpage_id(self, new_subpage_id: SubpageId) {
|
||||||
|
self.subpage_id.set(Some(new_subpage_id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLIFrameElement {
|
impl HTMLIFrameElement {
|
||||||
|
|
|
@ -652,6 +652,10 @@ impl ScriptTask {
|
||||||
subpage_id,
|
subpage_id,
|
||||||
event_name,
|
event_name,
|
||||||
event_detail),
|
event_detail),
|
||||||
|
ConstellationControlMsg::UpdateSubpageId(containing_pipeline_id,
|
||||||
|
old_subpage_id,
|
||||||
|
new_subpage_id) =>
|
||||||
|
self.handle_update_subpage_id(containing_pipeline_id, old_subpage_id, new_subpage_id),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,6 +821,25 @@ impl ScriptTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn handle_update_subpage_id(&self,
|
||||||
|
containing_pipeline_id: PipelineId,
|
||||||
|
old_subpage_id: SubpageId,
|
||||||
|
new_subpage_id: SubpageId) {
|
||||||
|
let borrowed_page = self.root_page();
|
||||||
|
|
||||||
|
let frame_element = borrowed_page.find(containing_pipeline_id).and_then(|page| {
|
||||||
|
let doc = page.document().root();
|
||||||
|
let doc: JSRef<Node> = NodeCast::from_ref(doc.r());
|
||||||
|
|
||||||
|
doc.traverse_preorder()
|
||||||
|
.filter_map(HTMLIFrameElementCast::to_ref)
|
||||||
|
.find(|node| node.subpage_id() == Some(old_subpage_id))
|
||||||
|
.map(Temporary::from_rooted)
|
||||||
|
}).root();
|
||||||
|
|
||||||
|
frame_element.unwrap().r().update_subpage_id(new_subpage_id);
|
||||||
|
}
|
||||||
|
|
||||||
/// Handles a notification that reflow completed.
|
/// Handles a notification that reflow completed.
|
||||||
fn handle_reflow_complete_msg(&self, pipeline_id: PipelineId, reflow_id: uint) {
|
fn handle_reflow_complete_msg(&self, pipeline_id: PipelineId, reflow_id: uint) {
|
||||||
debug!("Script: Reflow {:?} complete for {:?}", reflow_id, pipeline_id);
|
debug!("Script: Reflow {:?} complete for {:?}", reflow_id, pipeline_id);
|
||||||
|
|
|
@ -74,6 +74,8 @@ pub enum ConstellationControlMsg {
|
||||||
Navigate(PipelineId, SubpageId, LoadData),
|
Navigate(PipelineId, SubpageId, LoadData),
|
||||||
/// Requests the script task forward a mozbrowser event to an iframe it owns
|
/// Requests the script task forward a mozbrowser event to an iframe it owns
|
||||||
MozBrowserEvent(PipelineId, SubpageId, String, Option<String>),
|
MozBrowserEvent(PipelineId, SubpageId, String, Option<String>),
|
||||||
|
/// Updates the current subpage id of a given iframe
|
||||||
|
UpdateSubpageId(PipelineId, SubpageId, SubpageId),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for ConstellationControlMsg {
|
unsafe impl Send for ConstellationControlMsg {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue