Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a TopLevelBrowsingContextId type. #16916

Merged

Conversation

@asajeffrey
Copy link
Member

asajeffrey commented May 17, 2017

Added a TopLevelBrowsingContextId type, which is a subtype of BrowsingContextId that only refers to top-level browsing contexts.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes do not require tests because refactoring

This change is Reviewable

@highfive
Copy link

highfive commented May 17, 2017

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/htmliframeelement.rs, components/script/dom/document.rs, components/script/dom/windowproxy.rs, components/script/dom/node.rs, components/script_traits/script_msg.rs and 6 more
  • @KiChjang: components/script/dom/htmliframeelement.rs, components/script/dom/document.rs, components/script/dom/windowproxy.rs, components/script/dom/node.rs, components/script_traits/script_msg.rs and 6 more
@highfive
Copy link

highfive commented May 17, 2017

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
@asajeffrey
Copy link
Member Author

asajeffrey commented May 17, 2017

This is the next step in the effort to allow more than one root browsing context. cc @cbrewster @paulrouget

@asajeffrey
Copy link
Member Author

asajeffrey commented May 17, 2017

Copy link
Member

cbrewster left a comment

Looking good! +1 for more type safety

@@ -700,8 +685,8 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
/// Get an iterator for browsing contexts. Specify self.root_browsing context_id to
/// iterate the entire tree, or a specific browsing context id to iterate only that sub-tree.

This comment has been minimized.

@cbrewster

cbrewster May 18, 2017

Member

Update to state that this can only iterate a sub-tree

This comment has been minimized.

@asajeffrey

asajeffrey May 19, 2017

Author Member

Done.

@@ -710,11 +695,20 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
}

/// Get an iterator for browsing contexts. Specify self.root_browsing context_id to
/// iterate the entire tree, or a specific browsing context id to iterate only that sub-tree.

This comment has been minimized.

@cbrewster

cbrewster May 18, 2017

Member

This can only iterate an entire tree.

This comment has been minimized.

@asajeffrey

asajeffrey May 19, 2017

Author Member

Done.

{
self.fully_active_descendant_browsing_contexts_iter(BrowsingContextId::from(top_level_browsing_context_id))
}

/// Get an iterator for browsing contexts. Specify self.root_browsing_context_id to
/// iterate the entire tree, or a specific browsing context id to iterate only that sub-tree.

This comment has been minimized.

@cbrewster

cbrewster May 18, 2017

Member

Same as above

This comment has been minimized.

@asajeffrey

asajeffrey May 19, 2017

Author Member

Done.

@@ -723,28 +717,37 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
}

/// Get an iterator for browsing contexts. Specify self.root_browsing_context_id to
/// iterate the entire tree, or a specific browsing context id to iterate only that sub-tree.

This comment has been minimized.

@cbrewster

cbrewster May 18, 2017

Member

Same as above

This comment has been minimized.

@asajeffrey

asajeffrey May 19, 2017

Author Member

Done.

@@ -1862,17 +1892,20 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
// and pass the event to that script thread.
// If the pipeline lookup fails, it is because we have torn down the pipeline,
// so it is reasonable to silently ignore the event.
let browsing_context_id = self.pipelines.get(&pipeline_id).map(|pipeline| pipeline.browsing_context_id);
let top_level_browsing_context_id = self.pipelines.get(&pipeline_id)

This comment has been minimized.

@cbrewster

cbrewster May 18, 2017

Member

Nice catch!

This comment has been minimized.

@asajeffrey

asajeffrey May 19, 2017

Author Member

Yes, this is one of those odd cases that the extra typechecking helped with. Yay types!

@@ -244,7 +244,6 @@ impl LayoutThreadFactory for LayoutThread {

/// Spawns a new layout thread.
fn create(id: PipelineId,
top_level_browsing_context_id: Option<BrowsingContextId>,

This comment has been minimized.

This comment has been minimized.

@asajeffrey

asajeffrey May 19, 2017

Author Member

I remembered why we wanted this, which is for crash reporting, so that if a layout panic happens we know which top-level browsing context to blame.

@@ -104,7 +104,7 @@ pub struct InitialPipelineState {
pub browsing_context_id: BrowsingContextId,

/// The ID of the top-level browsing context that contains this Pipeline.
pub top_level_browsing_context_id: BrowsingContextId,
pub top_level_browsing_context_id: TopLevelBrowsingContextId,

This comment has been minimized.

@cbrewster

cbrewster May 18, 2017

Member

Is this still needed since the layout thread no longer needs it?

Copy link
Member Author

asajeffrey left a comment

Changes made.

@@ -710,11 +695,20 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
}

/// Get an iterator for browsing contexts. Specify self.root_browsing context_id to
/// iterate the entire tree, or a specific browsing context id to iterate only that sub-tree.

This comment has been minimized.

@asajeffrey

asajeffrey May 19, 2017

Author Member

Done.

{
self.fully_active_descendant_browsing_contexts_iter(BrowsingContextId::from(top_level_browsing_context_id))
}

/// Get an iterator for browsing contexts. Specify self.root_browsing_context_id to
/// iterate the entire tree, or a specific browsing context id to iterate only that sub-tree.

This comment has been minimized.

@asajeffrey

asajeffrey May 19, 2017

Author Member

Done.

@@ -723,28 +717,37 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
}

/// Get an iterator for browsing contexts. Specify self.root_browsing_context_id to
/// iterate the entire tree, or a specific browsing context id to iterate only that sub-tree.

This comment has been minimized.

@asajeffrey

asajeffrey May 19, 2017

Author Member

Done.

@@ -1862,17 +1892,20 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
// and pass the event to that script thread.
// If the pipeline lookup fails, it is because we have torn down the pipeline,
// so it is reasonable to silently ignore the event.
let browsing_context_id = self.pipelines.get(&pipeline_id).map(|pipeline| pipeline.browsing_context_id);
let top_level_browsing_context_id = self.pipelines.get(&pipeline_id)

This comment has been minimized.

@asajeffrey

asajeffrey May 19, 2017

Author Member

Yes, this is one of those odd cases that the extra typechecking helped with. Yay types!

@@ -244,7 +244,6 @@ impl LayoutThreadFactory for LayoutThread {

/// Spawns a new layout thread.
fn create(id: PipelineId,
top_level_browsing_context_id: Option<BrowsingContextId>,

This comment has been minimized.

@asajeffrey

asajeffrey May 19, 2017

Author Member

I remembered why we wanted this, which is for crash reporting, so that if a layout panic happens we know which top-level browsing context to blame.

@@ -1783,7 +1803,8 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
// Send to the explicitly focused pipeline (if it exists), or the root
// browsing context's current pipeline. If neither exist, fall back to sending to
// the compositor below.
let root_pipeline_id = self.browsing_contexts.get(&self.root_browsing_context_id)
let root_browsing_context_id = BrowsingContextId::from(self.root_browsing_context_id);
let root_pipeline_id = self.browsing_contexts.get(&root_browsing_context_id)

This comment has been minimized.

@cbrewster

cbrewster May 19, 2017

Member

I wonder if we could replace these occurrences with:

self.browsing_contexts.get(&self.root_browsing_context_id.into())

since From<T> for U implies Into<U> for T

This comment has been minimized.

@asajeffrey

asajeffrey May 19, 2017

Author Member

I prefer T::from(x) over x.into() just because I find it easier to read. x.into() is rather mysterious, it converts from one unnamed type to another unnamed type. YMMV.

@cbrewster
Copy link
Member

cbrewster commented May 19, 2017

You can decide whether to switch to .into() or keep using ::from. Other than that this looks good, so you can squash and r=me

@asajeffrey asajeffrey force-pushed the asajeffrey:constellation-top-level-browsing-contexts branch from 53174cb to 273c474 May 19, 2017
@asajeffrey
Copy link
Member Author

asajeffrey commented May 19, 2017

Squashed. @bors-servo r=cbrewster

@bors-servo
Copy link
Contributor

bors-servo commented May 19, 2017

📌 Commit 273c474 has been approved by cbrewster

@bors-servo
Copy link
Contributor

bors-servo commented May 20, 2017

Testing commit 273c474 with merge 09d18dd...

bors-servo added a commit that referenced this pull request May 20, 2017
…ntexts, r=cbrewster

Added a TopLevelBrowsingContextId type.

<!-- Please describe your changes on the following line: -->

Added a `TopLevelBrowsingContextId` type, which is a subtype of `BrowsingContextId` that only refers to top-level browsing contexts.

---
<!-- 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] These changes do not require tests because refactoring

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16916)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented May 20, 2017

💔 Test failed - mac-rel-wpt1

@cbrewster
Copy link
Member

cbrewster commented May 20, 2017

  ▶ Unexpected subtest result in /html/semantics/embedded-content/the-iframe-element/iframe-synchronously-discard.html:
  │ FAIL [expected PASS] IFrame discards are processed synchronously
  │   → assert_equals: grandchild should be discarded expected null but got object "[object Window]"
  │ 
  │ child.onload</grandchild.onload<@http://web-platform.test:8000/html/semantics/embedded-content/the-iframe-element/iframe-synchronously-discard.html:24:9
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1406:20
  └ Test.prototype.step_func/<@http://web-platform.test:8000/resources/testharness.js:1430:20
@asajeffrey
Copy link
Member Author

asajeffrey commented May 22, 2017

Well the good news is that I can replicate this locally. Not entirely sure how I broke synchronous iframe discarding, off to do some digging...

@asajeffrey
Copy link
Member Author

asajeffrey commented May 22, 2017

Figured it out...

$ git diff
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index 1c00f3e..0075521 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -806,9 +806,11 @@ impl VirtualMethods for HTMLIFrameElement {
         // when the `PipelineExit` message arrives.
         for exited_pipeline_id in exited_pipeline_ids {
             if let Some(exited_document) = ScriptThread::find_document(exited_pipeline_id) {
+                debug!("Discarding browsing context for pipeline {}", exited_pipeline_id);
                 exited_document.window().window_proxy().discard_browsing_context();
                 for exited_iframe in exited_document.iter_iframes() {
-                    exited_iframe.pipeline_id.set(None);
+                    debug!("Discarding nested browsing context");
+                    exited_iframe.destroy_nested_browsing_context();
                 }
             }
         }

When we were synchronously discarding a browsing context, we were calling exited_iframe.pipeline_id.set(None);, which used to do the job, but now should be exited_iframe.destroy_nested_browsing_context();.

@asajeffrey asajeffrey force-pushed the asajeffrey:constellation-top-level-browsing-contexts branch from 273c474 to 4257736 May 22, 2017
@asajeffrey
Copy link
Member Author

asajeffrey commented May 22, 2017

@bors-servo r=cbrewster

@bors-servo
Copy link
Contributor

bors-servo commented May 22, 2017

📌 Commit 4257736 has been approved by cbrewster

@asajeffrey asajeffrey mentioned this pull request May 22, 2017
3 of 3 tasks complete
@bors-servo
Copy link
Contributor

bors-servo commented May 22, 2017

Testing commit 4257736 with merge a0d6d68...

bors-servo added a commit that referenced this pull request May 22, 2017
…ntexts, r=cbrewster

Added a TopLevelBrowsingContextId type.

<!-- Please describe your changes on the following line: -->

Added a `TopLevelBrowsingContextId` type, which is a subtype of `BrowsingContextId` that only refers to top-level browsing contexts.

---
<!-- 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] These changes do not require tests because refactoring

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16916)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented May 22, 2017

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-msvc-dev
Approved by: cbrewster
Pushing a0d6d68 to master...

@bors-servo bors-servo merged commit 4257736 into servo:master May 22, 2017
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request May 22, 2017
4 of 5 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.