diff --git a/third_party/WebKit/LayoutTests/FlagExpectations/enable-slimming-paint-v2 b/third_party/WebKit/LayoutTests/FlagExpectations/enable-slimming-paint-v2
index c6d3cd6bcaee..3bb8a4b6ee40 100644
--- a/third_party/WebKit/LayoutTests/FlagExpectations/enable-slimming-paint-v2
+++ b/third_party/WebKit/LayoutTests/FlagExpectations/enable-slimming-paint-v2
@@ -903,6 +903,7 @@ Bug(none) paint/invalidation/overflow-changed-on-child-of-composited-layer.html
Bug(none) paint/invalidation/overflow-hidden-yet-scrolled-with-custom-scrollbar.html [ Failure ]
Bug(none) paint/invalidation/overflow-hidden-yet-scrolled.html [ Failure ]
Bug(none) paint/invalidation/paint-invalidation-with-reparent-across-frame-boundaries.html [ Failure ]
+Bug(none) paint/invalidation/scrollbar-ancestor-clip-change.html [ Failure ]
Bug(none) paint/invalidation/svg/resize-svg-invalidate-children-2.html [ Failure ]
Bug(none) paint/invalidation/svg/resize-svg-invalidate-children.html [ Failure ]
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/caret-ancestor-clip-change-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/caret-ancestor-clip-change-expected.txt
new file mode 100644
index 000000000000..ac939119a33b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/caret-ancestor-clip-change-expected.txt
@@ -0,0 +1,33 @@
+{
+ "layers": [
+ {
+ "name": "LayoutView #document",
+ "bounds": [800, 600],
+ "contentsOpaque": true,
+ "backgroundColor": "#FFFFFF",
+ "paintInvalidations": [
+ {
+ "object": "LayoutBlockFlow DIV",
+ "rect": [8, 8, 95, 112],
+ "reason": "paint property change"
+ },
+ {
+ "object": "LayoutTextControl INPUT id='target'",
+ "rect": [8, 8, 95, 112],
+ "reason": "paint property change"
+ },
+ {
+ "object": "LayoutBlockFlow DIV",
+ "rect": [8, 8, 95, 50],
+ "reason": "paint property change"
+ },
+ {
+ "object": "LayoutTextControl INPUT id='target'",
+ "rect": [8, 8, 95, 50],
+ "reason": "paint property change"
+ }
+ ]
+ }
+ ]
+}
+
diff --git a/third_party/WebKit/LayoutTests/paint/invalidation/caret-ancestor-clip-change-expected.html b/third_party/WebKit/LayoutTests/paint/invalidation/caret-ancestor-clip-change-expected.html
new file mode 100644
index 000000000000..fb8aeb3633b4
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/paint/invalidation/caret-ancestor-clip-change-expected.html
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/third_party/WebKit/LayoutTests/paint/invalidation/caret-ancestor-clip-change-expected.txt b/third_party/WebKit/LayoutTests/paint/invalidation/caret-ancestor-clip-change-expected.txt
new file mode 100644
index 000000000000..2d364fc89294
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/paint/invalidation/caret-ancestor-clip-change-expected.txt
@@ -0,0 +1,46 @@
+{
+ "layers": [
+ {
+ "name": "LayoutView #document",
+ "bounds": [800, 600],
+ "contentsOpaque": true,
+ "backgroundColor": "#FFFFFF",
+ "paintInvalidations": [
+ {
+ "object": "LayoutBlockFlow DIV",
+ "rect": [8, 8, 200, 300],
+ "reason": "geometry"
+ },
+ {
+ "object": "LayoutBlockFlow DIV",
+ "rect": [8, 8, 200, 300],
+ "reason": "geometry"
+ },
+ {
+ "object": "LayoutBlockFlow DIV id='clip'",
+ "rect": [8, 58, 200, 250],
+ "reason": "incremental"
+ }
+ ]
+ }
+ ],
+ "objectPaintInvalidations": [
+ {
+ "object": "LayoutBlockFlow DIV id='clip'",
+ "reason": "incremental"
+ },
+ {
+ "object": "LayoutBlockFlow DIV",
+ "reason": "geometry"
+ },
+ {
+ "object": "LayoutBlockFlow DIV",
+ "reason": "geometry"
+ },
+ {
+ "object": "RootInlineBox",
+ "reason": "geometry"
+ }
+ ]
+}
+
diff --git a/third_party/WebKit/LayoutTests/paint/invalidation/caret-ancestor-clip-change.html b/third_party/WebKit/LayoutTests/paint/invalidation/caret-ancestor-clip-change.html
new file mode 100644
index 000000000000..7916b9c44625
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/paint/invalidation/caret-ancestor-clip-change.html
@@ -0,0 +1,21 @@
+
+
+
+
diff --git a/third_party/WebKit/LayoutTests/paint/invalidation/scrollbar-ancestor-clip-change-expected.html b/third_party/WebKit/LayoutTests/paint/invalidation/scrollbar-ancestor-clip-change-expected.html
new file mode 100644
index 000000000000..5af04754716b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/paint/invalidation/scrollbar-ancestor-clip-change-expected.html
@@ -0,0 +1,4 @@
+
+
diff --git a/third_party/WebKit/LayoutTests/paint/invalidation/scrollbar-ancestor-clip-change-expected.txt b/third_party/WebKit/LayoutTests/paint/invalidation/scrollbar-ancestor-clip-change-expected.txt
new file mode 100644
index 000000000000..caee27a0c852
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/paint/invalidation/scrollbar-ancestor-clip-change-expected.txt
@@ -0,0 +1,78 @@
+{
+ "layers": [
+ {
+ "name": "LayoutView #document",
+ "bounds": [800, 600],
+ "contentsOpaque": true,
+ "backgroundColor": "#FFFFFF",
+ "paintInvalidations": [
+ {
+ "object": "LayoutBlockFlow DIV",
+ "rect": [8, 8, 100, 300],
+ "reason": "geometry"
+ },
+ {
+ "object": "LayoutBlockFlow DIV",
+ "rect": [8, 8, 100, 300],
+ "reason": "geometry"
+ },
+ {
+ "object": "LayoutBlockFlow DIV id='clip'",
+ "rect": [8, 108, 100, 200],
+ "reason": "incremental"
+ },
+ {
+ "object": "LayoutBlockFlow DIV id='target'",
+ "rect": [8, 193, 85, 15],
+ "reason": "scroll control"
+ },
+ {
+ "object": "LayoutBlockFlow DIV id='target'",
+ "rect": [93, 8, 15, 185],
+ "reason": "scroll control"
+ },
+ {
+ "object": "LayoutBlockFlow DIV id='target'",
+ "rect": [93, 8, 15, 100],
+ "reason": "scroll control"
+ },
+ {
+ "object": "LayoutBlockFlow DIV id='target'",
+ "rect": [93, 193, 15, 15],
+ "reason": "scroll control"
+ }
+ ]
+ }
+ ],
+ "objectPaintInvalidations": [
+ {
+ "object": "LayoutBlockFlow DIV id='clip'",
+ "reason": "incremental"
+ },
+ {
+ "object": "LayoutBlockFlow DIV",
+ "reason": "geometry"
+ },
+ {
+ "object": "LayoutBlockFlow DIV",
+ "reason": "geometry"
+ },
+ {
+ "object": "LayoutBlockFlow DIV id='target'",
+ "reason": "geometry"
+ },
+ {
+ "object": "HorizontalScrollbar",
+ "reason": "scroll control"
+ },
+ {
+ "object": "LayoutBlockFlow DIV id='target'",
+ "reason": "geometry"
+ },
+ {
+ "object": "VerticalScrollbar",
+ "reason": "scroll control"
+ }
+ ]
+}
+
diff --git a/third_party/WebKit/LayoutTests/paint/invalidation/scrollbar-ancestor-clip-change.html b/third_party/WebKit/LayoutTests/paint/invalidation/scrollbar-ancestor-clip-change.html
new file mode 100644
index 000000000000..7e87b3eb837a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/paint/invalidation/scrollbar-ancestor-clip-change.html
@@ -0,0 +1,19 @@
+
+
+
+
diff --git a/third_party/WebKit/Source/core/paint/BoxPaintInvalidatorTest.cpp b/third_party/WebKit/Source/core/paint/BoxPaintInvalidatorTest.cpp
index 810e6a117295..2e1c2da64b57 100644
--- a/third_party/WebKit/Source/core/paint/BoxPaintInvalidatorTest.cpp
+++ b/third_party/WebKit/Source/core/paint/BoxPaintInvalidatorTest.cpp
@@ -189,6 +189,7 @@ TEST_P(BoxPaintInvalidatorTest, ComputePaintInvalidationReasonBasic) {
target.setAttribute(HTMLNames::styleAttr, "background: blue");
GetDocument().View()->UpdateAllLifecyclePhases();
+ box.SetMayNeedPaintInvalidation();
LayoutRect visual_rect = box.VisualRect();
EXPECT_EQ(LayoutRect(0, 0, 50, 100), visual_rect);
diff --git a/third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp b/third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp
index 4058e2bcc9ac..36c82ab0833f 100644
--- a/third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp
+++ b/third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp
@@ -439,6 +439,16 @@ ObjectPaintInvalidatorWithContext::ComputePaintInvalidationReason() {
background_obscuration_changed = true;
}
+ if (!object_.ShouldCheckForPaintInvalidation() &&
+ (!context_.subtree_flags ||
+ context_.subtree_flags ==
+ PaintInvalidatorContext::kSubtreeVisualRectUpdate)) {
+ // No paint invalidation flag, or just kSubtreeVisualRectUpdate (which has
+ // been handled in PaintInvalidator). No paint invalidation is needed.
+ DCHECK(!background_obscuration_changed);
+ return PaintInvalidationReason::kNone;
+ }
+
if (context_.subtree_flags &
PaintInvalidatorContext::kSubtreeFullInvalidation)
return PaintInvalidationReason::kSubtree;
diff --git a/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp b/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp
index b0e2dc985c45..3e41c412509e 100644
--- a/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp
@@ -504,14 +504,6 @@ void PaintInvalidator::InvalidatePaint(
UpdateEmptyVisualRectFlag(object, context);
UpdateVisualRectIfNeeded(object, tree_builder_context, context);
- if (!object.ShouldCheckForPaintInvalidation() &&
- !(context.subtree_flags &
- ~PaintInvalidatorContext::kSubtreeVisualRectUpdate)) {
- // We are done updating anything needed. No other paint invalidation work to
- // do for this object.
- return;
- }
-
PaintInvalidationReason reason = object.InvalidatePaint(context);
switch (reason) {
case PaintInvalidationReason::kDelayedFull: