-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc1e8a4
commit 76b9588
Showing
30 changed files
with
1,096 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
MunishMummadi
Author
Contributor
|
||
- (self.size_for_baseline_positioning.ascent | ||
+ self.size_for_baseline_positioning.descent); | ||
leading.scale_by(0.5) + self.size_for_baseline_positioning.ascent | ||
}, | ||
} | ||
|
@@ -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 | ||
|
@@ -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 { | ||
|
@@ -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 => { | ||
|
@@ -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) | ||
}, | ||
} | ||
}, | ||
|
@@ -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(), | ||
|
@@ -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 | ||
|
@@ -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() | ||
{ | ||
|
@@ -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) | ||
|
@@ -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, | ||
|
@@ -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() | ||
|
@@ -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()) | ||
|
@@ -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( | ||
|
@@ -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) | ||
) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
.../wpt/meta-legacy-layout/css/css-inline/baseline-source/baseline-source-first-001.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
60 changes: 60 additions & 0 deletions
60
.../wpt/meta-legacy-layout/css/css-inline/baseline-source/baseline-source-first-002.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
60 changes: 60 additions & 0 deletions
60
.../wpt/meta-legacy-layout/css/css-inline/baseline-source/baseline-source-first-003.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
18 changes: 18 additions & 0 deletions
18
...yout/css/css-inline/baseline-source/baseline-source-first-textarea-001.tentative.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.
I think the changes in this file are unintentional. Please undo them.