Commit f1ebd4aa authored by wangxianzhu's avatar wangxianzhu Committed by Commit bot

[SPInvalidation] Update paint properties of frame subtree when unthrottled

BUG=645667
TEST=FrameThrottlingTest.MutatingThrottledFrameDoesNotCauseAnimation etc. with --enable-slimming-paint-invalidation

Review-Url: https://codereview.chromium.org/2598073003
Cr-Commit-Position: refs/heads/master@{#440823}
parent 46dcc19e
...@@ -4622,6 +4622,9 @@ void FrameView::updateRenderThrottlingStatus(bool hidden, ...@@ -4622,6 +4622,9 @@ void FrameView::updateRenderThrottlingStatus(bool hidden,
LayoutViewItem layoutViewItem = this->layoutViewItem(); LayoutViewItem layoutViewItem = this->layoutViewItem();
if (!layoutViewItem.isNull()) if (!layoutViewItem.isNull())
layoutViewItem.invalidatePaintForViewAndCompositedLayers(); layoutViewItem.invalidatePaintForViewAndCompositedLayers();
// Also need to update all paint properties that might be skipped while
// the frame was throttled.
setSubtreeNeedsPaintPropertyUpdate();
} }
bool hasHandlers = m_frame->host() && bool hasHandlers = m_frame->host() &&
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "core/page/FocusController.h" #include "core/page/FocusController.h"
#include "core/page/Page.h" #include "core/page/Page.h"
#include "core/paint/PaintLayer.h" #include "core/paint/PaintLayer.h"
#include "platform/graphics/paint/TransformPaintPropertyNode.h"
#include "platform/testing/URLTestHelpers.h" #include "platform/testing/URLTestHelpers.h"
#include "platform/testing/UnitTestHelpers.h" #include "platform/testing/UnitTestHelpers.h"
#include "public/platform/WebDisplayItemList.h" #include "public/platform/WebDisplayItemList.h"
...@@ -930,4 +931,50 @@ TEST_F(FrameThrottlingTest, AllowOneAnimationFrame) { ...@@ -930,4 +931,50 @@ TEST_F(FrameThrottlingTest, AllowOneAnimationFrame) {
EXPECT_TRUE(result->IsTrue()); EXPECT_TRUE(result->IsTrue());
} }
TEST_F(FrameThrottlingTest, UpdatePaintPropertiesOnUnthrottling) {
if (!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
return;
SimRequest mainResource("https://example.com/", "text/html");
SimRequest frameResource("https://example.com/iframe.html", "text/html");
loadURL("https://example.com/");
mainResource.complete("<iframe id=frame sandbox src=iframe.html></iframe>");
frameResource.complete("<div id='div'>Inner</div>");
compositeFrame();
auto* frameElement = toHTMLIFrameElement(document().getElementById("frame"));
auto* frameDocument = frameElement->contentDocument();
auto* innerDiv = frameDocument->getElementById("div");
auto* innerDivObject = innerDiv->layoutObject();
EXPECT_FALSE(frameDocument->view()->shouldThrottleRendering());
frameElement->setAttribute(HTMLNames::styleAttr,
"transform: translateY(1000px)");
compositeFrame();
EXPECT_TRUE(frameDocument->view()->canThrottleRendering());
EXPECT_FALSE(innerDivObject->paintProperties()->transform());
// Mutating the throttled frame should not cause paint property update.
innerDiv->setAttribute(HTMLNames::styleAttr, "transform: translateY(20px)");
EXPECT_FALSE(compositor().needsBeginFrame());
EXPECT_TRUE(frameDocument->view()->canThrottleRendering());
{
DocumentLifecycle::AllowThrottlingScope throttlingScope(
document().lifecycle());
document().view()->updateAllLifecyclePhases();
}
EXPECT_FALSE(innerDivObject->paintProperties()->transform());
// Move the frame back on screen to unthrottle it.
frameElement->setAttribute(HTMLNames::styleAttr, "");
// The first update unthrottles the frame, the second actually update layout
// and paint properties etc.
compositeFrame();
compositeFrame();
EXPECT_FALSE(frameDocument->view()->canThrottleRendering());
EXPECT_EQ(TransformationMatrix().translate(0, 20),
innerDiv->layoutObject()->paintProperties()->transform()->matrix());
}
} // namespace blink } // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment