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

LayoutTests/ChangeLog

 12011-01-11 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-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-11 Dimitri Glazkov <dglazkov@chromium.org>
233
334 Reviewed by Eric Seidel.

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-display-expected.txt

 1PASS

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

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

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/inspector/console-websocket-error.html
55945594# layoutTestController.queueLoad() does not work
55955595http/tests/xmlhttprequest/basic-auth-nouser.html
55965596http/tests/xmlhttprequest/basic-auth-nopassword.html
 5597
 5598# Requires requestAnimationFrame support
 5599fast/animation/
 5600
 5601# https://bugs.webkit.org/show_bug.cgi?id=51734
 5602fast/multicol/span/double-merge-anonymous-block-crash.html

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

@@editing/selection/caret-bidi-first-and-last-letters.html
53695369# https://bugs.webkit.org/show_bug.cgi?id=52155
53705370fast/text/emphasis-avoid-ruby.html
53715371
 5372# Requires requestAnimationFrame support
 5373fast/animation/
 5374
53725375# https://bugs.webkit.org/show_bug.cgi?id=42578
53735376# [Qt] DRT sideeffect revealed by r63657 and r75305
53745377fast/tokenizer/flush-characters-in-document-write-evil.html

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

112011-01-11 James Robinson <jamesr@chromium.org>
22
 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-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
 672011-01-11 James Robinson <jamesr@chromium.org>
 68
369 Reviewed by Dimitri Glazkov.
470
571 Set all RenderBlocks as replaced when an inline display type is specified

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

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 typedef Vector<RefPtr<RequestAnimationFrameCallback> > RequestAnimationFrameCallbackList;
 1407 OwnPtr<RequestAnimationFrameCallbackList> m_requestAnimationFrameCallbacks;
 1408 int m_nextRequestAnimationFrameCallbackId;
 1409#endif
13941410};
13951411
13961412inline 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_firedOrCancelled;
 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-11 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-11 Eric Seidel <eric@webkit.org>
217
318 Unreviewed.

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

@@void WebViewHost::paintRect(const WebRect& rect)
14381451
14391452void WebViewHost::paintInvalidatedRegion()
14401453{
 1454#if ENABLE(REQUEST_ANIMATION_FRAME)
 1455 webWidget()->animate();
 1456#endif
14411457 webWidget()->layout();
14421458 WebSize widgetSize = webWidget()->size();
14431459 WebRect clientRect(0, 0, widgetSize.width, widgetSize.height);

Tools/DumpRenderTree/chromium/WebViewHost.h

@@class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient,
147147 virtual void didInvalidateRect(const WebKit::WebRect&);
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();
152155 virtual void didChangeCursor(const WebKit::WebCursorInfo&);

WebKit/chromium/ChangeLog

 12011-01-11 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-11 Pavel Feldman <pfeldman@chromium.org>
226
327 Reviewed by Yury Semikhatsky.

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)
973973#endif
974974}
975975
 976void WebViewImpl::animate()
 977{
 978#if ENABLE(REQUEST_ANIMATION_FRAME)
 979 WebFrameImpl* webframe = mainFrameImpl();
 980 if (webframe) {
 981 FrameView* view = webframe->frameView();
 982 if (view)
 983 view->serviceScriptedAnimations();
 984 }
 985#endif
 986}
 987
976988void WebViewImpl::layout()
977989{
978990 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();