Revert "Move break_token_ to NGPhysicalContainerFragment from NGPhysicalFragment"
This reverts commit 4386eb056f61e7b335842145acd1b38f5eb8f1b0.
Reason for revert: Breaks beta builds, crbug 974731
Original change's description:
> Move break_token_ to NGPhysicalContainerFragment from NGPhysicalFragment
>
> This patch moves |NGPhysicalFragment::break_token_| member to
> |NGPhysicalContainerFragment| to reduce size of |NGPhysicalTextFragment| since
> |NGPhysicalTextFragment| never has break token.
>
> TBR=yosin@chromium.org
>
> Bug: 962108
> Change-Id: I9f86c413c01932dfaed5d55933b490deaddbde1a
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1662095
> Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
> Cr-Commit-Position: refs/branch-heads/3809@{#336}
> Cr-Branched-From: d82dec1a818f378c464ba307ddd9c92133eac355-refs/heads/master@{#665002}
TBR=yosin@chromium.org
Change-Id: I89b7d0af4ec1799b132b66277a98659086d683c7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 962108
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1661372
Reviewed-by: Krishna Govind <govind@chromium.org>
Cr-Commit-Position: refs/branch-heads/3809@{#345}
Cr-Branched-From: d82dec1a818f378c464ba307ddd9c92133eac355-refs/heads/master@{#665002}
diff --git a/third_party/blink/renderer/core/layout/ng/inline/ng_abstract_inline_text_box.cc b/third_party/blink/renderer/core/layout/ng/inline/ng_abstract_inline_text_box.cc
index 7fe1900..f0cb6b1 100644
--- a/third_party/blink/renderer/core/layout/ng/inline/ng_abstract_inline_text_box.cc
+++ b/third_party/blink/renderer/core/layout/ng/inline/ng_abstract_inline_text_box.cc
@@ -91,8 +91,8 @@
return false;
if (text_fragment.TextContent()[text_fragment.EndOffset()] != ' ')
return false;
- const NGInlineBreakToken& break_token = *To<NGInlineBreakToken>(
- To<NGPhysicalLineBoxFragment>(line_box.PhysicalFragment()).BreakToken());
+ const NGInlineBreakToken& break_token =
+ *To<NGInlineBreakToken>(line_box.PhysicalFragment().BreakToken());
// TODO(yosin): We should support OOF fragments between |fragment_| and
// break token.
if (break_token.TextOffset() != text_fragment.EndOffset() + 1)
diff --git a/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc
index 3a7bc24c..9b9feab 100644
--- a/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc
+++ b/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc
@@ -1940,7 +1940,7 @@
if (!container_builder_.BfcBlockOffset().has_value())
return NoBreak;
- const NGPhysicalContainerFragment& physical_fragment =
+ const NGPhysicalFragment& physical_fragment =
layout_result.PhysicalFragment();
// If we haven't used any space at all in the fragmentainer yet, we cannot
diff --git a/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm_test.cc b/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm_test.cc
index 4743312..63131ad1 100644
--- a/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm_test.cc
+++ b/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm_test.cc
@@ -90,7 +90,7 @@
NGBlockNode box(ToLayoutBox(GetLayoutObjectByElementId("box")));
- scoped_refptr<const NGPhysicalBoxFragment> fragment =
+ scoped_refptr<const NGPhysicalFragment> fragment =
RunBlockLayoutAlgorithm(box, space);
EXPECT_EQ(PhysicalSize(30, 40), fragment->Size());
@@ -1772,7 +1772,7 @@
NGConstraintSpace space = ConstructBlockLayoutTestConstraintSpace(
WritingMode::kHorizontalTb, TextDirection::kLtr,
LogicalSize(LayoutUnit(100), kIndefiniteSize), true);
- scoped_refptr<const NGPhysicalBoxFragment> fragment =
+ scoped_refptr<const NGPhysicalFragment> fragment =
RunBlockLayoutAlgorithm(container, space);
EXPECT_EQ(LayoutUnit(kWidthChild2), fragment->Size().width);
@@ -1924,7 +1924,7 @@
node.CreatesNewFormattingContext(), kFragmentainerSpaceAvailable);
// We should only have one 150x200 fragment with no fragmentation.
- scoped_refptr<const NGPhysicalBoxFragment> fragment =
+ scoped_refptr<const NGPhysicalFragment> fragment =
RunBlockLayoutAlgorithm(node, space);
EXPECT_EQ(PhysicalSize(150, 200), fragment->Size());
ASSERT_TRUE(fragment->BreakToken()->IsFinished());
@@ -1951,7 +1951,7 @@
LogicalSize(LayoutUnit(1000), kIndefiniteSize), false,
node.CreatesNewFormattingContext(), kFragmentainerSpaceAvailable);
- scoped_refptr<const NGPhysicalBoxFragment> fragment =
+ scoped_refptr<const NGPhysicalFragment> fragment =
RunBlockLayoutAlgorithm(node, space);
EXPECT_EQ(PhysicalSize(150, 200), fragment->Size());
ASSERT_FALSE(fragment->BreakToken()->IsFinished());
@@ -1994,7 +1994,7 @@
LogicalSize(LayoutUnit(1000), kIndefiniteSize), false,
node.CreatesNewFormattingContext(), kFragmentainerSpaceAvailable);
- scoped_refptr<const NGPhysicalBoxFragment> fragment =
+ scoped_refptr<const NGPhysicalFragment> fragment =
RunBlockLayoutAlgorithm(node, space);
EXPECT_EQ(PhysicalSize(150, 200), fragment->Size());
ASSERT_FALSE(fragment->BreakToken()->IsFinished());
@@ -2059,7 +2059,7 @@
LogicalSize(LayoutUnit(1000), kIndefiniteSize), false,
node.CreatesNewFormattingContext(), kFragmentainerSpaceAvailable);
- scoped_refptr<const NGPhysicalBoxFragment> fragment =
+ scoped_refptr<const NGPhysicalFragment> fragment =
RunBlockLayoutAlgorithm(node, space);
EXPECT_EQ(PhysicalSize(150, 200), fragment->Size());
ASSERT_FALSE(fragment->BreakToken()->IsFinished());
@@ -2122,7 +2122,7 @@
LogicalSize(LayoutUnit(1000), kIndefiniteSize), false,
node.CreatesNewFormattingContext(), kFragmentainerSpaceAvailable);
- scoped_refptr<const NGPhysicalBoxFragment> fragment =
+ scoped_refptr<const NGPhysicalFragment> fragment =
RunBlockLayoutAlgorithm(node, space);
EXPECT_EQ(PhysicalSize(150, 70), fragment->Size());
ASSERT_FALSE(fragment->BreakToken()->IsFinished());
@@ -2188,7 +2188,7 @@
LogicalSize(LayoutUnit(1000), kIndefiniteSize), false,
node.CreatesNewFormattingContext(), kFragmentainerSpaceAvailable);
- scoped_refptr<const NGPhysicalBoxFragment> fragment =
+ scoped_refptr<const NGPhysicalFragment> fragment =
RunBlockLayoutAlgorithm(node, space);
EXPECT_EQ(PhysicalSize(150, 50), fragment->Size());
ASSERT_FALSE(fragment->BreakToken()->IsFinished());
@@ -2268,7 +2268,7 @@
AdvanceToLayoutPhase();
- scoped_refptr<const NGPhysicalBoxFragment> fragment =
+ scoped_refptr<const NGPhysicalFragment> fragment =
RunBlockLayoutAlgorithm(node, space);
EXPECT_EQ(PhysicalSize(150, 60), fragment->Size());
ASSERT_TRUE(!fragment->BreakToken() || fragment->BreakToken()->IsFinished());
@@ -2280,9 +2280,7 @@
// float2 should only have one fragment.
EXPECT_EQ(PhysicalSize(60, 200), float2->Size());
- ASSERT_TRUE(float2->IsBox());
- NGBreakToken* break_token = To<NGPhysicalBoxFragment>(float2)->BreakToken();
- EXPECT_TRUE(!break_token || break_token->IsFinished());
+ ASSERT_TRUE(!float2->BreakToken() || float2->BreakToken()->IsFinished());
}
// Tests that a float child inside a zero height block fragments correctly.
@@ -2318,7 +2316,7 @@
LogicalSize(LayoutUnit(1000), kIndefiniteSize), false,
node.CreatesNewFormattingContext(), kFragmentainerSpaceAvailable);
- scoped_refptr<const NGPhysicalBoxFragment> fragment =
+ scoped_refptr<const NGPhysicalFragment> fragment =
RunBlockLayoutAlgorithm(node, space);
EXPECT_EQ(PhysicalSize(150, 50), fragment->Size());
ASSERT_FALSE(fragment->BreakToken()->IsFinished());
@@ -2441,7 +2439,7 @@
WritingMode::kHorizontalTb, TextDirection::kLtr,
LogicalSize(LayoutUnit(1000), kIndefiniteSize));
- scoped_refptr<const NGPhysicalBoxFragment> fragment =
+ scoped_refptr<const NGPhysicalFragment> fragment =
RunBlockLayoutAlgorithm(node, space);
EXPECT_EQ(PhysicalSize(200, 150), fragment->Size());
@@ -2477,7 +2475,7 @@
WritingMode::kHorizontalTb, TextDirection::kLtr,
LogicalSize(LayoutUnit(1000), kIndefiniteSize), false, true);
- scoped_refptr<const NGPhysicalBoxFragment> fragment =
+ scoped_refptr<const NGPhysicalFragment> fragment =
RunBlockLayoutAlgorithm(node, space);
EXPECT_EQ(PhysicalSize(200, 10), fragment->Size());
@@ -2515,7 +2513,7 @@
WritingMode::kHorizontalTb, TextDirection::kLtr,
LogicalSize(LayoutUnit(1000), kIndefiniteSize), false, true);
- scoped_refptr<const NGPhysicalBoxFragment> fragment =
+ scoped_refptr<const NGPhysicalFragment> fragment =
RunBlockLayoutAlgorithm(node, space);
EXPECT_EQ(PhysicalSize(200, 10), fragment->Size());
diff --git a/third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.cc b/third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.cc
index 21b54f6c..cf3108c 100644
--- a/third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.cc
+++ b/third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.cc
@@ -153,7 +153,7 @@
}
NGBoxFragmentBuilder& NGBoxFragmentBuilder::PropagateBreak(
- const NGPhysicalContainerFragment& child_fragment) {
+ const NGPhysicalFragment& child_fragment) {
DCHECK(has_block_fragmentation_);
if (!did_break_) {
const auto* token = child_fragment.BreakToken();
diff --git a/third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.h b/third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.h
index 29ffa670..d491b25 100644
--- a/third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.h
+++ b/third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.h
@@ -97,7 +97,7 @@
// Update if we have fragmented in this flow.
NGBoxFragmentBuilder& PropagateBreak(const NGLayoutResult&);
- NGBoxFragmentBuilder& PropagateBreak(const NGPhysicalContainerFragment&);
+ NGBoxFragmentBuilder& PropagateBreak(const NGPhysicalFragment&);
void AddOutOfFlowLegacyCandidate(NGBlockNode,
const NGStaticPosition&,
diff --git a/third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.cc b/third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.cc
index 9c556e3..e61ae6a5 100644
--- a/third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.cc
+++ b/third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.cc
@@ -17,13 +17,12 @@
const NGPhysicalFragment& fragment) {
if (!fragment.IsBox())
return LayoutUnit();
- const NGPhysicalBoxFragment& box_fragment =
- To<NGPhysicalBoxFragment>(fragment);
- const auto* break_token = To<NGBlockBreakToken>(box_fragment.BreakToken());
+ const auto* break_token = To<NGBlockBreakToken>(fragment.BreakToken());
if (!break_token)
return LayoutUnit();
NGBoxFragment logical_fragment(constraint_space.GetWritingMode(),
- constraint_space.Direction(), box_fragment);
+ constraint_space.Direction(),
+ To<NGPhysicalBoxFragment>(fragment));
return break_token->UsedBlockSize() - logical_fragment.BlockSize();
}
diff --git a/third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.h b/third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.h
index 31ead90..bc14ebb 100644
--- a/third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.h
+++ b/third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.h
@@ -7,7 +7,7 @@
#include "third_party/blink/renderer/core/layout/ng/ng_block_break_token.h"
#include "third_party/blink/renderer/core/layout/ng/ng_layout_input_node.h"
-#include "third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.h"
+#include "third_party/blink/renderer/core/layout/ng/ng_physical_fragment.h"
#include "third_party/blink/renderer/core/style/computed_style_constants.h"
#include "third_party/blink/renderer/platform/geometry/layout_unit.h"
@@ -34,10 +34,7 @@
// Return true if the specified fragment is the final fragment of some node.
inline bool IsLastFragment(const NGPhysicalFragment& fragment) {
- if (!fragment.IsContainer())
- return false;
- const auto* break_token =
- To<NGPhysicalContainerFragment>(fragment).BreakToken();
+ const auto* break_token = fragment.BreakToken();
return !break_token || break_token->IsFinished();
}
diff --git a/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.cc b/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.cc
index f46de53..6ce7d4c 100644
--- a/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.cc
+++ b/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.cc
@@ -17,13 +17,7 @@
namespace {
struct SameSizeAsNGPhysicalContainerFragment : NGPhysicalFragment {
-<<<<<<< HEAD (d91d4f Allocate memory for borders and padding members of NGPhysica)
Vector<NGOutOfFlowPositionedDescendant> oof_positioned_descendants_;
-=======
- void* break_token;
- std::unique_ptr<Vector<NGOutOfFlowPositionedDescendant>>
- oof_positioned_descendants_;
->>>>>>> CHANGE (3ad1c0 Move break_token_ to NGPhysicalContainerFragment from NGPhys)
void* pointer;
wtf_size_t size;
};
@@ -41,7 +35,6 @@
NGFragmentType type,
unsigned sub_type)
: NGPhysicalFragment(builder, type, sub_type),
- break_token_(std::move(builder->break_token_)),
oof_positioned_descendants_(
std::move(builder->oof_positioned_descendants_)),
buffer_(buffer),
diff --git a/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.h b/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.h
index 3d24e51..d79c9f5 100644
--- a/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.h
+++ b/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.h
@@ -7,7 +7,6 @@
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h"
-#include "third_party/blink/renderer/core/layout/ng/ng_break_token.h"
#include "third_party/blink/renderer/core/layout/ng/ng_link.h"
#include "third_party/blink/renderer/core/layout/ng/ng_physical_fragment.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
@@ -100,8 +99,6 @@
~NGPhysicalContainerFragment();
- NGBreakToken* BreakToken() const { return break_token_.get(); }
-
// Returns the children of |this|.
//
// Note, children in this collection maybe old generations. Items in this
@@ -160,13 +157,7 @@
static bool DependsOnPercentageBlockSize(const NGContainerFragmentBuilder&);
-<<<<<<< HEAD (d91d4f Allocate memory for borders and padding members of NGPhysica)
Vector<NGOutOfFlowPositionedDescendant> oof_positioned_descendants_;
-=======
- scoped_refptr<NGBreakToken> break_token_;
- const std::unique_ptr<Vector<NGOutOfFlowPositionedDescendant>>
- oof_positioned_descendants_;
->>>>>>> CHANGE (3ad1c0 Move break_token_ to NGPhysicalContainerFragment from NGPhys)
// Because flexible arrays need to be the last member in a class, the actual
// storage is in the subclass and we just keep a pointer to it here.
diff --git a/third_party/blink/renderer/core/layout/ng/ng_physical_fragment.cc b/third_party/blink/renderer/core/layout/ng/ng_physical_fragment.cc
index b81af6f..38ae5af7 100644
--- a/third_party/blink/renderer/core/layout/ng/ng_physical_fragment.cc
+++ b/third_party/blink/renderer/core/layout/ng/ng_physical_fragment.cc
@@ -12,6 +12,7 @@
#include "third_party/blink/renderer/core/layout/ng/inline/ng_physical_line_box_fragment.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_physical_text_fragment.h"
#include "third_party/blink/renderer/core/layout/ng/ng_block_node.h"
+#include "third_party/blink/renderer/core/layout/ng/ng_break_token.h"
#include "third_party/blink/renderer/core/layout/ng/ng_fragment_builder.h"
#include "third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
@@ -23,7 +24,7 @@
struct SameSizeAsNGPhysicalFragment
: RefCounted<const NGPhysicalFragment, NGPhysicalFragmentTraits> {
- void* layout_object;
+ void* pointers[2];
PhysicalSize size;
unsigned flags;
};
@@ -220,6 +221,7 @@
unsigned sub_type)
: layout_object_(*builder->layout_object_),
size_(ToPhysicalSize(builder->size_, builder->GetWritingMode())),
+ break_token_(std::move(builder->break_token_)),
type_(type),
sub_type_(sub_type),
style_variant_((unsigned)builder->style_variant_),
@@ -233,9 +235,11 @@
NGStyleVariant style_variant,
PhysicalSize size,
NGFragmentType type,
- unsigned sub_type)
+ unsigned sub_type,
+ scoped_refptr<NGBreakToken> break_token)
: layout_object_(*layout_object),
size_(size),
+ break_token_(std::move(break_token)),
type_(type),
sub_type_(sub_type),
style_variant_((unsigned)style_variant),
diff --git a/third_party/blink/renderer/core/layout/ng/ng_physical_fragment.h b/third_party/blink/renderer/core/layout/ng/ng_physical_fragment.h
index 4df643c0..868db0e 100644
--- a/third_party/blink/renderer/core/layout/ng/ng_physical_fragment.h
+++ b/third_party/blink/renderer/core/layout/ng/ng_physical_fragment.h
@@ -11,7 +11,7 @@
#include "third_party/blink/renderer/core/layout/geometry/physical_offset.h"
#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h"
#include "third_party/blink/renderer/core/layout/geometry/physical_size.h"
-#include "third_party/blink/renderer/core/layout/layout_object.h"
+#include "third_party/blink/renderer/core/layout/ng/ng_break_token.h"
#include "third_party/blink/renderer/core/layout/ng/ng_style_variant.h"
#include "third_party/blink/renderer/platform/graphics/touch_action.h"
#include "third_party/blink/renderer/platform/wtf/ref_counted.h"
@@ -21,8 +21,10 @@
namespace blink {
class ComputedStyle;
+class LayoutObject;
class Node;
class NGFragmentBuilder;
+class NGBreakToken;
class NGInlineItem;
class PaintLayer;
@@ -154,6 +156,7 @@
// (0, 0).
PhysicalRect LocalRect() const { return {{}, size_}; }
+ NGBreakToken* BreakToken() const { return break_token_.get(); }
NGStyleVariant StyleVariant() const {
return static_cast<NGStyleVariant>(style_variant_);
}
@@ -272,7 +275,8 @@
NGStyleVariant,
PhysicalSize size,
NGFragmentType type,
- unsigned sub_type);
+ unsigned sub_type,
+ scoped_refptr<NGBreakToken> break_token = nullptr);
const ComputedStyle& SlowEffectiveStyle() const;
@@ -280,6 +284,7 @@
LayoutObject& layout_object_;
const PhysicalSize size_;
+ scoped_refptr<NGBreakToken> break_token_;
const unsigned type_ : 2; // NGFragmentType
const unsigned sub_type_ : 3; // NGBoxType, NGTextType, or NGLineBoxType
diff --git a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.cc b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.cc
index 674dbd8..bf5cf74 100644
--- a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.cc
+++ b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.cc
@@ -365,9 +365,7 @@
return fragment;
scoped_refptr<NGPaintFragment>* next = &(*fragment)->next_fragmented_;
- auto* container =
- DynamicTo<NGPhysicalContainerFragment>((*fragment)->PhysicalFragment());
- if (container && container->BreakToken() == break_token)
+ if ((*fragment)->PhysicalFragment().BreakToken() == break_token)
return next;
fragment = next;
}