servo: Merge #14978 - Implemented display: inline-flex (from shinglyu:inline-flex); r=notriddle

<!-- 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 #14685 (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: c75946c3ed52d262aae585055023becd5a2e9769
This commit is contained in:
Shing Lyu 2017-01-22 19:57:49 -08:00
Родитель 8d91d8e444
Коммит 4821e9de84
5 изменённых файлов: 28 добавлений и 10 удалений

Просмотреть файл

@ -567,7 +567,7 @@ impl BlockFlow {
} else { } else {
BlockType::FloatNonReplaced BlockType::FloatNonReplaced
} }
} else if self.is_inline_block() { } else if self.is_inline_block_or_inline_flex() {
if self.fragment.is_replaced() { if self.fragment.is_replaced() {
BlockType::InlineBlockReplaced BlockType::InlineBlockReplaced
} else { } else {
@ -1558,8 +1558,9 @@ impl BlockFlow {
debug_assert_eq!(self.fragment.margin_box_inline_size(), self.base.position.size.inline); debug_assert_eq!(self.fragment.margin_box_inline_size(), self.base.position.size.inline);
} }
fn is_inline_block(&self) -> bool { fn is_inline_block_or_inline_flex(&self) -> bool {
self.fragment.style().get_box().display == display::T::inline_block self.fragment.style().get_box().display == display::T::inline_block ||
self.fragment.style().get_box().display == display::T::inline_flex
} }
/// Computes the content portion (only) of the intrinsic inline sizes of this flow. This is /// Computes the content portion (only) of the intrinsic inline sizes of this flow. This is

Просмотреть файл

@ -937,9 +937,14 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
ConstructionResult::ConstructionItem(construction_item) ConstructionResult::ConstructionItem(construction_item)
} }
fn build_fragment_for_inline_block(&mut self, node: &ConcreteThreadSafeLayoutNode) /// Build the fragment for an inline-block or inline-flex, based on the `display` flag
-> ConstructionResult { fn build_fragment_for_inline_block_or_inline_flex(&mut self, node: &ConcreteThreadSafeLayoutNode,
let block_flow_result = self.build_flow_for_block(node, None); display: display::T) -> ConstructionResult {
let block_flow_result = match display {
display::T::inline_block => self.build_flow_for_block(node, None),
display::T::inline_flex => self.build_flow_for_flex(node, None),
_ => panic!("The flag should be inline-block or inline-flex")
};
let (block_flow, abs_descendants) = match block_flow_result { let (block_flow, abs_descendants) = match block_flow_result {
ConstructionResult::Flow(block_flow, abs_descendants) => (block_flow, abs_descendants), ConstructionResult::Flow(block_flow, abs_descendants) => (block_flow, abs_descendants),
_ => unreachable!() _ => unreachable!()
@ -1548,7 +1553,8 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS
// Inline-block items contribute inline fragment construction results. // Inline-block items contribute inline fragment construction results.
(display::T::inline_block, float::T::none, _) => { (display::T::inline_block, float::T::none, _) => {
let construction_result = self.build_fragment_for_inline_block(node); let construction_result = self.build_fragment_for_inline_block_or_inline_flex(node,
display::T::inline_block);
self.set_flow_construction_result(node, construction_result) self.set_flow_construction_result(node, construction_result)
} }
@ -1597,6 +1603,12 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS
self.set_flow_construction_result(node, construction_result) self.set_flow_construction_result(node, construction_result)
} }
(display::T::inline_flex, _, _) => {
let construction_result = self.build_fragment_for_inline_block_or_inline_flex(node,
display::T::inline_flex);
self.set_flow_construction_result(node, construction_result)
}
// Block flows that are not floated contribute block flow construction results. // Block flows that are not floated contribute block flow construction results.
// //
// TODO(pcwalton): Make this only trigger for blocks and handle the other `display` // TODO(pcwalton): Make this only trigger for blocks and handle the other `display`

Просмотреть файл

@ -1151,6 +1151,7 @@ impl InlineFlow {
match (display_value, vertical_align_value) { match (display_value, vertical_align_value) {
(display::T::inline, vertical_align::T::top) | (display::T::inline, vertical_align::T::top) |
(display::T::block, vertical_align::T::top) | (display::T::block, vertical_align::T::top) |
(display::T::inline_flex, vertical_align::T::top) |
(display::T::inline_block, vertical_align::T::top) if (display::T::inline_block, vertical_align::T::top) if
inline_metrics.space_above_baseline >= Au(0) => { inline_metrics.space_above_baseline >= Au(0) => {
*largest_block_size_for_top_fragments = max( *largest_block_size_for_top_fragments = max(
@ -1159,6 +1160,7 @@ impl InlineFlow {
} }
(display::T::inline, vertical_align::T::bottom) | (display::T::inline, vertical_align::T::bottom) |
(display::T::block, vertical_align::T::bottom) | (display::T::block, vertical_align::T::bottom) |
(display::T::inline_flex, vertical_align::T::bottom) |
(display::T::inline_block, vertical_align::T::bottom) if (display::T::inline_block, vertical_align::T::bottom) if
inline_metrics.space_below_baseline >= Au(0) => { inline_metrics.space_below_baseline >= Au(0) => {
*largest_block_size_for_bottom_fragments = max( *largest_block_size_for_bottom_fragments = max(

Просмотреть файл

@ -19,10 +19,11 @@
values = """inline block inline-block values = """inline block inline-block
table inline-table table-row-group table-header-group table-footer-group table inline-table table-row-group table-header-group table-footer-group
table-row table-column-group table-column table-cell table-caption table-row table-column-group table-column table-cell table-caption
list-item flex none list-item flex inline-flex
none
""".split() """.split()
if product == "gecko": if product == "gecko":
values += """inline-flex grid inline-grid ruby ruby-base ruby-base-container values += """grid inline-grid ruby ruby-base ruby-base-container
ruby-text ruby-text-container contents flow-root -webkit-box ruby-text ruby-text-container contents flow-root -webkit-box
-webkit-inline-box -moz-box -moz-inline-box -moz-grid -moz-inline-grid -webkit-inline-box -moz-box -moz-inline-box -moz-grid -moz-inline-grid
-moz-grid-group -moz-grid-line -moz-stack -moz-inline-stack -moz-deck -moz-grid-group -moz-grid-line -moz-stack -moz-inline-stack -moz-deck

Просмотреть файл

@ -1953,8 +1953,10 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
let is_item = matches!(context.inherited_style.get_box().clone_display(), let is_item = matches!(context.inherited_style.get_box().clone_display(),
% if product == "gecko": % if product == "gecko":
computed_values::display::T::grid | computed_values::display::T::grid |
computed_values::display::T::inline_grid |
% endif % endif
computed_values::display::T::flex); computed_values::display::T::flex |
computed_values::display::T::inline_flex);
let (blockify_root, blockify_item) = match flags.contains(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) { let (blockify_root, blockify_item) = match flags.contains(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) {
false => (is_root_element, is_item), false => (is_root_element, is_item),
true => (false, false), true => (false, false),