[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

jamesr at google.com jamesr at google.com
Sun Feb 20 23:21:25 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 7e243a3860e3799511f5be09c3110adfae1a7535
Author: jamesr at google.com <jamesr at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jan 20 02:59:06 2011 +0000

    2011-01-19  James Robinson  <jamesr at chromium.org>
    
            Reviewed by Darin Fisher.
    
            Implement mozilla's requestAnimationFrame API
            https://bugs.webkit.org/show_bug.cgi?id=51218
    
            Tests for window.webkitRequestAnimationFrame().  The new tests
            are in the Skipped lists for platforms that do not set
            ENABLE(REQUEST_ANIMATION_FRAME) - which is currently all but chromium.
    
            * fast/animation/request-animation-frame-cancel-expected.txt: Added.
            * fast/animation/request-animation-frame-cancel.html: Added.
                Tests cancelling a callback within a webkitRequestAnimationFrame() callback.
            * fast/animation/request-animation-frame-cancel2-expected.txt: Added.
            * fast/animation/request-animation-frame-cancel2.html: Added.
                Tests interactions between multiple webkitRequestAnimationFrame() callbacks.
            * fast/animation/request-animation-frame-display-expected.txt: Added.
            * fast/animation/request-animation-frame-display.html: Added.
                Tests changing the display: property of an element within a callback.
            * fast/animation/request-animation-frame-expected.txt: Added.
            * fast/animation/request-animation-frame.html: Added.
                Tests the basic use of window.webkitRequestAnimationFrame().
            * fast/animation/request-animation-frame-within-callback-expected.txt: Added.
            * fast/animation/request-animation-frame-within-callback.html: Added.
                Tests setting one webkit.webkitRequestAnimationFrame() callback within another.
            * platform/gtk/Skipped:
            * platform/mac/Skipped:
            * platform/qt/Skipped:
            * platform/win/Skipped:
    2011-01-19  James Robinson  <jamesr at chromium.org>
    
            Reviewed by Darin Fisher.
    
            Implement mozilla's requestAnimationFrame API
            https://bugs.webkit.org/show_bug.cgi?id=51218
    
            This implements mozilla's proposed requestAnimationFrame API.  The idea with this API is that
            an author driving an animation from script could use window.requestAnimationFrame(callback)
            instead of window.setTimeout(callback, 0) to schedule their update logic and let the browser
            decide when to update the animations.  This avoids doing unnecessary work when the page content
            is offscreen or is being displayed at a different framerate than what the page author expects.
    
            Mozilla's proposal is here: https://developer.mozilla.org/en/DOM/window.mozRequestAnimationFrame
            This implements window.mozRequestAnimationFrame as window.webkitRequestAnimationFrame with the
            following changes:
            *) Only the callback syntax is supported, there is no before paint event
            *) webkitRequestAnimationFrame supports a second parameter Element to let the author indicate
                what content they intend to animate.  That way if the page is being displayed but the element
                in question is offscreen, we can avoid invoking the callback.
            *) No timestamp is provided to the caller and there is no window.animationStartTime property
                (see https://bugs.webkit.org/show_bug.cgi?id=51952 for discussion of this property)
            *) window.webkitRequestAnimationFrame returns a numerical id that can be used to cancel the callback
                using window.cancelWebkitRequestAnimationFrame, to parallel window.setTimeout()/window.clearTime().
    
            The implementation depends on the embedder scheduling the callbacks since the callback invocation
            depends on the page's visibility and the embedder's paint scheduling, neither of which are exposed
            to WebCore.  The expectation for the embedder is that at some point Chrome::scheduleAnimation() is
            called FrameView::serviceScriptedAnimations() should be called for the associated Page's main frame.
            Ideally serviceScriptedAnimations() would be called prior to rendering - although in practice the
            embedder has to rate limit callbacks and may not be able to tie the callback directly to the
            rendering loop.
    
            Tests: fast/animation/request-animation-frame-cancel.html
                   fast/animation/request-animation-frame-cancel2.html
                   fast/animation/request-animation-frame-display.html
                   fast/animation/request-animation-frame-within-callback.html
                   fast/animation/request-animation-frame.html
    
            * WebCore.gypi:
            * dom/Document.cpp:
            (WebCore::Document::Document):
            (WebCore::Document::webkitRequestAnimationFrame):
            (WebCore::Document::webkitCancelRequestAnimationFrame):
            (WebCore::Document::serviceScriptedAnimations):
            * dom/Document.h:
            * dom/RequestAnimationFrameCallback.h: Added.
            (WebCore::RequestAnimationFrameCallback::~RequestAnimationFrameCallback):
            * dom/RequestAnimationFrameCallback.idl: Added.
            * loader/EmptyClients.h:
            (WebCore::EmptyChromeClient::scheduleAnimation):
            * page/Chrome.cpp:
            (WebCore::Chrome::scheduleAnimation):
            * page/Chrome.h:
            * page/ChromeClient.h:
            * page/DOMWindow.cpp:
            (WebCore::DOMWindow::webkitRequestAnimationFrame):
            (WebCore::DOMWindow::webkitCancelRequestAnimationFrame):
            * page/DOMWindow.h:
            * page/DOMWindow.idl:
            * page/FrameView.cpp:
            (WebCore::FrameView::scheduleAnimation):
            (WebCore::FrameView::serviceScriptedAnimations):
            * page/FrameView.h:
            * platform/HostWindow.h:
    2011-01-19  James Robinson  <jamesr at chromium.org>
    
            Reviewed by Darin Fisher.
    
            Implement mozilla's requestAnimationFrame API
            https://bugs.webkit.org/show_bug.cgi?id=51218
    
            Chromium WebKit API support for window.webkitRequestAnimationFrame()
    
            * features.gypi:
            * public/WebWidget.h:
            * public/WebWidgetClient.h:
            (WebKit::WebWidgetClient::scheduleAnimation):
            * src/ChromeClientImpl.cpp:
            (WebKit::ChromeClientImpl::scheduleAnimation):
            * src/ChromeClientImpl.h:
            * src/WebPopupMenuImpl.cpp:
            (WebKit::WebPopupMenuImpl::animate):
            (WebKit::WebPopupMenuImpl::scheduleAnimation):
            * src/WebPopupMenuImpl.h:
            * src/WebViewImpl.cpp:
            (WebKit::WebViewImpl::animate):
            * src/WebViewImpl.h:
    2011-01-19  James Robinson  <jamesr at chromium.org>
    
            Reviewed by Darin Fisher.
    
            Implement mozilla's requestAnimationFrame API
            https://bugs.webkit.org/show_bug.cgi?id=51218
    
            Chromium DumpRenderTree support for window.webkitRequestAnimationFrame.
    
            * DumpRenderTree/chromium/WebViewHost.cpp:
            (invokeScheduleComposite):
            (WebViewHost::scheduleAnimation):
            (WebViewHost::paintInvalidatedRegion):
            * DumpRenderTree/chromium/WebViewHost.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76194 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 083c0bf..02f913f 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,34 @@
+2011-01-19  James Robinson  <jamesr at chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        Implement mozilla's requestAnimationFrame API
+        https://bugs.webkit.org/show_bug.cgi?id=51218
+
+        Tests for window.webkitRequestAnimationFrame().  The new tests
+        are in the Skipped lists for platforms that do not set
+        ENABLE(REQUEST_ANIMATION_FRAME) - which is currently all but chromium.
+
+        * fast/animation/request-animation-frame-cancel-expected.txt: Added.
+        * fast/animation/request-animation-frame-cancel.html: Added.
+            Tests cancelling a callback within a webkitRequestAnimationFrame() callback.
+        * fast/animation/request-animation-frame-cancel2-expected.txt: Added.
+        * fast/animation/request-animation-frame-cancel2.html: Added.
+            Tests interactions between multiple webkitRequestAnimationFrame() callbacks.
+        * fast/animation/request-animation-frame-display-expected.txt: Added.
+        * fast/animation/request-animation-frame-display.html: Added.
+            Tests changing the display: property of an element within a callback.
+        * fast/animation/request-animation-frame-expected.txt: Added.
+        * fast/animation/request-animation-frame.html: Added.
+            Tests the basic use of window.webkitRequestAnimationFrame().
+        * fast/animation/request-animation-frame-within-callback-expected.txt: Added.
+        * fast/animation/request-animation-frame-within-callback.html: Added.
+            Tests setting one webkit.webkitRequestAnimationFrame() callback within another.
+        * platform/gtk/Skipped:
+        * platform/mac/Skipped:
+        * platform/qt/Skipped:
+        * platform/win/Skipped:
+
 2011-01-19  Dmitry Titov  <dimich at chromium.org>
 
         [Chromium] Not reviewed, reverts the following changes:
diff --git a/LayoutTests/compositing/overflow/get-transform-from-non-box-container-expected.txt b/LayoutTests/fast/animation/request-animation-frame-cancel-expected.txt
similarity index 100%
copy from LayoutTests/compositing/overflow/get-transform-from-non-box-container-expected.txt
copy to LayoutTests/fast/animation/request-animation-frame-cancel-expected.txt
diff --git a/LayoutTests/fast/animation/request-animation-frame-cancel.html b/LayoutTests/fast/animation/request-animation-frame-cancel.html
new file mode 100644
index 0000000..4210f7b
--- /dev/null
+++ b/LayoutTests/fast/animation/request-animation-frame-cancel.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<span id="e">PASS</span>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+var e = document.getElementById("e");
+var id = window.webkitRequestAnimationFrame(function() {
+    e.innerHTML = "FAIL";
+}, e);
+
+window.webkitCancelRequestAnimationFrame(id);
+
+if (window.layoutTestController)
+    layoutTestController.display();
+</script>
diff --git a/LayoutTests/compositing/overflow/get-transform-from-non-box-container-expected.txt b/LayoutTests/fast/animation/request-animation-frame-cancel2-expected.txt
similarity index 100%
copy from LayoutTests/compositing/overflow/get-transform-from-non-box-container-expected.txt
copy to LayoutTests/fast/animation/request-animation-frame-cancel2-expected.txt
diff --git a/LayoutTests/fast/animation/request-animation-frame-cancel2.html b/LayoutTests/fast/animation/request-animation-frame-cancel2.html
new file mode 100644
index 0000000..4ac2e93
--- /dev/null
+++ b/LayoutTests/fast/animation/request-animation-frame-cancel2.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<span id="e">PASS</span>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+var e = document.getElementById("e");
+var secondCallbackId;
+
+window.webkitRequestAnimationFrame(function() {
+    window.webkitCancelRequestAnimationFrame(secondCallbackId);
+}, e);
+
+secondCallbackId = window.webkitRequestAnimationFrame(function() {
+    e.innerHTML =  "FAIL";
+}, e);
+
+if (window.layoutTestController)
+    layoutTestController.display();
+</script>
diff --git a/LayoutTests/compositing/overflow/get-transform-from-non-box-container-expected.txt b/LayoutTests/fast/animation/request-animation-frame-display-expected.txt
similarity index 100%
copy from LayoutTests/compositing/overflow/get-transform-from-non-box-container-expected.txt
copy to LayoutTests/fast/animation/request-animation-frame-display-expected.txt
diff --git a/LayoutTests/fast/animation/request-animation-frame-display.html b/LayoutTests/fast/animation/request-animation-frame-display.html
new file mode 100644
index 0000000..b822577
--- /dev/null
+++ b/LayoutTests/fast/animation/request-animation-frame-display.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<span id="a" style="display:none"></span>
+<span id="b">FAIL</span>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+var a = document.getElementById("a");
+window.webkitRequestAnimationFrame(function() {
+    b.innerHTML="PASS";
+}, a);
+
+var b = document.getElementById("b");
+window.webkitRequestAnimationFrame(function() {
+    a.style.display="";
+}, b);
+
+if (window.layoutTestController)
+    layoutTestController.display();
+</script>
+</html>
diff --git a/LayoutTests/compositing/overflow/get-transform-from-non-box-container-expected.txt b/LayoutTests/fast/animation/request-animation-frame-expected.txt
similarity index 100%
copy from LayoutTests/compositing/overflow/get-transform-from-non-box-container-expected.txt
copy to LayoutTests/fast/animation/request-animation-frame-expected.txt
diff --git a/LayoutTests/compositing/overflow/get-transform-from-non-box-container-expected.txt b/LayoutTests/fast/animation/request-animation-frame-within-callback-expected.txt
similarity index 100%
copy from LayoutTests/compositing/overflow/get-transform-from-non-box-container-expected.txt
copy to LayoutTests/fast/animation/request-animation-frame-within-callback-expected.txt
diff --git a/LayoutTests/fast/animation/request-animation-frame-within-callback.html b/LayoutTests/fast/animation/request-animation-frame-within-callback.html
new file mode 100644
index 0000000..d5a366f
--- /dev/null
+++ b/LayoutTests/fast/animation/request-animation-frame-within-callback.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<span id="e">FAIL</span>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+var e = document.getElementById("e");
+var sameFrame;
+window.webkitRequestAnimationFrame(function() {
+    sameFrame = true;
+}, e);
+window.webkitRequestAnimationFrame(function() {
+    window.webkitRequestAnimationFrame(function() {
+        e.innerHTML = sameFrame ? "FAIL" : "PASS";
+    }, e);
+}, e);
+window.webkitRequestAnimationFrame(function() {
+    sameFrame = false;
+}, e);
+
+// This should fire the three already registered callbacks, but not the one dynamically registered.
+if (window.layoutTestController)
+    layoutTestController.display();
+// This should fire the dynamically registered callback.
+if (window.layoutTestController)
+    layoutTestController.display();
+</script>
diff --git a/LayoutTests/fast/animation/request-animation-frame.html b/LayoutTests/fast/animation/request-animation-frame.html
new file mode 100644
index 0000000..7d67a97
--- /dev/null
+++ b/LayoutTests/fast/animation/request-animation-frame.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<span id="e">FAIL</span>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+var e = document.getElementById("e");
+window.webkitRequestAnimationFrame(function() {
+    e.innerHTML="PASS";
+}, e);
+if (window.layoutTestController)
+    layoutTestController.display();
+</script>
diff --git a/LayoutTests/platform/chromium/test_expectations.txt b/LayoutTests/platform/chromium/test_expectations.txt
index edd67bf..adf5cf3 100644
--- a/LayoutTests/platform/chromium/test_expectations.txt
+++ b/LayoutTests/platform/chromium/test_expectations.txt
@@ -3059,6 +3059,9 @@ BUGWK52061 DEBUG : transitions/change-values-during-transition.html = PASS TEXT
 BUGWK52061 DEBUG : transitions/interrupted-accelerated-transition.html = PASS TEXT
 BUGWK52061 DEBUG : transitions/transition-timing-function.html = PASS TEXT
 
+// These will fail on the canaries until a chromium-side features_overrides.gypi change lands
+BUG_JAMESR : fast/animation = TEXT
+
 // Failing since creation in http://trac.webkit.org/changeset/75308
 BUG_ABARTH : svg/text/caret-in-svg-text.xhtml = TEXT
 
@@ -3087,4 +3090,4 @@ BUGCR69736 : fast/js/js-continue-break-restrictions.html = TEXT
 BUGCR1 REBASELINE MAC : fast/events/offsetX-offsetY.html = TEXT
 
 // Waiting to rebaseline
-BUG_DGLAZKOV : fast/forms/slider-mouse-events.html = TEXT
\ No newline at end of file
+BUG_DGLAZKOV : fast/forms/slider-mouse-events.html = TEXT
diff --git a/LayoutTests/platform/gtk/Skipped b/LayoutTests/platform/gtk/Skipped
index 68be9d6..74a94b0 100644
--- a/LayoutTests/platform/gtk/Skipped
+++ b/LayoutTests/platform/gtk/Skipped
@@ -5588,6 +5588,9 @@ http/tests/inspector/console-websocket-error.html
 http/tests/xmlhttprequest/basic-auth-nouser.html
 http/tests/xmlhttprequest/basic-auth-nopassword.html
 
+# Requires requestAnimationFrame support
+fast/animation/
+
 # https://bugs.webkit.org/show_bug.cgi?id=52297
 editing/input/page-up-down-scrolls.html
 
diff --git a/LayoutTests/platform/mac/Skipped b/LayoutTests/platform/mac/Skipped
index 524519b..eea146b 100644
--- a/LayoutTests/platform/mac/Skipped
+++ b/LayoutTests/platform/mac/Skipped
@@ -280,3 +280,6 @@ animations/stop-animation-on-suspend.html
 
 # DRT does not support toggling caret browsing on / off
 editing/selection/caret-mode-paragraph-keys-navigation.html
+
+# Requires requestAnimationFrame support
+fast/animation/
diff --git a/LayoutTests/platform/qt/Skipped b/LayoutTests/platform/qt/Skipped
index 55368c0..52ac69f 100644
--- a/LayoutTests/platform/qt/Skipped
+++ b/LayoutTests/platform/qt/Skipped
@@ -5087,6 +5087,9 @@ editing/selection/caret-bidi-first-and-last-letters.html
 # https://bugs.webkit.org/show_bug.cgi?id=52155
 fast/text/emphasis-avoid-ruby.html
 
+# Requires requestAnimationFrame support
+fast/animation/
+
 # https://bugs.webkit.org/show_bug.cgi?id=42578
 # [Qt] DRT sideeffect revealed by r63657 and r75305
 fast/tokenizer/flush-characters-in-document-write-evil.html
diff --git a/LayoutTests/platform/win/Skipped b/LayoutTests/platform/win/Skipped
index a7456cb..703bedc 100644
--- a/LayoutTests/platform/win/Skipped
+++ b/LayoutTests/platform/win/Skipped
@@ -1115,5 +1115,6 @@ fast/loader/user-stylesheet-fast-path.html
 # DRT does not support toggling caret browsing on / off
 editing/selection/caret-mode-paragraph-keys-navigation.html
 
-# DRT does not obey addURLToRedirect
-http/tests/loading/cross-origin-XHR-willLoadRequest.html
+# Requires requestAnimationFrame support
+fast/animation/
+
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 2c53fe3..dd52c45 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,69 @@
+2011-01-19  James Robinson  <jamesr at chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        Implement mozilla's requestAnimationFrame API
+        https://bugs.webkit.org/show_bug.cgi?id=51218
+
+        This implements mozilla's proposed requestAnimationFrame API.  The idea with this API is that
+        an author driving an animation from script could use window.requestAnimationFrame(callback)
+        instead of window.setTimeout(callback, 0) to schedule their update logic and let the browser
+        decide when to update the animations.  This avoids doing unnecessary work when the page content
+        is offscreen or is being displayed at a different framerate than what the page author expects.
+
+        Mozilla's proposal is here: https://developer.mozilla.org/en/DOM/window.mozRequestAnimationFrame
+        This implements window.mozRequestAnimationFrame as window.webkitRequestAnimationFrame with the
+        following changes:
+        *) Only the callback syntax is supported, there is no before paint event
+        *) webkitRequestAnimationFrame supports a second parameter Element to let the author indicate
+            what content they intend to animate.  That way if the page is being displayed but the element
+            in question is offscreen, we can avoid invoking the callback.
+        *) No timestamp is provided to the caller and there is no window.animationStartTime property
+            (see https://bugs.webkit.org/show_bug.cgi?id=51952 for discussion of this property)
+        *) window.webkitRequestAnimationFrame returns a numerical id that can be used to cancel the callback
+            using window.cancelWebkitRequestAnimationFrame, to parallel window.setTimeout()/window.clearTime().
+
+        The implementation depends on the embedder scheduling the callbacks since the callback invocation
+        depends on the page's visibility and the embedder's paint scheduling, neither of which are exposed
+        to WebCore.  The expectation for the embedder is that at some point Chrome::scheduleAnimation() is
+        called FrameView::serviceScriptedAnimations() should be called for the associated Page's main frame.
+        Ideally serviceScriptedAnimations() would be called prior to rendering - although in practice the
+        embedder has to rate limit callbacks and may not be able to tie the callback directly to the
+        rendering loop.
+
+        Tests: fast/animation/request-animation-frame-cancel.html
+               fast/animation/request-animation-frame-cancel2.html
+               fast/animation/request-animation-frame-display.html
+               fast/animation/request-animation-frame-within-callback.html
+               fast/animation/request-animation-frame.html
+
+        * WebCore.gypi:
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        (WebCore::Document::webkitRequestAnimationFrame):
+        (WebCore::Document::webkitCancelRequestAnimationFrame):
+        (WebCore::Document::serviceScriptedAnimations):
+        * dom/Document.h:
+        * dom/RequestAnimationFrameCallback.h: Added.
+        (WebCore::RequestAnimationFrameCallback::~RequestAnimationFrameCallback):
+        * dom/RequestAnimationFrameCallback.idl: Added.
+        * loader/EmptyClients.h:
+        (WebCore::EmptyChromeClient::scheduleAnimation):
+        * page/Chrome.cpp:
+        (WebCore::Chrome::scheduleAnimation):
+        * page/Chrome.h:
+        * page/ChromeClient.h:
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::webkitRequestAnimationFrame):
+        (WebCore::DOMWindow::webkitCancelRequestAnimationFrame):
+        * page/DOMWindow.h:
+        * page/DOMWindow.idl:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::scheduleAnimation):
+        (WebCore::FrameView::serviceScriptedAnimations):
+        * page/FrameView.h:
+        * platform/HostWindow.h:
+
 2011-01-13  Martin Robinson  <mrobinson at igalia.com>
 
         Reviewed by Daniel Bates.
diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi
index d293614..018e068 100644
--- a/Source/WebCore/WebCore.gypi
+++ b/Source/WebCore/WebCore.gypi
@@ -75,6 +75,7 @@
             'dom/ProgressEvent.idl',
             'dom/Range.idl',
             'dom/RangeException.idl',
+            'dom/RequestAnimationFrameCallback.idl',
             'dom/Text.idl',
             'dom/TextEvent.idl',
             'dom/Touch.idl',
@@ -1315,6 +1316,7 @@
             'dom/Range.h',
             'dom/RangeBoundaryPoint.h',
             'dom/RangeException.h',
+            'dom/RequestAnimationFrameCallback.h',
             'dom/RawDataDocumentParser.h',
             'dom/RegisteredEventListener.cpp',
             'dom/RegisteredEventListener.h',
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
index ce05a09..f69851b 100644
--- a/Source/WebCore/dom/Document.cpp
+++ b/Source/WebCore/dom/Document.cpp
@@ -206,6 +206,10 @@
 #include "RenderFullScreen.h"
 #endif
 
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+#include "RequestAnimationFrameCallback.h"
+#endif
+
 using namespace std;
 using namespace WTF;
 using namespace Unicode;
@@ -424,6 +428,9 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML, con
     , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired)
     , m_directionSetOnDocumentElement(false)
     , m_writingModeSetOnDocumentElement(false)
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    , m_nextRequestAnimationFrameCallbackId(0)
+#endif
 {
     m_document = this;
 
@@ -4942,6 +4949,86 @@ void Document::loadEventDelayTimerFired(Timer<Document>*)
         frame()->loader()->checkCompleted();
 }
 
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+int Document::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback, Element* e)
+{
+    if (!m_requestAnimationFrameCallbacks)
+        m_requestAnimationFrameCallbacks = new RequestAnimationFrameCallbackList;
+    int id = m_nextRequestAnimationFrameCallbackId++;
+    callback->m_firedOrCancelled = false;
+    callback->m_id = id;
+    callback->m_element = e;
+    m_requestAnimationFrameCallbacks->append(callback);
+    if (FrameView* v = view())
+        v->scheduleAnimation();
+    return id;
+}
+
+void Document::webkitCancelRequestAnimationFrame(int id)
+{
+    if (!m_requestAnimationFrameCallbacks)
+        return;
+    for (size_t i = 0; i < m_requestAnimationFrameCallbacks->size(); ++i) {
+        if (m_requestAnimationFrameCallbacks->at(i)->m_id == id) {
+            m_requestAnimationFrameCallbacks->at(i)->m_firedOrCancelled = true;
+            m_requestAnimationFrameCallbacks->remove(i);
+            return;
+        }
+    }
+}
+
+void Document::serviceScriptedAnimations()
+{
+    if (!m_requestAnimationFrameCallbacks)
+        return;
+    // We want to run the callback for all elements in the document that have registered
+    // for a callback and that are visible.  Running the callbacks can cause new callbacks
+    // to be registered, existing callbacks to be cancelled, and elements to gain or lose
+    // visibility so this code has to iterate carefully.
+
+    // FIXME: Currently, this code doesn't do any visibility tests beyond checking display:
+
+    // First, generate a list of callbacks to consider.  Callbacks registered from this point
+    // on are considered only for the "next" frame, not this one.
+    RequestAnimationFrameCallbackList callbacks(*m_requestAnimationFrameCallbacks);
+
+    // Firing the callback may cause the visibility of other elements to change.  To avoid
+    // missing any callbacks, we keep iterating through the list of candiate callbacks and firing
+    // them until nothing new becomes visible.
+    bool firedCallback;
+    do {
+        firedCallback = false;
+        // A previous iteration may have invalidated style (or layout).  Update styles for each iteration
+        // for now since all we check is the existence of a renderer.
+        updateStyleIfNeeded();
+        for (size_t i = 0; i < callbacks.size(); ++i) {
+            RequestAnimationFrameCallback* callback = callbacks[i].get();
+            if (!callback->m_firedOrCancelled && (!callback->m_element || callback->m_element->renderer())) {
+                callback->m_firedOrCancelled = true;
+                callback->handleEvent();
+                firedCallback = true;
+                callbacks.remove(i);
+                break;
+            }
+        }
+    } while (firedCallback);
+
+    // Remove any callbacks we fired from the list of pending callbacks.
+    for (size_t i = 0; i < m_requestAnimationFrameCallbacks->size();) {
+        if (m_requestAnimationFrameCallbacks->at(i)->m_firedOrCancelled)
+            m_requestAnimationFrameCallbacks->remove(i);
+        else
+            ++i;
+    }
+
+    // In most cases we expect this list to be empty, so no need to keep around the vector's inline buffer.
+    if (!m_requestAnimationFrameCallbacks->size())
+        m_requestAnimationFrameCallbacks.clear();
+    else if (FrameView* v = view())
+        v->scheduleAnimation();
+}
+#endif
+
 #if ENABLE(TOUCH_EVENTS)
 PassRefPtr<Touch> Document::createTouch(DOMWindow* window, EventTarget* target, int identifier, int pageX, int pageY, int screenX, int screenY, ExceptionCode&) const
 {
diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h
index 2cd26f9..c78ba5f 100644
--- a/Source/WebCore/dom/Document.h
+++ b/Source/WebCore/dom/Document.h
@@ -146,6 +146,10 @@ class Touch;
 class TouchList;
 #endif
 
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+class RequestAnimationFrameCallback;
+#endif
+
 typedef int ExceptionCode;
 
 class FormElementKey {
@@ -1072,6 +1076,12 @@ public:
 
     const DocumentTiming* timing() const { return &m_documentTiming; }
 
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>, Element*);
+    void webkitCancelRequestAnimationFrame(int id);
+    void serviceScriptedAnimations();
+#endif
+
     bool mayCauseFlashOfUnstyledContent() const;
 
     void initDNSPrefetch();
@@ -1391,6 +1401,12 @@ private:
 
     DocumentTiming m_documentTiming;
     RefPtr<MediaQueryMatcher> m_mediaQueryMatcher;
+
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    typedef Vector<RefPtr<RequestAnimationFrameCallback> > RequestAnimationFrameCallbackList;
+    OwnPtr<RequestAnimationFrameCallbackList> m_requestAnimationFrameCallbacks;
+    int m_nextRequestAnimationFrameCallbackId;
+#endif
 };
 
 inline bool Document::DocumentOrderedMap::contains(AtomicStringImpl* id) const
diff --git a/Source/WebCore/dom/RequestAnimationFrameCallback.h b/Source/WebCore/dom/RequestAnimationFrameCallback.h
new file mode 100644
index 0000000..819e495
--- /dev/null
+++ b/Source/WebCore/dom/RequestAnimationFrameCallback.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef RequestAnimationFrameCallback_h
+#define RequestAnimationFrameCallback_h
+
+#include "Element.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class RequestAnimationFrameCallback : public RefCounted<RequestAnimationFrameCallback> {
+public:
+    virtual ~RequestAnimationFrameCallback() { }
+    virtual bool handleEvent() = 0;
+
+    RefPtr<Element> m_element;
+    int m_id;
+    bool m_firedOrCancelled;
+};
+
+}
+
+#endif // RequestAnimationFrameCallback_h
+
diff --git a/Source/WebCore/dom/RequestAnimationFrameCallback.idl b/Source/WebCore/dom/RequestAnimationFrameCallback.idl
new file mode 100644
index 0000000..8d232e5
--- /dev/null
+++ b/Source/WebCore/dom/RequestAnimationFrameCallback.idl
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module core {
+    interface [
+        Callback=FunctionOnly,Conditional=REQUEST_ANIMATION_FRAME
+    ] RequestAnimationFrameCallback{
+        boolean handleEvent();
+    };
+}
diff --git a/Source/WebCore/loader/EmptyClients.h b/Source/WebCore/loader/EmptyClients.h
index e4cefc5..5a6bda0 100644
--- a/Source/WebCore/loader/EmptyClients.h
+++ b/Source/WebCore/loader/EmptyClients.h
@@ -157,6 +157,9 @@ public:
 #if ENABLE(TILED_BACKING_STORE)
     virtual void delegatedScrollRequested(const IntSize&) { }
 #endif
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    virtual void scheduleAnimation() { }
+#endif
 
     virtual IntPoint screenToWindow(const IntPoint& p) const { return p; }
     virtual IntRect windowToScreen(const IntRect& r) const { return r; }
diff --git a/Source/WebCore/page/Chrome.cpp b/Source/WebCore/page/Chrome.cpp
index 0405408..d96b6c9 100644
--- a/Source/WebCore/page/Chrome.cpp
+++ b/Source/WebCore/page/Chrome.cpp
@@ -445,6 +445,13 @@ void Chrome::setCursor(const Cursor& cursor)
     m_client->setCursor(cursor);
 }
 
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+void Chrome::scheduleAnimation()
+{
+    m_client->scheduleAnimation();
+}
+#endif
+
 #if ENABLE(NOTIFICATIONS)
 NotificationPresenter* Chrome::notificationPresenter() const
 {
diff --git a/Source/WebCore/page/Chrome.h b/Source/WebCore/page/Chrome.h
index 93b8c4a..0afd807 100644
--- a/Source/WebCore/page/Chrome.h
+++ b/Source/WebCore/page/Chrome.h
@@ -78,6 +78,9 @@ namespace WebCore {
         virtual PlatformPageClient platformPageClient() const;
         virtual void scrollbarsModeDidChange() const;
         virtual void setCursor(const Cursor&);
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+        virtual void scheduleAnimation();
+#endif
 
         void scrollRectIntoView(const IntRect&) const;
 
diff --git a/Source/WebCore/page/ChromeClient.h b/Source/WebCore/page/ChromeClient.h
index 67e1325..e348afb 100644
--- a/Source/WebCore/page/ChromeClient.h
+++ b/Source/WebCore/page/ChromeClient.h
@@ -151,6 +151,9 @@ namespace WebCore {
         virtual PlatformPageClient platformPageClient() const = 0;
         virtual void scrollbarsModeDidChange() const = 0;
         virtual void setCursor(const Cursor&) = 0;
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+        virtual void scheduleAnimation() = 0;
+#endif
         // End methods used by HostWindow.
 
         virtual void dispatchViewportDataDidChange(const ViewportArguments&) const { }
diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp
index 77a7dbc..f6ba6c9 100644
--- a/Source/WebCore/page/DOMWindow.cpp
+++ b/Source/WebCore/page/DOMWindow.cpp
@@ -105,6 +105,10 @@
 #include "LocalFileSystem.h"
 #endif
 
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+#include "RequestAnimationFrameCallback.h"
+#endif
+
 using std::min;
 using std::max;
 
@@ -1460,6 +1464,21 @@ void DOMWindow::clearInterval(int timeoutId)
     DOMTimer::removeById(context, timeoutId);
 }
 
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+int DOMWindow::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback, Element* e)
+{
+    if (Document* d = document())
+        return d->webkitRequestAnimationFrame(callback, e);
+    return 0;
+}
+
+void DOMWindow::webkitCancelRequestAnimationFrame(int id)
+{
+    if (Document* d = document())
+        d->webkitCancelRequestAnimationFrame(id);
+}
+#endif
+
 bool DOMWindow::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture)
 {
     if (!EventTarget::addEventListener(eventType, listener, useCapture))
diff --git a/Source/WebCore/page/DOMWindow.h b/Source/WebCore/page/DOMWindow.h
index 81931b5..a1e4462 100644
--- a/Source/WebCore/page/DOMWindow.h
+++ b/Source/WebCore/page/DOMWindow.h
@@ -64,6 +64,10 @@ namespace WebCore {
     class StyleMedia;
     class WebKitPoint;
 
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    class RequestAnimationFrameCallback;
+#endif
+
     struct WindowFeatures;
 
     typedef int ExceptionCode;
@@ -237,6 +241,12 @@ namespace WebCore {
         int setInterval(PassOwnPtr<ScheduledAction>, int timeout, ExceptionCode&);
         void clearInterval(int timeoutId);
 
+        // WebKit animation extensions
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+        int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>, Element*);
+        void webkitCancelRequestAnimationFrame(int id);
+#endif
+
         // Events
         // EventTarget API
         virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
diff --git a/Source/WebCore/page/DOMWindow.idl b/Source/WebCore/page/DOMWindow.idl
index 9b71cce..fb56a88 100644
--- a/Source/WebCore/page/DOMWindow.idl
+++ b/Source/WebCore/page/DOMWindow.idl
@@ -235,6 +235,12 @@ module window {
         // [Custom] long setInterval(in DOMString code, in long timeout);
         void clearInterval(in long handle);
 
+#if defined(ENABLE_REQUEST_ANIMATION_FRAME)
+        // WebKit animation extensions
+        long webkitRequestAnimationFrame(in [Callback] RequestAnimationFrameCallback callback, in Element element);
+        void webkitCancelRequestAnimationFrame(in long id);
+#endif
+
         // Base64
         DOMString atob(in [ConvertNullToNullString] DOMString string)
             raises(DOMException);
diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp
index 1187318..51d226f 100644
--- a/Source/WebCore/page/FrameView.cpp
+++ b/Source/WebCore/page/FrameView.cpp
@@ -342,6 +342,14 @@ void FrameView::setFrameRect(const IntRect& newRect)
 #endif
 }
 
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+void FrameView::scheduleAnimation()
+{
+    if (hostWindow())
+        hostWindow()->scheduleAnimation();
+}
+#endif
+
 void FrameView::setMarginWidth(int w)
 {
     // make it update the rendering area when set
@@ -1644,6 +1652,14 @@ void FrameView::unscheduleRelayout()
     m_delayedLayout = false;
 }
 
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+void FrameView::serviceScriptedAnimations()
+{
+    for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNext())
+        frame->document()->serviceScriptedAnimations();
+}
+#endif
+
 bool FrameView::isTransparent() const
 {
     return m_isTransparent;
diff --git a/Source/WebCore/page/FrameView.h b/Source/WebCore/page/FrameView.h
index 65a3a85..9beca93 100644
--- a/Source/WebCore/page/FrameView.h
+++ b/Source/WebCore/page/FrameView.h
@@ -62,6 +62,9 @@ public:
     
     virtual void invalidateRect(const IntRect&);
     virtual void setFrameRect(const IntRect&);
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    void scheduleAnimation();
+#endif
 
     Frame* frame() const { return m_frame.get(); }
     void clearFrame();
@@ -97,6 +100,10 @@ public:
 
     bool needsFullRepaint() const { return m_doFullRepaint; }
 
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    void serviceScriptedAnimations();
+#endif
+
 #if USE(ACCELERATED_COMPOSITING)
     void updateCompositingLayers();
     void syncCompositingStateForThisFrame();
diff --git a/Source/WebCore/platform/HostWindow.h b/Source/WebCore/platform/HostWindow.h
index 7882d48..45c887b 100644
--- a/Source/WebCore/platform/HostWindow.h
+++ b/Source/WebCore/platform/HostWindow.h
@@ -66,6 +66,10 @@ public:
 
     // Request that the cursor change.
     virtual void setCursor(const Cursor&) = 0;
+
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    virtual void scheduleAnimation() = 0;
+#endif
 };
 
 } // namespace WebCore
diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog
index 0ceb5d0..066b630 100644
--- a/Source/WebKit/chromium/ChangeLog
+++ b/Source/WebKit/chromium/ChangeLog
@@ -1,3 +1,27 @@
+2011-01-19  James Robinson  <jamesr at chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        Implement mozilla's requestAnimationFrame API
+        https://bugs.webkit.org/show_bug.cgi?id=51218
+
+        Chromium WebKit API support for window.webkitRequestAnimationFrame()
+
+        * features.gypi:
+        * public/WebWidget.h:
+        * public/WebWidgetClient.h:
+        (WebKit::WebWidgetClient::scheduleAnimation):
+        * src/ChromeClientImpl.cpp:
+        (WebKit::ChromeClientImpl::scheduleAnimation):
+        * src/ChromeClientImpl.h:
+        * src/WebPopupMenuImpl.cpp:
+        (WebKit::WebPopupMenuImpl::animate):
+        (WebKit::WebPopupMenuImpl::scheduleAnimation):
+        * src/WebPopupMenuImpl.h:
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::animate):
+        * src/WebViewImpl.h:
+
 2011-01-19  Tony Chang  <tony at chromium.org>
 
         Unreviewed, roll chromium deps to pick up fixes for the linux build.
diff --git a/Source/WebKit/chromium/features.gypi b/Source/WebKit/chromium/features.gypi
index 372cc5c..7f4cda6 100644
--- a/Source/WebKit/chromium/features.gypi
+++ b/Source/WebKit/chromium/features.gypi
@@ -69,6 +69,7 @@
         'ENABLE_OPENTYPE_SANITIZER=1',
         'ENABLE_ORIENTATION_EVENTS=0',
         'ENABLE_PROGRESS_TAG=1',
+        'ENABLE_REQUEST_ANIMATION_FRAME=1',
         'ENABLE_SHARED_WORKERS=1',
         'ENABLE_SVG=1',
         'ENABLE_SVG_ANIMATION=1',
diff --git a/Source/WebKit/chromium/public/WebWidget.h b/Source/WebKit/chromium/public/WebWidget.h
index ccad134..36fbf31 100644
--- a/Source/WebKit/chromium/public/WebWidget.h
+++ b/Source/WebKit/chromium/public/WebWidget.h
@@ -56,6 +56,10 @@ public:
     // Called to resize the WebWidget.
     virtual void resize(const WebSize&) = 0;
 
+    // Called to update imperative animation state.  This should be called before
+    // paint, although the client can rate-limit these calls.
+    virtual void animate() = 0;
+
     // Called to layout the WebWidget.  This MUST be called before Paint,
     // and it may result in calls to WebWidgetClient::didInvalidateRect.
     virtual void layout() = 0;
diff --git a/Source/WebKit/chromium/public/WebWidgetClient.h b/Source/WebKit/chromium/public/WebWidgetClient.h
index 373426d..85e4015 100644
--- a/Source/WebKit/chromium/public/WebWidgetClient.h
+++ b/Source/WebKit/chromium/public/WebWidgetClient.h
@@ -56,6 +56,9 @@ public:
     // Called when a call to WebWidget::composite is required
     virtual void scheduleComposite() { }
 
+    // Called when a call to WebWidget::animate is required
+    virtual void scheduleAnimation() { }
+
     // Called when the widget acquires or loses focus, respectively.
     virtual void didFocus() { }
     virtual void didBlur() { }
diff --git a/Source/WebKit/chromium/src/ChromeClientImpl.cpp b/Source/WebKit/chromium/src/ChromeClientImpl.cpp
index 826c3b8..99b98f0 100644
--- a/Source/WebKit/chromium/src/ChromeClientImpl.cpp
+++ b/Source/WebKit/chromium/src/ChromeClientImpl.cpp
@@ -532,6 +532,13 @@ void ChromeClientImpl::invalidateContentsForSlowScroll(const IntRect& updateRect
     invalidateContentsAndWindow(updateRect, immediate);
 }
 
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+void ChromeClientImpl::scheduleAnimation()
+{
+    m_webView->client()->scheduleAnimation();
+}
+#endif
+
 void ChromeClientImpl::scroll(
     const IntSize& scrollDelta, const IntRect& scrollRect,
     const IntRect& clipRect)
diff --git a/Source/WebKit/chromium/src/ChromeClientImpl.h b/Source/WebKit/chromium/src/ChromeClientImpl.h
index a093f09..07f7d1f 100644
--- a/Source/WebKit/chromium/src/ChromeClientImpl.h
+++ b/Source/WebKit/chromium/src/ChromeClientImpl.h
@@ -105,6 +105,9 @@ public:
     virtual void invalidateWindow(const WebCore::IntRect&, bool);
     virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool);
     virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    virtual void scheduleAnimation();
+#endif
     virtual void scroll(
         const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll,
         const WebCore::IntRect& clipRect);
diff --git a/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp b/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp
index 63ebed8..a209e6a 100644
--- a/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp
+++ b/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp
@@ -151,6 +151,10 @@ void WebPopupMenuImpl::resize(const WebSize& newSize)
     }
 }
 
+void WebPopupMenuImpl::animate()
+{
+}
+
 void WebPopupMenuImpl::layout()
 {
 }
@@ -299,6 +303,10 @@ void WebPopupMenuImpl::invalidateContentsForSlowScroll(const IntRect& updateRect
     invalidateContentsAndWindow(updateRect, immediate);
 }
 
+void WebPopupMenuImpl::scheduleAnimation()
+{
+}
+
 void WebPopupMenuImpl::scroll(const IntSize& scrollDelta,
                               const IntRect& scrollRect,
                               const IntRect& clipRect)
diff --git a/Source/WebKit/chromium/src/WebPopupMenuImpl.h b/Source/WebKit/chromium/src/WebPopupMenuImpl.h
index b8ef7ba..9bf14d5 100644
--- a/Source/WebKit/chromium/src/WebPopupMenuImpl.h
+++ b/Source/WebKit/chromium/src/WebPopupMenuImpl.h
@@ -61,6 +61,7 @@ public:
     virtual void close();
     virtual WebSize size() { return m_size; }
     virtual void resize(const WebSize&);
+    virtual void animate();
     virtual void layout();
     virtual void paint(WebCanvas* canvas, const WebRect& rect);
     virtual void themeChanged();
@@ -105,6 +106,7 @@ public:
     virtual void invalidateWindow(const WebCore::IntRect&, bool);
     virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool);
     virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
+    virtual void scheduleAnimation();
     virtual void scroll(
         const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect,
         const WebCore::IntRect& clipRect);
diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp
index 41a0804..e1756d2 100644
--- a/Source/WebKit/chromium/src/WebViewImpl.cpp
+++ b/Source/WebKit/chromium/src/WebViewImpl.cpp
@@ -972,6 +972,18 @@ void WebViewImpl::resize(const WebSize& newSize)
 #endif
 }
 
+void WebViewImpl::animate()
+{
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    WebFrameImpl* webframe = mainFrameImpl();
+    if (webframe) {
+        FrameView* view = webframe->frameView();
+        if (view)
+            view->serviceScriptedAnimations();
+    }
+#endif
+}
+
 void WebViewImpl::layout()
 {
     WebFrameImpl* webframe = mainFrameImpl();
diff --git a/Source/WebKit/chromium/src/WebViewImpl.h b/Source/WebKit/chromium/src/WebViewImpl.h
index bc79ec1..d164a48 100644
--- a/Source/WebKit/chromium/src/WebViewImpl.h
+++ b/Source/WebKit/chromium/src/WebViewImpl.h
@@ -91,6 +91,7 @@ public:
     virtual void close();
     virtual WebSize size() { return m_size; }
     virtual void resize(const WebSize&);
+    virtual void animate();
     virtual void layout();
     virtual void paint(WebCanvas*, const WebRect&);
     virtual void themeChanged();
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index d41901d..6557014 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,18 @@
+2011-01-19  James Robinson  <jamesr at chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        Implement mozilla's requestAnimationFrame API
+        https://bugs.webkit.org/show_bug.cgi?id=51218
+
+        Chromium DumpRenderTree support for window.webkitRequestAnimationFrame.
+
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (invokeScheduleComposite):
+        (WebViewHost::scheduleAnimation):
+        (WebViewHost::paintInvalidatedRegion):
+        * DumpRenderTree/chromium/WebViewHost.h:
+
 2011-01-19  Dirk Pranke  <dpranke at chromium.org>
 
         Unreviewed, build fix.
diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.cpp b/Tools/DumpRenderTree/chromium/WebViewHost.cpp
index 62df390..18b107f 100644
--- a/Tools/DumpRenderTree/chromium/WebViewHost.cpp
+++ b/Tools/DumpRenderTree/chromium/WebViewHost.cpp
@@ -624,6 +624,19 @@ void WebViewHost::scheduleComposite()
     didInvalidateRect(clientRect);
 }
 
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+static void invokeScheduleComposite(void* context)
+{
+    WebViewHost* wvh = static_cast<WebViewHost*>(context);
+    wvh->scheduleComposite();
+}
+
+void WebViewHost::scheduleAnimation()
+{
+    webkit_support::PostDelayedTask(invokeScheduleComposite, this, 0);
+}
+#endif
+
 void WebViewHost::didFocus()
 {
     m_shell->setFocus(webWidget(), true);
@@ -1438,6 +1451,9 @@ void WebViewHost::paintRect(const WebRect& rect)
 
 void WebViewHost::paintInvalidatedRegion()
 {
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    webWidget()->animate();
+#endif
     webWidget()->layout();
     WebSize widgetSize = webWidget()->size();
     WebRect clientRect(0, 0, widgetSize.width, widgetSize.height);
diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.h b/Tools/DumpRenderTree/chromium/WebViewHost.h
index 0a36aec..83d21dc 100644
--- a/Tools/DumpRenderTree/chromium/WebViewHost.h
+++ b/Tools/DumpRenderTree/chromium/WebViewHost.h
@@ -147,6 +147,9 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient,
     virtual void didInvalidateRect(const WebKit::WebRect&);
     virtual void didScrollRect(int dx, int dy, const WebKit::WebRect&);
     virtual void scheduleComposite();
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    virtual void scheduleAnimation();
+#endif
     virtual void didFocus();
     virtual void didBlur();
     virtual void didChangeCursor(const WebKit::WebCursorInfo&);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list