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 upRefactor to send iframe resize messages directly from layout thread to constellation #15129
Conversation
highfive
commented
Jan 20, 2017
|
Heads up! This PR modifies the following files:
|
| DisplayItem::Iframe(ref iframe) => { | ||
| let size = Size2D::new((*item).bounds().size.width.to_f32_px(), | ||
| (*item).bounds().size.height.to_f32_px()); | ||
| debug!("new iframe size: {:?}", size); |
This comment has been minimized.
This comment has been minimized.
cynicaldevil
Jan 20, 2017
Author
Contributor
Left this debug message because I thought it would be helpful, but can remove if its unneeded.
This comment has been minimized.
This comment has been minimized.
jdm
Jan 20, 2017
Member
Rather than iterating over the complete display list every time we build one, we should send this message when we create an iframe display item instead: https://dxr.mozilla.org/servo/rev/1f76aa6ef7ec7db0a0c40223874a72e8f4059deb/components/layout/display_list_builder.rs#1441
This comment has been minimized.
This comment has been minimized.
jdm
Jan 20, 2017
Member
In fact, we may want to consider batching up all of the iframe sizes that are discovered and sending them in a single message once the display list has been created, rather than one by one.
This comment has been minimized.
This comment has been minimized.
cynicaldevil
Jan 20, 2017
Author
Contributor
heh, I had thought of this but forgot all about it when I couldn't get those tests to pass....
| @@ -1089,6 +1083,12 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> | |||
| FromLayoutMsg::ChangeRunningAnimationsState(pipeline_id, animation_state) => { | |||
| self.handle_change_running_animations_state(pipeline_id, animation_state) | |||
| } | |||
| // The compositor discovered the size of a subframe. This needs to be reflected by all | |||
This comment has been minimized.
This comment has been minimized.
| DisplayItem::Iframe(ref iframe) => { | ||
| let size = Size2D::new((*item).bounds().size.width.to_f32_px(), | ||
| (*item).bounds().size.height.to_f32_px()); | ||
| debug!("new iframe size: {:?}", size); |
This comment has been minimized.
This comment has been minimized.
jdm
Jan 20, 2017
Member
Rather than iterating over the complete display list every time we build one, we should send this message when we create an iframe display item instead: https://dxr.mozilla.org/servo/rev/1f76aa6ef7ec7db0a0c40223874a72e8f4059deb/components/layout/display_list_builder.rs#1441
| warn!("Layout resize to constellation failed ({}).", e); | ||
| } | ||
| }, | ||
| _ => debug!("other!"), |
This comment has been minimized.
This comment has been minimized.
| // early exit if that occurs. | ||
| match self.pipelines.get_mut(&pipeline_id) { | ||
| Some(pipeline) => { | ||
| let result = match self.pipelines.get_mut(&pipeline_id) { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cynicaldevil
Jan 22, 2017
Author
Contributor
The compiler complains about having mutably borrowed self outside the closure if I use this. Besides, I can't use map here because result can be None even if pipeline is resolved, in the case where sizes are equal.
| @@ -32,6 +32,8 @@ use style_traits::viewport::ViewportConstraints; | |||
| pub enum LayoutMsg { | |||
| /// Indicates whether this pipeline is currently running animations. | |||
| ChangeRunningAnimationsState(PipelineId, AnimationState), | |||
| /// Inform the constellation of the size of the viewport. | |||
This comment has been minimized.
This comment has been minimized.
| DisplayItem::Iframe(ref iframe) => { | ||
| let size = Size2D::new((*item).bounds().size.width.to_f32_px(), | ||
| (*item).bounds().size.height.to_f32_px()); | ||
| debug!("new iframe size: {:?}", size); |
This comment has been minimized.
This comment has been minimized.
jdm
Jan 20, 2017
Member
In fact, we may want to consider batching up all of the iframe sizes that are discovered and sending them in a single message once the display list has been created, rather than one by one.
jrmuizel
commented
Jan 20, 2017
|
Indeed this will allow a nice cleanup. |
|
@jdm Added new changes. |
| // frame trees in the navigation context containing the subframe. | ||
| FromLayoutMsg::FrameSize(pipeline_id, size) => { | ||
| FromLayoutMsg::FrameSize(iframe_sizes) => { |
This comment has been minimized.
This comment has been minimized.
| } else { | ||
| None | ||
| iframe_sizes: Vec<(PipelineId, Size2D<f32>)>) { | ||
| for size_data in iframe_sizes { |
This comment has been minimized.
This comment has been minimized.
emilio
Jan 22, 2017
Member
nit: for (pipeline_id, untyped_size) in frame sizes.
Also, could we send the TypedSize2D through IPC directly? if not, why not?
| if let Err(e) = self.constellation_chan.send(msg) { | ||
| warn!("Layout resize to constellation failed ({}).", e); | ||
| } | ||
| iframe_sizes.push(((*iframe).iframe, size)); |
This comment has been minimized.
This comment has been minimized.
emilio
Jan 22, 2017
Member
This is still walking all the display list instead of doing it at display list building time. You should collect the sizes in build_fragment_type_specific_display_items in components/layout/display_list_builder.rs, under the Iframe branch.
For that, you probably want to add the vector of iframe sizes to DisplayListBuildState (in that same file), and send the sizes to the constellation once you're done building the display list.
| } | ||
| } | ||
|
|
||
| if iframe_sizes.len() > 0 { |
This comment has been minimized.
This comment has been minimized.
|
@emilio Fixed. |
b5d95ec
to
5feba01
|
The rest looks great to me, thanks for doing this @cynicaldevil! \o/ |
| @@ -105,6 +107,7 @@ pub struct DisplayListBuildState<'a> { | |||
| /// The current scroll root id, used to keep track of state when | |||
| /// recursively building and processing the display list. | |||
| pub current_scroll_root_id: ScrollRootId, | |||
| pub iframe_sizes: Vec<(PipelineId, TypedSize2D<f32, PagePx>)>, | |||
This comment has been minimized.
This comment has been minimized.
emilio
Jan 22, 2017
Member
Can you add a comment here, in the lines of:
/// The collection of sizes of iframe display items, needed to inform the constellation about iframe resizes.| @@ -1463,6 +1467,10 @@ impl FragmentDisplayListBuilding for Fragment { | |||
| iframe: fragment_info.pipeline_id, | |||
| }); | |||
|
|
|||
| let size = Size2D::new((item).bounds().size.width.to_f32_px(), | |||
This comment has been minimized.
This comment has been minimized.
| @@ -934,6 +934,14 @@ impl LayoutThread { | |||
| let origin = Rect::new(Point2D::new(Au(0), Au(0)), root_size); | |||
| build_state.root_stacking_context.bounds = origin; | |||
| build_state.root_stacking_context.overflow = origin; | |||
|
|
|||
| if !build_state.iframe_sizes.is_empty() { | |||
| let msg = ConstellationMsg::FrameSizes(build_state.iframe_sizes.clone()); | |||
This comment has been minimized.
This comment has been minimized.
emilio
Jan 22, 2017
Member
nit: Since the iframe sizes are not going to be useful, you can prevent the extra allocation doing the following:
let iframe_sizes = mem::replace(&mut build_state.iframe_sizes, vec![]);
let msg = ConstellationMsg::FrameSizes(iframe_sizes);You can also make that first line a method in DisplayListBuildState if you want, something along the lines of:
fn take_iframe_sizes(&mut self) -> Vec<..> {
mem::replace(..)
}But given it's only used here, it's not a big deal.
|
@bors-servo try |
Refactor to send iframe resize messages directly from layout thread to constellation <!-- Please describe your changes on the following line: --> --- <!-- 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 fix #14682. <!-- Either: --> r? @jdm passing tests: tests/wpt/mozilla/tests/css/matchMedia.html, tests/wpt/mozilla/tests/mozilla/window_resize_not_triggered_on_load.html, tests/wpt/mozilla/tests/mozilla/iframe/resize_after_load.html, tests/wpt/mozilla/tests/css/meta_viewport_resize.html <!-- 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/15129) <!-- Reviewable:end -->
|
Also, please do squash all the commits together :) |
|
|
5feba01
to
bca565a
|
Fixed and squashed the commits! |
| None => return, | ||
| None => None | ||
| }; | ||
| if let Some(Err(e)) = result { |
This comment has been minimized.
This comment has been minimized.
emilio
Jan 23, 2017
Member
We could handle this below send, and early return in the None case so this looks a bit clearer, but not a big deal.
This comment has been minimized.
This comment has been minimized.
cynicaldevil
Jan 23, 2017
Author
Contributor
That's actually not possible, the compiler complains about self being mutably borrowed in the match line; because self needs to be mutably borrowed again for handle_send_error. I had to resort to using this method then :)
This comment has been minimized.
This comment has been minimized.
|
@bors-servo r+ |
|
|
Refactor to send iframe resize messages directly from layout thread to constellation <!-- Please describe your changes on the following line: --> --- <!-- 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 fix #14682. <!-- Either: --> r? @jdm passing tests: tests/wpt/mozilla/tests/css/matchMedia.html, tests/wpt/mozilla/tests/mozilla/window_resize_not_triggered_on_load.html, tests/wpt/mozilla/tests/mozilla/iframe/resize_after_load.html, tests/wpt/mozilla/tests/css/meta_viewport_resize.html <!-- 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/15129) <!-- Reviewable:end -->
|
|
jrmuizel
commented
Jan 23, 2017
|
@cynicaldevil Thanks for doing this work! |
This is a followup to servo#15129, addressing my last review comment.
constellation: Cleanup the frame size handler. This is a followup to #15129, addressing my last review comment. r? anyone <!-- 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/15155) <!-- Reviewable:end -->
Revert several changes that broke tests This is based on #15158 by @aneeshusa, with additional reverts. This reverts #15064, which is causing many tests not to run, and #15129 and #15155 which landed while tests were not running and may have caused some new failures in iframe tests. <!-- 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/15164) <!-- Reviewable:end -->
Revert several changes that broke tests This is based on #15158 by @aneeshusa, with additional reverts. This reverts #15064, which is causing many tests not to run, and #15129 and #15155 which landed while tests were not running and may have caused some new failures in iframe tests. <!-- 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/15164) <!-- Reviewable:end -->
Revert several changes that broke tests This is based on #15158 by @aneeshusa, with additional reverts. This reverts #15064, which is causing many tests not to run, and #15129 and #15155 which landed while tests were not running and may have caused some new failures in iframe tests. <!-- 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/15164) <!-- Reviewable:end -->
cynicaldevil commentedJan 20, 2017
•
edited by larsbergstrom
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsr? @jdm
passing tests:
tests/wpt/mozilla/tests/css/matchMedia.html, tests/wpt/mozilla/tests/mozilla/window_resize_not_triggered_on_load.html, tests/wpt/mozilla/tests/mozilla/iframe/resize_after_load.html, tests/wpt/mozilla/tests/css/meta_viewport_resize.html
This change is