Skip to content

Added a TopLevelBrowsingContextId type. - #16916

Merged
bors-servo merged 1 commit into
servo:masterfrom
asajeffrey:constellation-top-level-browsing-contexts
May 22, 2017
Merged

bors-servo merged 1 commit into
servo:masterfrom
asajeffrey:constellation-top-level-browsing-contexts

Conversation

@asajeffrey

@asajeffrey asajeffrey commented May 17, 2017 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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 highfive added the S-awaiting-review There is new code that needs to be reviewed. label May 17, 2017
@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!

@asajeffrey

Copy link
Copy Markdown
Contributor Author

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

@asajeffrey asajeffrey added the A-constellation Involves the constellation label May 17, 2017
@asajeffrey

Copy link
Copy Markdown
Contributor Author

r? @cbrewster

@cbrewster cbrewster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

/// 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can only iterate an entire tree.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

/// 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

/// 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


/// 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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@cbrewster cbrewster added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 18, 2017
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels May 19, 2017

@asajeffrey asajeffrey left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes made.

}

/// 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

/// 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

/// 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// 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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

// 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy Markdown
Contributor

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 constellation-top-level-browsing-contexts branch from 53174cb to 273c474 Compare May 19, 2017 17:45
@asajeffrey

Copy link
Copy Markdown
Contributor Author

Squashed. @bors-servo r=cbrewster

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 273c474 has been approved by cbrewster

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 19, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 273c474 with merge 09d18dd...

bors-servo pushed 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
Copy Markdown
Contributor

💔 Test failed - mac-rel-wpt1

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels May 20, 2017
@cbrewster

Copy link
Copy Markdown
Contributor
Details
  ▶ 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
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor Author

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 constellation-top-level-browsing-contexts branch from 273c474 to 4257736 Compare May 22, 2017 14:27
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels May 22, 2017
@asajeffrey

Copy link
Copy Markdown
Contributor Author

@bors-servo r=cbrewster

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 4257736 has been approved by cbrewster

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 22, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 4257736 with merge a0d6d68...

bors-servo pushed 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
Copy Markdown
Contributor

☀️ 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
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label May 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-constellation Involves the constellation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants