| 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 "core/dom/Document.h" | 6 #include "core/dom/Document.h" |
| 7 #include "core/dom/Element.h" | 7 #include "core/dom/Element.h" |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "core/html/HTMLIFrameElement.h" | 10 #include "core/html/HTMLIFrameElement.h" |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 frameElement->contentDocument()->view()->notifyRenderThrottlingObserversForT
esting(); | 771 frameElement->contentDocument()->view()->notifyRenderThrottlingObserversForT
esting(); |
| 772 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering())
; | 772 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering())
; |
| 773 EXPECT_TRUE(childFrameElement->contentDocument()->view()->canThrottleRenderi
ng()); | 773 EXPECT_TRUE(childFrameElement->contentDocument()->view()->canThrottleRenderi
ng()); |
| 774 | 774 |
| 775 // Both frames should still be throttled after the second notification. | 775 // Both frames should still be throttled after the second notification. |
| 776 childFrameElement->contentDocument()->view()->notifyRenderThrottlingObserver
sForTesting(); | 776 childFrameElement->contentDocument()->view()->notifyRenderThrottlingObserver
sForTesting(); |
| 777 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering())
; | 777 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering())
; |
| 778 EXPECT_TRUE(childFrameElement->contentDocument()->view()->canThrottleRenderi
ng()); | 778 EXPECT_TRUE(childFrameElement->contentDocument()->view()->canThrottleRenderi
ng()); |
| 779 } | 779 } |
| 780 | 780 |
| 781 TEST_F(FrameThrottlingTest, SkipPaintingLayersInThrottledFrames) |
| 782 { |
| 783 webView().settings()->setAcceleratedCompositingEnabled(true); |
| 784 webView().settings()->setPreferCompositingToLCDTextEnabled(true); |
| 785 |
| 786 SimRequest mainResource("https://example.com/", "text/html"); |
| 787 SimRequest frameResource("https://example.com/iframe.html", "text/html"); |
| 788 |
| 789 loadURL("https://example.com/"); |
| 790 mainResource.complete("<iframe id=frame sandbox src=iframe.html></iframe>"); |
| 791 frameResource.complete("<div id=div style='transform: translateZ(0); backgro
und: red'>layer</div>"); |
| 792 auto displayItems = compositeFrame(); |
| 793 EXPECT_TRUE(displayItems.contains(SimCanvas::Rect, "red")); |
| 794 |
| 795 auto* frameElement = toHTMLIFrameElement(document().getElementById("frame"))
; |
| 796 frameElement->setAttribute(styleAttr, "transform: translateY(480px)"); |
| 797 compositeFrame(); |
| 798 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering())
; |
| 799 |
| 800 auto* frameDocument = frameElement->contentDocument(); |
| 801 EXPECT_EQ(DocumentLifecycle::PaintClean, frameDocument->lifecycle().state())
; |
| 802 |
| 803 // Simulate the paint for a graphics layer being externally invalidated |
| 804 // (e.g., by video playback). |
| 805 frameDocument->view()->layoutView()->invalidatePaintForViewAndCompositedLaye
rs(); |
| 806 |
| 807 // The layer inside the throttled frame should not get painted. |
| 808 auto displayItems2 = compositeFrame(); |
| 809 EXPECT_FALSE(displayItems2.contains(SimCanvas::Rect, "red")); |
| 810 } |
| 811 |
| 781 } // namespace blink | 812 } // namespace blink |
| OLD | NEW |