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
Added a TopLevelBrowsingContextId type. #16916
Conversation
Heads up! This PR modifies the following files:
|
This is the next step in the effort to allow more than one root browsing context. cc @cbrewster @paulrouget |
r? @cbrewster |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
There was a problem hiding this comment.
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!
@@ -244,7 +244,6 @@ impl LayoutThreadFactory for LayoutThread { | |||
|
|||
/// Spawns a new layout thread. | |||
fn create(id: PipelineId, | |||
top_level_browsing_context_id: Option<BrowsingContextId>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay!
There was a problem hiding this comment.
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.
@@ -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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
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!
@@ -244,7 +244,6 @@ impl LayoutThreadFactory for LayoutThread { | |||
|
|||
/// Spawns a new layout thread. | |||
fn create(id: PipelineId, | |||
top_level_browsing_context_id: Option<BrowsingContextId>, |
There was a problem hiding this comment.
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.
@@ -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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
You can decide whether to switch to |
53174cb
to
273c474
Compare
Squashed. @bors-servo r=cbrewster |
📌 Commit 273c474 has been approved by |
…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 -->
💔 Test failed - mac-rel-wpt1 |
|
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... |
Figured it out...
When we were synchronously discarding a browsing context, we were calling |
273c474
to
4257736
Compare
@bors-servo r=cbrewster |
📌 Commit 4257736 has been approved by |
…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 -->
☀️ 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 |
Added a
TopLevelBrowsingContextId
type, which is a subtype ofBrowsingContextId
that only refers to top-level browsing contexts../mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is