[LayoutNG] Move paint invalidations to layout

This patch moves paint invalidations from NGPaintFragment
creation to layout code. Style and layout knows what were
really changed, and should be smarter to invalidate.

This patch matches paint invalidations for inline boxes to
legacy in most cases.
1. Text boxes will always be FullPaintInvalidation.
   There maybe cases where legacy can skip it, as it does so
   when InlineTextBox is moved. This is to be investigated in
   future caching code.
2. Inline boxes (LayoutInline) is FullPaintInvalidation if it
   produces box fragments (DisplayItemClient). Otherwise NG
   does no paint invalidation.
   Legacy does |CheckForPaintInvalidation| even when it's
   culled, but this doesn't seem necessary.

This patch avoids paint invalidations on position changes
for the test case in crbug.com/950373.

Bug: 950373
Change-Id: I0b80a527ef4243e5a5eb5dc59a2fd9d52a913c39
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1574982
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653059}
diff --git a/third_party/blink/renderer/core/layout/layout_object.h b/third_party/blink/renderer/core/layout/layout_object.h
index 234b87f9..cd56168 100644
--- a/third_party/blink/renderer/core/layout/layout_object.h
+++ b/third_party/blink/renderer/core/layout/layout_object.h
@@ -1231,7 +1231,12 @@
       LayoutInvalidationReasonForTracing,
       MarkingBehavior = kMarkContainerChain,
       SubtreeLayoutScope* = nullptr);
+
+  void ClearNeedsLayoutWithoutPaintInvalidation();
+  // |ClearNeedsLayout()| calls |SetShouldCheckForPaintInvalidation()|.
   void ClearNeedsLayout();
+  void ClearNeedsLayoutWithFullPaintInvalidation();
+
   void SetChildNeedsLayout(MarkingBehavior = kMarkContainerChain,
                            SubtreeLayoutScope* = nullptr);
   void SetNeedsPositionedMovementLayout();
@@ -3109,10 +3114,9 @@
   SetShouldDoFullPaintInvalidation();
 }
 
-inline void LayoutObject::ClearNeedsLayout() {
+inline void LayoutObject::ClearNeedsLayoutWithoutPaintInvalidation() {
   // Set flags for later stages/cycles.
   SetEverHadLayout();
-  SetShouldCheckForPaintInvalidation();
 
   // Clear needsLayout flags.
   SetSelfNeedsLayoutForStyle(false);
@@ -3130,6 +3134,16 @@
   SetScrollAnchorDisablingStyleChanged(false);
 }
 
+inline void LayoutObject::ClearNeedsLayout() {
+  ClearNeedsLayoutWithoutPaintInvalidation();
+  SetShouldCheckForPaintInvalidation();
+}
+
+inline void LayoutObject::ClearNeedsLayoutWithFullPaintInvalidation() {
+  ClearNeedsLayoutWithoutPaintInvalidation();
+  SetShouldDoFullPaintInvalidation();
+}
+
 inline void LayoutObject::SetChildNeedsLayout(MarkingBehavior mark_parents,
                                               SubtreeLayoutScope* layouter) {
 #if DCHECK_IS_ON()
diff --git a/third_party/blink/renderer/core/layout/ng/inline/ng_inline_box_state.cc b/third_party/blink/renderer/core/layout/ng/inline/ng_inline_box_state.cc
index 1899fd1..a477d8f 100644
--- a/third_party/blink/renderer/core/layout/ng/inline/ng_inline_box_state.cc
+++ b/third_party/blink/renderer/core/layout/ng/inline/ng_inline_box_state.cc
@@ -609,6 +609,10 @@
     }
   }
 
+  // Inline boxes that produce DisplayItemClient should do full paint
+  // invalidations.
+  item->GetLayoutObject()->SetShouldDoFullPaintInvalidation();
+
   box.MoveOutOfFlowDescendantCandidatesToDescendants();
   return box.ToInlineBoxFragment();
 }
diff --git a/third_party/blink/renderer/core/layout/ng/inline/ng_inline_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/inline/ng_inline_layout_algorithm.cc
index c8c01e84..105a5ca 100644
--- a/third_party/blink/renderer/core/layout/ng/inline/ng_inline_layout_algorithm.cc
+++ b/third_party/blink/renderer/core/layout/ng/inline/ng_inline_layout_algorithm.cc
@@ -96,8 +96,10 @@
     box->EnsureTextMetrics(*item.Style(), baseline_type_);
   box = box_states_->OnCloseTag(&line_box_, box, baseline_type_,
                                 item.HasEndEdge());
-  item.GetLayoutObject()->SetShouldDoFullPaintInvalidation();
-  ClearNeedsLayoutIfNeeded(item.GetLayoutObject());
+  // Just clear |NeedsLayout| flags. Culled inline boxes do not need paint
+  // invalidations. If this object produces box fragments,
+  // |NGInlineBoxStateStack| takes care of invalidations.
+  item.GetLayoutObject()->ClearNeedsLayoutWithoutPaintInvalidation();
   return box;
 }
 
@@ -239,7 +241,8 @@
       }
       line_box_.AddChild(text_builder.ToTextFragment(), box->text_top,
                          item_result.inline_size, item.BidiLevel());
-      ClearNeedsLayoutIfNeeded(item.GetLayoutObject());
+      // Text boxes always need full paint invalidations.
+      item.GetLayoutObject()->ClearNeedsLayoutWithFullPaintInvalidation();
     } else if (item.Type() == NGInlineItem::kControl) {
       PlaceControlItem(item, *line_info, &item_result, box);
     } else if (item.Type() == NGInlineItem::kOpenTag) {
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 67a0197..3f14153 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
@@ -267,14 +267,6 @@
     // If the LayoutObject are the same, the new paint fragment should have the
     // same DisplayItemClient identity as the previous instance.
     if (previous_instance->GetLayoutObject() == fragment->GetLayoutObject()) {
-      // If our fragment has changed size or location, mark ourselves as
-      // requiring a full paint invalidation. We always require a full paint
-      // invalidation if we aren't a box, e.g. a text fragment.
-      if (previous_instance->physical_fragment_->Size() != fragment->Size() ||
-          previous_instance->offset_ != offset ||
-          fragment->Type() != NGPhysicalFragment::kFragmentBox)
-        previous_instance->SetShouldDoFullPaintInvalidation();
-
       previous_instance->physical_fragment_ = std::move(fragment);
       previous_instance->offset_ = offset;
       previous_instance->next_for_same_layout_object_ = nullptr;
@@ -287,7 +279,6 @@
 
   scoped_refptr<NGPaintFragment> new_instance =
       base::AdoptRef(new NGPaintFragment(std::move(fragment), offset, parent));
-  new_instance->SetShouldDoFullPaintInvalidation();
   return new_instance;
 }
 
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/http/tests/devtools/tracing/timeline-paint/timeline-paint-with-layout-invalidations-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/http/tests/devtools/tracing/timeline-paint/timeline-paint-with-layout-invalidations-expected.txt
new file mode 100644
index 0000000..5fbcb30
--- /dev/null
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/http/tests/devtools/tracing/timeline-paint/timeline-paint-with-layout-invalidations-expected.txt
@@ -0,0 +1,55 @@
+Tests the Timeline API instrumentation of paint events with layout invalidations.
+
+
+Running: testLocalFrame
+paint invalidations[
+    {
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: test://evaluations/0/timeline-paint-with-layout-invalidations.js:17}
+        changedAttribute : undefined
+        changedClass : undefined
+        changedId : undefined
+        changedPseudo : undefined
+        extraData : ""
+        nodeName : "BODY"
+        selectorPart : undefined
+        type : "StyleRecalcInvalidationTracking"
+    }
+]
+
+Running: testSubframe
+second paint invalidations[
+    {
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: test://evaluations/0/timeline-paint-with-layout-invalidations.js:25}
+        changedAttribute : undefined
+        changedClass : undefined
+        changedId : undefined
+        changedPseudo : undefined
+        extraData : ""
+        nodeName : "DIV"
+        selectorPart : undefined
+        type : "StyleRecalcInvalidationTracking"
+    }
+    {
+        cause : {reason: Style changed, stackTrace: test://evaluations/0/timeline-paint-with-layout-invalidations.js:26}
+        changedAttribute : undefined
+        changedClass : undefined
+        changedId : undefined
+        changedPseudo : undefined
+        extraData : undefined
+        nodeName : "DIV"
+        selectorPart : undefined
+        type : "LayoutInvalidationTracking"
+    }
+    {
+        cause : {reason: Scrollbar changed, stackTrace: test://evaluations/0/timeline-paint-with-layout-invalidations.js:26}
+        changedAttribute : undefined
+        changedClass : undefined
+        changedId : undefined
+        changedPseudo : undefined
+        extraData : undefined
+        nodeName : "#document"
+        selectorPart : undefined
+        type : "LayoutInvalidationTracking"
+    }
+]
+
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/background/background-resize-height-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/background/background-resize-height-expected.txt
index 6c0d2b3..af8cb8b 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/background/background-resize-height-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/background/background-resize-height-expected.txt
@@ -26,8 +26,8 @@
       "paintInvalidations": [
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test image'",
-          "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "rect": [0, 40, 60, 4],
+          "reason": "incremental"
         }
       ]
     },
@@ -41,7 +41,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test image size-cover'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     },
@@ -55,7 +55,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test image size-contain'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     },
@@ -68,8 +68,8 @@
       "paintInvalidations": [
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test image fixed-height'",
-          "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "rect": [0, 40, 60, 4],
+          "reason": "incremental"
         }
       ]
     },
@@ -83,7 +83,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test image percent-height'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     },
@@ -96,8 +96,8 @@
       "paintInvalidations": [
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test image top'",
-          "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "rect": [0, 40, 60, 4],
+          "reason": "incremental"
         }
       ]
     },
@@ -111,7 +111,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test image bottom'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     },
@@ -125,7 +125,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test image center'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     },
@@ -137,8 +137,8 @@
       "paintInvalidations": [
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test image no-repeat'",
-          "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "rect": [0, 40, 60, 4],
+          "reason": "incremental"
         }
       ]
     },
@@ -151,7 +151,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test image repeat-space'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     },
@@ -165,7 +165,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test image repeat-round'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     },
@@ -179,7 +179,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test generated'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     },
@@ -193,7 +193,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test generated size-cover'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     },
@@ -207,7 +207,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test generated size-contain'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     },
@@ -221,7 +221,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test generated percent-height'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     },
@@ -235,7 +235,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test generated top'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     },
@@ -249,7 +249,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test generated bottom'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     },
@@ -263,7 +263,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test generated center'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     },
@@ -276,7 +276,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test generated no-repeat'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     },
@@ -289,7 +289,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test generated repeat-space'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     },
@@ -303,7 +303,7 @@
         {
           "object": "LayoutNGBlockFlow (positioned) DIV class='test generated repeat-round'",
           "rect": [0, 0, 60, 44],
-          "reason": "geometry"
+          "reason": "background"
         }
       ]
     }
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/bugzilla-3509-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/bugzilla-3509-expected.txt
index cc12844..222f551 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/bugzilla-3509-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/bugzilla-3509-expected.txt
@@ -19,8 +19,8 @@
       "paintInvalidations": [
         {
           "object": "NGPhysicalBoxFragment LayoutNGBlockFlow DIV id='im'",
-          "rect": [11, 131, 100, 100],
-          "reason": "geometry"
+          "rect": [61, 131, 50, 100],
+          "reason": "incremental"
         },
         {
           "object": "NGPhysicalTextFragment '\u00A0'",
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/bugzilla-6278-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/bugzilla-6278-expected.txt
index 75317a3..c4d8cc1 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/bugzilla-6278-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/bugzilla-6278-expected.txt
@@ -18,11 +18,6 @@
       "backgroundColor": "#FFFFFF",
       "paintInvalidations": [
         {
-          "object": "NGPhysicalBoxFragment LayoutNGBlockFlow DIV",
-          "rect": [10, 138, 292, 160],
-          "reason": "geometry"
-        },
-        {
           "object": "LayoutNGBlockFlow DIV",
           "rect": [10, 303, 292, 50],
           "reason": "geometry"
@@ -68,11 +63,6 @@
           "reason": "geometry"
         },
         {
-          "object": "NGPhysicalBoxFragment LayoutNGBlockFlow DIV",
-          "rect": [10, 138, 242, 200],
-          "reason": "geometry"
-        },
-        {
           "object": "LayoutNGBlockFlow DIV",
           "rect": [10, 343, 242, 50],
           "reason": "geometry"
@@ -83,6 +73,11 @@
           "reason": "incremental"
         },
         {
+          "object": "NGPhysicalBoxFragment LayoutNGBlockFlow DIV",
+          "rect": [10, 298, 242, 40],
+          "reason": "incremental"
+        },
+        {
           "object": "NGPhysicalTextFragment 'Curabitur pretium, quam quis semper'",
           "rect": [10, 138, 235, 199],
           "reason": "geometry"
@@ -136,6 +131,11 @@
           "object": "LayoutNGTableCell TD id='col1'",
           "rect": [252, 138, 50, 215],
           "reason": "incremental"
+        },
+        {
+          "object": "NGPhysicalBoxFragment LayoutNGBlockFlow DIV",
+          "rect": [252, 138, 50, 160],
+          "reason": "incremental"
         }
       ]
     }
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/compositing/remove-squashed-layer-plus-move-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/compositing/remove-squashed-layer-plus-move-expected.txt
new file mode 100644
index 0000000..96d09b1
--- /dev/null
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/compositing/remove-squashed-layer-plus-move-expected.txt
@@ -0,0 +1,61 @@
+{
+  "layers": [
+    {
+      "name": "LayoutView #document",
+      "bounds": [800, 600],
+      "drawsContent": false,
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "Scrolling Layer",
+      "bounds": [785, 585],
+      "drawsContent": false
+    },
+    {
+      "name": "Scrolling Contents Layer",
+      "bounds": [1418, 1008],
+      "contentsOpaque": true,
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "Squashing Containment Layer",
+      "drawsContent": false
+    },
+    {
+      "name": "LayoutNGBlockFlow (positioned) DIV",
+      "bounds": [1000, 1000],
+      "drawsContent": false,
+      "transform": 1
+    },
+    {
+      "name": "Squashing Layer (first squashed layer: LayoutNGBlockFlow (relative positioned) DIV class='mv-tile')",
+      "position": [8, 8],
+      "bounds": [1000, 105],
+      "paintInvalidations": [
+        {
+          "object": "LayoutNGBlockFlow (relative positioned) DIV class='mv-tile'",
+          "rect": [0, 55, 100, 50],
+          "reason": "compositing update"
+        },
+        {
+          "object": "LayoutNGBlockFlow (relative positioned) DIV class='mv-tile'",
+          "rect": [0, 0, 100, 50],
+          "reason": "compositing update"
+        }
+      ]
+    }
+  ],
+  "transforms": [
+    {
+      "id": 1,
+      "transform": [
+        [1, 0, 0, 0],
+        [0, 1, 0, 0],
+        [0, 0, 1, 0],
+        [8, 8, 0, 1]
+      ],
+      "flattenInheritedTransform": false
+    }
+  ]
+}
+
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/line-flow-with-floats-1-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/line-flow-with-floats-1-expected.txt
index 024493a..dd1ef47 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/line-flow-with-floats-1-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/line-flow-with-floats-1-expected.txt
@@ -164,8 +164,8 @@
         },
         {
           "object": "LayoutNGBlockFlow (floating) DIV id='pinkFloat'",
-          "rect": [378, 18, 70, 150],
-          "reason": "geometry"
+          "rect": [378, 138, 70, 30],
+          "reason": "incremental"
         },
         {
           "object": "NGPhysicalTextFragment 'the Queen'",
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/line-flow-with-floats-5-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/line-flow-with-floats-5-expected.txt
index e6d5408..e151bfb 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/line-flow-with-floats-5-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/line-flow-with-floats-5-expected.txt
@@ -188,11 +188,6 @@
           "reason": "geometry"
         },
         {
-          "object": "LayoutNGBlockFlow (floating) SPAN id='greenFloat'",
-          "rect": [372, 403, 48, 81],
-          "reason": "geometry"
-        },
-        {
           "object": "LayoutNGBlockFlow (floating) SPAN id='blueFloat'",
           "rect": [14, 363, 48, 65],
           "reason": "geometry"
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/line-flow-with-floats-8-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/line-flow-with-floats-8-expected.txt
index a6abd2d..5dafdc4 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/line-flow-with-floats-8-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/line-flow-with-floats-8-expected.txt
@@ -193,11 +193,6 @@
           "reason": "geometry"
         },
         {
-          "object": "LayoutNGBlockFlow (floating) SPAN id='greenFloat'",
-          "rect": [372, 403, 48, 81],
-          "reason": "geometry"
-        },
-        {
           "object": "LayoutNGBlockFlow (floating) SPAN id='blueFloat'",
           "rect": [14, 363, 48, 65],
           "reason": "disappeared"
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/selection/selection-clear-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/selection/selection-clear-expected.txt
index e802c6b..a5919eee6 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/selection/selection-clear-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/selection/selection-clear-expected.txt
@@ -19,8 +19,8 @@
       "paintInvalidations": [
         {
           "object": "NGPhysicalBoxFragment LayoutNGBlockFlow DIV id='firstLine'",
-          "rect": [8, 8, 100, 200],
-          "reason": "geometry"
+          "rect": [8, 108, 100, 100],
+          "reason": "incremental"
         },
         {
           "object": "NGPhysicalTextFragment 'not run'",
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/svg/object-sizing-no-width-height-change-content-box-size-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/svg/object-sizing-no-width-height-change-content-box-size-expected.txt
index 4788dd67..d648fa9 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/svg/object-sizing-no-width-height-change-content-box-size-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/svg/object-sizing-no-width-height-change-content-box-size-expected.txt
@@ -23,16 +23,16 @@
           "reason": "geometry"
         },
         {
-          "object": "LayoutEmbeddedObject object",
-          "rect": [9, 9, 400, 400],
-          "reason": "geometry"
-        },
-        {
           "object": "LayoutSVGRoot svg",
           "rect": [9, 9, 400, 400],
           "reason": "paint property change"
         },
         {
+          "object": "LayoutEmbeddedObject object",
+          "rect": [209, 9, 200, 400],
+          "reason": "incremental"
+        },
+        {
           "object": "LayoutSVGRoot svg",
           "rect": [9, 109, 200, 200],
           "reason": "paint property change"
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/window-resize/window-resize-centered-inline-under-fixed-pos-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/window-resize/window-resize-centered-inline-under-fixed-pos-expected.txt
index 90f5fed..549e64a 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/window-resize/window-resize-centered-inline-under-fixed-pos-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/window-resize/window-resize-centered-inline-under-fixed-pos-expected.txt
@@ -23,11 +23,6 @@
           "reason": "geometry"
         },
         {
-          "object": "NGPhysicalBoxFragment LayoutNGBlockFlow DIV class='parent'",
-          "rect": [0, 0, 6, 250],
-          "reason": "geometry"
-        },
-        {
           "object": "LayoutNGBlockFlow (relative positioned) DIV class='child'",
           "rect": [0, 125, 6, 30],
           "reason": "geometry"
@@ -95,8 +90,8 @@
         },
         {
           "object": "NGPhysicalBoxFragment LayoutNGBlockFlow DIV class='parent'",
-          "rect": [0, 0, 6, 600],
-          "reason": "geometry"
+          "rect": [0, 250, 6, 350],
+          "reason": "incremental"
         },
         {
           "object": "LayoutNGBlockFlow (relative positioned) DIV class='child'",