Changeset 76278 in webkit


Ignore:
Timestamp:
Jan 20, 2011 1:50:34 PM (13 years ago)
Author:
jamesr@google.com
Message:

2011-01-20 James Robinson <jamesr@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-20 James Robinson <jamesr@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-20 James Robinson <jamesr@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-20 James Robinson <jamesr@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:
Location:
trunk
Files:
12 added
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r76276 r76278  
     12011-01-20  James Robinson  <jamesr@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        Implement mozilla's requestAnimationFrame API
     6        https://bugs.webkit.org/show_bug.cgi?id=51218
     7
     8        Tests for window.webkitRequestAnimationFrame().  The new tests
     9        are in the Skipped lists for platforms that do not set
     10        ENABLE(REQUEST_ANIMATION_FRAME) - which is currently all but chromium.
     11
     12        * fast/animation/request-animation-frame-cancel-expected.txt: Added.
     13        * fast/animation/request-animation-frame-cancel.html: Added.
     14            Tests cancelling a callback within a webkitRequestAnimationFrame() callback.
     15        * fast/animation/request-animation-frame-cancel2-expected.txt: Added.
     16        * fast/animation/request-animation-frame-cancel2.html: Added.
     17            Tests interactions between multiple webkitRequestAnimationFrame() callbacks.
     18        * fast/animation/request-animation-frame-display-expected.txt: Added.
     19        * fast/animation/request-animation-frame-display.html: Added.
     20            Tests changing the display: property of an element within a callback.
     21        * fast/animation/request-animation-frame-expected.txt: Added.
     22        * fast/animation/request-animation-frame.html: Added.
     23            Tests the basic use of window.webkitRequestAnimationFrame().
     24        * fast/animation/request-animation-frame-within-callback-expected.txt: Added.
     25        * fast/animation/request-animation-frame-within-callback.html: Added.
     26            Tests setting one webkit.webkitRequestAnimationFrame() callback within another.
     27        * platform/gtk/Skipped:
     28        * platform/mac/Skipped:
     29        * platform/qt/Skipped:
     30        * platform/win/Skipped:
     31
    1322011-01-20  James Robinson  <jamesr@chromium.org>
    233
  • trunk/LayoutTests/platform/gtk/Skipped

    r76225 r76278  
    55835583http/tests/local/link-stylesheet-load-order-preload.html
    55845584
     5585# Request ENABLE(REQUEST_ANIMATION_FRAME) support
     5586fast/animation
     5587
    55855588# https://bugs.webkit.org/show_bug.cgi?id=51380
    55865589http/tests/inspector/console-websocket-error.html
  • trunk/LayoutTests/platform/mac/Skipped

    r76198 r76278  
    281281# DRT does not support toggling caret browsing on / off
    282282editing/selection/caret-mode-paragraph-keys-navigation.html
     283
     284# Request ENABLE(REQUEST_ANIMATION_FRAME) support
     285fast/animation
     286
  • trunk/LayoutTests/platform/qt/Skipped

    r76218 r76278  
    50895089fast/text/emphasis-avoid-ruby.html
    50905090
     5091# Requires requestAnimationFrame support
     5092fast/animation/
     5093
    50915094# https://bugs.webkit.org/show_bug.cgi?id=42578
    50925095# [Qt] DRT sideeffect revealed by r63657 and r75305
  • trunk/LayoutTests/platform/win/Skipped

    r76225 r76278  
    11151115# DRT does not obey addURLToRedirect
    11161116http/tests/loading/cross-origin-XHR-willLoadRequest.html
     1117
     1118# Request ENABLE(REQUEST_ANIMATION_FRAME) support
     1119fast/animation
     1120
  • trunk/Source/WebCore/ChangeLog

    r76277 r76278  
     12011-01-20  James Robinson  <jamesr@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        Implement mozilla's requestAnimationFrame API
     6        https://bugs.webkit.org/show_bug.cgi?id=51218
     7
     8        This implements mozilla's proposed requestAnimationFrame API.  The idea with this API is that
     9        an author driving an animation from script could use window.requestAnimationFrame(callback)
     10        instead of window.setTimeout(callback, 0) to schedule their update logic and let the browser
     11        decide when to update the animations.  This avoids doing unnecessary work when the page content
     12        is offscreen or is being displayed at a different framerate than what the page author expects.
     13
     14        Mozilla's proposal is here: https://developer.mozilla.org/en/DOM/window.mozRequestAnimationFrame
     15        This implements window.mozRequestAnimationFrame as window.webkitRequestAnimationFrame with the
     16        following changes:
     17        *) Only the callback syntax is supported, there is no before paint event
     18        *) webkitRequestAnimationFrame supports a second parameter Element to let the author indicate
     19            what content they intend to animate.  That way if the page is being displayed but the element
     20            in question is offscreen, we can avoid invoking the callback.
     21        *) No timestamp is provided to the caller and there is no window.animationStartTime property
     22            (see https://bugs.webkit.org/show_bug.cgi?id=51952 for discussion of this property)
     23        *) window.webkitRequestAnimationFrame returns a numerical id that can be used to cancel the callback
     24            using window.cancelWebkitRequestAnimationFrame, to parallel window.setTimeout()/window.clearTime().
     25
     26        The implementation depends on the embedder scheduling the callbacks since the callback invocation
     27        depends on the page's visibility and the embedder's paint scheduling, neither of which are exposed
     28        to WebCore.  The expectation for the embedder is that at some point Chrome::scheduleAnimation() is
     29        called FrameView::serviceScriptedAnimations() should be called for the associated Page's main frame.
     30        Ideally serviceScriptedAnimations() would be called prior to rendering - although in practice the
     31        embedder has to rate limit callbacks and may not be able to tie the callback directly to the
     32        rendering loop.
     33
     34        Tests: fast/animation/request-animation-frame-cancel.html
     35               fast/animation/request-animation-frame-cancel2.html
     36               fast/animation/request-animation-frame-display.html
     37               fast/animation/request-animation-frame-within-callback.html
     38               fast/animation/request-animation-frame.html
     39
     40        * WebCore.gypi:
     41        * dom/Document.cpp:
     42        (WebCore::Document::Document):
     43        (WebCore::Document::webkitRequestAnimationFrame):
     44        (WebCore::Document::webkitCancelRequestAnimationFrame):
     45        (WebCore::Document::serviceScriptedAnimations):
     46        * dom/Document.h:
     47        * dom/RequestAnimationFrameCallback.h: Added.
     48        (WebCore::RequestAnimationFrameCallback::~RequestAnimationFrameCallback):
     49        * dom/RequestAnimationFrameCallback.idl: Added.
     50        * loader/EmptyClients.h:
     51        (WebCore::EmptyChromeClient::scheduleAnimation):
     52        * page/Chrome.cpp:
     53        (WebCore::Chrome::scheduleAnimation):
     54        * page/Chrome.h:
     55        * page/ChromeClient.h:
     56        * page/DOMWindow.cpp:
     57        (WebCore::DOMWindow::webkitRequestAnimationFrame):
     58        (WebCore::DOMWindow::webkitCancelRequestAnimationFrame):
     59        * page/DOMWindow.h:
     60        * page/DOMWindow.idl:
     61        * page/FrameView.cpp:
     62        (WebCore::FrameView::scheduleAnimation):
     63        (WebCore::FrameView::serviceScriptedAnimations):
     64        * page/FrameView.h:
     65        * platform/HostWindow.h:
     66
    1672011-01-20  James Robinson  <jamesr@chromium.org>
    268
  • trunk/Source/WebCore/WebCore.gypi

    r76246 r76278  
    7676            'dom/Range.idl',
    7777            'dom/RangeException.idl',
     78            'dom/RequestAnimationFrameCallback.idl',
    7879            'dom/Text.idl',
    7980            'dom/TextEvent.idl',
     
    13171318            'dom/RangeBoundaryPoint.h',
    13181319            'dom/RangeException.h',
     1320            'dom/RequestAnimationFrameCallback.h',
    13191321            'dom/RawDataDocumentParser.h',
    13201322            'dom/RegisteredEventListener.cpp',
  • trunk/Source/WebCore/dom/Document.cpp

    r76248 r76278  
    208208#endif
    209209
     210#if ENABLE(REQUEST_ANIMATION_FRAME)
     211#include "RequestAnimationFrameCallback.h"
     212#endif
     213
    210214using namespace std;
    211215using namespace WTF;
     
    426430    , m_directionSetOnDocumentElement(false)
    427431    , m_writingModeSetOnDocumentElement(false)
     432#if ENABLE(REQUEST_ANIMATION_FRAME)
     433    , m_nextRequestAnimationFrameCallbackId(0)
     434#endif
    428435{
    429436    m_document = this;
     
    49524959}
    49534960
     4961#if ENABLE(REQUEST_ANIMATION_FRAME)
     4962int Document::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback, Element* e)
     4963{
     4964    if (!m_requestAnimationFrameCallbacks)
     4965        m_requestAnimationFrameCallbacks = new RequestAnimationFrameCallbackList;
     4966    int id = m_nextRequestAnimationFrameCallbackId++;
     4967    callback->m_firedOrCancelled = false;
     4968    callback->m_id = id;
     4969    callback->m_element = e;
     4970    m_requestAnimationFrameCallbacks->append(callback);
     4971    if (FrameView* v = view())
     4972        v->scheduleAnimation();
     4973    return id;
     4974}
     4975
     4976void Document::webkitCancelRequestAnimationFrame(int id)
     4977{
     4978    if (!m_requestAnimationFrameCallbacks)
     4979        return;
     4980    for (size_t i = 0; i < m_requestAnimationFrameCallbacks->size(); ++i) {
     4981        if (m_requestAnimationFrameCallbacks->at(i)->m_id == id) {
     4982            m_requestAnimationFrameCallbacks->at(i)->m_firedOrCancelled = true;
     4983            m_requestAnimationFrameCallbacks->remove(i);
     4984            return;
     4985        }
     4986    }
     4987}
     4988
     4989void Document::serviceScriptedAnimations()
     4990{
     4991    if (!m_requestAnimationFrameCallbacks)
     4992        return;
     4993    // We want to run the callback for all elements in the document that have registered
     4994    // for a callback and that are visible.  Running the callbacks can cause new callbacks
     4995    // to be registered, existing callbacks to be cancelled, and elements to gain or lose
     4996    // visibility so this code has to iterate carefully.
     4997
     4998    // FIXME: Currently, this code doesn't do any visibility tests beyond checking display:
     4999
     5000    // First, generate a list of callbacks to consider.  Callbacks registered from this point
     5001    // on are considered only for the "next" frame, not this one.
     5002    RequestAnimationFrameCallbackList callbacks(*m_requestAnimationFrameCallbacks);
     5003
     5004    // Firing the callback may cause the visibility of other elements to change.  To avoid
     5005    // missing any callbacks, we keep iterating through the list of candiate callbacks and firing
     5006    // them until nothing new becomes visible.
     5007    bool firedCallback;
     5008    do {
     5009        firedCallback = false;
     5010        // A previous iteration may have invalidated style (or layout).  Update styles for each iteration
     5011        // for now since all we check is the existence of a renderer.
     5012        updateStyleIfNeeded();
     5013        for (size_t i = 0; i < callbacks.size(); ++i) {
     5014            RequestAnimationFrameCallback* callback = callbacks[i].get();
     5015            if (!callback->m_firedOrCancelled && (!callback->m_element || callback->m_element->renderer())) {
     5016                callback->m_firedOrCancelled = true;
     5017                callback->handleEvent();
     5018                firedCallback = true;
     5019                callbacks.remove(i);
     5020                break;
     5021            }
     5022        }
     5023    } while (firedCallback);
     5024
     5025    // Remove any callbacks we fired from the list of pending callbacks.
     5026    for (size_t i = 0; i < m_requestAnimationFrameCallbacks->size();) {
     5027        if (m_requestAnimationFrameCallbacks->at(i)->m_firedOrCancelled)
     5028            m_requestAnimationFrameCallbacks->remove(i);
     5029        else
     5030            ++i;
     5031    }
     5032
     5033    // In most cases we expect this list to be empty, so no need to keep around the vector's inline buffer.
     5034    if (!m_requestAnimationFrameCallbacks->size())
     5035        m_requestAnimationFrameCallbacks.clear();
     5036    else if (FrameView* v = view())
     5037        v->scheduleAnimation();
     5038}
     5039#endif
     5040
    49545041#if ENABLE(TOUCH_EVENTS)
    49555042PassRefPtr<Touch> Document::createTouch(DOMWindow* window, EventTarget* target, int identifier, int pageX, int pageY, int screenX, int screenY, ExceptionCode&) const
  • trunk/Source/WebCore/dom/Document.h

    r76216 r76278  
    147147#endif
    148148
     149#if ENABLE(REQUEST_ANIMATION_FRAME)
     150class RequestAnimationFrameCallback;
     151#endif
     152
    149153typedef int ExceptionCode;
    150154
     
    10721076    const DocumentTiming* timing() const { return &m_documentTiming; }
    10731077
     1078#if ENABLE(REQUEST_ANIMATION_FRAME)
     1079    int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>, Element*);
     1080    void webkitCancelRequestAnimationFrame(int id);
     1081    void serviceScriptedAnimations();
     1082#endif
     1083
    10741084    bool mayCauseFlashOfUnstyledContent() const;
    10751085
     
    13941404    DocumentTiming m_documentTiming;
    13951405    RefPtr<MediaQueryMatcher> m_mediaQueryMatcher;
     1406
     1407#if ENABLE(REQUEST_ANIMATION_FRAME)
     1408    typedef Vector<RefPtr<RequestAnimationFrameCallback> > RequestAnimationFrameCallbackList;
     1409    OwnPtr<RequestAnimationFrameCallbackList> m_requestAnimationFrameCallbacks;
     1410    int m_nextRequestAnimationFrameCallbackId;
     1411#endif
    13961412};
    13971413
  • trunk/Source/WebCore/loader/EmptyClients.h

    r76248 r76278  
    158158    virtual void delegatedScrollRequested(const IntSize&) { }
    159159#endif
     160#if ENABLE(REQUEST_ANIMATION_FRAME)
     161    virtual void scheduleAnimation() { }
     162#endif
    160163
    161164    virtual IntPoint screenToWindow(const IntPoint& p) const { return p; }
  • trunk/Source/WebCore/page/Chrome.cpp

    r76198 r76278  
    446446}
    447447
     448#if ENABLE(REQUEST_ANIMATION_FRAME)
     449void Chrome::scheduleAnimation()
     450{
     451    m_client->scheduleAnimation();
     452}
     453#endif
     454
    448455#if ENABLE(NOTIFICATIONS)
    449456NotificationPresenter* Chrome::notificationPresenter() const
  • trunk/Source/WebCore/page/Chrome.h

    r76198 r76278  
    7979        virtual void scrollbarsModeDidChange() const;
    8080        virtual void setCursor(const Cursor&);
     81#if ENABLE(REQUEST_ANIMATION_FRAME)
     82        virtual void scheduleAnimation();
     83#endif
    8184
    8285        void scrollRectIntoView(const IntRect&) const;
  • trunk/Source/WebCore/page/ChromeClient.h

    r76198 r76278  
    152152        virtual void scrollbarsModeDidChange() const = 0;
    153153        virtual void setCursor(const Cursor&) = 0;
     154#if ENABLE(REQUEST_ANIMATION_FRAME)
     155        virtual void scheduleAnimation() = 0;
     156#endif
    154157        // End methods used by HostWindow.
    155158
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r76198 r76278  
    106106#endif
    107107
     108#if ENABLE(REQUEST_ANIMATION_FRAME)
     109#include "RequestAnimationFrameCallback.h"
     110#endif
     111
    108112using std::min;
    109113using std::max;
     
    14611465}
    14621466
     1467#if ENABLE(REQUEST_ANIMATION_FRAME)
     1468int DOMWindow::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback, Element* e)
     1469{
     1470    if (Document* d = document())
     1471        return d->webkitRequestAnimationFrame(callback, e);
     1472    return 0;
     1473}
     1474
     1475void DOMWindow::webkitCancelRequestAnimationFrame(int id)
     1476{
     1477    if (Document* d = document())
     1478        d->webkitCancelRequestAnimationFrame(id);
     1479}
     1480#endif
     1481
    14631482bool DOMWindow::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture)
    14641483{
  • trunk/Source/WebCore/page/DOMWindow.h

    r76198 r76278  
    6565    class WebKitPoint;
    6666
     67#if ENABLE(REQUEST_ANIMATION_FRAME)
     68    class RequestAnimationFrameCallback;
     69#endif
     70
    6771    struct WindowFeatures;
    6872
     
    237241        int setInterval(PassOwnPtr<ScheduledAction>, int timeout, ExceptionCode&);
    238242        void clearInterval(int timeoutId);
     243
     244        // WebKit animation extensions
     245#if ENABLE(REQUEST_ANIMATION_FRAME)
     246        int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>, Element*);
     247        void webkitCancelRequestAnimationFrame(int id);
     248#endif
    239249
    240250        // Events
  • trunk/Source/WebCore/page/DOMWindow.idl

    r76208 r76278  
    235235        // [Custom] long setInterval(in DOMString code, in long timeout);
    236236        void clearInterval(in long handle);
     237
     238#if defined(ENABLE_REQUEST_ANIMATION_FRAME)
     239        // WebKit animation extensions
     240        long webkitRequestAnimationFrame(in [Callback] RequestAnimationFrameCallback callback, in Element element);
     241        void webkitCancelRequestAnimationFrame(in long id);
     242#endif
    237243
    238244        // Base64
  • trunk/Source/WebCore/page/FrameView.cpp

    r76248 r76278  
    346346}
    347347
     348#if ENABLE(REQUEST_ANIMATION_FRAME)
     349void FrameView::scheduleAnimation()
     350{
     351    if (hostWindow())
     352        hostWindow()->scheduleAnimation();
     353}
     354#endif
     355
    348356void FrameView::setMarginWidth(int w)
    349357{
     
    16421650}
    16431651
     1652#if ENABLE(REQUEST_ANIMATION_FRAME)
     1653void FrameView::serviceScriptedAnimations()
     1654{
     1655    for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNext())
     1656        frame->document()->serviceScriptedAnimations();
     1657}
     1658#endif
     1659
    16441660bool FrameView::isTransparent() const
    16451661{
  • trunk/Source/WebCore/page/FrameView.h

    r76198 r76278  
    6363    virtual void invalidateRect(const IntRect&);
    6464    virtual void setFrameRect(const IntRect&);
     65#if ENABLE(REQUEST_ANIMATION_FRAME)
     66    void scheduleAnimation();
     67#endif
    6568
    6669    Frame* frame() const { return m_frame.get(); }
     
    97100
    98101    bool needsFullRepaint() const { return m_doFullRepaint; }
     102
     103#if ENABLE(REQUEST_ANIMATION_FRAME)
     104    void serviceScriptedAnimations();
     105#endif
    99106
    100107#if USE(ACCELERATED_COMPOSITING)
  • trunk/Source/WebCore/platform/HostWindow.h

    r76248 r76278  
    6868    // Request that the cursor change.
    6969    virtual void setCursor(const Cursor&) = 0;
     70
     71#if ENABLE(REQUEST_ANIMATION_FRAME)
     72    virtual void scheduleAnimation() = 0;
     73#endif
    7074};
    7175
  • trunk/Source/WebKit/chromium/ChangeLog

    r76224 r76278  
     12011-01-20  James Robinson  <jamesr@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        Implement mozilla's requestAnimationFrame API
     6        https://bugs.webkit.org/show_bug.cgi?id=51218
     7
     8        Chromium WebKit API support for window.webkitRequestAnimationFrame()
     9
     10        * features.gypi:
     11        * public/WebWidget.h:
     12        * public/WebWidgetClient.h:
     13        (WebKit::WebWidgetClient::scheduleAnimation):
     14        * src/ChromeClientImpl.cpp:
     15        (WebKit::ChromeClientImpl::scheduleAnimation):
     16        * src/ChromeClientImpl.h:
     17        * src/WebPopupMenuImpl.cpp:
     18        (WebKit::WebPopupMenuImpl::animate):
     19        (WebKit::WebPopupMenuImpl::scheduleAnimation):
     20        * src/WebPopupMenuImpl.h:
     21        * src/WebViewImpl.cpp:
     22        (WebKit::WebViewImpl::animate):
     23        * src/WebViewImpl.h:
     24
    1252010-12-14  Yury Semikhatsky  <yurys@chromium.org>
    226
  • trunk/Source/WebKit/chromium/features.gypi

    r76198 r76278  
    7070        'ENABLE_ORIENTATION_EVENTS=0',
    7171        'ENABLE_PROGRESS_TAG=1',
     72        'ENABLE_REQUEST_ANIMATION_FRAME=1',
    7273        'ENABLE_SHARED_WORKERS=1',
    7374        'ENABLE_SVG=1',
  • trunk/Source/WebKit/chromium/public/WebWidget.h

    r76198 r76278  
    5656    // Called to resize the WebWidget.
    5757    virtual void resize(const WebSize&) = 0;
     58
     59    // Called to update imperative animation state.  This should be called before
     60    // paint, although the client can rate-limit these calls.
     61    virtual void animate() = 0;
    5862
    5963    // Called to layout the WebWidget.  This MUST be called before Paint,
  • trunk/Source/WebKit/chromium/public/WebWidgetClient.h

    r76198 r76278  
    5757    virtual void scheduleComposite() { }
    5858
     59    // Called when a call to WebWidget::animate is required
     60    virtual void scheduleAnimation() { }
     61
    5962    // Called when the widget acquires or loses focus, respectively.
    6063    virtual void didFocus() { }
  • trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp

    r76224 r76278  
    528528}
    529529
     530#if ENABLE(REQUEST_ANIMATION_FRAME)
     531void ChromeClientImpl::scheduleAnimation()
     532{
     533    m_webView->client()->scheduleAnimation();
     534}
     535#endif
     536
    530537void ChromeClientImpl::scroll(
    531538    const IntSize& scrollDelta, const IntRect& scrollRect,
  • trunk/Source/WebKit/chromium/src/ChromeClientImpl.h

    r76198 r76278  
    106106    virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool);
    107107    virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
     108#if ENABLE(REQUEST_ANIMATION_FRAME)
     109    virtual void scheduleAnimation();
     110#endif
    108111    virtual void scroll(
    109112        const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll,
  • trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp

    r76198 r76278  
    152152}
    153153
     154void WebPopupMenuImpl::animate()
     155{
     156}
     157
    154158void WebPopupMenuImpl::layout()
    155159{
     
    300304}
    301305
     306void WebPopupMenuImpl::scheduleAnimation()
     307{
     308}
     309
    302310void WebPopupMenuImpl::scroll(const IntSize& scrollDelta,
    303311                              const IntRect& scrollRect,
  • trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.h

    r76248 r76278  
    6363    virtual WebSize size() { return m_size; }
    6464    virtual void resize(const WebSize&);
     65    virtual void animate();
    6566    virtual void layout();
    6667    virtual void paint(WebCanvas* canvas, const WebRect& rect);
     
    107108    virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool);
    108109    virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
     110    virtual void scheduleAnimation();
    109111    virtual void scroll(
    110112        const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect,
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r76207 r76278  
    973973}
    974974
     975void WebViewImpl::animate()
     976{
     977#if ENABLE(REQUEST_ANIMATION_FRAME)
     978    WebFrameImpl* webframe = mainFrameImpl();
     979    if (webframe) {
     980        FrameView* view = webframe->frameView();
     981        if (view)
     982            view->serviceScriptedAnimations();
     983    }
     984#endif
     985}
     986
    975987void WebViewImpl::layout()
    976988{
  • trunk/Source/WebKit/chromium/src/WebViewImpl.h

    r76198 r76278  
    9292    virtual WebSize size() { return m_size; }
    9393    virtual void resize(const WebSize&);
     94    virtual void animate();
    9495    virtual void layout();
    9596    virtual void paint(WebCanvas*, const WebRect&);
  • trunk/Tools/ChangeLog

    r76259 r76278  
     12011-01-20  James Robinson  <jamesr@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        Implement mozilla's requestAnimationFrame API
     6        https://bugs.webkit.org/show_bug.cgi?id=51218
     7
     8        Chromium DumpRenderTree support for window.webkitRequestAnimationFrame.
     9
     10        * DumpRenderTree/chromium/WebViewHost.cpp:
     11        (invokeScheduleComposite):
     12        (WebViewHost::scheduleAnimation):
     13        (WebViewHost::paintInvalidatedRegion):
     14        * DumpRenderTree/chromium/WebViewHost.h:
     15
    1162011-01-20  Maciej Stachowiak  <mjs@apple.com>
    217
  • trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp

    r76198 r76278  
    625625}
    626626
     627#if ENABLE(REQUEST_ANIMATION_FRAME)
     628static void invokeScheduleComposite(void* context)
     629{
     630    WebViewHost* wvh = static_cast<WebViewHost*>(context);
     631    wvh->scheduleComposite();
     632}
     633
     634void WebViewHost::scheduleAnimation()
     635{
     636    webkit_support::PostDelayedTask(invokeScheduleComposite, this, 0);
     637}
     638#endif
     639
    627640void WebViewHost::didFocus()
    628641{
     
    14391452void WebViewHost::paintInvalidatedRegion()
    14401453{
     1454#if ENABLE(REQUEST_ANIMATION_FRAME)
     1455    webWidget()->animate();
     1456#endif
    14411457    webWidget()->layout();
    14421458    WebSize widgetSize = webWidget()->size();
  • trunk/Tools/DumpRenderTree/chromium/WebViewHost.h

    r76198 r76278  
    148148    virtual void didScrollRect(int dx, int dy, const WebKit::WebRect&);
    149149    virtual void scheduleComposite();
     150#if ENABLE(REQUEST_ANIMATION_FRAME)
     151    virtual void scheduleAnimation();
     152#endif
    150153    virtual void didFocus();
    151154    virtual void didBlur();
Note: See TracChangeset for help on using the changeset viewer.