[go: up one dir, main page]

Revert "Allocate vector of NGOutOfFlowPositionedDescendant in NGPhysicalContainerFragment only unless empty"

This reverts commit 4d4db721329b19642d3d5ff06f084352817a5762.

Reason for revert: Breaks beta builds, crbug 974731

Original change's description:
> Allocate vector of NGOutOfFlowPositionedDescendant in NGPhysicalContainerFragment only unless empty
> 
> This patch changes |NGPhysicalContainerFragment| to allocate vector of
> |NGOutOfFlowPositionedDescendant| only if it is not empty for reducing memory
> usage.
> 
> TBR=yosin@chromium.org
> Bug: 962108
> 
> Change-Id: If807348f4f9842e138a7fe3ae3491094e510ea73
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1661320
> Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
> Cr-Commit-Position: refs/branch-heads/3809@{#337}
> Cr-Branched-From: d82dec1a818f378c464ba307ddd9c92133eac355-refs/heads/master@{#665002}

TBR=yosin@chromium.org

Change-Id: I24603da25e9510a7ac8c7686965a0bc8f6518cbe
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 962108
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1661663
Reviewed-by: Krishna Govind <govind@chromium.org>
Cr-Commit-Position: refs/branch-heads/3809@{#344}
Cr-Branched-From: d82dec1a818f378c464ba307ddd9c92133eac355-refs/heads/master@{#665002}
diff --git a/third_party/blink/renderer/core/layout/layout_object.cc b/third_party/blink/renderer/core/layout/layout_object.cc
index b8f87d5..8c78317 100644
--- a/third_party/blink/renderer/core/layout/layout_object.cc
+++ b/third_party/blink/renderer/core/layout/layout_object.cc
@@ -925,8 +925,9 @@
     // parent. Therefore, we must mark parent chain for layout.
     if (layout_box->GetCachedLayoutResult() &&
         layout_box->GetCachedLayoutResult()
-            ->PhysicalFragment()
-            .HasOutOfFlowPositionedDescendants())
+                ->PhysicalFragment()
+                .OutOfFlowPositionedDescendants()
+                .size() > 0)
       return false;
   }
 
diff --git a/third_party/blink/renderer/core/layout/ng/inline/ng_inline_node.cc b/third_party/blink/renderer/core/layout/ng/inline/ng_inline_node.cc
index bad264f..0045de8 100644
--- a/third_party/blink/renderer/core/layout/ng/inline/ng_inline_node.cc
+++ b/third_party/blink/renderer/core/layout/ng/inline/ng_inline_node.cc
@@ -995,8 +995,9 @@
     return nullptr;
 
   // Propagating OOF needs re-layout.
-  if (cached_layout_result->PhysicalFragment()
-          .HasOutOfFlowPositionedDescendants())
+  if (!cached_layout_result->PhysicalFragment()
+           .OutOfFlowPositionedDescendants()
+           .IsEmpty())
     return nullptr;
 
   // Cached fragments are not for intermediate layout.
diff --git a/third_party/blink/renderer/core/layout/ng/inline/ng_line_truncator.cc b/third_party/blink/renderer/core/layout/ng/inline/ng_line_truncator.cc
index 747f3f13..caf78a0 100644
--- a/third_party/blink/renderer/core/layout/ng/inline/ng_line_truncator.cc
+++ b/third_party/blink/renderer/core/layout/ng/inline/ng_line_truncator.cc
@@ -99,7 +99,9 @@
   const NGPhysicalFragment* fragment = nullptr;
   if (const NGLayoutResult* layout_result = child->layout_result.get()) {
     // Need to propagate OOF descendants in this inline-block child.
-    if (layout_result->PhysicalFragment().HasOutOfFlowPositionedDescendants())
+    if (!layout_result->PhysicalFragment()
+             .OutOfFlowPositionedDescendants()
+             .IsEmpty())
       return;
     fragment = &layout_result->PhysicalFragment();
   } else {
diff --git a/third_party/blink/renderer/core/layout/ng/inline/ng_physical_line_box_fragment.cc b/third_party/blink/renderer/core/layout/ng/inline/ng_physical_line_box_fragment.cc
index 0868185..0ac7582 100644
--- a/third_party/blink/renderer/core/layout/ng/inline/ng_physical_line_box_fragment.cc
+++ b/third_party/blink/renderer/core/layout/ng/inline/ng_physical_line_box_fragment.cc
@@ -66,7 +66,7 @@
   base_direction_ = static_cast<unsigned>(builder->base_direction_);
   has_hanging_ = builder->hang_inline_size_ != 0;
   has_propagated_descendants_ = has_floating_descendants_ ||
-                                HasOutOfFlowPositionedDescendants() ||
+                                !oof_positioned_descendants_.IsEmpty() ||
                                 builder->unpositioned_list_marker_;
 }
 
diff --git a/third_party/blink/renderer/core/layout/ng/ng_container_fragment_builder.cc b/third_party/blink/renderer/core/layout/ng/ng_container_fragment_builder.cc
index 43a50cd1c..8e45280 100644
--- a/third_party/blink/renderer/core/layout/ng/ng_container_fragment_builder.cc
+++ b/third_party/blink/renderer/core/layout/ng/ng_container_fragment_builder.cc
@@ -19,9 +19,8 @@
   // Collect the child's out of flow descendants.
   // child_offset is offset of inline_start/block_start vertex.
   // Candidates need offset of top/left vertex.
-  if (child.HasOutOfFlowPositionedDescendants()) {
-    const auto& out_of_flow_descendants =
-        child.OutOfFlowPositionedDescendants();
+  const auto& out_of_flow_descendants = child.OutOfFlowPositionedDescendants();
+  if (!out_of_flow_descendants.IsEmpty()) {
     LogicalOffset top_left_offset;
     PhysicalSize child_size = child.Size();
     switch (GetWritingMode()) {
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 fcca557..f46de53 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,7 +17,6 @@
 namespace {
 
 struct SameSizeAsNGPhysicalContainerFragment : NGPhysicalFragment {
-<<<<<<< HEAD   (4386eb Move break_token_ to NGPhysicalContainerFragment from NGPhys)
 <<<<<<< HEAD   (d91d4f Allocate memory for borders and padding members of NGPhysica)
   Vector<NGOutOfFlowPositionedDescendant> oof_positioned_descendants_;
 =======
@@ -25,10 +24,6 @@
   std::unique_ptr<Vector<NGOutOfFlowPositionedDescendant>>
       oof_positioned_descendants_;
 >>>>>>> CHANGE (3ad1c0 Move break_token_ to NGPhysicalContainerFragment from NGPhys)
-=======
-  std::unique_ptr<Vector<NGOutOfFlowPositionedDescendant>>
-      oof_positioned_descendants_;
->>>>>>> CHANGE (763c67 Allocate vector of NGOutOfFlowPositionedDescendant in NGPhys)
   void* pointer;
   wtf_size_t size;
 };
@@ -48,10 +43,7 @@
     : NGPhysicalFragment(builder, type, sub_type),
       break_token_(std::move(builder->break_token_)),
       oof_positioned_descendants_(
-          builder->oof_positioned_descendants_.IsEmpty()
-              ? nullptr
-              : new Vector<NGOutOfFlowPositionedDescendant>(
-                    std::move(builder->oof_positioned_descendants_))),
+          std::move(builder->oof_positioned_descendants_)),
       buffer_(buffer),
       num_children_(builder->children_.size()) {
   has_floating_descendants_ = builder->has_floating_descendants_;
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 6bfe786..3d24e51 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
@@ -5,7 +5,6 @@
 #ifndef NGPhysicalContainerFragment_h
 #define NGPhysicalContainerFragment_h
 
-#include "base/containers/span.h"
 #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"
@@ -134,18 +133,9 @@
     return depends_on_percentage_block_size_;
   }
 
-  bool HasOutOfFlowPositionedDescendants() const {
-    DCHECK(!oof_positioned_descendants_ ||
-           !oof_positioned_descendants_->IsEmpty());
-    return oof_positioned_descendants_.get();
-  }
-
-  base::span<NGOutOfFlowPositionedDescendant> OutOfFlowPositionedDescendants()
-      const {
-    if (!HasOutOfFlowPositionedDescendants())
-      return base::span<NGOutOfFlowPositionedDescendant>();
-    return {oof_positioned_descendants_->data(),
-            oof_positioned_descendants_->size()};
+  const Vector<NGOutOfFlowPositionedDescendant>&
+  OutOfFlowPositionedDescendants() const {
+    return oof_positioned_descendants_;
   }
 
  protected:
@@ -170,7 +160,6 @@
 
   static bool DependsOnPercentageBlockSize(const NGContainerFragmentBuilder&);
 
-<<<<<<< HEAD   (4386eb Move break_token_ to NGPhysicalContainerFragment from NGPhys)
 <<<<<<< HEAD   (d91d4f Allocate memory for borders and padding members of NGPhysica)
   Vector<NGOutOfFlowPositionedDescendant> oof_positioned_descendants_;
 =======
@@ -178,10 +167,6 @@
   const std::unique_ptr<Vector<NGOutOfFlowPositionedDescendant>>
       oof_positioned_descendants_;
 >>>>>>> CHANGE (3ad1c0 Move break_token_ to NGPhysicalContainerFragment from NGPhys)
-=======
-  const std::unique_ptr<Vector<NGOutOfFlowPositionedDescendant>>
-      oof_positioned_descendants_;
->>>>>>> CHANGE (763c67 Allocate vector of NGOutOfFlowPositionedDescendant in 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.