diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-01-10 04:48:31 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-10 04:48:31 -0800 |
commit | dabb79c7878fce31b8b979dd5fcfdfb8713a9d80 (patch) | |
tree | 0ad536fc842868eb80081dde7513c151fe037ae2 /components/layout/traversal.rs | |
parent | f54dd0112bd9e51b21e9a5ee38bb2cfc0326e071 (diff) | |
parent | 29876d2703336fc74a3857854839badc1bb58ceb (diff) | |
download | servo-dabb79c7878fce31b8b979dd5fcfdfb8713a9d80.tar.gz servo-dabb79c7878fce31b8b979dd5fcfdfb8713a9d80.zip |
Auto merge of #14603 - mrobinson:collect-scoll-roots, r=emilio
Rework the way scroll roots are collected
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because they should not change behavior.
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Collect scroll roots during the collect_stacking_context phase instead
of during display list construction. This will be useful in order to
collect containing block scroll roots as well as to give scroll roots
sequential ids in the future. This change also pulls stacking context
children out of the StackingContext struct itself, which should reduce
very slightly the memory used by the finished display list. This also
simplifies the DisplayListBuilder because it no longer has to maintain
a stack of ScrollRootIds and StackingContextIds and can instead just
rely on the program stack.
<!-- 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/14603)
<!-- Reviewable:end -->
Diffstat (limited to 'components/layout/traversal.rs')
-rw-r--r-- | components/layout/traversal.rs | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index 0f7b1a3d89d..0b65d78df15 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -232,17 +232,11 @@ pub struct BuildDisplayList<'a> { impl<'a> BuildDisplayList<'a> { #[inline] pub fn traverse(&mut self, flow: &mut Flow) { - let new_stacking_context = - flow::base(flow).stacking_context_id != self.state.stacking_context_id(); - if new_stacking_context { - self.state.push_stacking_context_id(flow::base(flow).stacking_context_id); - } + let parent_stacking_context_id = self.state.current_stacking_context_id; + self.state.current_stacking_context_id = flow::base(flow).stacking_context_id; - let new_scroll_root = - flow::base(flow).scroll_root_id != self.state.scroll_root_id(); - if new_scroll_root { - self.state.push_scroll_root_id(flow::base(flow).scroll_root_id); - } + let parent_scroll_root_id = self.state.current_scroll_root_id; + self.state.current_scroll_root_id = flow::base(flow).scroll_root_id; if self.should_process() { flow.build_display_list(&mut self.state); @@ -253,13 +247,8 @@ impl<'a> BuildDisplayList<'a> { self.traverse(kid); } - if new_stacking_context { - self.state.pop_stacking_context_id(); - } - - if new_scroll_root { - self.state.pop_scroll_root_id(); - } + self.state.current_stacking_context_id = parent_stacking_context_id; + self.state.current_scroll_root_id = parent_scroll_root_id; } #[inline] |