diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index af37e6185c4a4ec06305d8a8f0cba6eb9fdc8ee7..0ad6f0c64b8732a8aaba43e0a94b1d1fa582b013 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,16 @@ +2011-01-06 James Robinson + + Reviewed by Simon Fraser. + + Implement mozilla's animationTime property + https://bugs.webkit.org/show_bug.cgi?id=51952 + + Tests for window.webkitAnimationTime. + + * animations/animation-time-expected.txt: Added. + * animations/animation-time.html: Added. + * animations/script-tests/animation-time.js: Added. + 2011-01-06 Abhishek Arya Reviewed by Simon Fraser. diff --git a/LayoutTests/animations/animation-time-expected.txt b/LayoutTests/animations/animation-time-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..86c2353d0c87604b3b2ca3d21d0e67f78058c186 --- /dev/null +++ b/LayoutTests/animations/animation-time-expected.txt @@ -0,0 +1,12 @@ +Tests that window.webkitAnimationTime remains the same during a script run and that all animations started within a script run are synchronized + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS startAnimationTime is defined. +PASS startAnimationTime is endAnimationTime +PASS window.getComputedStyle(div1).left is window.getComputedStyle(div2).left +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/animations/animation-time.html b/LayoutTests/animations/animation-time.html new file mode 100644 index 0000000000000000000000000000000000000000..0cf69503e0f19079f2f7b61ab53389c44c26b0ef --- /dev/null +++ b/LayoutTests/animations/animation-time.html @@ -0,0 +1,27 @@ + + + + + + + + +

+
+
+
+ + + + diff --git a/LayoutTests/animations/script-tests/animation-time.js b/LayoutTests/animations/script-tests/animation-time.js new file mode 100644 index 0000000000000000000000000000000000000000..4fcf31243174d16f2a6b0067ab24e45e4bbdee4b --- /dev/null +++ b/LayoutTests/animations/script-tests/animation-time.js @@ -0,0 +1,28 @@ +description("Tests that window.webkitAnimationTime remains the same during a script run and that all animations started within a script run are synchronized"); +window.jsTestIsAsync = true; + +var div1 = document.getElementById("div1"); +var div2 = document.getElementById("div2"); + +div1.classList.add("animated"); +document.body.offsetTop; // Force a style recalc to start the first animation. + +var startAnimationTime = window.webkitAnimationTime; +shouldBeDefined('startAnimationTime'); + +var startTime = Date.now(); +while (Date.now() - startTime < 10) {} + +var endAnimationTime = window.webkitAnimationTime; +// Test that the webkitAnimationTime value hasn't changed out from under us. +shouldBe('startAnimationTime', 'endAnimationTime'); + +// Start a second declarative animation ~10ms after the first one. They should be in sync. +div2.classList.add("animated"); + +window.setTimeout(function() { + shouldBe('window.getComputedStyle(div1).left', 'window.getComputedStyle(div2).left'); + finishJSTest(); +}, 50); + +var successfullyParsed = true; diff --git a/Tools/ChangeLog b/Tools/ChangeLog index 9ec4148adf3e6a14abc97fe6d21530424c08070e..b1c397c3590786a3ac5e598eb807ec31b23b3fa8 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,15 @@ +2011-01-06 James Robinson + + Reviewed by Simon Fraser. + + Implement mozilla's animationTime property + https://bugs.webkit.org/show_bug.cgi?id=51952 + + Chromium DRT support for webkitAnimationTime. + + * DumpRenderTree/chromium/WebViewHost.cpp: + (WebViewHost::paintInvalidatedRegion): + 2011-01-06 Julie Parent Reviewed by Tony Chang. diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.cpp b/Tools/DumpRenderTree/chromium/WebViewHost.cpp index 849312c4b05edb8234fc0c75614ba961d028f10a..bbc32fc5add9f6546a2e74879db287fd9b1c30ba 100644 --- a/Tools/DumpRenderTree/chromium/WebViewHost.cpp +++ b/Tools/DumpRenderTree/chromium/WebViewHost.cpp @@ -1482,6 +1482,7 @@ void WebViewHost::paintInvalidatedRegion() paintRect(rect); } ASSERT(m_paintRect.isEmpty()); + webWidget()->clearCurrentAnimationTime(); } PlatformCanvas* WebViewHost::canvas() diff --git a/WebCore/Android.mk b/WebCore/Android.mk index 20db667314227d63233f9bedd864bee65d4a1b18..530e6a19a5988a3feba097f083c11af00ce617b9 100644 --- a/WebCore/Android.mk +++ b/WebCore/Android.mk @@ -446,6 +446,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ \ page/animation/AnimationBase.cpp \ page/animation/AnimationController.cpp \ + page/animation/AnimationTimeController.cpp \ page/animation/CompositeAnimation.cpp \ page/animation/ImplicitAnimation.cpp \ page/animation/KeyframeAnimation.cpp \ diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt index 0be0bb8bcfee0a2dcc2a5e17acf87759c58134bc..5515f0e8194e288f74654337926f1fa8250508aa 100644 --- a/WebCore/CMakeLists.txt +++ b/WebCore/CMakeLists.txt @@ -1278,6 +1278,7 @@ SET(WebCore_SOURCES page/animation/AnimationBase.cpp page/animation/AnimationController.cpp + page/animation/AnimationTimeController.cpp page/animation/CompositeAnimation.cpp page/animation/ImplicitAnimation.cpp page/animation/KeyframeAnimation.cpp diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 7658e56ccef554ffd15b006630221d855cd3efa7..d96839df1fea0ff658badecf4e7edc88e7d71276 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,48 @@ +2011-01-06 James Robinson + + Reviewed by Simon Fraser. + + Implement mozilla's animationTime property + https://bugs.webkit.org/show_bug.cgi?id=51952 + + Implements mozilla's animationTime property as described here: + https://developer.mozilla.org/en/DOM/window.mozAnimationStartTime + and http://hacks.mozilla.org/2010/08/more-efficient-javascript-animations-with-mozrequestanimationframe/ + The property is called webkitAnimationTime as calling it the 'Start' time is not very informative. + This property exposes a notion of a 'current' time to use for declarative animations and allows + scripts to synchronize imperative animations with declarative ones if they choose to. Once queried + this time is saved and used for all declarative animation updates until the embedder paints/composites + the next frame and clears it, or 15ms elapse (in case the embedder isn't producing frames, for example + if the page is in a background tab). + + This patch also ensures that all declarative animations started in the same script execution block + are synchronized even if some time elapses while script is running. + + Test: fast/animation/animation-time.html + + * WebCore.gypi: + * page/DOMWindow.cpp: + (WebCore::DOMWindow::webkitAnimationTime): + * page/DOMWindow.h: + * page/DOMWindow.idl: + * page/Frame.cpp: + (WebCore::Frame::currentAnimationTime): + * page/Frame.h: + * page/Page.cpp: + (WebCore::Page::Page): + * page/Page.h: + (WebCore::Page::animationTime): + * page/animation/AnimationController.cpp: + (WebCore::AnimationControllerPrivate::beginAnimationUpdateTime): + * page/animation/AnimationTimeController.cpp: Added. + (WebCore::AnimationTimeController::AnimationTimeController): + (WebCore::AnimationTimeController::~AnimationTimeController): + (WebCore::AnimationTimeController::currentAnimationTime): + (WebCore::AnimationTimeController::clearCurrentAnimationTime): + (WebCore::AnimationTimeController::clearCurrentAnimationTimeTimerFired): + * page/animation/AnimationTimeController.h: Added. + (WebCore::AnimationTimeController::create): + 2011-01-06 Abhishek Arya Reviewed by Simon Fraser. diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am index f01088eb2b0ef559213fe3bdc70a23c5c240862d..06d7fc58469c431ad097ed7713ba0b55b6d451f0 100644 --- a/WebCore/GNUmakefile.am +++ b/WebCore/GNUmakefile.am @@ -2143,6 +2143,8 @@ webcore_sources += \ WebCore/page/animation/AnimationController.cpp \ WebCore/page/animation/AnimationController.h \ WebCore/page/animation/AnimationControllerPrivate.h \ + WebCore/page/animation/AnimationTimeController.cpp \ + WebCore/page/animation/AnimationTimeController.h \ WebCore/page/animation/CompositeAnimation.cpp \ WebCore/page/animation/CompositeAnimation.h \ WebCore/page/animation/ImplicitAnimation.cpp \ diff --git a/WebCore/WebCore.exp.in b/WebCore/WebCore.exp.in index e4462f36a51ed3afb98939c0dee0ccf3fd84b14d..aac7ddeea7b6291b7ef558a2d24695343a081543 100644 --- a/WebCore/WebCore.exp.in +++ b/WebCore/WebCore.exp.in @@ -519,6 +519,7 @@ __ZN7WebCore22contextMenuItemTagBoldEv __ZN7WebCore22counterValueForElementEPNS_7ElementE __ZN7WebCore22createFragmentFromTextEPNS_5RangeERKN3WTF6StringE __ZN7WebCore22externalRepresentationEPNS_5FrameEj +__ZN7WebCore23AnimationTimeController25clearCurrentAnimationTimeEv __ZN7WebCore23AuthenticationChallengeC1ERKNS_15ProtectionSpaceERKNS_10CredentialEjRKNS_16ResourceResponseERKNS_13ResourceErrorE __ZN7WebCore23ReplaceSelectionCommandC1EPNS_8DocumentEN3WTF10PassRefPtrINS_16DocumentFragmentEEEbbbbbNS_10EditActionE __ZN7WebCore23createFragmentFromNodesEPNS_8DocumentERKN3WTF6VectorIPNS_4NodeELm0EEE diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi index 6a519fb515c9f7c8e199bc881110f50caa240e79..14f39d668dacda6ad3b8e48c6cb0d44a93ed26dd 100644 --- a/WebCore/WebCore.gypi +++ b/WebCore/WebCore.gypi @@ -2220,6 +2220,8 @@ 'page/animation/AnimationController.cpp', 'page/animation/AnimationController.h', 'page/animation/AnimationControllerPrivate.h', + 'page/animation/AnimationTimeController.cpp', + 'page/animation/AnimationTimeController.h', 'page/animation/CompositeAnimation.cpp', 'page/animation/CompositeAnimation.h', 'page/animation/ImplicitAnimation.cpp', diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro index 96298e3b06ffb3c69dbfe45babb86dfdb2f2f9c2..68723bb7a8304548e68bf30d50989977b1a25e29 100644 --- a/WebCore/WebCore.pro +++ b/WebCore/WebCore.pro @@ -1113,6 +1113,7 @@ SOURCES += \ notifications/NotificationCenter.cpp \ page/animation/AnimationBase.cpp \ page/animation/AnimationController.cpp \ + page/animation/AnimationTimeController.cpp \ page/animation/CompositeAnimation.cpp \ page/animation/ImplicitAnimation.cpp \ page/animation/KeyframeAnimation.cpp \ diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj index e808cb99eaba7ad40a55b0e00f5a882118560ea6..a7ac6928d928fac8789a7dea2eb4a0a625146a04 100755 --- a/WebCore/WebCore.vcproj/WebCore.vcproj +++ b/WebCore/WebCore.vcproj/WebCore.vcproj @@ -24241,6 +24241,14 @@ RelativePath="..\page\animation\AnimationControllerPrivate.h" > + + + + diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj index 41c2532f04f0a8be2df2664e1ff3a978fbfcb839..0c53e09036d21e897f7dcec7bc408c910126967f 100644 --- a/WebCore/WebCore.xcodeproj/project.pbxproj +++ b/WebCore/WebCore.xcodeproj/project.pbxproj @@ -910,6 +910,8 @@ 37FD4298118368460093C029 /* TreeDepthLimit.h in Headers */ = {isa = PBXBuildFile; fileRef = 37FD4297118368460093C029 /* TreeDepthLimit.h */; }; 3888F6EE128C9889000CA8E0 /* InspectorFileSystemAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3888F6EC128C9889000CA8E0 /* InspectorFileSystemAgent.cpp */; }; 3888F6EF128C9889000CA8E0 /* InspectorFileSystemAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 3888F6ED128C9889000CA8E0 /* InspectorFileSystemAgent.h */; }; + 38DF1B3512D5284200F0477E /* AnimationTimeController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 38DF1B3312D5284200F0477E /* AnimationTimeController.cpp */; }; + 38DF1B3612D5284200F0477E /* AnimationTimeController.h in Headers */ = {isa = PBXBuildFile; fileRef = 38DF1B3412D5284200F0477E /* AnimationTimeController.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3AC648B2129E146500C3EB25 /* EditingBoundary.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AC648B1129E146500C3EB25 /* EditingBoundary.h */; settings = {ATTRIBUTES = (Private, ); }; }; 41002CCD0F66EDEF009E660D /* ScriptFunctionCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 41002CCB0F66EDEF009E660D /* ScriptFunctionCall.h */; }; 41002CCE0F66EDEF009E660D /* ScriptFunctionCall.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41002CCC0F66EDEF009E660D /* ScriptFunctionCall.cpp */; }; @@ -7228,6 +7230,8 @@ 37FD4297118368460093C029 /* TreeDepthLimit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TreeDepthLimit.h; sourceTree = ""; }; 3888F6EC128C9889000CA8E0 /* InspectorFileSystemAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorFileSystemAgent.cpp; sourceTree = ""; }; 3888F6ED128C9889000CA8E0 /* InspectorFileSystemAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorFileSystemAgent.h; sourceTree = ""; }; + 38DF1B3312D5284200F0477E /* AnimationTimeController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AnimationTimeController.cpp; path = animation/AnimationTimeController.cpp; sourceTree = ""; }; + 38DF1B3412D5284200F0477E /* AnimationTimeController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AnimationTimeController.h; path = animation/AnimationTimeController.h; sourceTree = ""; }; 3AC648B1129E146500C3EB25 /* EditingBoundary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditingBoundary.h; sourceTree = ""; }; 41002CCB0F66EDEF009E660D /* ScriptFunctionCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptFunctionCall.h; sourceTree = ""; }; 41002CCC0F66EDEF009E660D /* ScriptFunctionCall.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptFunctionCall.cpp; sourceTree = ""; }; @@ -13023,6 +13027,8 @@ 316FE1090E6E1DA700BF6088 /* AnimationController.cpp */, 316FE10A0E6E1DA700BF6088 /* AnimationController.h */, 0F15DA890F3AAEE70000CE47 /* AnimationControllerPrivate.h */, + 38DF1B3312D5284200F0477E /* AnimationTimeController.cpp */, + 38DF1B3412D5284200F0477E /* AnimationTimeController.h */, 316FE10B0E6E1DA700BF6088 /* CompositeAnimation.cpp */, 316FE10C0E6E1DA700BF6088 /* CompositeAnimation.h */, 316FE10D0E6E1DA700BF6088 /* ImplicitAnimation.cpp */, @@ -19310,6 +19316,7 @@ 316FE1120E6E1DA700BF6088 /* AnimationBase.h in Headers */, 316FE1140E6E1DA700BF6088 /* AnimationController.h in Headers */, 0F15DA8A0F3AAEE70000CE47 /* AnimationControllerPrivate.h in Headers */, + 38DF1B3612D5284200F0477E /* AnimationTimeController.h in Headers */, 49E912AD0EFAC906009D0CAF /* AnimationList.h in Headers */, 93309DD7099E64920056E581 /* AppendNodeCommand.h in Headers */, 1A8F6BBD0DB55CDC001DB794 /* ApplicationCache.h in Headers */, @@ -22595,6 +22602,7 @@ 49E912AA0EFAC906009D0CAF /* Animation.cpp in Sources */, 316FE1110E6E1DA700BF6088 /* AnimationBase.cpp in Sources */, 316FE1130E6E1DA700BF6088 /* AnimationController.cpp in Sources */, + 38DF1B3512D5284200F0477E /* AnimationTimeController.cpp in Sources */, 49E912AC0EFAC906009D0CAF /* AnimationList.cpp in Sources */, 93309DD6099E64920056E581 /* AppendNodeCommand.cpp in Sources */, 1A8F6BBC0DB55CDC001DB794 /* ApplicationCache.cpp in Sources */, diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp index 3497f131770a5edbd2fcb076aa60a733653f5b9b..0ab89124e0eeef736c7cf4ef8501c527bd1451db 100644 --- a/WebCore/page/DOMWindow.cpp +++ b/WebCore/page/DOMWindow.cpp @@ -1464,6 +1464,13 @@ void DOMWindow::clearInterval(int timeoutId) DOMTimer::removeById(context, timeoutId); } +DOMTimeStamp DOMWindow::webkitAnimationTime() +{ + if (Frame* f = frame()) + return convertSecondsToDOMTimeStamp(f->currentAnimationTime()); + return convertSecondsToDOMTimeStamp(currentTime()); +} + bool DOMWindow::addEventListener(const AtomicString& eventType, PassRefPtr listener, bool useCapture) { if (!EventTarget::addEventListener(eventType, listener, useCapture)) diff --git a/WebCore/page/DOMWindow.h b/WebCore/page/DOMWindow.h index 1c84f3caad8551f879e898fc455161d225db8862..4f68ed33cbc68190be5732f908a5404cd556e821 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" @@ -237,6 +238,9 @@ namespace WebCore { int setInterval(PassOwnPtr, int timeout, ExceptionCode&); void clearInterval(int timeoutId); + // WebKit animation extensions + DOMTimeStamp webkitAnimationTime(); + // Events // EventTarget API virtual bool addEventListener(const AtomicString& eventType, PassRefPtr, bool useCapture); diff --git a/WebCore/page/DOMWindow.idl b/WebCore/page/DOMWindow.idl index f3aa7ba5bd90f261e8e5ebc48e4ab915c0d967ac..3718108ead373f8c47c048cf24aac43dabd60d51 100644 --- a/WebCore/page/DOMWindow.idl +++ b/WebCore/page/DOMWindow.idl @@ -236,6 +236,9 @@ module window { // [Custom] long setInterval(in DOMString code, in long timeout); void clearInterval(in long handle); + // WebKit animation extensions + readonly attribute DOMTimeStamp webkitAnimationTime; + // Base64 DOMString atob(in [ConvertNullToNullString] DOMString string) raises(DOMException); diff --git a/WebCore/page/Frame.cpp b/WebCore/page/Frame.cpp index 85523c64ce1e5ad2a3bd5ffd2c41a480a42f8449..5c5ad3700a7837940438dcfeee0290567d947965 100644 --- a/WebCore/page/Frame.cpp +++ b/WebCore/page/Frame.cpp @@ -29,6 +29,7 @@ #include "config.h" #include "Frame.h" +#include "AnimationTimeController.h" #include "ApplyStyleCommand.h" #include "CSSComputedStyleDeclaration.h" #include "CSSMutableStyleDeclaration.h" @@ -83,6 +84,7 @@ #include "markup.h" #include "npruntime_impl.h" #include "visible_units.h" +#include #include #include @@ -752,6 +754,14 @@ void Frame::transferChildFrameToNewDocument() } } +double Frame::currentAnimationTime() +{ + if (Page* p = page()) + return p->animationTime()->currentAnimationTime(); + return currentTime(); +} + + String Frame::documentTypeString() const { if (DocumentType* doctype = document()->doctype()) diff --git a/WebCore/page/Frame.h b/WebCore/page/Frame.h index 1cdfa8188187601b8081270fef014b67a62e9b6e..892a5ea7a8b3d15eaf1bc6d7bb9e64314648d026 100644 --- a/WebCore/page/Frame.h +++ b/WebCore/page/Frame.h @@ -107,6 +107,8 @@ namespace WebCore { void transferChildFrameToNewDocument(); + double currentAnimationTime(); + // ======== All public functions below this point are candidates to move out of Frame into another class. ======== bool isDisconnected() const; diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp index a78cfb752e404beffa5032e0f7c64363de328981..b2c02415a17e7db59e121b9d0abba9af4cf54340 100644 --- a/WebCore/page/Page.cpp +++ b/WebCore/page/Page.cpp @@ -20,6 +20,7 @@ #include "config.h" #include "Page.h" +#include "AnimationTimeController.h" #include "BackForwardController.h" #include "BackForwardList.h" #include "Base64.h" @@ -156,6 +157,7 @@ Page::Page(const PageClients& pageClients) , m_settings(adoptPtr(new Settings(this))) , m_progress(adoptPtr(new ProgressTracker)) , m_backForwardController(adoptPtr(new BackForwardController(this, pageClients.backForwardClient))) + , m_animationTimeController(AnimationTimeController::create()) , m_theme(RenderTheme::themeForPage(this)) , m_editorClient(pageClients.editorClient) , m_frameCount(0) diff --git a/WebCore/page/Page.h b/WebCore/page/Page.h index 7413bb699df1f70dea545f55a8f79bf9a1c560b9..2a057c3841733b792f50477db92ab7d14050bc01 100644 --- a/WebCore/page/Page.h +++ b/WebCore/page/Page.h @@ -39,6 +39,7 @@ namespace JSC { namespace WebCore { + class AnimationTimeController; class BackForwardController; class BackForwardList; class Chrome; @@ -182,6 +183,7 @@ namespace WebCore { Settings* settings() const { return m_settings.get(); } ProgressTracker* progress() const { return m_progress.get(); } BackForwardController* backForward() const { return m_backForwardController.get(); } + AnimationTimeController* animationTime() const { return m_animationTimeController.get(); } enum ViewMode { ViewModeInvalid, @@ -327,6 +329,7 @@ namespace WebCore { OwnPtr m_progress; OwnPtr m_backForwardController; + OwnPtr m_animationTimeController; RefPtr m_mainFrame; RefPtr m_globalHistoryItem; @@ -380,6 +383,8 @@ namespace WebCore { NotificationPresenter* m_notificationPresenter; #endif + double m_currentAnimationTime; + ViewMode m_viewMode; ViewportArguments m_viewportArguments; diff --git a/WebCore/page/animation/AnimationController.cpp b/WebCore/page/animation/AnimationController.cpp index e1281dd18a7654c3ee625137a4a5c7873d4dfefa..a4e00637572f0f746a55959d780ed3bff3b034ff 100644 --- a/WebCore/page/animation/AnimationController.cpp +++ b/WebCore/page/animation/AnimationController.cpp @@ -316,7 +316,7 @@ bool AnimationControllerPrivate::pauseTransitionAtTime(RenderObject* renderer, c double AnimationControllerPrivate::beginAnimationUpdateTime() { if (m_beginAnimationUpdateTime == cBeginAnimationUpdateTimeNotSet) - m_beginAnimationUpdateTime = currentTime(); + m_beginAnimationUpdateTime = m_frame->currentAnimationTime(); return m_beginAnimationUpdateTime; } diff --git a/WebCore/page/animation/AnimationTimeController.cpp b/WebCore/page/animation/AnimationTimeController.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a0f2b334953a57403c2757cce90fa9a3a2b501cd --- /dev/null +++ b/WebCore/page/animation/AnimationTimeController.cpp @@ -0,0 +1,68 @@ +/* + * 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#include "config.h" + +#include "AnimationTimeController.h" + +#include + +static const double cCurrentAnimationTimeNotSet = -1; + +namespace WebCore { + +AnimationTimeController::AnimationTimeController() + : m_currentAnimationTime(cCurrentAnimationTimeNotSet) + , m_clearCurrentAnimationTimeTimer(this, &AnimationTimeController::clearCurrentAnimationTimeTimerFired) +{ +} + +AnimationTimeController::~AnimationTimeController() +{ +} + +double AnimationTimeController::currentAnimationTime() +{ + if (m_currentAnimationTime == cCurrentAnimationTimeNotSet) { + m_currentAnimationTime = currentTime(); + // Clear out the animation time after 15ms if it hasn't been already. + m_clearCurrentAnimationTimeTimer.startOneShot(0.015); + } + return m_currentAnimationTime; +} + +void AnimationTimeController::clearCurrentAnimationTime() +{ + m_currentAnimationTime = cCurrentAnimationTimeNotSet; + if (m_clearCurrentAnimationTimeTimer.isActive()) + m_clearCurrentAnimationTimeTimer.stop(); +} + +void AnimationTimeController::clearCurrentAnimationTimeTimerFired(Timer*) +{ + clearCurrentAnimationTime(); +} + +} diff --git a/WebCore/page/animation/AnimationTimeController.h b/WebCore/page/animation/AnimationTimeController.h new file mode 100644 index 0000000000000000000000000000000000000000..647fff20519f911bbda014ea973aee420f3eff99 --- /dev/null +++ b/WebCore/page/animation/AnimationTimeController.h @@ -0,0 +1,56 @@ +/* + * 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 AnimationTimeController_h +#define AnimationTimeController_h + +#include "Timer.h" +#include + +namespace WebCore { + +class AnimationTimeController : public Noncopyable { +public: + static PassOwnPtr create() + { + return adoptPtr(new AnimationTimeController); + } + ~AnimationTimeController(); + + double currentAnimationTime(); + void clearCurrentAnimationTime(); + +private: + AnimationTimeController(); + + void clearCurrentAnimationTimeTimerFired(Timer*); + + double m_currentAnimationTime; + Timer m_clearCurrentAnimationTimeTimer; +}; + +} + +#endif // AnimationTimeController_h diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog index 69a307038e6b677fffed68e8963031c123528a6b..7d512b0429808a52a7069c19b42d68d73e0963da 100644 --- a/WebKit/chromium/ChangeLog +++ b/WebKit/chromium/ChangeLog @@ -1,3 +1,20 @@ +2011-01-06 James Robinson + + Reviewed by Simon Fraser. + + Implement mozilla's animationTime property + https://bugs.webkit.org/show_bug.cgi?id=51952 + + WebKit API support for webkitAnimationTime. + + * public/WebWidget.h: + * src/WebPopupMenuImpl.cpp: + (WebKit::WebPopupMenuImpl::clearCurrentAnimationTime): + * src/WebPopupMenuImpl.h: + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::clearCurrentAnimationTime): + * src/WebViewImpl.h: + 2010-12-29 John Abd-El-Malek Reviewed by Darin Fisher. diff --git a/WebKit/chromium/public/WebWidget.h b/WebKit/chromium/public/WebWidget.h index ccad134f634e84f3fc0b9c644e660fc680f3ef12..676d303ef5af83e69f7a446d2f079bd0fadf65f5 100644 --- a/WebKit/chromium/public/WebWidget.h +++ b/WebKit/chromium/public/WebWidget.h @@ -56,6 +56,10 @@ public: // Called to resize the WebWidget. virtual void resize(const WebSize&) = 0; + // Called to indicate that this widget has been rendered and the widget + // no longer needs to store the animation time. + virtual void clearCurrentAnimationTime() = 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/src/WebPopupMenuImpl.cpp b/WebKit/chromium/src/WebPopupMenuImpl.cpp index 63ebed809befb04e80f643136fbd31d7e8c69271..d25b0f1707ffafa4fd60be33cfd74c18dd25faf3 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::clearCurrentAnimationTime() +{ +} + void WebPopupMenuImpl::layout() { } diff --git a/WebKit/chromium/src/WebPopupMenuImpl.h b/WebKit/chromium/src/WebPopupMenuImpl.h index b8ef7ba8e4b99fee904b8fb6793d6e6629e2ab49..281710116d6fd42069c6f1f0a727a7e577608333 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 clearCurrentAnimationTime(); virtual void layout(); virtual void paint(WebCanvas* canvas, const WebRect& rect); virtual void themeChanged(); diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp index e47c89e8a042ca2ef399ada40637518fb95aeb45..54e72b309155f5259f01dc77c68b0553bf142763 100644 --- a/WebKit/chromium/src/WebViewImpl.cpp +++ b/WebKit/chromium/src/WebViewImpl.cpp @@ -31,6 +31,7 @@ #include "config.h" #include "WebViewImpl.h" +#include "AnimationTimeController.h" #include "AutoFillPopupMenuClient.h" #include "AXObjectCache.h" #include "BackForwardListImpl.h" @@ -977,6 +978,13 @@ void WebViewImpl::resize(const WebSize& newSize) #endif } +void WebViewImpl::clearCurrentAnimationTime() +{ + WebFrameImpl* webframe = mainFrameImpl(); + if (webframe) + webframe->frame()->page()->animationTime()->clearCurrentAnimationTime(); +} + void WebViewImpl::layout() { WebFrameImpl* webframe = mainFrameImpl(); diff --git a/WebKit/chromium/src/WebViewImpl.h b/WebKit/chromium/src/WebViewImpl.h index cc25c8467193734d1c8a68bf39d255c50e9d5609..f5b5df31474137bcf4129073d815ff32fcf6bc2c 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 clearCurrentAnimationTime(); virtual void layout(); virtual void paint(WebCanvas*, const WebRect&); virtual void themeChanged(); diff --git a/WebKit/mac/WebView/WebHTMLView.mm b/WebKit/mac/WebView/WebHTMLView.mm index 093f3db50410754048a488919c06b6b7c81240f7..8083fce7c5be2108523c5df6f300585385d654ef 100644 --- a/WebKit/mac/WebView/WebHTMLView.mm +++ b/WebKit/mac/WebView/WebHTMLView.mm @@ -75,6 +75,7 @@ #import "WebViewInternal.h" #import #import +#import #import #import #import @@ -3505,6 +3506,10 @@ static void setMenuTargets(NSMenu* menu) } #endif + Frame* frame = [webView _mainCoreFrame]; + if (frame && frame->page()) + frame->page()->animationTime()->clearCurrentAnimationTime(); + if (webView) CallUIDelegate(webView, @selector(webView:didDrawFrame:), [self _frame]); } diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm index 96ea7d0d46645eaa3cd305c4a79d47cc05d2fcba..1d368e4eaf821ed9789d99a195bcd9211f8bae95 100644 --- a/WebKit/mac/WebView/WebView.mm +++ b/WebKit/mac/WebView/WebView.mm @@ -110,6 +110,7 @@ #import #import #import +#import #import #import #import @@ -5957,6 +5958,10 @@ static void layerSyncRunLoopObserverCallBack(CFRunLoopObserverRef, CFRunLoopActi // so that the layers draw with up-to-date layout. [webView _viewWillDrawInternal]; } + + Frame* frame = [webView _mainCoreFrame]; + if (frame && frame->page()) + frame->page()->animationTime()->clearCurrentAnimationTime(); } - (void)_scheduleCompositingLayerSync diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog index 65c021202f0a104df61be4a62b430f258427cadf..7268236324b8ec50207ef509a2eeeb29ada63513 100644 --- a/WebKit2/ChangeLog +++ b/WebKit2/ChangeLog @@ -1,3 +1,20 @@ +2011-01-06 James Robinson + + Reviewed by Simon Fraser. + + Implement mozilla's animationTime property + https://bugs.webkit.org/show_bug.cgi?id=51952 + + Tells the page to clear the current animation time after producing a frame. + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::drawRect): + * WebProcess/WebPage/ChunkedUpdateDrawingArea.cpp: + (WebKit::ChunkedUpdateDrawingArea::display): + (WebKit::ChunkedUpdateDrawingArea::setSize): + * WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm: + (WebKit::LayerBackedDrawingArea::syncCompositingLayers): + 2011-01-06 Darin Adler Redo the half-done rename from the last check-in. diff --git a/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.cpp b/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.cpp index 1cce5d01011415b752d87fb7141b3dc82495a483..53a1f252087132adfcbf20ee674dcf29692f37d0 100644 --- a/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.cpp +++ b/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.cpp @@ -32,6 +32,8 @@ #include "WebCoreArgumentCoders.h" #include "WebPage.h" #include "WebProcess.h" +#include +#include using namespace WebCore; @@ -90,6 +92,8 @@ void ChunkedUpdateDrawingArea::display() paintIntoUpdateChunk(&updateChunk); WebProcess::shared().connection()->send(DrawingAreaProxyLegacyMessage::Update, m_webPage->pageID(), CoreIPC::In(updateChunk)); + + m_webPage->corePage()->animationTime()->clearCurrentAnimationTime(); m_isWaitingForUpdate = true; m_displayTimer.stop(); @@ -143,6 +147,7 @@ void ChunkedUpdateDrawingArea::setSize(const IntSize& viewSize) m_displayTimer.stop(); WebProcess::shared().connection()->send(DrawingAreaProxyLegacyMessage::DidSetSize, m_webPage->pageID(), CoreIPC::In(updateChunk)); + m_webPage->corePage()->animationTime()->clearCurrentAnimationTime(); } void ChunkedUpdateDrawingArea::suspendPainting() diff --git a/WebKit2/WebProcess/WebPage/WebPage.cpp b/WebKit2/WebProcess/WebPage/WebPage.cpp index c9cebcf305ebe8035436cf1d230d1321117bf6d2..29a708d7d5b6a22c449d431fc28172d823261c90 100644 --- a/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -59,6 +59,7 @@ #include "WebProcessProxyMessageKinds.h" #include "WebProcessProxyMessages.h" #include +#include #include #include #include @@ -515,6 +516,8 @@ void WebPage::drawRect(GraphicsContext& graphicsContext, const IntRect& rect) m_pageOverlay->drawRect(graphicsContext, rect); graphicsContext.restore(); } + + m_page->animationTime()->clearCurrentAnimationTime(); } double WebPage::textZoomFactor() const diff --git a/WebKit2/WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm b/WebKit2/WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm index f8b7e71b23fb3e6f360d9b67af4505382c5d38a1..e30a69a970cdeccea54a2480b9e9a901cefc0800 100644 --- a/WebKit2/WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm +++ b/WebKit2/WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm @@ -31,6 +31,7 @@ #include "WebKitSystemInterface.h" #include "WebPage.h" #include "WebProcess.h" +#include #include #include #include @@ -121,6 +122,8 @@ void LayerBackedDrawingArea::syncCompositingLayers() if (!didSync) { } + + m_webPage->corePage()->animationTime()->clearCurrentAnimationTime(); } void LayerBackedDrawingArea::setUpUpdateLayoutRunLoopObserver()