mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Auto merge of #18212 - mrobinson:position-sticky, r=emilio
Add support for position:sticky This leverages the position:sticky support in WebRender to bring basic support for position:sticky in Servo. There are still some issues with nested sticky flows as well as a few other corner cases. Tests are imported from WPT and can be removed once we update to the latest version. <!-- 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. --> <!-- 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/18212) <!-- Reviewable:end -->
This commit is contained in:
commit
f1fab036ab
84 changed files with 5729 additions and 50 deletions
|
@ -29,9 +29,9 @@
|
|||
|
||||
use app_units::{Au, MAX_AU};
|
||||
use context::LayoutContext;
|
||||
use display_list_builder::{BorderPaintingMode, DisplayListBuildState};
|
||||
use display_list_builder::BlockFlowDisplayListBuilding;
|
||||
use euclid::{Point2D, Size2D, Rect};
|
||||
use display_list_builder::{BlockFlowDisplayListBuilding, BorderPaintingMode};
|
||||
use display_list_builder::{DisplayListBuildState, EstablishContainingBlock};
|
||||
use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
|
||||
use floats::{ClearType, FloatKind, Floats, PlacementInfo};
|
||||
use flow::{self, BaseFlow, EarlyAbsolutePositionInfo, Flow, FlowClass, ForceNonfloatedFlag};
|
||||
use flow::{BLOCK_POSITION_IS_STATIC, CLEARS_LEFT, CLEARS_RIGHT};
|
||||
|
@ -54,7 +54,7 @@ use std::sync::Arc;
|
|||
use style::computed_values::{box_sizing, display, float, overflow_x};
|
||||
use style::computed_values::{position, text_align};
|
||||
use style::context::SharedStyleContext;
|
||||
use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
|
||||
use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::ComputedValues;
|
||||
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW};
|
||||
use style::values::computed::{LengthOrPercentageOrNone, LengthOrPercentage};
|
||||
|
@ -643,7 +643,7 @@ impl BlockFlow {
|
|||
&mut self.fragment
|
||||
}
|
||||
|
||||
pub fn stacking_relative_position(&self, coor: CoordinateSystem) -> Rect<Au> {
|
||||
pub fn stacking_relative_border_box(&self, coor: CoordinateSystem) -> Rect<Au> {
|
||||
return self.fragment.stacking_relative_border_box(
|
||||
&self.base.stacking_relative_position,
|
||||
&self.base.early_absolute_position_info.relative_containing_block_size,
|
||||
|
@ -1790,6 +1790,20 @@ impl BlockFlow {
|
|||
self.flags.contains(HAS_SCROLLING_OVERFLOW)
|
||||
}
|
||||
|
||||
// Return offset from original position because of `position: sticky`.
|
||||
pub fn sticky_position(&self) -> SideOffsets2D<MaybeAuto> {
|
||||
let containing_block_size = &self.base.early_absolute_position_info
|
||||
.relative_containing_block_size;
|
||||
let writing_mode = self.base.early_absolute_position_info.relative_containing_block_mode;
|
||||
let offsets = self.fragment.style().logical_position();
|
||||
let as_margins = LogicalMargin::new(writing_mode,
|
||||
MaybeAuto::from_style(offsets.block_start, containing_block_size.inline),
|
||||
MaybeAuto::from_style(offsets.inline_end, containing_block_size.inline),
|
||||
MaybeAuto::from_style(offsets.block_end, containing_block_size.inline),
|
||||
MaybeAuto::from_style(offsets.inline_start, containing_block_size.inline));
|
||||
as_margins.to_physical(writing_mode)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl Flow for BlockFlow {
|
||||
|
@ -2137,7 +2151,7 @@ impl Flow for BlockFlow {
|
|||
}
|
||||
|
||||
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
|
||||
self.collect_stacking_contexts_for_block(state);
|
||||
self.collect_stacking_contexts_for_block(state, EstablishContainingBlock::Yes);
|
||||
}
|
||||
|
||||
fn build_display_list(&mut self, state: &mut DisplayListBuildState) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue