Mark for compositing inputs update after unthrottling.

A previous CL (*) made PaintLayerCompositor::CanBeComposited
depend on throttling state. CanBeComposited in turn affects compositing
inputs. Therefore when throttling state changes, compositing inputs
need to be re-computed.

(*) https://chromium-review.googlesource.com/c/chromium/src/+/2277332

Bug: 1139116

(cherry picked from commit 96f3048eb9194d8ab5ed157c46f549084bd103bb)

(cherry picked from commit 81eed342a1201a90a691dee3691ab79d299bf4fc)

Change-Id: I1152e447ade9f2f848707f992f9c4fc1574bba7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485438
Commit-Queue: Chris Harrelson <[email protected]>
Reviewed-by: Stefan Zager <[email protected]>
Cr-Original-Original-Commit-Position: refs/heads/master@{#818625}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485625
Reviewed-by: Krishna Govind <[email protected]>
Cr-Original-Commit-Position: refs/branch-heads/4296@{#11}
Cr-Original-Branched-From: 348f473375481bbae653524aad76d79cb8285fd7-refs/heads/master@{#818242}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2486545
Reviewed-by: Chris Harrelson <[email protected]>
Commit-Queue: Krishna Govind <[email protected]>
Cr-Commit-Position: refs/branch-heads/4280@{#524}
Cr-Branched-From: ea420fb963f9658c9969b6513c56b8f47efa1a2a-refs/heads/master@{#812852}
diff --git a/third_party/blink/renderer/core/frame/local_frame_view.cc b/third_party/blink/renderer/core/frame/local_frame_view.cc
index dc779bb..d5986709 100644
--- a/third_party/blink/renderer/core/frame/local_frame_view.cc
+++ b/third_party/blink/renderer/core/frame/local_frame_view.cc
@@ -4301,6 +4301,13 @@
     // the frame was throttled.
     layout_view->AddSubtreePaintPropertyUpdateReason(
         SubtreePaintPropertyUpdateReason::kPreviouslySkipped);
+
+    if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) {
+      // PaintLayerCompositor::CanBeComposited returns an incorrect visibility
+      // value for throttled frames, and it needs to be recomputed when the
+      // frame becomes unthrottled again.
+      layout_view->Layer()->SetNeedsCompositingInputsUpdate();
+    }
   }
   // Ensure we'll recompute viewport intersection for the frame subtree during
   // the scheduled visual update.
diff --git a/third_party/blink/renderer/core/scheduler_integration_tests/frame_throttling_test.cc b/third_party/blink/renderer/core/scheduler_integration_tests/frame_throttling_test.cc
index 503ff227..d9d93311 100644
--- a/third_party/blink/renderer/core/scheduler_integration_tests/frame_throttling_test.cc
+++ b/third_party/blink/renderer/core/scheduler_integration_tests/frame_throttling_test.cc
@@ -495,7 +495,26 @@
   // Then bring it back on-screen. This should schedule an animation update.
   frame_element->setAttribute(kStyleAttr, "");
   CompositeFrame();
+
+  if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) {
+    // Compositing inputs need to be re-computed on the next frame after
+    // unthrottling, because while throttled all throttled content is not
+    // considered eligible for compositing (PLC::CanBeComposited often returns
+    // false).
+    EXPECT_TRUE(frame_element->contentDocument()
+                    ->View()
+                    ->GetLayoutView()
+                    ->Layer()
+                    ->NeedsCompositingInputsUpdate());
+  }
+
   EXPECT_TRUE(Compositor().NeedsBeginFrame());
+  CompositeFrame();
+  EXPECT_FALSE(frame_element->contentDocument()
+                   ->View()
+                   ->GetLayoutView()
+                   ->Layer()
+                   ->NeedsCompositingInputsUpdate());
 }
 
 TEST_P(FrameThrottlingTest, MutatingThrottledFrameDoesNotCauseAnimation) {