Skip to content

Commit

Permalink
updated-for-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MunishMummadi committed Mar 28, 2024
1 parent fc1e8a4 commit 76b9588
Show file tree
Hide file tree
Showing 30 changed files with 1,096 additions and 48 deletions.
89 changes: 42 additions & 47 deletions components/layout_2020/flow/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ use style::properties::ComputedValues;
use style::values::computed::Length;
use style::values::generics::box_::VerticalAlignKeyword;
use style::values::generics::text::LineHeight;
use style::values::specified::box_::BaselineSource;
use style::values::specified::text::{TextAlignKeyword, TextDecorationLine};
use style::values::specified::{TextAlignLast, TextJustify};
use style::Zero;
Expand Down Expand Up @@ -384,9 +383,9 @@ impl LineBlockSizes {
None => {
// This is the case mentinoned above where there are multiple solutions.
// This code is putting the baseline roughly in the middle of the line.
let leading = Au::from(self.resolve()) -
(self.size_for_baseline_positioning.ascent +
self.size_for_baseline_positioning.descent);
let leading = Au::from(self.resolve())

This comment has been minimized.

Copy link
@mrobinson

mrobinson Mar 28, 2024

Member

I think the changes in this file are unintentional. Please undo them.

This comment has been minimized.

Copy link
@MunishMummadi

MunishMummadi Mar 28, 2024

Author Contributor

These changes are unintended. I ran the commands suggested in #31904

This comment has been minimized.

Copy link
@mrobinson

mrobinson Mar 28, 2024

Member

It's possible that your IDE formatted your code, but Servo does not use default rustfmt formatting. You simply need to run ./mach fmt again and then amend your previous commit.

This comment has been minimized.

Copy link
@MunishMummadi

MunishMummadi Mar 28, 2024

Author Contributor

@mrobinson Sorry for the trouble. I thought I am updating tests. Won't repeat again.

- (self.size_for_baseline_positioning.ascent
+ self.size_for_baseline_positioning.descent);
leading.scale_by(0.5) + self.size_for_baseline_positioning.ascent
},
}
Expand Down Expand Up @@ -723,8 +722,8 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {

if inline_box.is_first_fragment {
self.current_line.inline_position += Length::from(
inline_box_state.pbm.padding.inline_start +
inline_box_state.pbm.border.inline_start,
inline_box_state.pbm.padding.inline_start
+ inline_box_state.pbm.border.inline_start,
) + inline_box_state
.pbm
.margin
Expand Down Expand Up @@ -808,9 +807,9 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
let had_inline_advance =
self.current_line.inline_position != self.current_line.start_position.inline;

let effective_block_advance = if self.current_line.has_content ||
had_inline_advance ||
self.linebreak_before_new_content
let effective_block_advance = if self.current_line.has_content
|| had_inline_advance
|| self.linebreak_before_new_content
{
self.current_line_max_block_size_including_nested_containers()
} else {
Expand Down Expand Up @@ -971,8 +970,8 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
// line box."
let text_indent = self.current_line.start_position.inline;
let line_length = self.current_line.inline_position - whitespace_trimmed - text_indent;
let adjusted_line_start = line_start +
match text_align {
let adjusted_line_start = line_start
+ match text_align {
TextAlign::Start => text_indent,
TextAlign::End => (available_space - line_length).max(text_indent),
TextAlign::Center => {
Expand All @@ -992,8 +991,8 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
match self.current_line.count_justification_opportunities() {
0 => Length::zero(),
num_justification_opportunities => {
(available_space - text_indent - line_length) /
(num_justification_opportunities as f32)
(available_space - text_indent - line_length)
/ (num_justification_opportunities as f32)
},
}
},
Expand All @@ -1014,8 +1013,8 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
.expect("Tried to lay out a float with no sequential placement state!");

let block_offset_from_containining_block_top = state
.current_block_position_including_margins() -
state.current_containing_block_offset();
.current_block_position_including_margins()
- state.current_containing_block_offset();
state.place_float_fragment(
fragment,
CollapsedMargin::zero(),
Expand Down Expand Up @@ -1152,8 +1151,8 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
if !can_break {
// Even if we cannot break, adding content to this line might change its position.
// In that case we need to redo our placement among floats.
if self.sequential_layout_state.is_some() &&
(inline_would_overflow || block_would_overflow)
if self.sequential_layout_state.is_some()
&& (inline_would_overflow || block_would_overflow)
{
let new_placement = self.place_line_among_floats(potential_line_size);
self.current_line
Expand All @@ -1176,8 +1175,9 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
// If we have a limited block size then we are wedging this line between floats.
assert!(self.sequential_layout_state.is_some());
let new_placement = self.place_line_among_floats(potential_line_size);
if new_placement.start_corner.block !=
self.current_line
if new_placement.start_corner.block
!= self
.current_line
.line_block_start_considering_placement_among_floats()
.into()
{
Expand Down Expand Up @@ -1369,8 +1369,8 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
}

let potential_line_size = LogicalVec2 {
inline: self.current_line.inline_position + self.current_line_segment.inline_size -
self.current_line_segment.trailing_whitespace_size,
inline: self.current_line.inline_position + self.current_line_segment.inline_size
- self.current_line_segment.trailing_whitespace_size,
block: self
.current_line_max_block_size_including_nested_containers()
.max(&self.current_line_segment.max_block_size)
Expand Down Expand Up @@ -1673,9 +1673,9 @@ impl InlineFormattingContext {

let mut collapsible_margins_in_children = CollapsedBlockMargins::zero();
let content_block_size = ifc.current_line.start_position.block;
collapsible_margins_in_children.collapsed_through = !ifc.had_inflow_content &&
content_block_size == Length::zero() &&
collapsible_with_parent_start_margin.0;
collapsible_margins_in_children.collapsed_through = !ifc.had_inflow_content
&& content_block_size == Length::zero()
&& collapsible_with_parent_start_margin.0;

FlowLayout {
fragments: ifc.fragments,
Expand Down Expand Up @@ -1891,15 +1891,15 @@ impl InlineContainerState {
) -> Au {
let block_size =
self.get_block_size_contribution(child_vertical_align.clone(), &self.font_metrics);
self.baseline_offset +
match child_vertical_align {
self.baseline_offset
+ match child_vertical_align {
// `top` and `bottom are not actually relative to the baseline, but this value is unused
// in those cases.
// TODO: We should distinguish these from `baseline` in order to implement "aligned subtrees" properly.
// See https://drafts.csswg.org/css2/#aligned-subtree.
VerticalAlign::Keyword(VerticalAlignKeyword::Baseline) |
VerticalAlign::Keyword(VerticalAlignKeyword::Top) |
VerticalAlign::Keyword(VerticalAlignKeyword::Bottom) => Au::zero(),
VerticalAlign::Keyword(VerticalAlignKeyword::Baseline)
| VerticalAlign::Keyword(VerticalAlignKeyword::Top)
| VerticalAlign::Keyword(VerticalAlignKeyword::Bottom) => Au::zero(),
VerticalAlign::Keyword(VerticalAlignKeyword::Sub) => Au::from_f32_px(
block_size
.resolve()
Expand All @@ -1918,14 +1918,14 @@ impl InlineContainerState {
VerticalAlign::Keyword(VerticalAlignKeyword::Middle) => {
// "Align the vertical midpoint of the box with the baseline of the parent
// box plus half the x-height of the parent."
(child_block_size.size_for_baseline_positioning.ascent -
child_block_size.size_for_baseline_positioning.descent -
self.font_metrics.x_height)
(child_block_size.size_for_baseline_positioning.ascent
- child_block_size.size_for_baseline_positioning.descent
- self.font_metrics.x_height)
.scale_by(0.5)
},
VerticalAlign::Keyword(VerticalAlignKeyword::TextBottom) => {
self.font_metrics.descent -
child_block_size.size_for_baseline_positioning.descent
self.font_metrics.descent
- child_block_size.size_for_baseline_positioning.descent
},
VerticalAlign::Length(length_percentage) => {
Au::from_f32_px(-length_percentage.resolve(child_block_size.line_height).px())
Expand Down Expand Up @@ -2144,18 +2144,13 @@ impl IndependentFormattingContext {
/// Picks either the first or the last baseline, depending on `baseline-source`.
/// <https://drafts.csswg.org/css-inline/#baseline-source>
fn pick_baseline(&self, baselines: &Baselines) -> Option<Au> {
match self.style().clone_baseline_source() {
BaselineSource::First => baselines.first,
BaselineSource::Last => baselines.last,
BaselineSource::Auto => {
if let Self::NonReplaced(non_replaced) = self {
if let NonReplacedFormattingContextContents::Flow(_) = non_replaced.contents {
return baselines.last;
}
}
baselines.first
},
// TODO: Currently this only supports the initial `baseline-source: auto`.
if let Self::NonReplaced(non_replaced) = self {
if let NonReplacedFormattingContextContents::Flow(_) = non_replaced.contents {
return baselines.last;
}
}
baselines.first
}

fn get_block_sizes_and_baseline_offset(
Expand Down Expand Up @@ -2248,8 +2243,8 @@ fn effective_vertical_align(
fn is_baseline_relative(vertical_align: VerticalAlign) -> bool {
!matches!(
vertical_align,
VerticalAlign::Keyword(VerticalAlignKeyword::Top) |
VerticalAlign::Keyword(VerticalAlignKeyword::Bottom)
VerticalAlign::Keyword(VerticalAlignKeyword::Top)
| VerticalAlign::Keyword(VerticalAlignKeyword::Bottom)
)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/wpt/include.ini
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ skip: true
[css-highlight-api]
skip: true
[css-inline]
skip: true
skip: false
[css-layout-api]
skip: true
[css-masking]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[baseline-source-first-001.html]
[.target > * 1]
expected: FAIL

[.target > * 3]
expected: FAIL

[.target > * 5]
expected: FAIL

[.target > * 7]
expected: FAIL

[.target > * 9]
expected: FAIL

[.target > * 10]
expected: FAIL

[.target > * 11]
expected: FAIL

[.target > * 13]
expected: FAIL

[.target > * 14]
expected: FAIL

[.target > * 15]
expected: FAIL

[.target > * 17]
expected: FAIL

[.target > * 19]
expected: FAIL

[.target > * 20]
expected: FAIL

[.target > * 21]
expected: FAIL
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[baseline-source-first-002.html]
[.target > * 1]
expected: FAIL

[.target > * 2]
expected: FAIL

[.target > * 3]
expected: FAIL

[.target > * 4]
expected: FAIL

[.target > * 5]
expected: FAIL

[.target > * 6]
expected: FAIL

[.target > * 7]
expected: FAIL

[.target > * 8]
expected: FAIL

[.target > * 9]
expected: FAIL

[.target > * 11]
expected: FAIL

[.target > * 12]
expected: FAIL

[.target > * 13]
expected: FAIL

[.target > * 15]
expected: FAIL

[.target > * 16]
expected: FAIL

[.target > * 17]
expected: FAIL

[.target > * 18]
expected: FAIL

[.target > * 19]
expected: FAIL

[.target > * 20]
expected: FAIL

[.target > * 21]
expected: FAIL

[.target > * 22]
expected: FAIL
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[baseline-source-first-003.html]
[.target > * 1]
expected: FAIL

[.target > * 2]
expected: FAIL

[.target > * 3]
expected: FAIL

[.target > * 4]
expected: FAIL

[.target > * 5]
expected: FAIL

[.target > * 6]
expected: FAIL

[.target > * 7]
expected: FAIL

[.target > * 8]
expected: FAIL

[.target > * 9]
expected: FAIL

[.target > * 11]
expected: FAIL

[.target > * 12]
expected: FAIL

[.target > * 13]
expected: FAIL

[.target > * 15]
expected: FAIL

[.target > * 16]
expected: FAIL

[.target > * 17]
expected: FAIL

[.target > * 18]
expected: FAIL

[.target > * 19]
expected: FAIL

[.target > * 20]
expected: FAIL

[.target > * 21]
expected: FAIL

[.target > * 22]
expected: FAIL
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[baseline-source-first-textarea-001.tentative.html]
[.target > * 1]
expected: FAIL

[.target > * 3]
expected: FAIL

[.target > * 5]
expected: FAIL

[.target > * 7]
expected: FAIL

[.target > * 9]
expected: FAIL

[.target > * 11]
expected: FAIL

0 comments on commit 76b9588

Please sign in to comment.