[LayoutNG] Remove NGPaintFragment::SelfInkOverflow

Following CL:1510613, NGPaintFragment::SelfInkOverflow
returns InkOverflow which contains ContentInkOverflow. There
are several callers that seem to assume it's for self-only
because the function name has "Self".

This patch removes the function and let callers call the
appropriate functions in NGPhysicalFragment.

This is part of paint performance efforts as SSM indicates
computing InkOverflow is consuming more time in NG.

Bug: 936024
Change-Id: I6985cb9a1a1509c02a46c115af6fd38a216d85d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1510692
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#639035}
diff --git a/third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h b/third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h
index cd599b5..9a2791f 100644
--- a/third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h
+++ b/third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h
@@ -69,7 +69,7 @@
   NGPhysicalOffsetRect SelfInkOverflow() const;
 
   // Ink overflow including contents, in the local coordinates.
-  NGPhysicalOffsetRect InkOverflow(bool apply_clip) const;
+  NGPhysicalOffsetRect InkOverflow(bool apply_clip = true) const;
 
   // Ink overflow of children in local coordinates.
   NGPhysicalOffsetRect ContentsInkOverflow() const;
diff --git a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc
index 0a9146b8..66ec5de 100644
--- a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc
+++ b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc
@@ -802,11 +802,11 @@
   }
 }
 
-void NGBoxFragmentPainter::PaintTextChild(const NGPaintFragment& text_fragment,
+void NGBoxFragmentPainter::PaintTextChild(const NGPaintFragment& paint_fragment,
                                           const PaintInfo& paint_info,
                                           const LayoutPoint& paint_offset) {
   // Inline blocks should be painted by PaintAtomicInlineChild.
-  DCHECK(!text_fragment.PhysicalFragment().IsAtomicInline());
+  DCHECK(!paint_fragment.PhysicalFragment().IsAtomicInline());
 
   // Only paint during the foreground/selection phases.
   if (paint_info.phase != PaintPhase::kForeground &&
@@ -818,9 +818,12 @@
   // Note: To paint selection for <br>, we don't check intersection with
   // fragment paint rect and cull rect since computing selection rect is
   // expensive.
+  const NGPhysicalTextFragment& text_fragment =
+      ToNGPhysicalTextFragment(paint_fragment.PhysicalFragment());
   if (!text_fragment.Size().IsEmpty()) {
-    LayoutRect physical_visual_overflow = text_fragment.SelfInkOverflow();
-    physical_visual_overflow.MoveBy(text_fragment.Offset().ToLayoutPoint());
+    LayoutRect physical_visual_overflow =
+        text_fragment.SelfInkOverflow().ToLayoutRect();
+    physical_visual_overflow.MoveBy(paint_fragment.Offset().ToLayoutPoint());
     physical_visual_overflow.MoveBy(paint_offset);
     if (!paint_info.GetCullRect().Intersects(physical_visual_overflow))
       return;
@@ -832,7 +835,7 @@
       node_holder = ToLayoutText(node->GetLayoutObject())->EnsureNodeHolder();
   }
 
-  NGTextFragmentPainter text_painter(text_fragment);
+  NGTextFragmentPainter text_painter(paint_fragment);
   text_painter.Paint(paint_info, paint_offset, node_holder);
 }
 
@@ -877,7 +880,7 @@
     const ScopedPaintState& paint_state) const {
   // TODO(layout-dev): Add support for scrolling, see BlockPainter::ShouldPaint.
   return paint_state.LocalRectIntersectsCullRect(
-      box_fragment_.SelfInkOverflow());
+      PhysicalFragment().InkOverflow().ToLayoutRect());
 }
 
 void NGBoxFragmentPainter::PaintTextClipMask(GraphicsContext& context,
@@ -1067,7 +1070,7 @@
   LayoutRect rect = LayoutRect(PixelSnappedIntRect(border_rect));
   if (UNLIKELY(result.GetHitTestRequest().GetType() &
                HitTestRequest::kHitTestVisualOverflow)) {
-    rect = text_paint_fragment.SelfInkOverflow();
+    rect = text_fragment.SelfInkOverflow().ToLayoutRect();
     rect.MoveBy(border_rect.Location());
   }
 
@@ -1109,7 +1112,8 @@
     return false;
 
   const LayoutPoint overflow_location =
-      fragment.SelfInkOverflow().Location() + physical_offset;
+      fragment.PhysicalFragment().SelfInkOverflow().offset.ToLayoutPoint() +
+      physical_offset;
   if (HitTestClippedOutByBorder(location_in_container, overflow_location))
     return false;
 
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 02970b7f..96e6edba 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
@@ -363,10 +363,6 @@
          ToNGPhysicalBoxFragment(*physical_fragment_).ShouldClipOverflow();
 }
 
-LayoutRect NGPaintFragment::SelfInkOverflow() const {
-  return physical_fragment_->InkOverflow().ToLayoutRect();
-}
-
 // Populate descendants from NGPhysicalFragment tree.
 void NGPaintFragment::PopulateDescendants(
     const NGPhysicalOffset inline_offset_to_container_box,
diff --git a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h
index ad303dbe..169aa0a 100644
--- a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h
+++ b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h
@@ -159,10 +159,6 @@
   LayoutRect VisualRect() const override;
   LayoutRect PartialInvalidationVisualRect() const override;
 
-  // CSS ink overflow https://www.w3.org/TR/css-overflow-3/#ink
-  // Encloses all pixels painted by self + children.
-  LayoutRect SelfInkOverflow() const;
-
   NGPhysicalOffsetRect ComputeLocalSelectionRectForText(
       const LayoutSelectionStatus&) const;
   NGPhysicalOffsetRect ComputeLocalSelectionRectForReplaced() const;