这是indexloc提供的服务,不要输入任何密码

LayoutTests/ChangeLog

 12011-01-10 James Robinson <jamesr@chromium.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 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-expected.txt: Added.
 19 * fast/animation/request-animation-frame.html: Added.
 20 Tests the basic use of window.webkitRequestAnimationFrame().
 21 * fast/animation/request-animation-frame-within-callback-expected.txt: Added.
 22 * fast/animation/request-animation-frame-within-callback.html: Added.
 23 Tests setting one webkit.webkitRequestAnimationFrame() callback within another.
 24 * platform/gtk/Skipped:
 25 * platform/mac/Skipped:
 26 * platform/qt/Skipped:
 27 * platform/win/Skipped:
 28
1292011-01-10 Tony Chang <tony@chromium.org>
230
331 Reviewed by Mihai Parparita.

LayoutTests/fast/animation/request-animation-frame-cancel-expected.txt

 1PASS

LayoutTests/fast/animation/request-animation-frame-cancel.html

 1<!DOCTYPE html>
 2<html>
 3<span id="e">PASS</span>
 4<script>
 5if (window.layoutTestController)
 6 layoutTestController.dumpAsText();
 7
 8var e = document.getElementById("e");
 9var id = window.webkitRequestAnimationFrame(function() {
 10 e.innerHTML = "FAIL";
 11}, e);
 12
 13window.webkitCancelRequestAnimationFrame(id);
 14
 15if (window.layoutTestController)
 16 layoutTestController.display();
 17</script>

LayoutTests/fast/animation/request-animation-frame-cancel2-expected.txt

 1PASS

LayoutTests/fast/animation/request-animation-frame-cancel2.html

 1<!DOCTYPE html>
 2<html>
 3<span id="e">PASS</span>
 4<script>
 5if (window.layoutTestController)
 6 layoutTestController.dumpAsText();
 7
 8var e = document.getElementById("e");
 9var secondCallbackId;
 10
 11window.webkitRequestAnimationFrame(function() {
 12 window.webkitCancelRequestAnimationFrame(secondCallbackId);
 13}, e);
 14
 15secondCallbackId = window.webkitRequestAnimationFrame(function() {
 16 e.innerHTML = "FAIL";
 17}, e);
 18
 19if (window.layoutTestController)
 20 layoutTestController.display();
 21</script>

LayoutTests/fast/animation/request-animation-frame-expected.txt

 1PASS

LayoutTests/fast/animation/request-animation-frame-within-callback-expected.txt

 1PASS

LayoutTests/fast/animation/request-animation-frame-within-callback.html

 1<!DOCTYPE html>
 2<html>
 3<span id="e">FAIL</span>
 4<script>
 5if (window.layoutTestController)
 6 layoutTestController.dumpAsText();
 7
 8var e = document.getElementById("e");
 9var sameFrame;
 10window.webkitRequestAnimationFrame(function() {
 11 sameFrame = true;
 12}, e);
 13window.webkitRequestAnimationFrame(function() {
 14 window.webkitRequestAnimationFrame(function() {
 15 e.innerHTML = sameFrame ? "FAIL" : "PASS";
 16 }, e);
 17}, e);
 18window.webkitRequestAnimationFrame(function() {
 19 sameFrame = false;
 20}, e);
 21
 22// This should fire the three already registered callbacks, but not the one dynamically registered.
 23if (window.layoutTestController)
 24 layoutTestController.display();
 25// This should fire the dynamically registered callback.
 26if (window.layoutTestController)
 27 layoutTestController.display();
 28</script>

LayoutTests/fast/animation/request-animation-frame.html

 1<!DOCTYPE html>
 2<html>
 3<span id="e">FAIL</span>
 4<script>
 5if (window.layoutTestController)
 6 layoutTestController.dumpAsText();
 7
 8var e = document.getElementById("e");
 9window.webkitRequestAnimationFrame(function() {
 10 e.innerHTML="PASS";
 11}, e);
 12if (window.layoutTestController)
 13 layoutTestController.display();
 14</script>

LayoutTests/platform/gtk/Skipped

@@http/tests/xmlhttprequest/basic-auth-nopassword.html
56025602
56035603# https://bugs.webkit.org/show_bug.cgi?id=51734
56045604fast/multicol/span/double-merge-anonymous-block-crash.html
 5605
 5606# Requires requestAnimationFrame support
 5607fast/animation/

LayoutTests/platform/mac/Skipped

@@editing/selection/caret-mode-paragraph-keys-navigation.html
284284# This test is failing on the Leopard Intel Debug buildbot
285285# https://bugs.webkit.org/show_bug.cgi?id=51807
286286fast/blockflow/broken-ideograph-small-caps.html
 287
 288# Requires requestAnimationFrame support
 289fast/animation/

LayoutTests/platform/qt/Skipped

@@fast/events/before-unload-with-subframes.html
53795379# [Qt] fast/text/emphasis-avoid-ruby.html fails
53805380# https://bugs.webkit.org/show_bug.cgi?id=52155
53815381fast/text/emphasis-avoid-ruby.html
 5382
 5383# Requires requestAnimationFrame support
 5384fast/animation/

LayoutTests/platform/win/Skipped

@@fast/loader/user-stylesheet-fast-path.html
11141114
11151115# DRT does not support toggling caret browsing on / off
11161116editing/selection/caret-mode-paragraph-keys-navigation.html
 1117
 1118# Requires requestAnimationFrame support
 1119fast/animation/

Source/WebCore/ChangeLog

 12011-01-10 James Robinson <jamesr@chromium.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 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-within-callback.html
 37 fast/animation/request-animation-frame.html
 38
 39 * WebCore.gypi:
 40 * dom/Document.cpp:
 41 (WebCore::Document::Document):
 42 (WebCore::Document::webkitRequestAnimationFrame):
 43 (WebCore::Document::webkitCancelRequestAnimationFrame):
 44 (WebCore::Document::serviceScriptedAnimations):
 45 * dom/Document.h:
 46 * dom/RequestAnimationFrameCallback.h: Added.
 47 (WebCore::RequestAnimationFrameCallback::~RequestAnimationFrameCallback):
 48 * dom/RequestAnimationFrameCallback.idl: Added.
 49 * loader/EmptyClients.h:
 50 (WebCore::EmptyChromeClient::scheduleAnimation):
 51 * page/Chrome.cpp:
 52 (WebCore::Chrome::scheduleAnimation):
 53 * page/Chrome.h:
 54 * page/ChromeClient.h:
 55 * page/DOMWindow.cpp:
 56 (WebCore::DOMWindow::webkitRequestAnimationFrame):
 57 (WebCore::DOMWindow::webkitCancelRequestAnimationFrame):
 58 * page/DOMWindow.h:
 59 * page/DOMWindow.idl:
 60 * page/FrameView.cpp:
 61 (WebCore::FrameView::scheduleAnimation):
 62 (WebCore::FrameView::serviceScriptedAnimations):
 63 * page/FrameView.h:
 64 * platform/HostWindow.h:
 65
1662011-01-10 Alejandro G. Castro <alex@igalia.com>
267
368 Reviewed by Xan Lopez.

Source/WebCore/WebCore.gypi

7575 'dom/ProgressEvent.idl',
7676 'dom/Range.idl',
7777 'dom/RangeException.idl',
 78 'dom/RequestAnimationFrameCallback.idl',
7879 'dom/Text.idl',
7980 'dom/TextEvent.idl',
8081 'dom/Touch.idl',

13141315 'dom/Range.h',
13151316 'dom/RangeBoundaryPoint.h',
13161317 'dom/RangeException.h',
 1318 'dom/RequestAnimationFrameCallback.h',
13171319 'dom/RawDataDocumentParser.h',
13181320 'dom/RegisteredEventListener.cpp',
13191321 'dom/RegisteredEventListener.h',

Source/WebCore/dom/Document.cpp

207207#include "RenderFullScreen.h"
208208#endif
209209
 210#if ENABLE(REQUEST_ANIMATION_FRAME)
 211#include "RequestAnimationFrameCallback.h"
 212#endif
 213
210214using namespace std;
211215using namespace WTF;
212216using namespace Unicode;

@@Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML, con
425429 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired)
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;
430437

@@void Document::loadEventDelayTimerFired(Timer<Document>*)
49454952 frame()->loader()->checkCompleted();
49464953}
49474954
 4955#if ENABLE(REQUEST_ANIMATION_FRAME)
 4956int Document::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback, Element* e)
 4957{
 4958 if (!m_requestAnimationFrameCallbacks)
 4959 m_requestAnimationFrameCallbacks = new Vector<RefPtr<RequestAnimationFrameCallback> >();
 4960 int id = m_nextRequestAnimationFrameCallbackId++;
 4961 callback->m_enabled = true;
 4962 callback->m_id = id;
 4963 callback->m_element = e;
 4964 m_requestAnimationFrameCallbacks->append(callback);
 4965 if (FrameView* v = view())
 4966 v->scheduleAnimation();
 4967 return id;
 4968}
 4969
 4970void Document::webkitCancelRequestAnimationFrame(int id)
 4971{
 4972 if (!m_requestAnimationFrameCallbacks)
 4973 return;
 4974 for (size_t i = 0; i < m_requestAnimationFrameCallbacks->size(); ++i) {
 4975 if (m_requestAnimationFrameCallbacks->at(i)->m_id == id) {
 4976 m_requestAnimationFrameCallbacks->at(i)->m_enabled = false;
 4977 m_requestAnimationFrameCallbacks->remove(i);
 4978 return;
 4979 }
 4980 }
 4981}
 4982
 4983void Document::serviceScriptedAnimations()
 4984{
 4985 if (!m_requestAnimationFrameCallbacks)
 4986 return;
 4987 // We want to run the callback for all elements in the document that have registered
 4988 // for a callback and that are visible. Running the callbacks can cause new callbacks
 4989 // to be registered, existing callbacks to be cancelled, and elements to gain or lose
 4990 // visibility so this code has to iterate carefully.
 4991
 4992 // First, generate a list of callbacks to consider. Callbacks registered from this point
 4993 // on are considered only for the "next" frame, not this one.
 4994 Vector<RefPtr<RequestAnimationFrameCallback> > callbacks(*m_requestAnimationFrameCallbacks);
 4995
 4996 // Firing the callback may cause the visibility of other elements to change. To avoid
 4997 // missing any callbacks, we keep iterating through the list of candiate callbacks and firing
 4998 // them until nothing new becomes visible.
 4999 bool firedCallback;
 5000 do {
 5001 firedCallback = false;
 5002 // A previous iteration may have invalidated style (or layout). Update styles for each iteration
 5003 // for now since all we check is the existence of a renderer.
 5004 updateStyleIfNeeded();
 5005 for (size_t i = 0; i < callbacks.size(); ++i) {
 5006 RequestAnimationFrameCallback* callback = callbacks[i].get();
 5007 if (callback->m_enabled && (!callback->m_element || callback->m_element->renderer())) {
 5008 callback->m_enabled = false;
 5009 callback->handleEvent();
 5010 firedCallback = true;
 5011 callbacks.remove(i);
 5012 break;
 5013 }
 5014 }
 5015 } while (firedCallback);
 5016
 5017 // Any callbacks left in the callbacks array that have not been cancelled were skipped and have to be added
 5018 // back to the pending list. These go at the start of the list since they were registered before any callbacks
 5019 // registered this frame were.
 5020 size_t callbacksAdded = 0;
 5021 for (size_t i = 0; i < callbacks.size(); ++i) {
 5022 if (callbacks[i]->m_enabled)
 5023 m_requestAnimationFrameCallbacks->insert(callbacksAdded++, callbacks[i]);
 5024 }
 5025
 5026 // In most cases we expect this list to be empty, so no need to keep around the vector's default buffer.
 5027 if (!m_requestAnimationFrameCallbacks->size())
 5028 m_requestAnimationFrameCallbacks.clear();
 5029 else if (FrameView* v = view())
 5030 v->scheduleAnimation();
 5031}
 5032#endif
 5033
49485034#if ENABLE(TOUCH_EVENTS)
49495035PassRefPtr<Touch> Document::createTouch(DOMWindow* window, EventTarget* target, int identifier, int pageX, int pageY, int screenX, int screenY, ExceptionCode&) const
49505036{

Source/WebCore/dom/Document.h

@@class Touch;
147147class TouchList;
148148#endif
149149
 150#if ENABLE(REQUEST_ANIMATION_FRAME)
 151class RequestAnimationFrameCallback;
 152#endif
 153
150154typedef int ExceptionCode;
151155
152156class FormElementKey {

@@public:
10721076
10731077 const DocumentTiming* timing() const { return &m_documentTiming; }
10741078
 1079#if ENABLE(REQUEST_ANIMATION_FRAME)
 1080 int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>, Element*);
 1081 void webkitCancelRequestAnimationFrame(int id);
 1082 void serviceScriptedAnimations();
 1083#endif
 1084
10751085 bool mayCauseFlashOfUnstyledContent() const;
10761086
10771087 void initDNSPrefetch();

@@private:
13911401
13921402 DocumentTiming m_documentTiming;
13931403 RefPtr<MediaQueryMatcher> m_mediaQueryMatcher;
 1404
 1405#if ENABLE(REQUEST_ANIMATION_FRAME)
 1406 OwnPtr<Vector<RefPtr<RequestAnimationFrameCallback> > > m_requestAnimationFrameCallbacks;
 1407 int m_nextRequestAnimationFrameCallbackId;
 1408#endif
13941409};
13951410
13961411inline bool Document::DocumentOrderedMap::contains(AtomicStringImpl* id) const

Source/WebCore/dom/RequestAnimationFrameCallback.h

 1/*
 2 * Copyright (C) 2011 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions are
 6 * met:
 7 *
 8 * * Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * * Redistributions in binary form must reproduce the above
 11 * copyright notice, this list of conditions and the following disclaimer
 12 * in the documentation and/or other materials provided with the
 13 * distribution.
 14 * * Neither the name of Google Inc. nor the names of its
 15 * contributors may be used to endorse or promote products derived from
 16 * this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29 */
 30
 31#ifndef RequestAnimationFrameCallback_h
 32#define RequestAnimationFrameCallback_h
 33
 34#include "Element.h"
 35#include <wtf/PassRefPtr.h>
 36#include <wtf/RefCounted.h>
 37
 38namespace WebCore {
 39
 40class RequestAnimationFrameCallback : public RefCounted<RequestAnimationFrameCallback> {
 41public:
 42 virtual ~RequestAnimationFrameCallback() { }
 43 virtual bool handleEvent() = 0;
 44
 45 RefPtr<Element> m_element;
 46 int m_id;
 47 bool m_enabled;
 48};
 49
 50}
 51
 52#endif // RequestAnimationFrameCallback_h
 53

Source/WebCore/dom/RequestAnimationFrameCallback.idl

 1/*
 2 * Copyright (C) 2010 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions are
 6 * met:
 7 *
 8 * * Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * * Redistributions in binary form must reproduce the above
 11 * copyright notice, this list of conditions and the following disclaimer
 12 * in the documentation and/or other materials provided with the
 13 * distribution.
 14 * * Neither the name of Google Inc. nor the names of its
 15 * contributors may be used to endorse or promote products derived from
 16 * this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29 */
 30
 31module core {
 32 interface [
 33 Callback=FunctionOnly,Conditional=REQUEST_ANIMATION_FRAME
 34 ] RequestAnimationFrameCallback{
 35 boolean handleEvent();
 36 };
 37}

Source/WebCore/loader/EmptyClients.h

@@public:
157157#if ENABLE(TILED_BACKING_STORE)
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; }
162165 virtual IntRect windowToScreen(const IntRect& r) const { return r; }

Source/WebCore/page/Chrome.cpp

@@void Chrome::setCursor(const Cursor& cursor)
448448 m_client->setCursor(cursor);
449449}
450450
 451#if ENABLE(REQUEST_ANIMATION_FRAME)
 452void Chrome::scheduleAnimation()
 453{
 454 m_client->scheduleAnimation();
 455}
 456#endif
 457
451458#if ENABLE(NOTIFICATIONS)
452459NotificationPresenter* Chrome::notificationPresenter() const
453460{

Source/WebCore/page/Chrome.h

@@namespace WebCore {
7878 virtual PlatformPageClient platformPageClient() const;
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;
8386

Source/WebCore/page/ChromeClient.h

@@namespace WebCore {
151151 virtual PlatformPageClient platformPageClient() const = 0;
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
156159 virtual void dispatchViewportDataDidChange(const ViewportArguments&) const { }

Source/WebCore/page/DOMWindow.cpp

105105#include "LocalFileSystem.h"
106106#endif
107107
 108#if ENABLE(REQUEST_ANIMATION_FRAME)
 109#include "RequestAnimationFrameCallback.h"
 110#endif
 111
108112using std::min;
109113using std::max;
110114

@@void DOMWindow::clearInterval(int timeoutId)
14641468 DOMTimer::removeById(context, timeoutId);
14651469}
14661470
 1471#if ENABLE(REQUEST_ANIMATION_FRAME)
 1472int DOMWindow::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback, Element* e)
 1473{
 1474 if (Document* d = document())
 1475 return d->webkitRequestAnimationFrame(callback, e);
 1476 return 0;
 1477}
 1478
 1479void DOMWindow::webkitCancelRequestAnimationFrame(int id)
 1480{
 1481 if (Document* d = document())
 1482 d->webkitCancelRequestAnimationFrame(id);
 1483}
 1484#endif
 1485
14671486bool DOMWindow::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture)
14681487{
14691488 if (!EventTarget::addEventListener(eventType, listener, useCapture))

Source/WebCore/page/DOMWindow.h

@@namespace WebCore {
6464 class StyleMedia;
6565 class WebKitPoint;
6666
 67#if ENABLE(REQUEST_ANIMATION_FRAME)
 68 class RequestAnimationFrameCallback;
 69#endif
 70
6771 struct WindowFeatures;
6872
6973 typedef int ExceptionCode;

@@namespace WebCore {
237241 int setInterval(PassOwnPtr<ScheduledAction>, int timeout, ExceptionCode&);
238242 void clearInterval(int timeoutId);
239243
 244 // WebKit animation extensions
 245#if ENABLE(REQUEST_ANIMATION_FRAME)
 246 int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>, Element*);
 247 void webkitCancelRequestAnimationFrame(int id);
 248#endif
 249
240250 // Events
241251 // EventTarget API
242252 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);

Source/WebCore/page/DOMWindow.idl

@@module window {
235235 // [Custom] long setInterval(in DOMString code, in long timeout);
236236 void clearInterval(in long handle);
237237
 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
 243
238244 // Base64
239245 DOMString atob(in [ConvertNullToNullString] DOMString string)
240246 raises(DOMException);

Source/WebCore/page/FrameView.cpp

@@void FrameView::setFrameRect(const IntRect& newRect)
342342#endif
343343}
344344
 345#if ENABLE(REQUEST_ANIMATION_FRAME)
 346void FrameView::scheduleAnimation()
 347{
 348 if (hostWindow())
 349 hostWindow()->scheduleAnimation();
 350}
 351#endif
 352
345353void FrameView::setMarginWidth(int w)
346354{
347355 // make it update the rendering area when set

@@void FrameView::unscheduleRelayout()
16391647 m_delayedLayout = false;
16401648}
16411649
 1650#if ENABLE(REQUEST_ANIMATION_FRAME)
 1651void FrameView::serviceScriptedAnimations()
 1652{
 1653 for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNext())
 1654 frame->document()->serviceScriptedAnimations();
 1655}
 1656#endif
 1657
16421658bool FrameView::isTransparent() const
16431659{
16441660 return m_isTransparent;

Source/WebCore/page/FrameView.h

@@public:
6262
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(); }
6770 void clearFrame();

@@public:
97100
98101 bool needsFullRepaint() const { return m_doFullRepaint; }
99102
 103#if ENABLE(REQUEST_ANIMATION_FRAME)
 104 void serviceScriptedAnimations();
 105#endif
 106
100107#if USE(ACCELERATED_COMPOSITING)
101108 void updateCompositingLayers();
102109

Source/WebCore/platform/HostWindow.h

@@public:
6666
6767 // Request that the cursor change.
6868 virtual void setCursor(const Cursor&) = 0;
 69
 70#if ENABLE(REQUEST_ANIMATION_FRAME)
 71 virtual void scheduleAnimation() = 0;
 72#endif
6973};
7074
7175} // namespace WebCore

Tools/ChangeLog

 12011-01-10 James Robinson <jamesr@chromium.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 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-10 Tony Chang <tony@chromium.org>
217
318 Reviewed by Mihai Parparita.

Tools/DumpRenderTree/chromium/WebViewHost.cpp

@@void WebViewHost::scheduleComposite()
624624 didInvalidateRect(clientRect);
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, static_cast<void*>(this), 0);
 637}
 638#endif
 639
627640void WebViewHost::didFocus()
628641{
629642 m_shell->setFocus(webWidget(), true);

@@void WebViewHost::paintRect(const WebRect& rect)
14451458
14461459void WebViewHost::paintInvalidatedRegion()
14471460{
 1461#if ENABLE(REQUEST_ANIMATION_FRAME)
 1462 webWidget()->animate();
 1463#endif
14481464 webWidget()->layout();
14491465 WebSize widgetSize = webWidget()->size();
14501466 WebRect clientRect(0, 0, widgetSize.width, widgetSize.height);

Tools/DumpRenderTree/chromium/WebViewHost.h

@@class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient,
151151 virtual void didInvalidateRect(const WebKit::WebRect&);
152152 virtual void didScrollRect(int dx, int dy, const WebKit::WebRect&);
153153 virtual void scheduleComposite();
 154#if ENABLE(REQUEST_ANIMATION_FRAME)
 155 virtual void scheduleAnimation();
 156#endif
154157 virtual void didFocus();
155158 virtual void didBlur();
156159 virtual void didChangeCursor(const WebKit::WebCursorInfo&);

WebKit/chromium/ChangeLog

 12011-01-10 James Robinson <jamesr@chromium.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 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
1252011-01-10 John Knottenbelt <jknotten@chromium.org>
226
327 Reviewed by Jeremy Orlow.

WebKit/chromium/features.gypi

6969 'ENABLE_OPENTYPE_SANITIZER=1',
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',
7475 'ENABLE_SVG_ANIMATION=1',

WebKit/chromium/public/WebWidget.h

@@public:
5656 // Called to resize the WebWidget.
5757 virtual void resize(const WebSize&) = 0;
5858
 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;
 62
5963 // Called to layout the WebWidget. This MUST be called before Paint,
6064 // and it may result in calls to WebWidgetClient::didInvalidateRect.
6165 virtual void layout() = 0;

WebKit/chromium/public/WebWidgetClient.h

@@public:
5656 // Called when a call to WebWidget::composite is required
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() { }
6164 virtual void didBlur() { }

WebKit/chromium/src/ChromeClientImpl.cpp

@@void ChromeClientImpl::invalidateContentsForSlowScroll(const IntRect& updateRect
532532 invalidateContentsAndWindow(updateRect, immediate);
533533}
534534
 535#if ENABLE(REQUEST_ANIMATION_FRAME)
 536void ChromeClientImpl::scheduleAnimation()
 537{
 538 m_webView->client()->scheduleAnimation();
 539}
 540#endif
 541
535542void ChromeClientImpl::scroll(
536543 const IntSize& scrollDelta, const IntRect& scrollRect,
537544 const IntRect& clipRect)

WebKit/chromium/src/ChromeClientImpl.h

@@public:
105105 virtual void invalidateWindow(const WebCore::IntRect&, bool);
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,
110113 const WebCore::IntRect& clipRect);

WebKit/chromium/src/WebPopupMenuImpl.cpp

@@void WebPopupMenuImpl::resize(const WebSize& newSize)
151151 }
152152}
153153
 154void WebPopupMenuImpl::animate()
 155{
 156}
 157
154158void WebPopupMenuImpl::layout()
155159{
156160}

@@void WebPopupMenuImpl::invalidateContentsForSlowScroll(const IntRect& updateRect
299303 invalidateContentsAndWindow(updateRect, immediate);
300304}
301305
 306void WebPopupMenuImpl::scheduleAnimation()
 307{
 308}
 309
302310void WebPopupMenuImpl::scroll(const IntSize& scrollDelta,
303311 const IntRect& scrollRect,
304312 const IntRect& clipRect)

WebKit/chromium/src/WebPopupMenuImpl.h

@@public:
6161 virtual void close();
6262 virtual WebSize size() { return m_size; }
6363 virtual void resize(const WebSize&);
 64 virtual void animate();
6465 virtual void layout();
6566 virtual void paint(WebCanvas* canvas, const WebRect& rect);
6667 virtual void themeChanged();

@@public:
105106 virtual void invalidateWindow(const WebCore::IntRect&, bool);
106107 virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool);
107108 virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
 109 virtual void scheduleAnimation();
108110 virtual void scroll(
109111 const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect,
110112 const WebCore::IntRect& clipRect);

WebKit/chromium/src/WebViewImpl.cpp

@@void WebViewImpl::resize(const WebSize& newSize)
971971#endif
972972}
973973
 974void WebViewImpl::animate()
 975{
 976#if ENABLE(REQUEST_ANIMATION_FRAME)
 977 WebFrameImpl* webframe = mainFrameImpl();
 978 if (webframe) {
 979 FrameView* view = webframe->frameView();
 980 if (view)
 981 view->serviceScriptedAnimations();
 982 }
 983#endif
 984}
 985
974986void WebViewImpl::layout()
975987{
976988 WebFrameImpl* webframe = mainFrameImpl();

WebKit/chromium/src/WebViewImpl.h

@@public:
9292 virtual void close();
9393 virtual WebSize size() { return m_size; }
9494 virtual void resize(const WebSize&);
 95 virtual void animate();
9596 virtual void layout();
9697 virtual void paint(WebCanvas*, const WebRect&);
9798 virtual void themeChanged();