这是indexloc提供的服务,不要输入任何密码
WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
initial patch for discussion
bug-51218-20110104161909.patch (text/plain), 36.71 KB, created by
James Robinson
on 2011-01-04 16:19:10 PST
(
hide
)
Description:
initial patch for discussion
Filename:
MIME Type:
Creator:
James Robinson
Created:
2011-01-04 16:19:10 PST
Size:
36.71 KB
patch
obsolete
>diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index f14b5bbabc3bbbb6c284e5b7b27dd1ec8f9c3724..ec1e519c7b765b9fa3f3956f91870dcb1effe19d 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,25 @@ >+2011-01-04 James Robinson <jamesr@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implement mozilla's requestAnimationFrame API >+ https://bugs.webkit.org/show_bug.cgi?id=51218 >+ >+ Add tests for webkitRequestAnimationFrame. >+ >+ * fast/animation/request-animation-frame-cancel-expected.txt: Added. >+ * fast/animation/request-animation-frame-cancel.html: Added. >+ Tests that cancelling a callback before it fires prevents the callback from firing. >+ * fast/animation/request-animation-frame-cancel2-expected.txt: Added. >+ * fast/animation/request-animation-frame-cancel2.html: Added. >+ Tests cancelling a callback from within another callback. >+ * fast/animation/request-animation-frame-expected.txt: Added. >+ * fast/animation/request-animation-frame-within-callback-expected.txt: Added. >+ * fast/animation/request-animation-frame-within-callback.html: Added. >+ Tests registering a callback within a callback. >+ * fast/animation/request-animation-frame.html: Added. >+ Tests basic use of webkitRequestAnimationFrame. >+ > 2011-01-04 Ryosuke Niwa <rniwa@webkit.org> > > Reviewed by Dan Bernstein. >diff --git a/LayoutTests/fast/animation/request-animation-frame-cancel-expected.txt b/LayoutTests/fast/animation/request-animation-frame-cancel-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..7ef22e9a431ad0272713b71fdc8794016c8ef12f >--- /dev/null >+++ b/LayoutTests/fast/animation/request-animation-frame-cancel-expected.txt >@@ -0,0 +1 @@ >+PASS >diff --git a/LayoutTests/fast/animation/request-animation-frame-cancel.html b/LayoutTests/fast/animation/request-animation-frame-cancel.html >new file mode 100644 >index 0000000000000000000000000000000000000000..4210f7b9f69e6016a3c7a24d93574488d899910f >--- /dev/null >+++ b/LayoutTests/fast/animation/request-animation-frame-cancel.html >@@ -0,0 +1,17 @@ >+<!DOCTYPE html> >+<html> >+<span id="e">PASS</span> >+<script> >+if (window.layoutTestController) >+ layoutTestController.dumpAsText(); >+ >+var e = document.getElementById("e"); >+var id = window.webkitRequestAnimationFrame(function() { >+ e.innerHTML = "FAIL"; >+}, e); >+ >+window.webkitCancelRequestAnimationFrame(id); >+ >+if (window.layoutTestController) >+ layoutTestController.display(); >+</script> >diff --git a/LayoutTests/fast/animation/request-animation-frame-cancel2-expected.txt b/LayoutTests/fast/animation/request-animation-frame-cancel2-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..7ef22e9a431ad0272713b71fdc8794016c8ef12f >--- /dev/null >+++ b/LayoutTests/fast/animation/request-animation-frame-cancel2-expected.txt >@@ -0,0 +1 @@ >+PASS >diff --git a/LayoutTests/fast/animation/request-animation-frame-cancel2.html b/LayoutTests/fast/animation/request-animation-frame-cancel2.html >new file mode 100644 >index 0000000000000000000000000000000000000000..4ac2e93fd335856cd626f4a61dcff41d3546a029 >--- /dev/null >+++ b/LayoutTests/fast/animation/request-animation-frame-cancel2.html >@@ -0,0 +1,21 @@ >+<!DOCTYPE html> >+<html> >+<span id="e">PASS</span> >+<script> >+if (window.layoutTestController) >+ layoutTestController.dumpAsText(); >+ >+var e = document.getElementById("e"); >+var secondCallbackId; >+ >+window.webkitRequestAnimationFrame(function() { >+ window.webkitCancelRequestAnimationFrame(secondCallbackId); >+}, e); >+ >+secondCallbackId = window.webkitRequestAnimationFrame(function() { >+ e.innerHTML = "FAIL"; >+}, e); >+ >+if (window.layoutTestController) >+ layoutTestController.display(); >+</script> >diff --git a/LayoutTests/fast/animation/request-animation-frame-expected.txt b/LayoutTests/fast/animation/request-animation-frame-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..7ef22e9a431ad0272713b71fdc8794016c8ef12f >--- /dev/null >+++ b/LayoutTests/fast/animation/request-animation-frame-expected.txt >@@ -0,0 +1 @@ >+PASS >diff --git a/LayoutTests/fast/animation/request-animation-frame-within-callback-expected.txt b/LayoutTests/fast/animation/request-animation-frame-within-callback-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..7ef22e9a431ad0272713b71fdc8794016c8ef12f >--- /dev/null >+++ b/LayoutTests/fast/animation/request-animation-frame-within-callback-expected.txt >@@ -0,0 +1 @@ >+PASS >diff --git a/LayoutTests/fast/animation/request-animation-frame-within-callback.html b/LayoutTests/fast/animation/request-animation-frame-within-callback.html >new file mode 100644 >index 0000000000000000000000000000000000000000..d5a366fee0458343945d00fc965ae859d5352aa9 >--- /dev/null >+++ b/LayoutTests/fast/animation/request-animation-frame-within-callback.html >@@ -0,0 +1,28 @@ >+<!DOCTYPE html> >+<html> >+<span id="e">FAIL</span> >+<script> >+if (window.layoutTestController) >+ layoutTestController.dumpAsText(); >+ >+var e = document.getElementById("e"); >+var sameFrame; >+window.webkitRequestAnimationFrame(function() { >+ sameFrame = true; >+}, e); >+window.webkitRequestAnimationFrame(function() { >+ window.webkitRequestAnimationFrame(function() { >+ e.innerHTML = sameFrame ? "FAIL" : "PASS"; >+ }, e); >+}, e); >+window.webkitRequestAnimationFrame(function() { >+ sameFrame = false; >+}, e); >+ >+// This should fire the three already registered callbacks, but not the one dynamically registered. >+if (window.layoutTestController) >+ layoutTestController.display(); >+// This should fire the dynamically registered callback. >+if (window.layoutTestController) >+ layoutTestController.display(); >+</script> >diff --git a/LayoutTests/fast/animation/request-animation-frame.html b/LayoutTests/fast/animation/request-animation-frame.html >new file mode 100644 >index 0000000000000000000000000000000000000000..7d67a977421685e4f1dc6b7e9d02b0e98d64c509 >--- /dev/null >+++ b/LayoutTests/fast/animation/request-animation-frame.html >@@ -0,0 +1,14 @@ >+<!DOCTYPE html> >+<html> >+<span id="e">FAIL</span> >+<script> >+if (window.layoutTestController) >+ layoutTestController.dumpAsText(); >+ >+var e = document.getElementById("e"); >+window.webkitRequestAnimationFrame(function() { >+ e.innerHTML="PASS"; >+}, e); >+if (window.layoutTestController) >+ layoutTestController.display(); >+</script> >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 90096b0326d1276f98cbd47a34a9c25828a03827..e7f5ac29a90d4a8541f0c3128c38f7e0fae8d308 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,18 @@ >+2011-01-04 James Robinson <jamesr@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implement mozilla's requestAnimationFrame API >+ https://bugs.webkit.org/show_bug.cgi?id=51218 >+ >+ Adds webkitRequestAnimationFrame support to chromium's DRT. >+ >+ * DumpRenderTree/chromium/WebViewHost.cpp: >+ (invokeScheduleComposite): >+ (WebViewHost::scheduleAnimation): >+ (WebViewHost::paintInvalidatedRegion): >+ * DumpRenderTree/chromium/WebViewHost.h: >+ > 2011-01-03 Yi Shen <yi.4.shen@nokia.com> > > Reviewed by Adam Barth. >diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.cpp b/Tools/DumpRenderTree/chromium/WebViewHost.cpp >index 849312c4b05edb8234fc0c75614ba961d028f10a..0bb632a57549c0c4e825b22a469234d17d623f75 100644 >--- a/Tools/DumpRenderTree/chromium/WebViewHost.cpp >+++ b/Tools/DumpRenderTree/chromium/WebViewHost.cpp >@@ -637,6 +637,17 @@ void WebViewHost::scheduleComposite() > didInvalidateRect(clientRect); > } > >+static void invokeScheduleComposite(void* context) >+{ >+ WebViewHost* wvh = static_cast<WebViewHost*>(context); >+ wvh->scheduleComposite(); >+} >+ >+void WebViewHost::scheduleAnimation() >+{ >+ webkit_support::PostDelayedTask(invokeScheduleComposite, static_cast<void*>(this), 0); >+} >+ > void WebViewHost::didFocus() > { > m_shell->setFocus(webWidget(), true); >@@ -1455,6 +1466,7 @@ void WebViewHost::paintRect(const WebRect& rect) > > void WebViewHost::paintInvalidatedRegion() > { >+ webWidget()->animate(); > webWidget()->layout(); > WebSize widgetSize = webWidget()->size(); > WebRect clientRect(0, 0, widgetSize.width, widgetSize.height); >diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.h b/Tools/DumpRenderTree/chromium/WebViewHost.h >index 20b29c0d9cb6109ef555a008470b3ced1508e988..ad116ce7dc15f73e943c38d1cbcd67941e5c5de9 100644 >--- a/Tools/DumpRenderTree/chromium/WebViewHost.h >+++ b/Tools/DumpRenderTree/chromium/WebViewHost.h >@@ -151,6 +151,7 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, > virtual void didInvalidateRect(const WebKit::WebRect&); > virtual void didScrollRect(int dx, int dy, const WebKit::WebRect&); > virtual void scheduleComposite(); >+ virtual void scheduleAnimation(); > virtual void didFocus(); > virtual void didBlur(); > virtual void didChangeCursor(const WebKit::WebCursorInfo&); >diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog >index 95f291330bbf1e4517402dcd07f4d323558a9bed..deaffe69735be915c90054d3da2a1846175ed68e 100644 >--- a/WebCore/ChangeLog >+++ b/WebCore/ChangeLog >@@ -1,3 +1,45 @@ >+2011-01-04 James Robinson <jamesr@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implement mozilla's requestAnimationFrame API >+ https://bugs.webkit.org/show_bug.cgi?id=51218 >+ >+ Tests: fast/animation/request-animation-frame-cancel.html >+ fast/animation/request-animation-frame-cancel2.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::requestAnimationFrames): >+ * dom/Document.h: >+ * dom/Element.h: >+ * dom/ElementRareData.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::webkitAnimationTime): >+ (WebCore::DOMWindow::webkitRequestAnimationFrame): >+ (WebCore::DOMWindow::webkitCancelRequestAnimationFrame): >+ * page/DOMWindow.h: >+ * page/DOMWindow.idl: >+ * page/FrameView.cpp: >+ (WebCore::FrameView::scheduleAnimation): >+ (WebCore::FrameView::requestAnimationFrames): >+ * page/FrameView.h: >+ * platform/HostWindow.h: >+ > 2011-01-04 Tony Gentilcore <tonyg@chromium.org> > > Unreviewed build fix. >diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi >index 70d3bdf2a247ef3b404f28e9a257400294d0fbf9..77caa1e606fdafa15976f7cff3f81548603d9e43 100644 >--- a/WebCore/WebCore.gypi >+++ b/WebCore/WebCore.gypi >@@ -75,6 +75,7 @@ > 'dom/ProgressEvent.idl', > 'dom/Range.idl', > 'dom/RangeException.idl', >+ 'dom/RequestAnimationFrameCallback.idl', > 'dom/Text.idl', > 'dom/TextEvent.idl', > 'dom/Touch.idl', >@@ -1311,6 +1312,7 @@ > 'dom/Range.h', > 'dom/RangeBoundaryPoint.h', > 'dom/RangeException.h', >+ 'dom/RequestAnimationFrameCallback.h', > 'dom/RawDataDocumentParser.h', > 'dom/RegisteredEventListener.cpp', > 'dom/RegisteredEventListener.h', >diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp >index 76b0a4fe9b7846e94457ffc9c9a2f4d9010ef731..a31b11de238c21a59257ea8991a3f4b0f96c3780 100644 >--- a/WebCore/dom/Document.cpp >+++ b/WebCore/dom/Document.cpp >@@ -120,6 +120,7 @@ > #include "RenderTextControl.h" > #include "RenderView.h" > #include "RenderWidget.h" >+#include "RequestAnimationFrameCallback.h" > #include "ScriptController.h" > #include "ScriptElement.h" > #include "ScriptEventListener.h" >@@ -419,6 +420,7 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML, con > , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) > , m_directionSetOnDocumentElement(false) > , m_writingModeSetOnDocumentElement(false) >+ , m_requestAnimationFrameCallbackId(false) > { > m_document = this; > >@@ -4870,6 +4872,83 @@ void Document::loadEventDelayTimerFired(Timer<Document>*) > frame()->loader()->checkCompleted(); > } > >+int Document::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback, Element* e) >+{ >+ if (!m_requestAnimationFrameCallbacks) >+ m_requestAnimationFrameCallbacks = new Vector<RefPtr<RequestAnimationFrameCallback> >(); >+ int id = m_requestAnimationFrameCallbackId++; >+ callback->m_enabled = true; >+ callback->m_id = id; >+ callback->m_element = e; >+ m_requestAnimationFrameCallbacks->append(callback); >+ if (FrameView* v = view()) >+ v->scheduleAnimation(); >+ return id; >+} >+ >+void Document::webkitCancelRequestAnimationFrame(int id) >+{ >+ if (!m_requestAnimationFrameCallbacks) >+ return; >+ for (size_t i = 0; i < m_requestAnimationFrameCallbacks->size(); ++i) { >+ if (m_requestAnimationFrameCallbacks->at(i)->m_id == id) { >+ m_requestAnimationFrameCallbacks->at(i)->m_enabled = false; >+ m_requestAnimationFrameCallbacks->remove(i); >+ return; >+ } >+ } >+} >+ >+void Document::requestAnimationFrames() >+{ >+ if (!m_requestAnimationFrameCallbacks) >+ return; >+ // We want to run the callback for all elements in the document that have registered >+ // for a callback and that are visible. Running the callbacks can cause new callbacks >+ // to be registered, existing callbacks to be cancelled, and elements to gain or lose >+ // visibility so this code has to iterate carefully. >+ >+ // First, generate a list of callbacks to consider. Callbacks registered from this point >+ // on are considered only for the "next" frame, not this one. >+ Vector<RefPtr<RequestAnimationFrameCallback> > callbacks(*m_requestAnimationFrameCallbacks); >+ >+ // Firing the callback may cause the visibility of other elements to change. To avoid >+ // missing any callbacks, we keep iterating through the list of candiate callbacks and firing >+ // them until nothing new becomes visible. >+ bool firedCallback; >+ do { >+ firedCallback = false; >+ // A previous iteration may have invalidated style (or layout). Update styles for each iteration >+ // for now since all we check is the existence of a renderer. >+ updateStyleIfNeeded(); >+ for (size_t i = 0; i < callbacks.size(); ++i) { >+ RequestAnimationFrameCallback* callback = callbacks[i].get(); >+ if (callback->m_enabled && (!callback->m_element || callback->m_element->renderer())) { >+ callback->m_enabled = false; >+ callback->handleEvent(); >+ firedCallback = true; >+ callbacks.remove(i); >+ break; >+ } >+ } >+ } while (firedCallback); >+ >+ // Any callbacks left in the callbacks array that have not been cancelled were skipped and have to be added >+ // back to the pending list. These go at the start of the list since they were registered before any callbacks >+ // registered this frame were. >+ size_t callbacksAdded = 0; >+ for (size_t i = 0; i < callbacks.size(); ++i) { >+ if (callbacks[i]->m_enabled) >+ m_requestAnimationFrameCallbacks->insert(callbacksAdded++, callbacks[i]); >+ } >+ >+ // In most cases we expect this list to be empty, so no need to keep around the vector's default buffer. >+ if (!m_requestAnimationFrameCallbacks->size()) >+ m_requestAnimationFrameCallbacks.clear(); >+ else if (FrameView* v = view()) >+ v->scheduleAnimation(); >+} >+ > #if ENABLE(TOUCH_EVENTS) > PassRefPtr<Touch> Document::createTouch(DOMWindow* window, EventTarget* target, int identifier, int pageX, int pageY, int screenX, int screenY, ExceptionCode&) const > { >diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h >index 7e7967f1ba9ff7571de94f97b41373d22e425246..34b0500d1e931a756b9ab0bfc6ff8633c58cb797 100644 >--- a/WebCore/dom/Document.h >+++ b/WebCore/dom/Document.h >@@ -106,6 +106,7 @@ class PlatformMouseEvent; > class ProcessingInstruction; > class Range; > class RegisteredEventListener; >+class RequestAnimationFrameCallback; > class RenderArena; > class RenderView; > class ScriptableDocumentParser; >@@ -1063,6 +1064,10 @@ public: > > const DocumentTiming* timing() const { return &m_documentTiming; } > >+ int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>, Element*); >+ void webkitCancelRequestAnimationFrame(int id); >+ void requestAnimationFrames(); >+ > bool mayCauseFlashOfUnstyledContent() const; > > void initDNSPrefetch(); >@@ -1380,6 +1385,9 @@ private: > > DocumentTiming m_documentTiming; > RefPtr<MediaQueryMatcher> m_mediaQueryMatcher; >+ >+ OwnPtr<Vector<RefPtr<RequestAnimationFrameCallback> > > m_requestAnimationFrameCallbacks; >+ int m_requestAnimationFrameCallbackId; > }; > > inline bool Document::DocumentOrderedMap::contains(AtomicStringImpl* id) const >diff --git a/WebCore/dom/Element.h b/WebCore/dom/Element.h >index 9bad66fcfd4e62dba2ddd07bbb7e6a5f57722638..21f32426595bb73db8a41983db2486a5e61241ef 100644 >--- a/WebCore/dom/Element.h >+++ b/WebCore/dom/Element.h >@@ -39,6 +39,7 @@ class DOMStringMap; > class DOMTokenList; > class ElementRareData; > class IntSize; >+class RequestAnimationFrameCallback; > > enum SpellcheckAttributeState { > SpellcheckAttributeTrue, >diff --git a/WebCore/dom/ElementRareData.h b/WebCore/dom/ElementRareData.h >index f7f30bb708d1fe835ee68faa905763bb64886c47..85de75da28927b2cd34198d59bbade7047d84502 100644 >--- a/WebCore/dom/ElementRareData.h >+++ b/WebCore/dom/ElementRareData.h >@@ -26,6 +26,7 @@ > #include "DatasetDOMStringMap.h" > #include "Element.h" > #include "NodeRareData.h" >+#include "RequestAnimationFrameCallback.h" > #include <wtf/OwnPtr.h> > > namespace WebCore { >@@ -45,6 +46,8 @@ public: > > OwnPtr<DatasetDOMStringMap> m_datasetDOMStringMap; > OwnPtr<ClassList> m_classList; >+ >+ RefPtr<RequestAnimationFrameCallback> m_requestAnimationFrameCallback; > }; > > inline IntSize defaultMinimumSizeForResizing() >diff --git a/WebCore/dom/RequestAnimationFrameCallback.h b/WebCore/dom/RequestAnimationFrameCallback.h >new file mode 100644 >index 0000000000000000000000000000000000000000..170e440c31bd376b47b74c466dd3e58e81118397 >--- /dev/null >+++ b/WebCore/dom/RequestAnimationFrameCallback.h >@@ -0,0 +1,53 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef RequestAnimationFrameCallback_h >+#define RequestAnimationFrameCallback_h >+ >+#include "Element.h" >+#include <wtf/PassRefPtr.h> >+#include <wtf/RefCounted.h> >+ >+namespace WebCore { >+ >+class RequestAnimationFrameCallback : public RefCounted<RequestAnimationFrameCallback> { >+public: >+ virtual ~RequestAnimationFrameCallback() { } >+ virtual bool handleEvent() = 0; >+ >+ bool m_enabled; >+ int m_id; >+ RefPtr<Element> m_element; >+}; >+ >+} >+ >+#endif // RequestAnimationFrameCallback_h >+ >diff --git a/WebCore/dom/RequestAnimationFrameCallback.idl b/WebCore/dom/RequestAnimationFrameCallback.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..763258b3573e579238abdcd1691b1e39d186435a >--- /dev/null >+++ b/WebCore/dom/RequestAnimationFrameCallback.idl >@@ -0,0 +1,37 @@ >+/* >+ * Copyright (C) 2010 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+module core { >+ interface [ >+ Callback=FunctionOnly >+ ] RequestAnimationFrameCallback{ >+ boolean handleEvent(); >+ }; >+} >diff --git a/WebCore/loader/EmptyClients.h b/WebCore/loader/EmptyClients.h >index 560ea9110f274880fcfe4a896f40d5b5699071b9..35ca74b6bade79eedb642f13972e4eea808b012a 100644 >--- a/WebCore/loader/EmptyClients.h >+++ b/WebCore/loader/EmptyClients.h >@@ -157,6 +157,7 @@ public: > #if ENABLE(TILED_BACKING_STORE) > virtual void delegatedScrollRequested(const IntSize&) { } > #endif >+ virtual void scheduleAnimation() { } > > virtual IntPoint screenToWindow(const IntPoint& p) const { return p; } > virtual IntRect windowToScreen(const IntRect& r) const { return r; } >diff --git a/WebCore/page/Chrome.cpp b/WebCore/page/Chrome.cpp >index a8010650de243df5cb8e8602eac17d9bdec32cb8..dd1fa3abbfea5c4c7081371527819d3c4ba27f2b 100644 >--- a/WebCore/page/Chrome.cpp >+++ b/WebCore/page/Chrome.cpp >@@ -448,6 +448,11 @@ void Chrome::setCursor(const Cursor& cursor) > m_client->setCursor(cursor); > } > >+void Chrome::scheduleAnimation() >+{ >+ m_client->scheduleAnimation(); >+} >+ > #if ENABLE(NOTIFICATIONS) > NotificationPresenter* Chrome::notificationPresenter() const > { >diff --git a/WebCore/page/Chrome.h b/WebCore/page/Chrome.h >index 93b8c4a712d67f080a254b77e0fa6b33fb4c289b..7a4f8089a8823815bf97e829a998d05de0b042df 100644 >--- a/WebCore/page/Chrome.h >+++ b/WebCore/page/Chrome.h >@@ -78,6 +78,7 @@ namespace WebCore { > virtual PlatformPageClient platformPageClient() const; > virtual void scrollbarsModeDidChange() const; > virtual void setCursor(const Cursor&); >+ virtual void scheduleAnimation(); > > void scrollRectIntoView(const IntRect&) const; > >diff --git a/WebCore/page/ChromeClient.h b/WebCore/page/ChromeClient.h >index 3eb48a056f89122ad1ded92ca44d4e4459336408..a0622c5de2c9ab30b2cf3921771079508620bd22 100644 >--- a/WebCore/page/ChromeClient.h >+++ b/WebCore/page/ChromeClient.h >@@ -149,6 +149,7 @@ namespace WebCore { > virtual PlatformPageClient platformPageClient() const = 0; > virtual void scrollbarsModeDidChange() const = 0; > virtual void setCursor(const Cursor&) = 0; >+ virtual void scheduleAnimation() = 0; > // End methods used by HostWindow. > > virtual void dispatchViewportDataDidChange(const ViewportArguments&) const { } >diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp >index 3497f131770a5edbd2fcb076aa60a733653f5b9b..53be2753b143ce89eb61c457fc91abb106ec75fa 100644 >--- a/WebCore/page/DOMWindow.cpp >+++ b/WebCore/page/DOMWindow.cpp >@@ -79,6 +79,7 @@ > #include "Performance.h" > #include "PlatformScreen.h" > #include "PlatformString.h" >+#include "RequestAnimationFrameCallback.h" > #include "Screen.h" > #include "SecurityOrigin.h" > #include "SerializedScriptValue.h" >@@ -1464,6 +1465,27 @@ void DOMWindow::clearInterval(int timeoutId) > DOMTimer::removeById(context, timeoutId); > } > >+DOMTimeStamp DOMWindow::webkitAnimationTime() >+{ >+ // FIXME: Multiple queries of this value within the same script execution run >+ // should return the same value, so we need to calculate this value lazily and >+ // store it. >+ return convertSecondsToDOMTimeStamp(WTF::currentTime()); >+} >+ >+int DOMWindow::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback, Element* e) >+{ >+ if (Document* d = document()) >+ return d->webkitRequestAnimationFrame(callback, e); >+ return 0; >+} >+ >+void DOMWindow::webkitCancelRequestAnimationFrame(int id) >+{ >+ if (Document* d = document()) >+ d->webkitCancelRequestAnimationFrame(id); >+} >+ > bool DOMWindow::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture) > { > if (!EventTarget::addEventListener(eventType, listener, useCapture)) >diff --git a/WebCore/page/DOMWindow.h b/WebCore/page/DOMWindow.h >index 1c84f3caad8551f879e898fc455161d225db8862..490e8ab83b9eec8febd0fd7c4833dfb4aff68330 100644 >--- a/WebCore/page/DOMWindow.h >+++ b/WebCore/page/DOMWindow.h >@@ -27,6 +27,7 @@ > #ifndef DOMWindow_h > #define DOMWindow_h > >+#include "DOMTimeStamp.h" > #include "KURL.h" > #include "MessagePort.h" > #include "SecurityOrigin.h" >@@ -57,6 +58,7 @@ namespace WebCore { > class NotificationCenter; > class Performance; > class PostMessageTimer; >+ class RequestAnimationFrameCallback; > class ScheduledAction; > class Screen; > class SerializedScriptValue; >@@ -237,6 +239,10 @@ namespace WebCore { > int setInterval(PassOwnPtr<ScheduledAction>, int timeout, ExceptionCode&); > void clearInterval(int timeoutId); > >+ DOMTimeStamp webkitAnimationTime(); >+ int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>, Element*); >+ void webkitCancelRequestAnimationFrame(int id); >+ > // Events > // EventTarget API > virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture); >diff --git a/WebCore/page/DOMWindow.idl b/WebCore/page/DOMWindow.idl >index f3aa7ba5bd90f261e8e5ebc48e4ab915c0d967ac..f9e8176eb8d3a487eeb0484ceee5866050e4e467 100644 >--- a/WebCore/page/DOMWindow.idl >+++ b/WebCore/page/DOMWindow.idl >@@ -236,6 +236,11 @@ module window { > // [Custom] long setInterval(in DOMString code, in long timeout); > void clearInterval(in long handle); > >+ // WebKit animation extensions >+ readonly attribute DOMTimeStamp webkitAnimationTime; >+ long webkitRequestAnimationFrame(in [Callback] RequestAnimationFrameCallback callback, in Element element); >+ void webkitCancelRequestAnimationFrame(in long id); >+ > // Base64 > DOMString atob(in [ConvertNullToNullString] DOMString string) > raises(DOMException); >diff --git a/WebCore/page/FrameView.cpp b/WebCore/page/FrameView.cpp >index 66ea9c74a2cf02edc6de0466d6dd742bd3c8d376..6b30ba54ff52d0d22efd6d963f28086ce0b7dfa7 100644 >--- a/WebCore/page/FrameView.cpp >+++ b/WebCore/page/FrameView.cpp >@@ -338,6 +338,12 @@ void FrameView::setFrameRect(const IntRect& newRect) > #endif > } > >+void FrameView::scheduleAnimation() >+{ >+ if (hostWindow()) >+ hostWindow()->scheduleAnimation(); >+} >+ > void FrameView::setMarginWidth(int w) > { > // make it update the rendering area when set >@@ -1611,6 +1617,12 @@ void FrameView::unscheduleRelayout() > m_delayedLayout = false; > } > >+void FrameView::requestAnimationFrames() >+{ >+ for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNext()) >+ frame->document()->requestAnimationFrames(); >+} >+ > bool FrameView::isTransparent() const > { > return m_isTransparent; >diff --git a/WebCore/page/FrameView.h b/WebCore/page/FrameView.h >index 1712a3e6933ccf8fd111b3122ed2ab7dafc928f9..2348f2b82d9fc9758899a668c6f80cfc02fa3cbf 100644 >--- a/WebCore/page/FrameView.h >+++ b/WebCore/page/FrameView.h >@@ -62,6 +62,7 @@ public: > > virtual void invalidateRect(const IntRect&); > virtual void setFrameRect(const IntRect&); >+ void scheduleAnimation(); > > Frame* frame() const { return m_frame.get(); } > void clearFrame(); >@@ -97,6 +98,8 @@ public: > > bool needsFullRepaint() const { return m_doFullRepaint; } > >+ void requestAnimationFrames(); >+ > #if USE(ACCELERATED_COMPOSITING) > void updateCompositingLayers(); > >diff --git a/WebCore/platform/HostWindow.h b/WebCore/platform/HostWindow.h >index 7882d48fb4c291bb234f47a8184ce0aaf8f19d5a..db518cec2b6a8eea02e71130c6420c96bfac5f1a 100644 >--- a/WebCore/platform/HostWindow.h >+++ b/WebCore/platform/HostWindow.h >@@ -66,6 +66,8 @@ public: > > // Request that the cursor change. > virtual void setCursor(const Cursor&) = 0; >+ >+ virtual void scheduleAnimation() = 0; > }; > > } // namespace WebCore >diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog >index 6ef058c33e2b61589ca38a30e4215e780efba2ef..ce6467b324bd8ae9bb3313ab55d1a41528b831fc 100644 >--- a/WebKit/chromium/ChangeLog >+++ b/WebKit/chromium/ChangeLog >@@ -1,3 +1,24 @@ >+2011-01-04 James Robinson <jamesr@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implement mozilla's requestAnimationFrame API >+ https://bugs.webkit.org/show_bug.cgi?id=51218 >+ >+ * 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-03 Daniel Bates <dbates@rim.com> > > Attempt to fix the Chromium Linux Release build after changeset 74895 <http://trac.webkit.org/changeset/74895>. >diff --git a/WebKit/chromium/public/WebWidget.h b/WebKit/chromium/public/WebWidget.h >index d01027065c9e90c14756e7787ca266df67eaec3b..0da426d77a8052a6da6b70153539c6711ac47685 100644 >--- a/WebKit/chromium/public/WebWidget.h >+++ b/WebKit/chromium/public/WebWidget.h >@@ -56,6 +56,8 @@ public: > // Called to resize the WebWidget. > virtual void resize(const WebSize&) = 0; > >+ virtual void animate() = 0; >+ > // Called to layout the WebWidget. This MUST be called before Paint, > // and it may result in calls to WebWidgetClient::didInvalidateRect. > virtual void layout() = 0; >diff --git a/WebKit/chromium/public/WebWidgetClient.h b/WebKit/chromium/public/WebWidgetClient.h >index 373426df4f68c713913f9e728ce9900de663c7ac..eab93a9e039e633efa099f68ade70190fe546a16 100644 >--- a/WebKit/chromium/public/WebWidgetClient.h >+++ b/WebKit/chromium/public/WebWidgetClient.h >@@ -56,6 +56,8 @@ public: > // Called when a call to WebWidget::composite is required > virtual void scheduleComposite() { } > >+ virtual void scheduleAnimation() { } >+ > // Called when the widget acquires or loses focus, respectively. > virtual void didFocus() { } > virtual void didBlur() { } >diff --git a/WebKit/chromium/src/ChromeClientImpl.cpp b/WebKit/chromium/src/ChromeClientImpl.cpp >index 28d78d0c8aa62b92338c98642bd90af9fb57b36d..4ab38c72cf3b98ea4e193dab159862d0dae16207 100644 >--- a/WebKit/chromium/src/ChromeClientImpl.cpp >+++ b/WebKit/chromium/src/ChromeClientImpl.cpp >@@ -538,6 +538,11 @@ void ChromeClientImpl::invalidateContentsForSlowScroll(const IntRect& updateRect > invalidateContentsAndWindow(updateRect, immediate); > } > >+void ChromeClientImpl::scheduleAnimation() >+{ >+ m_webView->client()->scheduleAnimation(); >+} >+ > void ChromeClientImpl::scroll( > const IntSize& scrollDelta, const IntRect& scrollRect, > const IntRect& clipRect) >diff --git a/WebKit/chromium/src/ChromeClientImpl.h b/WebKit/chromium/src/ChromeClientImpl.h >index b024bc01ecc9024bcdcb5051288a32b37222041e..3eb8ad85907d54ba666fb7bcd04cf3c16e49bd0d 100644 >--- a/WebKit/chromium/src/ChromeClientImpl.h >+++ b/WebKit/chromium/src/ChromeClientImpl.h >@@ -105,6 +105,7 @@ public: > virtual void invalidateWindow(const WebCore::IntRect&, bool); > virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool); > virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool); >+ virtual void scheduleAnimation(); > virtual void scroll( > const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, > const WebCore::IntRect& clipRect); >diff --git a/WebKit/chromium/src/WebPopupMenuImpl.cpp b/WebKit/chromium/src/WebPopupMenuImpl.cpp >index 085a1575e54bf0e7a4ac8e5878a038605892e5d9..4a7346260bea6064dd95e5ab7dd7b9db5c5a8aba 100644 >--- a/WebKit/chromium/src/WebPopupMenuImpl.cpp >+++ b/WebKit/chromium/src/WebPopupMenuImpl.cpp >@@ -151,6 +151,10 @@ void WebPopupMenuImpl::resize(const WebSize& newSize) > } > } > >+void WebPopupMenuImpl::animate() >+{ >+} >+ > void WebPopupMenuImpl::layout() > { > } >@@ -294,6 +298,10 @@ void WebPopupMenuImpl::invalidateContentsForSlowScroll(const IntRect& updateRect > invalidateContentsAndWindow(updateRect, immediate); > } > >+void WebPopupMenuImpl::scheduleAnimation() >+{ >+} >+ > void WebPopupMenuImpl::scroll(const IntSize& scrollDelta, > const IntRect& scrollRect, > const IntRect& clipRect) >diff --git a/WebKit/chromium/src/WebPopupMenuImpl.h b/WebKit/chromium/src/WebPopupMenuImpl.h >index 221ba038f2c4c736d677fabfa322e051f904264c..59cda8fc2a024c46c72644188790ba932b84a9c0 100644 >--- a/WebKit/chromium/src/WebPopupMenuImpl.h >+++ b/WebKit/chromium/src/WebPopupMenuImpl.h >@@ -61,6 +61,7 @@ public: > virtual void close(); > virtual WebSize size() { return m_size; } > virtual void resize(const WebSize&); >+ virtual void animate(); > virtual void layout(); > virtual void paint(WebCanvas* canvas, const WebRect& rect); > virtual void themeChanged(); >@@ -104,6 +105,7 @@ public: > virtual void invalidateWindow(const WebCore::IntRect&, bool); > virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool); > virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool); >+ virtual void scheduleAnimation(); > virtual void scroll( > const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect, > const WebCore::IntRect& clipRect); >diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp >index d77a5b3f62f3f97e6435f9c14509ed0b499a1e67..a42c109c12f165b770bff0773e8441ec7b375f8c 100644 >--- a/WebKit/chromium/src/WebViewImpl.cpp >+++ b/WebKit/chromium/src/WebViewImpl.cpp >@@ -977,6 +977,16 @@ void WebViewImpl::resize(const WebSize& newSize) > #endif > } > >+void WebViewImpl::animate() >+{ >+ WebFrameImpl* webframe = mainFrameImpl(); >+ if (webframe) { >+ FrameView* view = webframe->frameView(); >+ if (view) >+ view->requestAnimationFrames(); >+ } >+} >+ > void WebViewImpl::layout() > { > WebFrameImpl* webframe = mainFrameImpl(); >diff --git a/WebKit/chromium/src/WebViewImpl.h b/WebKit/chromium/src/WebViewImpl.h >index 80abf813eebf962165e20e9952bdd69cac02f1da..44b7abfe1a612819014d56f2513effc8ec190172 100644 >--- a/WebKit/chromium/src/WebViewImpl.h >+++ b/WebKit/chromium/src/WebViewImpl.h >@@ -92,6 +92,7 @@ public: > virtual void close(); > virtual WebSize size() { return m_size; } > virtual void resize(const WebSize&); >+ virtual void animate(); > virtual void layout(); > virtual void paint(WebCanvas*, const WebRect&); > virtual void themeChanged();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 51218
:
77944
|
78468
|
78604