Auto merge of #29650 - Loirooriol:text-indent, r=mrobinson

Support text-indent in layout-2020

Existing WPT now passing:
  - _mozilla/css/text_indent_a.html
  - css/CSS2/css1/c71-fwd-parsing-002.xht
  - css/CSS2/css1/c71-fwd-parsing-004.xht
  - css/CSS2/floats-clear/floats-138.xht
  - css/CSS2/text/text-indent-007.xht
  - css/CSS2/text/text-indent-008.xht
  - css/CSS2/text/text-indent-010.xht
  - css/CSS2/text/text-indent-019.xht
  - css/CSS2/text/text-indent-020.xht
  - css/CSS2/text/text-indent-031.xht
  - css/CSS2/text/text-indent-032.xht
  - css/CSS2/text/text-indent-043.xht
  - css/CSS2/text/text-indent-044.xht
  - css/CSS2/text/text-indent-055.xht
  - css/CSS2/text/text-indent-056.xht
  - css/CSS2/text/text-indent-067.xht
  - css/CSS2/text/text-indent-068.xht
  - css/CSS2/text/text-indent-079.xht
  - css/CSS2/text/text-indent-080.xht
  - css/CSS2/text/text-indent-091.xht
  - css/CSS2/text/text-indent-092.xht
  - css/CSS2/text/text-indent-103.xht
  - css/CSS2/text/text-indent-104.xht
  - css/CSS2/text/text-indent-112.xht
  - css/CSS2/text/text-indent-113.xht
  - css/CSS2/text/text-indent-115.xht
  - css/CSS2/text/text-indent-applies-to-002.xht
  - css/CSS2/text/text-indent-applies-to-003.xht
  - css/CSS2/text/text-indent-applies-to-005.xht
  - css/CSS2/text/text-indent-applies-to-006.xht
  - css/CSS2/text/text-indent-applies-to-007.xht
  - css/CSS2/text/text-indent-applies-to-008.xht
  - css/CSS2/text/text-indent-applies-to-009.xht
  - css/CSS2/text/text-indent-applies-to-010.xht
  - css/CSS2/text/text-indent-applies-to-011.xht
  - css/CSS2/text/text-indent-applies-to-014.xht
  - css/CSS2/text/text-indent-applies-to-015.xht
  - css/CSS2/text/text-indent-inherited-001.xht
  - css/CSS2/text/text-indent-overflow-001.xht
  - css/CSS2/text/text-indent-overflow-002.xht
  - css/CSS2/text/text-indent-overflow-003.xht
  - css/CSS2/text/text-indent-overflow-004.xht
  - css/CSS2/text/text-indent-wrap-001.xht
  - css/css-text-decor/text-shadow/textindent.html
  - css/css-text/text-indent/text-indent-percentage-001.xht
  - css/css-text/text-indent/text-indent-percentage-002.html
  - css/css-text/text-indent/text-indent-percentage-003.html
  - css/css-text/text-indent/text-indent-percentage-004.html
  - css/css-values/minmax-length-percent-serialize.html
  - css/css-values/minmax-length-serialize.html

Also improvements in:
  - _mozilla/mozilla/calc.html
  - css/css-text/animations/text-indent-interpolation.html
  - css/css-text/inheritance.html
  - css/css-text/parsing/text-indent-computed.html
  - css/css-text/parsing/text-indent-valid.html
  - css/css-transitions/properties-value-implicit-001.html
  - css/css-values/animations/calc-interpolation.html
  - css/css-values/minmax-percentage-serialize.html
  - css/css-values/viewport-units-css2-001.html
  - css/css-variables/variable-substitution-basic.html
  - css/cssom/serialize-values.html

Existing WPT now failing, due to lack of direction, outside list markers,
flex and grid:
  - css/CSS2/text/text-indent-rtl-001.xht
  - css/CSS2/text/text-indent-rtl-002.xht
  - css/css-pseudo/marker-content-023.html
  - css/css-text/text-indent/anonymous-flex-item-001.html
  - css/css-text/text-indent/anonymous-grid-item-001.html

New WPT tests:
 - css/css-text/text-indent/text-indent-length-001.html
 - css/css-text/text-indent/text-indent-length-002.html
   This one fails in layout-2013.

<!-- 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 #29649 (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. -->
This commit is contained in:
bors-servo 2023-04-26 01:11:55 +02:00 committed by GitHub
commit 7114b31cf7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
75 changed files with 213 additions and 805 deletions

View file

@ -63,6 +63,7 @@ impl BlockFormattingContext {
let ifc = InlineFormattingContext {
inline_level_boxes,
text_decoration_line,
has_first_formatted_line: true,
};
let contents = BlockContainer::InlineFormattingContext(ifc);
let bfc = Self {
@ -187,7 +188,10 @@ impl BlockContainer {
context,
info,
block_level_boxes: Vec::new(),
ongoing_inline_formatting_context: InlineFormattingContext::new(text_decoration_line),
ongoing_inline_formatting_context: InlineFormattingContext::new(
text_decoration_line,
/* has_first_formatted_line = */ true,
),
ongoing_inline_boxes_stack: Vec::new(),
anonymous_style: None,
contains_floats: ContainsFloats::No,
@ -690,6 +694,8 @@ where
.is_empty()
{
// There should never be an empty inline formatting context.
self.ongoing_inline_formatting_context
.has_first_formatted_line = false;
return;
}

View file

@ -35,6 +35,9 @@ use webrender_api::FontInstanceKey;
pub(crate) struct InlineFormattingContext {
pub(super) inline_level_boxes: Vec<ArcRefCell<InlineLevelBox>>,
pub(super) text_decoration_line: TextDecorationLine,
// Whether this IFC contains the 1st formatted line of an element
// https://www.w3.org/TR/css-pseudo-4/#first-formatted-line
pub(super) has_first_formatted_line: bool,
}
#[derive(Debug, Serialize)]
@ -130,10 +133,14 @@ struct Lines {
}
impl InlineFormattingContext {
pub(super) fn new(text_decoration_line: TextDecorationLine) -> InlineFormattingContext {
pub(super) fn new(
text_decoration_line: TextDecorationLine,
has_first_formatted_line: bool,
) -> InlineFormattingContext {
InlineFormattingContext {
inline_level_boxes: Default::default(),
text_decoration_line,
has_first_formatted_line,
}
}
@ -273,7 +280,16 @@ impl InlineFormattingContext {
fragments: Vec::new(),
next_line_block_position: Length::zero(),
},
inline_position: Length::zero(),
inline_position: if self.has_first_formatted_line {
containing_block
.style
.get_inherited_text()
.text_indent
.to_used_value(containing_block.inline_size.into())
.into()
} else {
Length::zero()
},
current_nesting_level: InlineNestingLevelState {
remaining_boxes: InlineBoxChildIter::from_formatting_context(self),
fragments_so_far: Vec::with_capacity(self.inline_level_boxes.len()),