requestAnimationFrame doesn't throttle on Mac
https://bugs.webkit.org/show_bug.cgi?id=67171

Reviewed by Simon Fraser.

Source/JavaScriptCore:

Added WTF_USE_REQUEST_ANIMATION_FRAME_TIMER to allow any platform to run
requestAnimationFrame callbacks on a Timer defined in ScriptedAnimationController.
Currently only enabled for PLATFORM(MAC)

* wtf/Platform.h:

Source/WebCore:

Changed requestAnimationFrame to use a Timer in ScriptedAnimationController
on Mac, rather than runLoopObservers. The Timer is throttled to fire no
faster than every 15ms. It is behind a WTF_USE_REQUEST_ANIMATION_FRAME_TIMER
flag and can be used by any implementation, but currently it is only enabled
by PLATFORM(MAC).

* dom/ScriptedAnimationController.cpp:
(WebCore::ScriptedAnimationController::ScriptedAnimationController):
(WebCore::ScriptedAnimationController::resume):
(WebCore::ScriptedAnimationController::registerCallback):
(WebCore::ScriptedAnimationController::serviceScriptedAnimations):
(WebCore::ScriptedAnimationController::scheduleAnimation):
(WebCore::ScriptedAnimationController::animationTimerFired):
* dom/ScriptedAnimationController.h:
* loader/EmptyClients.h:
* page/Chrome.cpp:
(WebCore::Chrome::scheduleAnimation):
* page/ChromeClient.h:

Source/WebKit/mac:

Removed runLoopObserver for requestAnimationFrame. It's now
done by a Timer in ScriptedAnimationController in WebCore.

* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
* WebView/WebView.mm:
(-[WebView _close]):
* WebView/WebViewData.h:
* WebView/WebViewInternal.h:

Source/WebKit2:

Removed runLoopObserver for requestAnimationFrame. It's now
done by a Timer in ScriptedAnimationController in WebCore.

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::~WebPage):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/mac/WebPageMac.mm:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@94908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/dom/ScriptedAnimationController.h b/Source/WebCore/dom/ScriptedAnimationController.h
index 7141968..ec24fb3 100644
--- a/Source/WebCore/dom/ScriptedAnimationController.h
+++ b/Source/WebCore/dom/ScriptedAnimationController.h
@@ -28,6 +28,9 @@
 
 #if ENABLE(REQUEST_ANIMATION_FRAME)
 #include "DOMTimeStamp.h"
+#if USE(REQUEST_ANIMATION_FRAME_TIMER)
+#include "Timer.h"
+#endif
 #include <wtf/Noncopyable.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/RefPtr.h>
@@ -58,12 +61,21 @@
 
 private:
     explicit ScriptedAnimationController(Document*);
+    
     typedef Vector<RefPtr<RequestAnimationFrameCallback> > CallbackList;
     CallbackList m_callbacks;
 
     Document* m_document;
     CallbackId m_nextCallbackId;
     int m_suspendCount;
+
+    void scheduleAnimation();
+
+#if USE(REQUEST_ANIMATION_FRAME_TIMER)
+    void animationTimerFired(Timer<ScriptedAnimationController>*);
+    Timer<ScriptedAnimationController> m_animationTimer;
+    double m_lastAnimationFrameTime;
+#endif
 };
 
 }