Throttle RequestAnimationFrame in subframes that are outside the viewport
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 May 2015 18:15:57 +0000 (18:15 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 May 2015 18:15:57 +0000 (18:15 +0000)
commit1903a3d649ef9a13f9d76c61a546a4a687c6d012
tree232011d0338ebea068f87906ea5875055e3a3c3f
parent4c85f51909937c16aba53d958757d434fe68af43
Throttle RequestAnimationFrame in subframes that are outside the viewport
https://bugs.webkit.org/show_bug.cgi?id=144718
<rdar://problem/20688782>

Reviewed by Simon Fraser.

Source/WebCore:

Throttle RequestAnimationFrame in subframes that are outside the
viewport or have "display: none" for performance and power.

Tests: fast/animation/request-animation-frame-throttle-subframe-display-none.html
       fast/animation/request-animation-frame-throttle-subframe.html

* dom/Document.h:
(WebCore::Document::scriptedAnimationController):
* dom/ScriptedAnimationController.cpp:
(WebCore::ScriptedAnimationController::setThrottled):
(WebCore::ScriptedAnimationController::isThrottled):
* dom/ScriptedAnimationController.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::open):
Call FrameView::setFrameRect() only *after* the view has been
set on the Frame. Otherwise, setFrameRect() ends up calling
viewportContentsChanged() and we hit the
ASSERT(frame().view() == this) assertion in windowClipRect()
because the Frame still has its old FrameView. This is covered
by loader/go-back-to-different-window-size.html layout test.

* page/FrameView.cpp:
(WebCore::FrameView::viewportContentsChanged):
(WebCore::FrameView::applyRecursivelyWithVisibleRect):
(WebCore::FrameView::resumeVisibleImageAnimations):
(WebCore::FrameView::updateScriptedAnimationsThrottlingState):
(WebCore::FrameView::resumeVisibleImageAnimationsIncludingSubframes):
(WebCore::FrameView::updateThrottledDOMTimersState):
(WebCore::FrameView::scrollPositionChanged): Deleted.
(WebCore::FrameView::sendResizeEventIfNeeded): Deleted.
* page/FrameView.h:
* testing/Internals.cpp:
(WebCore::Internals::isRequestAnimationFrameThrottled):
(WebCore::Internals::isTimerThrottled): Deleted.
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* fast/animation/request-animation-frame-throttle-subframe-display-none-expected.txt: Added.
* fast/animation/request-animation-frame-throttle-subframe-display-none.html: Added.
Add layout test to test that RequestAnimationFrame is properly throttled
in "display: none" subframes.

* fast/animation/request-animation-frame-throttle-subframe-expected.txt: Added.
* fast/animation/request-animation-frame-throttle-subframe.html: Added.
Add layout test to test that RequestAnimationFrame is properly throttled
in frames that are outside the viewport.

* fast/animation/resources/requestAnimationFrame-frame-2.html: Added.
* fast/animation/resources/requestAnimationFrame-frame.html: Added.

* platform/win/TestExpectations:
Skip the 2 new tests on Windows as requestAnimationFrame throttling is
only supported on Cocoa.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183998 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/animation/request-animation-frame-throttle-subframe-display-none-expected.txt [new file with mode: 0644]
LayoutTests/fast/animation/request-animation-frame-throttle-subframe-display-none.html [new file with mode: 0644]
LayoutTests/fast/animation/request-animation-frame-throttle-subframe-expected.txt [new file with mode: 0644]
LayoutTests/fast/animation/request-animation-frame-throttle-subframe.html [new file with mode: 0644]
LayoutTests/fast/animation/resources/requestAnimationFrame-frame-2.html [new file with mode: 0644]
LayoutTests/fast/animation/resources/requestAnimationFrame-frame.html [new file with mode: 0644]
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.h
Source/WebCore/dom/ScriptedAnimationController.cpp
Source/WebCore/dom/ScriptedAnimationController.h
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl