| 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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 | 506 |
| 507 // Make the frame visible by changing its transform. This doesn't cause a | 507 // Make the frame visible by changing its transform. This doesn't cause a |
| 508 // layout, but should still unthrottle the frame. | 508 // layout, but should still unthrottle the frame. |
| 509 frameElement->setAttribute(styleAttr, "transform: translateY(0px)"); | 509 frameElement->setAttribute(styleAttr, "transform: translateY(0px)"); |
| 510 compositeFrame(); | 510 compositeFrame(); |
| 511 EXPECT_FALSE(frameElement->contentDocument()->view()->canThrottleRendering()
); | 511 EXPECT_FALSE(frameElement->contentDocument()->view()->canThrottleRendering()
); |
| 512 // The fixed background in the throttled sub frame should be considered. | 512 // The fixed background in the throttled sub frame should be considered. |
| 513 EXPECT_TRUE(document().view()->shouldScrollOnMainThread()); | 513 EXPECT_TRUE(document().view()->shouldScrollOnMainThread()); |
| 514 } | 514 } |
| 515 | 515 |
| 516 TEST_F(FrameThrottlingTest, ScrollingCoordinatorShouldSkipThrottledLayer) |
| 517 { |
| 518 webView().settings()->setJavaScriptEnabled(true); |
| 519 webView().settings()->setAcceleratedCompositingEnabled(true); |
| 520 webView().settings()->setPreferCompositingToLCDTextEnabled(true); |
| 521 |
| 522 // Create a hidden frame which is throttled and has a touch handler inside a |
| 523 // composited layer. |
| 524 SimRequest mainResource("https://example.com/", "text/html"); |
| 525 SimRequest frameResource("https://example.com/iframe.html", "text/html"); |
| 526 |
| 527 loadURL("https://example.com/"); |
| 528 mainResource.complete("<iframe id=frame sandbox=allow-scripts src=iframe.htm
l></iframe>"); |
| 529 frameResource.complete("<div id=div style='transform: translateZ(0)' ontouch
start='foo()'>touch handler</div>"); |
| 530 |
| 531 // Move the frame offscreen to throttle it. |
| 532 auto* frameElement = toHTMLIFrameElement(document().getElementById("frame"))
; |
| 533 frameElement->setAttribute(styleAttr, "transform: translateY(480px)"); |
| 534 EXPECT_FALSE(frameElement->contentDocument()->view()->canThrottleRendering()
); |
| 535 compositeFrame(); |
| 536 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering())
; |
| 537 |
| 538 // Change style of the frame's content to make it in VisualUpdatePending sta
te. |
| 539 frameElement->contentDocument()->body()->setAttribute(styleAttr, "background
: green"); |
| 540 // Change root frame's layout so that the next lifecycle update will call |
| 541 // ScrollingCoordinator::updateAfterCompositingChangeIfNeeded(). |
| 542 document().body()->setAttribute(styleAttr, "margin: 20px"); |
| 543 EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameElement->contentDocum
ent()->lifecycle().state()); |
| 544 |
| 545 DocumentLifecycle::AllowThrottlingScope throttlingScope(document().lifecycle
()); |
| 546 // This will call ScrollingCoordinator::updateAfterCompositingChangeIfNeeded
() and should not |
| 547 // cause assert failure about isAllowedToQueryCompositingState() in the thro
ttled frame. |
| 548 document().view()->updateAllLifecyclePhases(); |
| 549 testing::runPendingTasks(); |
| 550 EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameElement->contentDocum
ent()->lifecycle().state()); |
| 551 } |
| 552 |
| 516 TEST_F(FrameThrottlingTest, ScrollingCoordinatorShouldSkipCompositedThrottledFra
me) | 553 TEST_F(FrameThrottlingTest, ScrollingCoordinatorShouldSkipCompositedThrottledFra
me) |
| 517 { | 554 { |
| 518 webView().settings()->setAcceleratedCompositingEnabled(true); | 555 webView().settings()->setAcceleratedCompositingEnabled(true); |
| 519 webView().settings()->setPreferCompositingToLCDTextEnabled(true); | 556 webView().settings()->setPreferCompositingToLCDTextEnabled(true); |
| 520 | 557 |
| 521 // Create a hidden frame which is throttled. | 558 // Create a hidden frame which is throttled. |
| 522 SimRequest mainResource("https://example.com/", "text/html"); | 559 SimRequest mainResource("https://example.com/", "text/html"); |
| 523 SimRequest frameResource("https://example.com/iframe.html", "text/html"); | 560 SimRequest frameResource("https://example.com/iframe.html", "text/html"); |
| 524 | 561 |
| 525 loadURL("https://example.com/"); | 562 loadURL("https://example.com/"); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering())
; | 772 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering())
; |
| 736 EXPECT_TRUE(childFrameElement->contentDocument()->view()->canThrottleRenderi
ng()); | 773 EXPECT_TRUE(childFrameElement->contentDocument()->view()->canThrottleRenderi
ng()); |
| 737 | 774 |
| 738 // Both frames should still be throttled after the second notification. | 775 // Both frames should still be throttled after the second notification. |
| 739 childFrameElement->contentDocument()->view()->notifyRenderThrottlingObserver
sForTesting(); | 776 childFrameElement->contentDocument()->view()->notifyRenderThrottlingObserver
sForTesting(); |
| 740 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering())
; | 777 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering())
; |
| 741 EXPECT_TRUE(childFrameElement->contentDocument()->view()->canThrottleRenderi
ng()); | 778 EXPECT_TRUE(childFrameElement->contentDocument()->view()->canThrottleRenderi
ng()); |
| 742 } | 779 } |
| 743 | 780 |
| 744 } // namespace blink | 781 } // namespace blink |
| OLD | NEW |