Commit 7881e321 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Add IsInlineBox and IsInline to NGPhysicalFragment

This patch adds IsInlineBox() and IsInline() to NGPhysicalFragment
as we need claer distinction of inline boxes in NGPaint.

Also anonymous fragment was removed. This fragment type was used
to create an anonymous fragment for inline children, where two
fragments are generated for one LayoutBlockFlow.  This was changed
to create line boxes directly under the parent box fragment in
line-by-line refactoring by ikilpatrick@.

One crash was upgraded to failure because the logic to determine
anonymous fragment was wrong when ::first-line was used, and now
it is gone.

Bug: 636993, 714962
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: Iac918830f1696789008376e77d36557e373236f8
Reviewed-on: https://chromium-review.googlesource.com/890878Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532531}
parent 481d3480
...@@ -2966,7 +2966,7 @@ crbug.com/714962 fast/css3-text/css3-text-decoration/text-underline-position/tex ...@@ -2966,7 +2966,7 @@ crbug.com/714962 fast/css3-text/css3-text-decoration/text-underline-position/tex
crbug.com/591099 fast/css3-text/css3-text-decoration/text-underline-position/text-underline-position-auto.html [ Failure ] crbug.com/591099 fast/css3-text/css3-text-decoration/text-underline-position/text-underline-position-auto.html [ Failure ]
crbug.com/591099 fast/css3-text/css3-text-decoration/text-underline-position/text-underline-position-cjk.html [ Failure ] crbug.com/591099 fast/css3-text/css3-text-decoration/text-underline-position/text-underline-position-cjk.html [ Failure ]
crbug.com/714962 fast/css3-text/css3-text-decoration/text-underline-position/text-underline-position-dynamic.html [ Failure ] crbug.com/714962 fast/css3-text/css3-text-decoration/text-underline-position/text-underline-position-dynamic.html [ Failure ]
crbug.com/714962 fast/css3-text/css3-text-decoration/text-underline-position/text-underline-position-subscript.html [ Crash ] crbug.com/714962 fast/css3-text/css3-text-decoration/text-underline-position/text-underline-position-subscript.html [ Failure ]
crbug.com/714962 fast/css3-text/css3-text-decoration/text-underline-position/text-underline-position-under-out-of-flow.html [ Failure ] crbug.com/714962 fast/css3-text/css3-text-decoration/text-underline-position/text-underline-position-under-out-of-flow.html [ Failure ]
crbug.com/714962 fast/css3-text/css3-text-decoration/text-underline-position/text-underline-position-under-vertical.html [ Failure ] crbug.com/714962 fast/css3-text/css3-text-decoration/text-underline-position/text-underline-position-under-vertical.html [ Failure ]
crbug.com/591099 fast/css3-text/css3-text-decoration/text-underline-position/text-underline-position-under.html [ Failure ] crbug.com/591099 fast/css3-text/css3-text-decoration/text-underline-position/text-underline-position-under.html [ Failure ]
......
...@@ -430,6 +430,7 @@ NGInlineLayoutStateStack::BoxData::CreateBoxFragment( ...@@ -430,6 +430,7 @@ NGInlineLayoutStateStack::BoxData::CreateBoxFragment(
// fragment builder so that it should not transform the coordinates for RTL. // fragment builder so that it should not transform the coordinates for RTL.
NGFragmentBuilder box(item->GetLayoutObject(), &style, style.GetWritingMode(), NGFragmentBuilder box(item->GetLayoutObject(), &style, style.GetWritingMode(),
TextDirection::kLtr); TextDirection::kLtr);
box.SetBoxType(NGPhysicalFragment::kInlineBox);
// Inline boxes have block start/end borders, even when its containing block // Inline boxes have block start/end borders, even when its containing block
// was fragmented. Fragmenting a line box in block direction is not // was fragmented. Fragmenting a line box in block direction is not
......
...@@ -21,6 +21,24 @@ ...@@ -21,6 +21,24 @@
namespace blink { namespace blink {
namespace {
NGPhysicalFragment::NGBoxType BoxTypeFromLayoutObject(
const LayoutObject* layout_object) {
DCHECK(layout_object);
if (layout_object->IsFloating())
return NGPhysicalFragment::NGBoxType::kFloating;
if (layout_object->IsOutOfFlowPositioned())
return NGPhysicalFragment::NGBoxType::kOutOfFlowPositioned;
if (layout_object->IsAtomicInlineLevel())
return NGPhysicalFragment::NGBoxType::kInlineBlock;
if (layout_object->IsInline())
return NGPhysicalFragment::NGBoxType::kInlineBox;
return NGPhysicalFragment::NGBoxType::kNormalBox;
}
} // namespace
NGFragmentBuilder::NGFragmentBuilder(NGLayoutInputNode node, NGFragmentBuilder::NGFragmentBuilder(NGLayoutInputNode node,
scoped_refptr<const ComputedStyle> style, scoped_refptr<const ComputedStyle> style,
WritingMode writing_mode, WritingMode writing_mode,
...@@ -201,18 +219,13 @@ void NGFragmentBuilder::AddOutOfFlowLegacyCandidate( ...@@ -201,18 +219,13 @@ void NGFragmentBuilder::AddOutOfFlowLegacyCandidate(
} }
NGPhysicalFragment::NGBoxType NGFragmentBuilder::BoxType() const { NGPhysicalFragment::NGBoxType NGFragmentBuilder::BoxType() const {
if (box_type_ != NGPhysicalFragment::NGBoxType::kNormalBox) if (box_type_ != NGPhysicalFragment::NGBoxType::kNormalBox) {
DCHECK_EQ(box_type_, BoxTypeFromLayoutObject(layout_object_));
return box_type_; return box_type_;
}
// When implicit, compute from LayoutObject. // When implicit, compute from LayoutObject.
if (!layout_object_ || layout_object_->Style() != &Style()) return BoxTypeFromLayoutObject(layout_object_);
return NGPhysicalFragment::NGBoxType::kAnonymousBox;
if (layout_object_->IsFloating())
return NGPhysicalFragment::NGBoxType::kFloating;
if (layout_object_->IsOutOfFlowPositioned())
return NGPhysicalFragment::NGBoxType::kOutOfFlowPositioned;
if (layout_object_->IsAtomicInlineLevel())
return NGPhysicalFragment::NGBoxType::kInlineBlock;
return NGPhysicalFragment::NGBoxType::kNormalBox;
} }
NGFragmentBuilder& NGFragmentBuilder::SetBoxType( NGFragmentBuilder& NGFragmentBuilder::SetBoxType(
......
...@@ -49,8 +49,7 @@ bool NGPhysicalBoxFragment::HasSelfPaintingLayer() const { ...@@ -49,8 +49,7 @@ bool NGPhysicalBoxFragment::HasSelfPaintingLayer() const {
const LayoutObject* layout_object = GetLayoutObject(); const LayoutObject* layout_object = GetLayoutObject();
DCHECK(layout_object); DCHECK(layout_object);
DCHECK(layout_object->IsBoxModelObject()); DCHECK(layout_object->IsBoxModelObject());
return ToLayoutBoxModelObject(layout_object)->HasSelfPaintingLayer() && return ToLayoutBoxModelObject(layout_object)->HasSelfPaintingLayer();
BoxType() != kAnonymousBox;
} }
bool NGPhysicalBoxFragment::ChildrenInline() const { bool NGPhysicalBoxFragment::ChildrenInline() const {
...@@ -62,15 +61,14 @@ bool NGPhysicalBoxFragment::ChildrenInline() const { ...@@ -62,15 +61,14 @@ bool NGPhysicalBoxFragment::ChildrenInline() const {
bool NGPhysicalBoxFragment::HasOverflowClip() const { bool NGPhysicalBoxFragment::HasOverflowClip() const {
const LayoutObject* layout_object = GetLayoutObject(); const LayoutObject* layout_object = GetLayoutObject();
DCHECK(layout_object); DCHECK(layout_object);
return layout_object->HasOverflowClip() && BoxType() != kAnonymousBox; return layout_object->HasOverflowClip();
} }
bool NGPhysicalBoxFragment::ShouldClipOverflow() const { bool NGPhysicalBoxFragment::ShouldClipOverflow() const {
const LayoutObject* layout_object = GetLayoutObject(); const LayoutObject* layout_object = GetLayoutObject();
DCHECK(layout_object); DCHECK(layout_object);
return layout_object->IsBox() && return layout_object->IsBox() &&
ToLayoutBox(layout_object)->ShouldClipOverflow() && ToLayoutBox(layout_object)->ShouldClipOverflow();
BoxType() != kAnonymousBox;
} }
NGPhysicalOffsetRect NGPhysicalBoxFragment::SelfVisualRect() const { NGPhysicalOffsetRect NGPhysicalBoxFragment::SelfVisualRect() const {
......
...@@ -46,6 +46,9 @@ String StringForBoxType(const NGPhysicalFragment& fragment) { ...@@ -46,6 +46,9 @@ String StringForBoxType(const NGPhysicalFragment& fragment) {
switch (fragment.BoxType()) { switch (fragment.BoxType()) {
case NGPhysicalFragment::NGBoxType::kNormalBox: case NGPhysicalFragment::NGBoxType::kNormalBox:
break; break;
case NGPhysicalFragment::NGBoxType::kInlineBox:
result.Append("inline");
break;
case NGPhysicalFragment::NGBoxType::kInlineBlock: case NGPhysicalFragment::NGBoxType::kInlineBlock:
result.Append("inline-block"); result.Append("inline-block");
break; break;
...@@ -55,11 +58,6 @@ String StringForBoxType(const NGPhysicalFragment& fragment) { ...@@ -55,11 +58,6 @@ String StringForBoxType(const NGPhysicalFragment& fragment) {
case NGPhysicalFragment::NGBoxType::kOutOfFlowPositioned: case NGPhysicalFragment::NGBoxType::kOutOfFlowPositioned:
result.Append("out-of-flow-positioned"); result.Append("out-of-flow-positioned");
break; break;
case NGPhysicalFragment::NGBoxType::kAnonymousBox:
result.Append("anonymous");
break;
default:
NOTREACHED();
} }
if (fragment.IsOldLayoutRoot()) { if (fragment.IsOldLayoutRoot()) {
if (result.length()) if (result.length())
......
...@@ -49,7 +49,7 @@ class CORE_EXPORT NGPhysicalFragment ...@@ -49,7 +49,7 @@ class CORE_EXPORT NGPhysicalFragment
}; };
enum NGBoxType { enum NGBoxType {
kNormalBox, kNormalBox,
kAnonymousBox, kInlineBox,
kInlineBlock, kInlineBlock,
kFloating, kFloating,
kOutOfFlowPositioned, kOutOfFlowPositioned,
...@@ -74,20 +74,22 @@ class CORE_EXPORT NGPhysicalFragment ...@@ -74,20 +74,22 @@ class CORE_EXPORT NGPhysicalFragment
// Returns the box type of this fragment. // Returns the box type of this fragment.
NGBoxType BoxType() const { return static_cast<NGBoxType>(box_type_); } NGBoxType BoxType() const { return static_cast<NGBoxType>(box_type_); }
// True if this is an inline box; e.g., <span>. Atomic inlines such as
// replaced elements or inline block are not included.
bool IsInlineBox() const { return BoxType() == NGBoxType::kInlineBox; }
// Returns whether the fragment is old layout root. // Returns whether the fragment is old layout root.
bool IsOldLayoutRoot() const { return is_old_layout_root_; } bool IsOldLayoutRoot() const { return is_old_layout_root_; }
// An inline block is represented as a kFragmentBox. // An inline block is represented as a kFragmentBox.
// TODO(eae): This isn't true for replaces elements at the moment. // TODO(eae): This isn't true for replaces elements at the moment.
bool IsInlineBlock() const { return BoxType() == NGBoxType::kInlineBlock; } bool IsInlineBlock() const { return BoxType() == NGBoxType::kInlineBlock; }
// True if this fragment is in-flow in an inline formatting context.
bool IsInline() const { return IsText() || IsInlineBox() || IsInlineBlock(); }
bool IsFloating() const { return BoxType() == NGBoxType::kFloating; } bool IsFloating() const { return BoxType() == NGBoxType::kFloating; }
bool IsOutOfFlowPositioned() const { bool IsOutOfFlowPositioned() const {
return BoxType() == NGBoxType::kOutOfFlowPositioned; return BoxType() == NGBoxType::kOutOfFlowPositioned;
} }
bool IsBlockFlow() const; bool IsBlockFlow() const;
// A box fragment that do not exist in LayoutObject tree. Its LayoutObject is
// co-owned by other fragments.
bool IsAnonymousBox() const { return BoxType() == NGBoxType::kAnonymousBox; }
// A block sub-layout starts on this fragment. Inline blocks, floats, out of // A block sub-layout starts on this fragment. Inline blocks, floats, out of
// flow positioned objects are such examples. This is also true on NG/legacy // flow positioned objects are such examples. This is also true on NG/legacy
// boundary. // boundary.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment