mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Window::Parent and Window::Top now return the right result inisde a mozbrowser iframe.
This commit is contained in:
parent
2e6711aa5f
commit
0769982ec3
15 changed files with 180 additions and 76 deletions
|
@ -29,7 +29,7 @@ encoding = "0.2"
|
|||
euclid = {version = "0.6.4", features = ["plugins"]}
|
||||
fnv = "1.0"
|
||||
gfx_traits = {path = "../gfx_traits"}
|
||||
heapsize = "0.3.0"
|
||||
heapsize = "0.3.6"
|
||||
heapsize_plugin = "0.1.2"
|
||||
html5ever = {version = "0.5.1", features = ["heap_size", "unstable"]}
|
||||
hyper = {version = "0.9", features = ["serde-serialization"]}
|
||||
|
|
|
@ -1259,7 +1259,7 @@ impl Document {
|
|||
|
||||
pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) {
|
||||
if mozbrowser_enabled() {
|
||||
if let Some((containing_pipeline_id, subpage_id)) = self.window.parent_info() {
|
||||
if let Some((containing_pipeline_id, subpage_id, _)) = self.window.parent_info() {
|
||||
let event = ConstellationMsg::MozBrowserEvent(containing_pipeline_id,
|
||||
subpage_id,
|
||||
event);
|
||||
|
|
|
@ -45,7 +45,7 @@ use js::rust::Runtime;
|
|||
use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow};
|
||||
use layout_interface::{LayoutRPC, Msg, Reflow, ReflowQueryType, MarginStyleResponse};
|
||||
use libc;
|
||||
use msg::constellation_msg::{LoadData, PanicMsg, PipelineId, SubpageId};
|
||||
use msg::constellation_msg::{FrameType, LoadData, PanicMsg, PipelineId, SubpageId};
|
||||
use msg::constellation_msg::{WindowSizeData, WindowSizeType};
|
||||
use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
|
||||
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
||||
|
@ -202,7 +202,7 @@ pub struct Window {
|
|||
id: PipelineId,
|
||||
|
||||
/// Subpage id associated with this page, if any.
|
||||
parent_info: Option<(PipelineId, SubpageId)>,
|
||||
parent_info: Option<(PipelineId, SubpageId, FrameType)>,
|
||||
|
||||
/// Global static data related to the DOM.
|
||||
dom_static: GlobalStaticData,
|
||||
|
@ -330,7 +330,7 @@ impl Window {
|
|||
self.parent_info.map(|p| p.1)
|
||||
}
|
||||
|
||||
pub fn parent_info(&self) -> Option<(PipelineId, SubpageId)> {
|
||||
pub fn parent_info(&self) -> Option<(PipelineId, SubpageId, FrameType)> {
|
||||
self.parent_info
|
||||
}
|
||||
|
||||
|
@ -1510,7 +1510,20 @@ impl Window {
|
|||
self.current_state.get() == WindowState::Alive
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#top-level-browsing-context
|
||||
pub fn is_top_level(&self) -> bool {
|
||||
match self.parent_info {
|
||||
Some((_, _, FrameType::IFrame)) => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#parent-browsing-context
|
||||
pub fn parent(&self) -> Option<Root<Window>> {
|
||||
if self.is_top_level() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let browsing_context = self.browsing_context();
|
||||
|
||||
browsing_context.frame_element().map(|frame_element| {
|
||||
|
@ -1559,7 +1572,7 @@ impl Window {
|
|||
timer_event_chan: IpcSender<TimerEvent>,
|
||||
layout_chan: Sender<Msg>,
|
||||
id: PipelineId,
|
||||
parent_info: Option<(PipelineId, SubpageId)>,
|
||||
parent_info: Option<(PipelineId, SubpageId, FrameType)>,
|
||||
window_size: Option<WindowSizeData>)
|
||||
-> Root<Window> {
|
||||
let layout_rpc: Box<LayoutRPC> = {
|
||||
|
|
|
@ -63,7 +63,7 @@ use js::jsval::UndefinedValue;
|
|||
use js::rust::Runtime;
|
||||
use layout_interface::{self, NewLayoutThreadInfo, ReflowQueryType};
|
||||
use mem::heap_size_of_self_and_children;
|
||||
use msg::constellation_msg::{LoadData, PanicMsg, PipelineId, PipelineNamespace};
|
||||
use msg::constellation_msg::{FrameType, LoadData, PanicMsg, PipelineId, PipelineNamespace};
|
||||
use msg::constellation_msg::{SubpageId, WindowSizeData, WindowSizeType};
|
||||
use msg::webdriver_msg::WebDriverScriptCommand;
|
||||
use net_traits::LoadData as NetLoadData;
|
||||
|
@ -130,7 +130,7 @@ struct InProgressLoad {
|
|||
/// The pipeline which requested this load.
|
||||
pipeline_id: PipelineId,
|
||||
/// The parent pipeline and child subpage associated with this load, if any.
|
||||
parent_info: Option<(PipelineId, SubpageId)>,
|
||||
parent_info: Option<(PipelineId, SubpageId, FrameType)>,
|
||||
/// The current window size associated with this pipeline.
|
||||
window_size: Option<WindowSizeData>,
|
||||
/// Channel to the layout thread associated with this pipeline.
|
||||
|
@ -146,7 +146,7 @@ struct InProgressLoad {
|
|||
impl InProgressLoad {
|
||||
/// Create a new InProgressLoad object.
|
||||
fn new(id: PipelineId,
|
||||
parent_info: Option<(PipelineId, SubpageId)>,
|
||||
parent_info: Option<(PipelineId, SubpageId, FrameType)>,
|
||||
layout_chan: Sender<layout_interface::Msg>,
|
||||
window_size: Option<WindowSizeData>,
|
||||
url: Url) -> InProgressLoad {
|
||||
|
@ -1126,6 +1126,7 @@ impl ScriptThread {
|
|||
containing_pipeline_id,
|
||||
new_pipeline_id,
|
||||
subpage_id,
|
||||
frame_type,
|
||||
load_data,
|
||||
paint_chan,
|
||||
panic_chan,
|
||||
|
@ -1163,7 +1164,7 @@ impl ScriptThread {
|
|||
.unwrap();
|
||||
|
||||
// Kick off the fetch for the new resource.
|
||||
let new_load = InProgressLoad::new(new_pipeline_id, Some((containing_pipeline_id, subpage_id)),
|
||||
let new_load = InProgressLoad::new(new_pipeline_id, Some((containing_pipeline_id, subpage_id, frame_type)),
|
||||
layout_chan, parent_window.window_size(),
|
||||
load_data.url.clone());
|
||||
self.start_page_load(new_load, load_data);
|
||||
|
@ -1459,7 +1460,7 @@ impl ScriptThread {
|
|||
}
|
||||
debug!("ScriptThread: loading {} on pipeline {:?}", incomplete.url, incomplete.pipeline_id);
|
||||
|
||||
let frame_element = incomplete.parent_info.and_then(|(parent_id, subpage_id)| {
|
||||
let frame_element = incomplete.parent_info.and_then(|(parent_id, subpage_id, _)| {
|
||||
// The root context may not exist yet, if the parent of this frame
|
||||
// exists in a different script thread.
|
||||
let root_context = self.browsing_context.get();
|
||||
|
@ -1565,7 +1566,7 @@ impl ScriptThread {
|
|||
// We have a new root frame tree.
|
||||
self.browsing_context.set(Some(&new_context));
|
||||
(new_context, ContextToRemove::Root)
|
||||
} else if let Some((parent, _)) = incomplete.parent_info {
|
||||
} else if let Some((parent, _, _)) = incomplete.parent_info {
|
||||
// Create a new context tree entry. This will be a child context.
|
||||
let new_context = BrowsingContext::new(&window, frame_element, incomplete.pipeline_id);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue