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(
NGFragmentBuilder box(item->GetLayoutObject(), &style, style.GetWritingMode(),
TextDirection::kLtr);
box.SetBoxType(NGPhysicalFragment::kInlineBox);
box.SetStyleVariant(item->StyleVariant());
// Inline boxes have block start/end borders, even when its containing block
// was fragmented. Fragmenting a line box in block direction is not
......
......@@ -298,6 +298,8 @@ void NGInlineLayoutAlgorithm::CreateLine(NGLineInfo* line_info,
if (IsLtr(line_info->BaseDirection()))
line_bfc_offset.line_offset += line_info->TextIndent();
if (line_info->UseFirstLineStyle())
container_builder_.SetStyleVariant(NGStyleVariant::kFirstLine);
container_builder_.AddChildren(line_box_);
container_builder_.SetInlineSize(inline_size);
container_builder_.SetBaseDirection(line_info->BaseDirection());
......
......@@ -160,8 +160,8 @@ scoped_refptr<NGLayoutResult> NGLineBoxFragmentBuilder::ToLineBoxFragment() {
scoped_refptr<NGPhysicalLineBoxFragment> fragment =
base::AdoptRef(new NGPhysicalLineBoxFragment(
Style(), physical_size, children_, contents_visual_rect,
scrollable_overflow, metrics_, base_direction_,
Style(), style_variant_, physical_size, children_,
contents_visual_rect, scrollable_overflow, metrics_, base_direction_,
break_token_ ? std::move(break_token_)
: NGInlineBreakToken::Create(node_)));
......
......@@ -43,6 +43,7 @@ static const NGPhysicalFragment* LastLogicalLeafExceptLinebreakInternal(
NGPhysicalLineBoxFragment::NGPhysicalLineBoxFragment(
const ComputedStyle& style,
NGStyleVariant style_variant,
NGPhysicalSize size,
Vector<scoped_refptr<NGPhysicalFragment>>& children,
const NGPhysicalOffsetRect& contents_visual_rect,
......@@ -52,6 +53,7 @@ NGPhysicalLineBoxFragment::NGPhysicalLineBoxFragment(
scoped_refptr<NGBreakToken> break_token)
: NGPhysicalContainerFragment(nullptr,
style,
style_variant,
size,
kFragmentLineBox,
0,
......
......@@ -17,6 +17,7 @@ class CORE_EXPORT NGPhysicalLineBoxFragment final
public:
// This modifies the passed-in children vector.
NGPhysicalLineBoxFragment(const ComputedStyle&,
NGStyleVariant style_variant,
NGPhysicalSize size,
Vector<scoped_refptr<NGPhysicalFragment>>& children,
const NGPhysicalOffsetRect& contents_visual_rect,
......@@ -59,7 +60,7 @@ class CORE_EXPORT NGPhysicalLineBoxFragment final
scoped_refptr<NGPhysicalFragment> CloneWithoutOffset() const {
Vector<scoped_refptr<NGPhysicalFragment>> children_copy(children_);
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_));
}
......
......@@ -22,6 +22,12 @@ NGBaseFragmentBuilder::NGBaseFragmentBuilder(WritingMode writing_mode,
NGBaseFragmentBuilder::~NGBaseFragmentBuilder() = default;
NGBaseFragmentBuilder& NGBaseFragmentBuilder::SetStyleVariant(
NGStyleVariant style_variant) {
style_variant_ = style_variant;
return *this;
}
NGBaseFragmentBuilder& NGBaseFragmentBuilder::SetStyle(
scoped_refptr<const ComputedStyle> style,
NGStyleVariant style_variant) {
......
......@@ -24,6 +24,7 @@ class CORE_EXPORT NGBaseFragmentBuilder {
DCHECK(style_);
return *style_;
}
NGBaseFragmentBuilder& SetStyleVariant(NGStyleVariant);
NGBaseFragmentBuilder& SetStyle(scoped_refptr<const ComputedStyle>,
NGStyleVariant);
......
......@@ -558,6 +558,9 @@ scoped_refptr<NGLayoutResult> NGBlockLayoutAlgorithm::Layout() {
DCHECK(exclusion_space_);
container_builder_.SetExclusionSpace(std::move(exclusion_space_));
if (ConstraintSpace().UseFirstLineStyle())
container_builder_.SetStyleVariant(NGStyleVariant::kFirstLine);
return container_builder_.ToBoxFragment();
}
......
......@@ -285,7 +285,7 @@ scoped_refptr<NGLayoutResult> NGFragmentBuilder::ToBoxFragment() {
scoped_refptr<NGPhysicalBoxFragment> fragment =
base::AdoptRef(new NGPhysicalBoxFragment(
layout_object_, Style(), physical_size, children_,
layout_object_, Style(), style_variant_, physical_size, children_,
padding_.ConvertToPhysical(GetWritingMode(), Direction())
.SnapToDevicePixels(),
contents_visual_rect, baselines_, BoxType(), is_old_layout_root_,
......
......@@ -19,6 +19,7 @@ namespace blink {
NGPhysicalBoxFragment::NGPhysicalBoxFragment(
LayoutObject* layout_object,
const ComputedStyle& style,
NGStyleVariant style_variant,
NGPhysicalSize size,
Vector<scoped_refptr<NGPhysicalFragment>>& children,
const NGPixelSnappedPhysicalBoxStrut& padding,
......@@ -30,6 +31,7 @@ NGPhysicalBoxFragment::NGPhysicalBoxFragment(
scoped_refptr<NGBreakToken> break_token)
: NGPhysicalContainerFragment(layout_object,
style,
style_variant,
size,
kFragmentBox,
box_type,
......@@ -220,9 +222,9 @@ scoped_refptr<NGPhysicalFragment> NGPhysicalBoxFragment::CloneWithoutOffset()
Vector<NGBaseline> baselines_copy(baselines_);
scoped_refptr<NGPhysicalFragment> physical_fragment =
base::AdoptRef(new NGPhysicalBoxFragment(
layout_object_, Style(), size_, children_copy, padding_,
contents_visual_rect_, baselines_copy, BoxType(), is_old_layout_root_,
border_edge_, break_token_));
layout_object_, Style(), StyleVariant(), size_, children_copy,
padding_, contents_visual_rect_, baselines_copy, BoxType(),
is_old_layout_root_, border_edge_, break_token_));
return physical_fragment;
}
......
......@@ -19,6 +19,7 @@ class CORE_EXPORT NGPhysicalBoxFragment final
// This modifies the passed-in children vector.
NGPhysicalBoxFragment(LayoutObject* layout_object,
const ComputedStyle& style,
NGStyleVariant style_variant,
NGPhysicalSize size,
Vector<scoped_refptr<NGPhysicalFragment>>& children,
const NGPixelSnappedPhysicalBoxStrut& padding,
......
......@@ -9,6 +9,7 @@ namespace blink {
NGPhysicalContainerFragment::NGPhysicalContainerFragment(
LayoutObject* layout_object,
const ComputedStyle& style,
NGStyleVariant style_variant,
NGPhysicalSize size,
NGFragmentType type,
unsigned sub_type,
......@@ -17,7 +18,7 @@ NGPhysicalContainerFragment::NGPhysicalContainerFragment(
scoped_refptr<NGBreakToken> break_token)
: NGPhysicalFragment(layout_object,
style,
NGStyleVariant::kStandard,
style_variant,
size,
type,
sub_type,
......
......@@ -28,6 +28,7 @@ class CORE_EXPORT NGPhysicalContainerFragment : public NGPhysicalFragment {
NGPhysicalContainerFragment(
LayoutObject*,
const ComputedStyle&,
NGStyleVariant,
NGPhysicalSize,
NGFragmentType,
unsigned sub_type,
......
......@@ -248,7 +248,7 @@ const ComputedStyle& NGPhysicalFragment::Style() const {
// ellipsis styles have this problem.
if (!GetLayoutObject())
return *style_;
switch ((NGStyleVariant)style_variant_) {
switch (StyleVariant()) {
case NGStyleVariant::kStandard:
return *GetLayoutObject()->Style();
case NGStyleVariant::kFirstLine:
......
......@@ -150,6 +150,12 @@ class CORE_EXPORT NGPhysicalFragment
}
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;
Node* GetNode() const;
......
......@@ -86,7 +86,8 @@ void NGBoxFragmentPainter::Paint(const PaintInfo& paint_info,
adjustment.AdjustedPaintOffset());
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);
PaintWithAdjustedOffset(adjustment.MutablePaintInfo(),
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