aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/window.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-06-07 13:27:44 -0500
committerbors-servo <lbergstrom+bors@mozilla.com>2016-06-07 13:27:44 -0500
commit280bfc961a013bec58ba23d756db002b3e44fdef (patch)
tree1bf2fe8fe36edacd891606585259350b59147680 /components/script/dom/window.rs
parent1e3edf3ca454b91dfdc267c5b2f4347eda9b7cb6 (diff)
parent0769982ec30fabc45a7a52f83de184d9c6cb596a (diff)
downloadservo-280bfc961a013bec58ba23d756db002b3e44fdef.tar.gz
servo-280bfc961a013bec58ba23d756db002b3e44fdef.zip
Auto merge of #11644 - asajeffrey:mozbrowser-top-level-browsing-context, r=ConnerGBrewster
Mozbrowser top level browsing context <!-- Please describe your changes on the following line: --> Got `window.top` and `window.parent` to return the right result inside a `mozbrowser` iframe. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11644) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/window.rs')
-rw-r--r--components/script/dom/window.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 90c1ee1bdba..c8d327897d2 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -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> = {