Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdded a TopLevelBrowsingContextId type. #16916
Conversation
highfive
commented
May 17, 2017
|
Heads up! This PR modifies the following files:
|
highfive
commented
May 17, 2017
|
This is the next step in the effort to allow more than one root browsing context. cc @cbrewster @paulrouget |
|
r? @cbrewster |
|
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| @@ -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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| { | ||
| 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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| @@ -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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| @@ -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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
|
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.
This comment has been minimized.
| { | ||
| 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.
This comment has been minimized.
| @@ -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.
This comment has been minimized.
| @@ -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.
This comment has been minimized.
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
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.
This comment has been minimized.
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.
This comment has been minimized.
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.
|
You can decide whether to switch to |
53174cb
to
273c474
|
Squashed. @bors-servo r=cbrewster |
|
|
…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 -->
|
|
|
|
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
|
@bors-servo r=cbrewster |
|
|
…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 -->
|
|
asajeffrey commentedMay 17, 2017
•
edited by larsbergstrom
Added a
TopLevelBrowsingContextIdtype, which is a subtype ofBrowsingContextIdthat only refers to top-level browsing contexts../mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is