aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2020-02-11 06:21:39 -0500
committerGitHub <noreply@github.com>2020-02-11 06:21:39 -0500
commitf3dbe7d388211ea899c0a84a21c8ae9bfb673c37 (patch)
tree00ca1adccec359235805cc97d4b2b6c5085687d9 /components
parent9f4b674fb5b277d2955c6851002e9c4e752f8f67 (diff)
parent63aae0178f3508349add959657864569ff790e05 (diff)
downloadservo-f3dbe7d388211ea899c0a84a21c8ae9bfb673c37.tar.gz
servo-f3dbe7d388211ea899c0a84a21c8ae9bfb673c37.zip
Auto merge of #25715 - mrobinson:position-fixed, r=SimonSapin
Improve position:fixed support in layout_2020 <!-- 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: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- 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. -->
Diffstat (limited to 'components')
-rw-r--r--components/layout_2020/display_list/mod.rs110
1 files changed, 67 insertions, 43 deletions
diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs
index fa193874892..2e1af55c9db 100644
--- a/components/layout_2020/display_list/mod.rs
+++ b/components/layout_2020/display_list/mod.rs
@@ -14,8 +14,10 @@ use mitochondria::OnceCell;
use net_traits::image_cache::UsePlaceholder;
use std::sync::Arc;
use style::computed_values::overflow_x::T as ComputedOverflow;
+use style::computed_values::position::T as ComputedPosition;
use style::dom::OpaqueNode;
use style::properties::ComputedValues;
+
use style::values::computed::{BorderStyle, Length, LengthPercentage};
use style::values::specified::ui::CursorKind;
use webrender_api::{self as wr, units};
@@ -244,51 +246,15 @@ impl<'a> BuilderForBoxFragment<'a> {
}
fn build(&mut self, builder: &mut DisplayListBuilder) {
- let hit_info = hit_info(&self.fragment.style, self.fragment.tag, Cursor::Default);
- if hit_info.is_some() {
- let mut common = builder.common_properties(self.border_rect);
- common.hit_info = hit_info;
- if let Some(clip_id) = self.border_edge_clip(builder) {
- common.clip_id = clip_id
- }
- builder.wr.push_hit_test(&common)
- }
-
- self.build_background(builder);
- self.build_border(builder);
-
builder.clipping_and_scrolling_scope(|builder| {
- let overflow_x = self.fragment.style.get_box().overflow_x;
- let overflow_y = self.fragment.style.get_box().overflow_y;
- let original_scroll_and_clip_info = builder.current_space_and_clip;
- if overflow_x != ComputedOverflow::Visible || overflow_y != ComputedOverflow::Visible {
- // TODO(mrobinson): We should use the correct fragment type, once we generate
- // fragments from ::before and ::after generated content selectors.
- let id = combine_id_with_fragment_type(
- self.fragment.tag.id() as usize,
- FragmentType::FragmentBody,
- ) as u64;
- let external_id = wr::ExternalScrollId(id, builder.wr.pipeline_id);
-
- let sensitivity = if ComputedOverflow::Hidden == overflow_x &&
- ComputedOverflow::Hidden == overflow_y
- {
- wr::ScrollSensitivity::Script
- } else {
- wr::ScrollSensitivity::ScriptAndInputEvents
- };
+ self.adjust_spatial_id_for_positioning(builder);
+ self.build_hit_test(builder);
+ self.build_background(builder);
+ self.build_border(builder);
- builder.current_space_and_clip = builder.wr.define_scroll_frame(
- &original_scroll_and_clip_info,
- Some(external_id),
- self.fragment.scrollable_overflow().to_webrender(),
- *self.padding_rect(),
- vec![], // complex_clips
- None, // image_mask
- sensitivity,
- wr::units::LayoutVector2D::zero(),
- );
- }
+ // We want to build the scroll frame after the background and border, because
+ // they shouldn't scroll with the rest of the box content.
+ self.build_scroll_frame_if_necessary(builder);
let content_rect = self
.fragment
@@ -301,6 +267,64 @@ impl<'a> BuilderForBoxFragment<'a> {
});
}
+ fn adjust_spatial_id_for_positioning(&self, builder: &mut DisplayListBuilder) {
+ if self.fragment.style.get_box().position != ComputedPosition::Fixed {
+ return;
+ }
+
+ // TODO(mrobinson): Eventually this should use the spatial id of the reference
+ // frame that is the parent of this one once we have full support for stacking
+ // contexts and transforms.
+ builder.current_space_and_clip.spatial_id =
+ wr::SpatialId::root_reference_frame(builder.wr.pipeline_id);
+ }
+
+ fn build_scroll_frame_if_necessary(&self, builder: &mut DisplayListBuilder) {
+ let overflow_x = self.fragment.style.get_box().overflow_x;
+ let overflow_y = self.fragment.style.get_box().overflow_y;
+ let original_scroll_and_clip_info = builder.current_space_and_clip;
+ if overflow_x != ComputedOverflow::Visible || overflow_y != ComputedOverflow::Visible {
+ // TODO(mrobinson): We should use the correct fragment type, once we generate
+ // fragments from ::before and ::after generated content selectors.
+ let id = combine_id_with_fragment_type(
+ self.fragment.tag.id() as usize,
+ FragmentType::FragmentBody,
+ ) as u64;
+ let external_id = wr::ExternalScrollId(id, builder.wr.pipeline_id);
+
+ let sensitivity = if ComputedOverflow::Hidden == overflow_x &&
+ ComputedOverflow::Hidden == overflow_y
+ {
+ wr::ScrollSensitivity::Script
+ } else {
+ wr::ScrollSensitivity::ScriptAndInputEvents
+ };
+
+ builder.current_space_and_clip = builder.wr.define_scroll_frame(
+ &original_scroll_and_clip_info,
+ Some(external_id),
+ self.fragment.scrollable_overflow().to_webrender(),
+ *self.padding_rect(),
+ vec![], // complex_clips
+ None, // image_mask
+ sensitivity,
+ wr::units::LayoutVector2D::zero(),
+ );
+ }
+ }
+
+ fn build_hit_test(&self, builder: &mut DisplayListBuilder) {
+ let hit_info = hit_info(&self.fragment.style, self.fragment.tag, Cursor::Default);
+ if hit_info.is_some() {
+ let mut common = builder.common_properties(self.border_rect);
+ common.hit_info = hit_info;
+ if let Some(clip_id) = self.border_edge_clip(builder) {
+ common.clip_id = clip_id
+ }
+ builder.wr.push_hit_test(&common)
+ }
+ }
+
fn build_background(&mut self, builder: &mut DisplayListBuilder) {
use style::values::computed::image::{Image, ImageLayer};
let b = self.fragment.style.get_background();