Skip to content
This repository has been archived by the owner on Jul 18, 2018. It is now read-only.

Commit

Permalink
[LayoutNG] Implement atomic inlines for LayoutNGInline
Browse files Browse the repository at this point in the history
This patch implements the initial support for atomic inlines in
LayoutNGInline.

Atomic inlines are the first type of objects in LayoutNGInline that
needs be laid out to compute in-flow inline size. NGLineBuilder now
keeps NGLayoutResult for atomic inlines while it builds a line box.

Some tests turned from false-passes to real-failures. Because atomic
inlines were not rendered before this patch, tests using images and
inline-blocks passed by comparing blank result with blank reference.

Some work are not included in this patch and will follow, such as:
* Keep NGBlockNode for atomic inlines in NGLayoutInlineItem.
* Use NGLayoutResult not only for layout but also for fragment
  generation.
* Margin, padding, borders.
* BreakToken if we support breaking atomic inlines[1].
* ...and obviously more.

[1] w3c/csswg-drafts#1111

BUG=636993

Review-Url: https://codereview.chromium.org/2745973002
Cr-Commit-Position: refs/heads/master@{#457673}
  • Loading branch information
kojiishi authored and Commit bot committed Mar 17, 2017
1 parent 32c86f9 commit 45bfc6a
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 42 deletions.
26 changes: 15 additions & 11 deletions third_party/WebKit/LayoutTests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ crbug.com/702006 virtual/disable-spinvalidation/paint/invalidation/compositing/s
# LayoutNG - is a new layout system for Blink.

#### css2.1/20110323
#### Passed: 222
#### Skipped: 187
#### Passed: 216
#### Skipped: 193
crbug.com/635619 virtual/layout_ng/css2.1/20110323/absolute-non-replaced-height-006.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/absolute-non-replaced-width-017.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/absolute-non-replaced-width-018.htm [ Skip ]
Expand Down Expand Up @@ -259,6 +259,7 @@ crbug.com/635619 virtual/layout_ng/css2.1/20110323/float-replaced-width-002.htm
crbug.com/635619 virtual/layout_ng/css2.1/20110323/float-replaced-width-006.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/float-replaced-width-011.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/floating-replaced-height-008.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/floats-001.html [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/floats-102.html [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/floats-149.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/floats-wrap-top-below-bfc-001l.htm [ Skip ]
Expand All @@ -267,9 +268,12 @@ crbug.com/635619 virtual/layout_ng/css2.1/20110323/floats-wrap-top-below-bfc-002
crbug.com/635619 virtual/layout_ng/css2.1/20110323/floats-wrap-top-below-bfc-002r.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/floats-wrap-top-below-bfc-003l.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/floats-wrap-top-below-bfc-003r.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/floats-wrap-top-below-inline-001l.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/floats-wrap-top-below-inline-002l.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/floats-wrap-top-below-inline-002r.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/floats-wrap-top-below-inline-003l.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/height-applies-to-010a.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/height-percentage-005.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/height-width-inline-table-001.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/height-width-table-001.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/inline-block-non-replaced-height-001.htm [ Skip ]
Expand Down Expand Up @@ -329,6 +333,7 @@ crbug.com/635619 virtual/layout_ng/css2.1/20110323/margin-collapse-clear-012.htm
crbug.com/635619 virtual/layout_ng/css2.1/20110323/margin-collapse-clear-013.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/margin-collapse-clear-014.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/margin-collapse-clear-015.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/max-height-percentage-003.html [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/outline-color-001.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/outline-color-applies-to-008.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/outline-color-applies-to-012.htm [ Skip ]
Expand All @@ -350,11 +355,12 @@ crbug.com/635619 virtual/layout_ng/css2.1/20110323/table-caption-optional-002.ht
crbug.com/635619 virtual/layout_ng/css2.1/20110323/table-height-algorithm-023.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/table-height-algorithm-024.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/text-indent-014.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/vertical-align-boxes-001.htm [ Skip ]
crbug.com/635619 virtual/layout_ng/css2.1/20110323/width-non-replaced-inline-001.htm [ Skip ]

#### fast/block/basic
#### Passed: 5
#### Skipped: 27
#### Passed: 6
#### Skipped: 26
crbug.com/635619 virtual/layout_ng/fast/block/basic/001.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/basic/002.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/basic/003.html [ Skip ]
Expand All @@ -372,7 +378,6 @@ crbug.com/635619 virtual/layout_ng/fast/block/basic/019.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/basic/020.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/basic/021.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/basic/adding-near-anonymous-block.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/basic/empty-anonymous-block-remove-crash.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/basic/fieldset-stretch-to-legend.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/basic/min-pref-width-nowrap-floats.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/basic/minheight.html [ Skip ]
Expand Down Expand Up @@ -450,8 +455,8 @@ crbug.com/635619 virtual/layout_ng/fast/block/margin-collapse/webkit-margin-coll
crbug.com/635619 virtual/layout_ng/fast/block/margin-collapse/webkit-margin-collapse-floats.html [ Skip ]

#### fast/block/float
#### Passed: 33
#### Skipped: 174
#### Passed: 35
#### Skipped: 172
crbug.com/635619 virtual/layout_ng/fast/block/float/001.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/002.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/003.html [ Skip ]
Expand Down Expand Up @@ -491,6 +496,7 @@ crbug.com/635619 virtual/layout_ng/fast/block/float/4145535Crash.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/add-abspos-before-float-in-block-children-block.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/add-float-back-to-anonymous-block-previous.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/add-float-back-to-anonymous-block.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/add-inline-before-float-and-after-anonymous-block.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/add-inline-before-float-in-block-children-block.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/add-inline-between-floats-with-preceding-anonymous-box.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/add-inline-to-block-flow-and-ensure-layout-on-containers-of-removed-floats.html [ Skip ]
Expand Down Expand Up @@ -548,6 +554,8 @@ crbug.com/635619 virtual/layout_ng/fast/block/float/float-reinsertion-failure.ht
crbug.com/635619 virtual/layout_ng/fast/block/float/float-reparent-during-detach-crash.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/float-should-dirty-line-even-when-it-doesnt-intersect-it-2.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/float-should-dirty-line-even-when-it-doesnt-intersect-it.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/float-should-dirty-line-when-adjacent-to-line-breaks-2.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/float-should-dirty-line-when-adjacent-to-line-breaks.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/floats-and-text-indent-rl.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/floats-and-text-indent.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/floats-do-not-overhang-from-block-formatting-context.html [ Skip ]
Expand Down Expand Up @@ -593,13 +601,11 @@ crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-after-height-dec
crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-float-add-in-static-position-block.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-float-add-in-static-position-block2.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-float-container-add-compositing.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-float-crashes-when-sibling-becomes-formatting-context.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-float-remove-from-absolute-position-block.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-float-remove-from-absolute-position-block2.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-float-remove-from-fixed-position-block.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-float-remove-from-fixed-position-block2.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-from-second-last-sibling.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-from-third-last-sibling.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-tall-block.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overlapping-floats-paint-hittest-order-1.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overlapping-floats-paint-hittest-order-2.html [ Skip ]
Expand Down Expand Up @@ -627,13 +633,11 @@ crbug.com/635619 virtual/layout_ng/fast/block/float/trailing-float.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/vertical-move-relayout.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/width-update-after-clear.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/clear-intruding-floats-when-moving-to-inline-parent-3.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/float-append-child-crash.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/float-list-changed-before-layout-crash.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/float-mark-descendants-for-layout-crash.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/float-not-removed-crash.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/float-should-dirty-line-even-when-it-doesnt-intersect-it-3.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/floats-not-cleared-from-grand-parents.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/intruding-float-not-removed-from-next-sibling-crash.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/line-break-after-white-space-crash.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/max-width-clear-float-with-overflow-hidden.html [ Skip ]
crbug.com/635619 virtual/layout_ng/fast/block/float/trailing-float-with-content.html [ Skip ]
Expand Down
12 changes: 8 additions & 4 deletions third_party/WebKit/Source/core/layout/ng/ng_inline_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,11 @@ LayoutUnit NGLayoutInlineItem::InlineSize(unsigned start, unsigned end) const {
return LayoutUnit();

if (!style_ || !shape_result_) {
// Bidi controls do not have widths.
// TODO(kojii): Atomic inline not supported yet.
DCHECK(start == start_offset_ && end == end_offset_);
DCHECK(!IsAtomicInlineLevel()) << "Use NGLineBuilder::InlineSize";
DCHECK(!layout_object_ ||
layout_object_->isFloatingOrOutOfFlowPositioned());
// Bidi controls and out-of-flow objects do not have in-flow widths.
return LayoutUnit();
}

Expand Down Expand Up @@ -250,7 +253,8 @@ void NGInlineNode::ShapeText() {
// Shape each item with the full context of the entire node.
HarfBuzzShaper shaper(text_content_.characters16(), text_content_.length());
for (auto& item : items_) {
// Skip object replacement characters and bidi control characters.
// Skip non-text items; e.g., bidi controls, atomic inlines, out-of-flow
// objects.
if (!item.style_)
continue;

Expand Down Expand Up @@ -305,7 +309,7 @@ MinMaxContentSize NGInlineNode::ComputeMinMaxContentSize() {
// max-content is the width without any line wrapping.
// TODO(kojii): Implement hard breaks (<br> etc.) to break.
for (const auto& item : items_)
sizes.max_content += item.InlineSize();
sizes.max_content += line_builder.InlineSize(item);

return sizes;
}
Expand Down
4 changes: 4 additions & 0 deletions third_party/WebKit/Source/core/layout/ng/ng_inline_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ class NGLayoutInlineItem {
const ComputedStyle* Style() const { return style_; }
LayoutObject* GetLayoutObject() const { return layout_object_; }

bool IsAtomicInlineLevel() const {
return layout_object_ && layout_object_->isAtomicInlineLevel();
}

void SetEndOffset(unsigned);

LayoutUnit InlineSize() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class NGInlineNodeTest : public RenderingTest {
RefPtr<const ComputedStyle> style_;
LayoutBlockFlow* layout_block_flow_ = nullptr;
LayoutObject* layout_object_ = nullptr;
FontCachePurgePreventer purge_preventer_;
};

#define TEST_ITEM_OFFSET_DIR(item, start, end, direction) \
Expand Down Expand Up @@ -218,6 +219,7 @@ TEST_F(NGInlineNodeTest, CreateLineBidiIsolate) {
style->font().update(nullptr);
NGInlineNodeForTest* node =
CreateBidiIsolateNode(CreateInlineNode(), style.get(), layout_object_);
node->ShapeText();
Vector<RefPtr<const NGPhysicalTextFragment>> fragments;
CreateLine(node, &fragments);
ASSERT_EQ(5u, fragments.size());
Expand Down
Loading

0 comments on commit 45bfc6a

Please sign in to comment.