OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bindings/core/v8/ScriptController.h" | 5 #include "bindings/core/v8/ScriptController.h" |
6 #include "bindings/core/v8/ScriptSourceCode.h" | 6 #include "bindings/core/v8/ScriptSourceCode.h" |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/dom/Element.h" | 8 #include "core/dom/Element.h" |
9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
11 #include "core/html/HTMLIFrameElement.h" | 11 #include "core/html/HTMLIFrameElement.h" |
12 #include "core/layout/api/LayoutViewItem.h" | 12 #include "core/layout/api/LayoutViewItem.h" |
13 #include "core/page/FocusController.h" | 13 #include "core/page/FocusController.h" |
14 #include "core/page/Page.h" | 14 #include "core/page/Page.h" |
15 #include "core/paint/PaintLayer.h" | 15 #include "core/paint/PaintLayer.h" |
| 16 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
16 #include "platform/testing/URLTestHelpers.h" | 17 #include "platform/testing/URLTestHelpers.h" |
17 #include "platform/testing/UnitTestHelpers.h" | 18 #include "platform/testing/UnitTestHelpers.h" |
18 #include "public/platform/WebDisplayItemList.h" | 19 #include "public/platform/WebDisplayItemList.h" |
19 #include "public/platform/WebLayer.h" | 20 #include "public/platform/WebLayer.h" |
20 #include "public/web/WebFrameContentDumper.h" | 21 #include "public/web/WebFrameContentDumper.h" |
21 #include "public/web/WebHitTestResult.h" | 22 #include "public/web/WebHitTestResult.h" |
22 #include "public/web/WebSettings.h" | 23 #include "public/web/WebSettings.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
24 #include "web/WebLocalFrameImpl.h" | 25 #include "web/WebLocalFrameImpl.h" |
25 #include "web/WebRemoteFrameImpl.h" | 26 #include "web/WebRemoteFrameImpl.h" |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering()); | 924 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering()); |
924 | 925 |
925 LocalFrame* localFrame = toLocalFrame(frameElement->contentFrame()); | 926 LocalFrame* localFrame = toLocalFrame(frameElement->contentFrame()); |
926 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 927 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
927 v8::Local<v8::Value> result = | 928 v8::Local<v8::Value> result = |
928 localFrame->script().executeScriptInMainWorldAndReturnValue( | 929 localFrame->script().executeScriptInMainWorldAndReturnValue( |
929 ScriptSourceCode("window.didRaf;")); | 930 ScriptSourceCode("window.didRaf;")); |
930 EXPECT_TRUE(result->IsTrue()); | 931 EXPECT_TRUE(result->IsTrue()); |
931 } | 932 } |
932 | 933 |
| 934 TEST_F(FrameThrottlingTest, UpdatePaintPropertiesOnUnthrottling) { |
| 935 if (!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) |
| 936 return; |
| 937 |
| 938 SimRequest mainResource("https://example.com/", "text/html"); |
| 939 SimRequest frameResource("https://example.com/iframe.html", "text/html"); |
| 940 |
| 941 loadURL("https://example.com/"); |
| 942 mainResource.complete("<iframe id=frame sandbox src=iframe.html></iframe>"); |
| 943 frameResource.complete("<div id='div'>Inner</div>"); |
| 944 compositeFrame(); |
| 945 |
| 946 auto* frameElement = toHTMLIFrameElement(document().getElementById("frame")); |
| 947 auto* frameDocument = frameElement->contentDocument(); |
| 948 auto* innerDiv = frameDocument->getElementById("div"); |
| 949 auto* innerDivObject = innerDiv->layoutObject(); |
| 950 EXPECT_FALSE(frameDocument->view()->shouldThrottleRendering()); |
| 951 |
| 952 frameElement->setAttribute(HTMLNames::styleAttr, |
| 953 "transform: translateY(1000px)"); |
| 954 compositeFrame(); |
| 955 EXPECT_TRUE(frameDocument->view()->canThrottleRendering()); |
| 956 EXPECT_FALSE(innerDivObject->paintProperties()->transform()); |
| 957 |
| 958 // Mutating the throttled frame should not cause paint property update. |
| 959 innerDiv->setAttribute(HTMLNames::styleAttr, "transform: translateY(20px)"); |
| 960 EXPECT_FALSE(compositor().needsBeginFrame()); |
| 961 EXPECT_TRUE(frameDocument->view()->canThrottleRendering()); |
| 962 { |
| 963 DocumentLifecycle::AllowThrottlingScope throttlingScope( |
| 964 document().lifecycle()); |
| 965 document().view()->updateAllLifecyclePhases(); |
| 966 } |
| 967 EXPECT_FALSE(innerDivObject->paintProperties()->transform()); |
| 968 |
| 969 // Move the frame back on screen to unthrottle it. |
| 970 frameElement->setAttribute(HTMLNames::styleAttr, ""); |
| 971 // The first update unthrottles the frame, the second actually update layout |
| 972 // and paint properties etc. |
| 973 compositeFrame(); |
| 974 compositeFrame(); |
| 975 EXPECT_FALSE(frameDocument->view()->canThrottleRendering()); |
| 976 EXPECT_EQ(TransformationMatrix().translate(0, 20), |
| 977 innerDiv->layoutObject()->paintProperties()->transform()->matrix()); |
| 978 } |
| 979 |
933 } // namespace blink | 980 } // namespace blink |
OLD | NEW |