Commit 5917e9b5 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Support StyleVariant in all fragments

StyleVariant was added to NGPhysicalFragment but was enabled
only for NGPhysiclaTextFragment.

This patch enables it for all fragments.

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_layout_ng;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I892da56449f80ce4e072a9d78bfc51cafa1a535e
Bug: 636993
Reviewed-on: https://chromium-review.googlesource.com/1068781
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarAleks Totic <atotic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561004}
parent a5e08f96
...@@ -442,6 +442,7 @@ NGInlineLayoutStateStack::BoxData::CreateBoxFragment( ...@@ -442,6 +442,7 @@ NGInlineLayoutStateStack::BoxData::CreateBoxFragment(
NGFragmentBuilder box(item->GetLayoutObject(), &style, style.GetWritingMode(), NGFragmentBuilder box(item->GetLayoutObject(), &style, style.GetWritingMode(),
TextDirection::kLtr); TextDirection::kLtr);
box.SetBoxType(NGPhysicalFragment::kInlineBox); box.SetBoxType(NGPhysicalFragment::kInlineBox);
box.SetStyleVariant(item->StyleVariant());
// 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
......
...@@ -298,6 +298,8 @@ void NGInlineLayoutAlgorithm::CreateLine(NGLineInfo* line_info, ...@@ -298,6 +298,8 @@ void NGInlineLayoutAlgorithm::CreateLine(NGLineInfo* line_info,
if (IsLtr(line_info->BaseDirection())) if (IsLtr(line_info->BaseDirection()))
line_bfc_offset.line_offset += line_info->TextIndent(); line_bfc_offset.line_offset += line_info->TextIndent();
if (line_info->UseFirstLineStyle())
container_builder_.SetStyleVariant(NGStyleVariant::kFirstLine);
container_builder_.AddChildren(line_box_); container_builder_.AddChildren(line_box_);
container_builder_.SetInlineSize(inline_size); container_builder_.SetInlineSize(inline_size);
container_builder_.SetBaseDirection(line_info->BaseDirection()); container_builder_.SetBaseDirection(line_info->BaseDirection());
......
...@@ -160,8 +160,8 @@ scoped_refptr<NGLayoutResult> NGLineBoxFragmentBuilder::ToLineBoxFragment() { ...@@ -160,8 +160,8 @@ scoped_refptr<NGLayoutResult> NGLineBoxFragmentBuilder::ToLineBoxFragment() {
scoped_refptr<NGPhysicalLineBoxFragment> fragment = scoped_refptr<NGPhysicalLineBoxFragment> fragment =
base::AdoptRef(new NGPhysicalLineBoxFragment( base::AdoptRef(new NGPhysicalLineBoxFragment(
Style(), physical_size, children_, contents_visual_rect, Style(), style_variant_, physical_size, children_,
scrollable_overflow, metrics_, base_direction_, contents_visual_rect, scrollable_overflow, metrics_, base_direction_,
break_token_ ? std::move(break_token_) break_token_ ? std::move(break_token_)
: NGInlineBreakToken::Create(node_))); : NGInlineBreakToken::Create(node_)));
......
...@@ -43,6 +43,7 @@ static const NGPhysicalFragment* LastLogicalLeafExceptLinebreakInternal( ...@@ -43,6 +43,7 @@ static const NGPhysicalFragment* LastLogicalLeafExceptLinebreakInternal(
NGPhysicalLineBoxFragment::NGPhysicalLineBoxFragment( NGPhysicalLineBoxFragment::NGPhysicalLineBoxFragment(
const ComputedStyle& style, const ComputedStyle& style,
NGStyleVariant style_variant,
NGPhysicalSize size, NGPhysicalSize size,
Vector<scoped_refptr<NGPhysicalFragment>>& children, Vector<scoped_refptr<NGPhysicalFragment>>& children,
const NGPhysicalOffsetRect& contents_visual_rect, const NGPhysicalOffsetRect& contents_visual_rect,
...@@ -52,6 +53,7 @@ NGPhysicalLineBoxFragment::NGPhysicalLineBoxFragment( ...@@ -52,6 +53,7 @@ NGPhysicalLineBoxFragment::NGPhysicalLineBoxFragment(
scoped_refptr<NGBreakToken> break_token) scoped_refptr<NGBreakToken> break_token)
: NGPhysicalContainerFragment(nullptr, : NGPhysicalContainerFragment(nullptr,
style, style,
style_variant,
size, size,
kFragmentLineBox, kFragmentLineBox,
0, 0,
......
...@@ -17,6 +17,7 @@ class CORE_EXPORT NGPhysicalLineBoxFragment final ...@@ -17,6 +17,7 @@ class CORE_EXPORT NGPhysicalLineBoxFragment final
public: public:
// This modifies the passed-in children vector. // This modifies the passed-in children vector.
NGPhysicalLineBoxFragment(const ComputedStyle&, NGPhysicalLineBoxFragment(const ComputedStyle&,
NGStyleVariant style_variant,
NGPhysicalSize size, NGPhysicalSize size,
Vector<scoped_refptr<NGPhysicalFragment>>& children, Vector<scoped_refptr<NGPhysicalFragment>>& children,
const NGPhysicalOffsetRect& contents_visual_rect, const NGPhysicalOffsetRect& contents_visual_rect,
...@@ -59,7 +60,7 @@ class CORE_EXPORT NGPhysicalLineBoxFragment final ...@@ -59,7 +60,7 @@ class CORE_EXPORT NGPhysicalLineBoxFragment final
scoped_refptr<NGPhysicalFragment> CloneWithoutOffset() const { scoped_refptr<NGPhysicalFragment> CloneWithoutOffset() const {
Vector<scoped_refptr<NGPhysicalFragment>> children_copy(children_); Vector<scoped_refptr<NGPhysicalFragment>> children_copy(children_);
return base::AdoptRef(new NGPhysicalLineBoxFragment( return base::AdoptRef(new NGPhysicalLineBoxFragment(
Style(), size_, children_copy, contents_visual_rect_, Style(), StyleVariant(), size_, children_copy, contents_visual_rect_,
scrollable_overflow_, metrics_, BaseDirection(), break_token_)); scrollable_overflow_, metrics_, BaseDirection(), break_token_));
} }
......
...@@ -22,6 +22,12 @@ NGBaseFragmentBuilder::NGBaseFragmentBuilder(WritingMode writing_mode, ...@@ -22,6 +22,12 @@ NGBaseFragmentBuilder::NGBaseFragmentBuilder(WritingMode writing_mode,
NGBaseFragmentBuilder::~NGBaseFragmentBuilder() = default; NGBaseFragmentBuilder::~NGBaseFragmentBuilder() = default;
NGBaseFragmentBuilder& NGBaseFragmentBuilder::SetStyleVariant(
NGStyleVariant style_variant) {
style_variant_ = style_variant;
return *this;
}
NGBaseFragmentBuilder& NGBaseFragmentBuilder::SetStyle( NGBaseFragmentBuilder& NGBaseFragmentBuilder::SetStyle(
scoped_refptr<const ComputedStyle> style, scoped_refptr<const ComputedStyle> style,
NGStyleVariant style_variant) { NGStyleVariant style_variant) {
......
...@@ -24,6 +24,7 @@ class CORE_EXPORT NGBaseFragmentBuilder { ...@@ -24,6 +24,7 @@ class CORE_EXPORT NGBaseFragmentBuilder {
DCHECK(style_); DCHECK(style_);
return *style_; return *style_;
} }
NGBaseFragmentBuilder& SetStyleVariant(NGStyleVariant);
NGBaseFragmentBuilder& SetStyle(scoped_refptr<const ComputedStyle>, NGBaseFragmentBuilder& SetStyle(scoped_refptr<const ComputedStyle>,
NGStyleVariant); NGStyleVariant);
......
...@@ -558,6 +558,9 @@ scoped_refptr<NGLayoutResult> NGBlockLayoutAlgorithm::Layout() { ...@@ -558,6 +558,9 @@ scoped_refptr<NGLayoutResult> NGBlockLayoutAlgorithm::Layout() {
DCHECK(exclusion_space_); DCHECK(exclusion_space_);
container_builder_.SetExclusionSpace(std::move(exclusion_space_)); container_builder_.SetExclusionSpace(std::move(exclusion_space_));
if (ConstraintSpace().UseFirstLineStyle())
container_builder_.SetStyleVariant(NGStyleVariant::kFirstLine);
return container_builder_.ToBoxFragment(); return container_builder_.ToBoxFragment();
} }
......
...@@ -285,7 +285,7 @@ scoped_refptr<NGLayoutResult> NGFragmentBuilder::ToBoxFragment() { ...@@ -285,7 +285,7 @@ scoped_refptr<NGLayoutResult> NGFragmentBuilder::ToBoxFragment() {
scoped_refptr<NGPhysicalBoxFragment> fragment = scoped_refptr<NGPhysicalBoxFragment> fragment =
base::AdoptRef(new NGPhysicalBoxFragment( base::AdoptRef(new NGPhysicalBoxFragment(
layout_object_, Style(), physical_size, children_, layout_object_, Style(), style_variant_, physical_size, children_,
padding_.ConvertToPhysical(GetWritingMode(), Direction()) padding_.ConvertToPhysical(GetWritingMode(), Direction())
.SnapToDevicePixels(), .SnapToDevicePixels(),
contents_visual_rect, baselines_, BoxType(), is_old_layout_root_, contents_visual_rect, baselines_, BoxType(), is_old_layout_root_,
......
...@@ -19,6 +19,7 @@ namespace blink { ...@@ -19,6 +19,7 @@ namespace blink {
NGPhysicalBoxFragment::NGPhysicalBoxFragment( NGPhysicalBoxFragment::NGPhysicalBoxFragment(
LayoutObject* layout_object, LayoutObject* layout_object,
const ComputedStyle& style, const ComputedStyle& style,
NGStyleVariant style_variant,
NGPhysicalSize size, NGPhysicalSize size,
Vector<scoped_refptr<NGPhysicalFragment>>& children, Vector<scoped_refptr<NGPhysicalFragment>>& children,
const NGPixelSnappedPhysicalBoxStrut& padding, const NGPixelSnappedPhysicalBoxStrut& padding,
...@@ -30,6 +31,7 @@ NGPhysicalBoxFragment::NGPhysicalBoxFragment( ...@@ -30,6 +31,7 @@ NGPhysicalBoxFragment::NGPhysicalBoxFragment(
scoped_refptr<NGBreakToken> break_token) scoped_refptr<NGBreakToken> break_token)
: NGPhysicalContainerFragment(layout_object, : NGPhysicalContainerFragment(layout_object,
style, style,
style_variant,
size, size,
kFragmentBox, kFragmentBox,
box_type, box_type,
...@@ -220,9 +222,9 @@ scoped_refptr<NGPhysicalFragment> NGPhysicalBoxFragment::CloneWithoutOffset() ...@@ -220,9 +222,9 @@ scoped_refptr<NGPhysicalFragment> NGPhysicalBoxFragment::CloneWithoutOffset()
Vector<NGBaseline> baselines_copy(baselines_); Vector<NGBaseline> baselines_copy(baselines_);
scoped_refptr<NGPhysicalFragment> physical_fragment = scoped_refptr<NGPhysicalFragment> physical_fragment =
base::AdoptRef(new NGPhysicalBoxFragment( base::AdoptRef(new NGPhysicalBoxFragment(
layout_object_, Style(), size_, children_copy, padding_, layout_object_, Style(), StyleVariant(), size_, children_copy,
contents_visual_rect_, baselines_copy, BoxType(), is_old_layout_root_, padding_, contents_visual_rect_, baselines_copy, BoxType(),
border_edge_, break_token_)); is_old_layout_root_, border_edge_, break_token_));
return physical_fragment; return physical_fragment;
} }
......
...@@ -19,6 +19,7 @@ class CORE_EXPORT NGPhysicalBoxFragment final ...@@ -19,6 +19,7 @@ class CORE_EXPORT NGPhysicalBoxFragment final
// This modifies the passed-in children vector. // This modifies the passed-in children vector.
NGPhysicalBoxFragment(LayoutObject* layout_object, NGPhysicalBoxFragment(LayoutObject* layout_object,
const ComputedStyle& style, const ComputedStyle& style,
NGStyleVariant style_variant,
NGPhysicalSize size, NGPhysicalSize size,
Vector<scoped_refptr<NGPhysicalFragment>>& children, Vector<scoped_refptr<NGPhysicalFragment>>& children,
const NGPixelSnappedPhysicalBoxStrut& padding, const NGPixelSnappedPhysicalBoxStrut& padding,
......
...@@ -9,6 +9,7 @@ namespace blink { ...@@ -9,6 +9,7 @@ namespace blink {
NGPhysicalContainerFragment::NGPhysicalContainerFragment( NGPhysicalContainerFragment::NGPhysicalContainerFragment(
LayoutObject* layout_object, LayoutObject* layout_object,
const ComputedStyle& style, const ComputedStyle& style,
NGStyleVariant style_variant,
NGPhysicalSize size, NGPhysicalSize size,
NGFragmentType type, NGFragmentType type,
unsigned sub_type, unsigned sub_type,
...@@ -17,7 +18,7 @@ NGPhysicalContainerFragment::NGPhysicalContainerFragment( ...@@ -17,7 +18,7 @@ NGPhysicalContainerFragment::NGPhysicalContainerFragment(
scoped_refptr<NGBreakToken> break_token) scoped_refptr<NGBreakToken> break_token)
: NGPhysicalFragment(layout_object, : NGPhysicalFragment(layout_object,
style, style,
NGStyleVariant::kStandard, style_variant,
size, size,
type, type,
sub_type, sub_type,
......
...@@ -28,6 +28,7 @@ class CORE_EXPORT NGPhysicalContainerFragment : public NGPhysicalFragment { ...@@ -28,6 +28,7 @@ class CORE_EXPORT NGPhysicalContainerFragment : public NGPhysicalFragment {
NGPhysicalContainerFragment( NGPhysicalContainerFragment(
LayoutObject*, LayoutObject*,
const ComputedStyle&, const ComputedStyle&,
NGStyleVariant,
NGPhysicalSize, NGPhysicalSize,
NGFragmentType, NGFragmentType,
unsigned sub_type, unsigned sub_type,
......
...@@ -248,7 +248,7 @@ const ComputedStyle& NGPhysicalFragment::Style() const { ...@@ -248,7 +248,7 @@ const ComputedStyle& NGPhysicalFragment::Style() const {
// ellipsis styles have this problem. // ellipsis styles have this problem.
if (!GetLayoutObject()) if (!GetLayoutObject())
return *style_; return *style_;
switch ((NGStyleVariant)style_variant_) { switch (StyleVariant()) {
case NGStyleVariant::kStandard: case NGStyleVariant::kStandard:
return *GetLayoutObject()->Style(); return *GetLayoutObject()->Style();
case NGStyleVariant::kFirstLine: case NGStyleVariant::kFirstLine:
......
...@@ -150,6 +150,12 @@ class CORE_EXPORT NGPhysicalFragment ...@@ -150,6 +150,12 @@ class CORE_EXPORT NGPhysicalFragment
} }
NGBreakToken* BreakToken() const { return break_token_.get(); } NGBreakToken* BreakToken() const { return break_token_.get(); }
NGStyleVariant StyleVariant() const {
return static_cast<NGStyleVariant>(style_variant_);
}
bool UsesFirstLineStyle() const {
return StyleVariant() == NGStyleVariant::kFirstLine;
}
const ComputedStyle& Style() const; const ComputedStyle& Style() const;
Node* GetNode() const; Node* GetNode() const;
......
...@@ -86,7 +86,8 @@ void NGBoxFragmentPainter::Paint(const PaintInfo& paint_info, ...@@ -86,7 +86,8 @@ void NGBoxFragmentPainter::Paint(const PaintInfo& paint_info,
adjustment.AdjustedPaintOffset()); adjustment.AdjustedPaintOffset());
return; return;
} }
DCHECK_EQ(layout_object->Style(), &PhysicalFragment().Style()); DCHECK_EQ(layout_object->Style(PhysicalFragment().UsesFirstLineStyle()),
&PhysicalFragment().Style());
AdjustPaintOffsetScope adjustment(box_fragment_, paint_info, paint_offset); AdjustPaintOffsetScope adjustment(box_fragment_, paint_info, paint_offset);
PaintWithAdjustedOffset(adjustment.MutablePaintInfo(), PaintWithAdjustedOffset(adjustment.MutablePaintInfo(),
adjustment.AdjustedPaintOffset()); adjustment.AdjustedPaintOffset());
......
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