mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
Improve position:fixed support in layout_2020
This makes it so that position:fixed elements do not scroll with the rest of the contents, but does not tackle the rest of the issues with their positioning.
This commit is contained in:
parent
20b8edc625
commit
63aae0178f
4 changed files with 84 additions and 0 deletions
|
@ -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};
|
||||
|
@ -245,6 +247,7 @@ impl<'a> BuilderForBoxFragment<'a> {
|
|||
|
||||
fn build(&mut self, builder: &mut DisplayListBuilder) {
|
||||
builder.clipping_and_scrolling_scope(|builder| {
|
||||
self.adjust_spatial_id_for_positioning(builder);
|
||||
self.build_hit_test(builder);
|
||||
self.build_background(builder);
|
||||
self.build_border(builder);
|
||||
|
@ -264,6 +267,18 @@ 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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue