2010-07-11 Maciej Stachowiak <mjs@apple.com>
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Jul 2010 07:57:13 +0000 (07:57 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Jul 2010 07:57:13 +0000 (07:57 +0000)
        Reviewed by Dan Bernstein.

        Implement animation-related methods for WebKitTestRunner
        https://bugs.webkit.org/show_bug.cgi?id=42053

        * WebCore.exp.in: Export Document::getElementById for WebKit2's benefit.
2010-07-11  Maciej Stachowiak  <mjs@apple.com>

        Reviewed by Dan Bernstein.

        Implement animation-related methods for WebKitTestRunner
        https://bugs.webkit.org/show_bug.cgi?id=42053

        Implemented numberOfActiveAnimatiosn and pauseAnimationAtTimeOnElementWithId. Many
        animation tests were hanging otherwise.

        * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
        (WTR::LayoutTestController::numberOfActiveAnimations):
        (WTR::LayoutTestController::pauseAnimationAtTimeOnElementWithId):
        (WTR::numberOfActiveAnimationsCallback):
        (WTR::pauseAnimationAtTimeOnElementWithIdCallback):
        (WTR::LayoutTestController::staticFunctions):
        * WebKitTestRunner/InjectedBundle/LayoutTestController.h:
2010-07-11  Maciej Stachowiak  <mjs@apple.com>

        Reviewed by Dan Bernstein.

        Implement animation-related methods for WebKitTestRunner
        https://bugs.webkit.org/show_bug.cgi?id=42053

        Implemented some helpers for WebKitTestRunner;

        * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
        (WKBundleFrameGetNumberOfActiveAnimations):
        (WKBundleFramePauseAnimationOnElementWithId):
        * WebProcess/InjectedBundle/API/c/WKBundleFrame.h:
        * WebProcess/WebPage/WebFrame.cpp:
        (WebKit::WebFrame::numberOfActiveAnimations):
        (WebKit::WebFrame::pauseAnimationOnElementWithId):
        * WebProcess/WebPage/WebFrame.h:
        * mac/WebKit2.exp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63063 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/WebCore.exp.in
WebKit2/ChangeLog
WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h
WebKit2/WebProcess/WebPage/WebFrame.cpp
WebKit2/WebProcess/WebPage/WebFrame.h
WebKit2/mac/WebKit2.exp
WebKitTools/ChangeLog
WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h

index 17a9ae926549c0de93fd2e5cbdf7a1d2a640a822..c5e8ddfd53eea6810adcd6750bac15d71739f393 100644 (file)
@@ -1,3 +1,12 @@
+2010-07-11  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Implement animation-related methods for WebKitTestRunner
+        https://bugs.webkit.org/show_bug.cgi?id=42053
+
+        * WebCore.exp.in: Export Document::getElementById for WebKit2's benefit.
+
 2010-07-11  Adam Barth  <abarth@webkit.org>
 
         Rubber-stamped by Eric Seidel
index 0f11ca6d6eb895a18227867c78d0ef2252a84701..d9cb4222516cb0295a2c40171c4e4d0554f08265 100644 (file)
@@ -959,6 +959,7 @@ __ZNK7WebCore7IntRectcv7_NSRectEv
 __ZNK7WebCore7IntSizecv7_NSSizeEv
 __ZNK7WebCore8Document11completeURLERKNS_6StringE
 __ZNK7WebCore8Document13axObjectCacheEv
+__ZNK7WebCore8Document14getElementByIdERKNS_12AtomicStringE
 __ZNK7WebCore8Document20cacheDocumentElementEv
 __ZNK7WebCore8Document31displayStringModifiedByEncodingERKNS_6StringE
 __ZNK7WebCore8Document4bodyEv
index 8e894777d2f3aecd4c4a5ea5d760c76773b95a0c..489895941af7c2b642c0e6abb86ab7e60dd26be9 100644 (file)
@@ -1,3 +1,22 @@
+2010-07-11  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Implement animation-related methods for WebKitTestRunner
+        https://bugs.webkit.org/show_bug.cgi?id=42053
+
+        Implemented some helpers for WebKitTestRunner;
+        
+        * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
+        (WKBundleFrameGetNumberOfActiveAnimations):
+        (WKBundleFramePauseAnimationOnElementWithId):
+        * WebProcess/InjectedBundle/API/c/WKBundleFrame.h:
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::numberOfActiveAnimations):
+        (WebKit::WebFrame::pauseAnimationOnElementWithId):
+        * WebProcess/WebPage/WebFrame.h:
+        * mac/WebKit2.exp:
+
 2010-07-10  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Sam Weinig.
index fba2d08739f638d9641647f2e91958c624cb6196..1bb75ffad22c45ddd1c0a0bb17c9b72357858bb5 100644 (file)
@@ -53,3 +53,13 @@ WKArrayRef WKBundleFrameCopyChildFrames(WKBundleFrameRef frameRef)
 {
     return toRef(toWK(frameRef)->childFrames().releaseRef());    
 }
+
+unsigned WKBundleFrameGetNumberOfActiveAnimations(WKBundleFrameRef frameRef)
+{
+    return toWK(frameRef)->numberOfActiveAnimations();
+}
+
+bool WKBundleFramePauseAnimationOnElementWithId(WKBundleFrameRef frameRef, WKStringRef name, WKStringRef elementID, double time)
+{
+    return toWK(frameRef)->pauseAnimationOnElementWithId(toWK(name), toWK(elementID), time);
+}
index 4a839ba2dbb41784678f65797616b095c567c76a..32089885c9aba25bbd76b8e001d6968e163f38d0 100644 (file)
@@ -45,6 +45,10 @@ WK_EXPORT WKStringRef WKBundleFrameCopyInnerText(WKBundleFrameRef frame);
 
 WK_EXPORT WKArrayRef WKBundleFrameCopyChildFrames(WKBundleFrameRef frame);
 
+WK_EXPORT unsigned WKBundleFrameGetNumberOfActiveAnimations(WKBundleFrameRef frame);
+
+WK_EXPORT bool WKBundleFramePauseAnimationOnElementWithId(WKBundleFrameRef frame, WKStringRef name, WKStringRef elementID, double time);
+
 #ifdef __cplusplus
 }
 #endif
index 99a2504957696e2e9e97239a22fbea5c13575896..ea1c7bfca35083d353a11ac44781c7fd25bf7a13 100644 (file)
@@ -26,6 +26,7 @@
 #include "WebFrame.h"
 
 #include "WebPage.h"
+#include <WebCore/AnimationController.h>
 #include <WebCore/Frame.h>
 #include <WebCore/HTMLFrameOwnerElement.h>
 #include <WebCore/PlatformString.h>
@@ -211,4 +212,36 @@ PassRefPtr<ImmutableArray> WebFrame::childFrames()
     return ImmutableArray::adopt(array, size, &callbacks);
 }
 
+unsigned WebFrame::numberOfActiveAnimations()
+{
+    if (!m_coreFrame)
+        return 0;
+
+    AnimationController* controller = m_coreFrame->animation();
+    if (!controller)
+        return 0;
+
+    return controller->numberOfActiveAnimations();
+}
+
+bool WebFrame::pauseAnimationOnElementWithId(const String& animationName, const String& elementID, double time)
+{
+    if (!m_coreFrame)
+        return false;
+
+    AnimationController* controller = m_coreFrame->animation();
+    if (!controller)
+        return false;
+
+    if (!m_coreFrame->document())
+        return false;
+
+    Node* coreNode = m_coreFrame->document()->getElementById(elementID);
+    if (!coreNode || !coreNode->renderer())
+        return false;
+
+    return controller->pauseAnimationAtTime(coreNode->renderer(), animationName, time);
+}
+
+
 } // namespace WebKit
index 74e0c35e0ddbaf5e67b29a4f9e70ce7e9b51691a..2ea430b6fe7e913ad7ee3e893f9007f5c96cfc2b 100644 (file)
@@ -69,6 +69,9 @@ public:
     WebCore::String innerText() const;
     PassRefPtr<ImmutableArray> childFrames();
 
+    unsigned numberOfActiveAnimations();
+    bool pauseAnimationOnElementWithId(const WebCore::String& animationName, const WebCore::String& elementID, double time);
+    
 private:
     static PassRefPtr<WebFrame> create(WebPage*, const WebCore::String& frameName, WebCore::HTMLFrameOwnerElement*);
     WebFrame(WebPage*, const WebCore::String& frameName, WebCore::HTMLFrameOwnerElement*);
index 8d07efe8b5ffa31fe32c61d16f09c4c44107fefc..e81e12a5c8cb3e1b66b823e2d6fff9bf3b7d1ff1 100644 (file)
@@ -5,8 +5,10 @@ _WKArrayRelease
 _WKArrayRetain
 _WKBundleFrameCopyChildFrames
 _WKBundleFrameCopyInnerText
+_WKBundleFrameGetNumberOfActiveAnimations
 _WKBundleFrameGetURL
 _WKBundleFrameIsMainFrame
+_WKBundleFramePauseAnimationOnElementWithId
 _WKBundlePageCopyRenderTreeExternalRepresentation
 _WKBundlePageGetMainFrame
 _WKBundlePageSetLoaderClient
index c73c4e54b1911849a55fdf7b478b5bfc69eae8ca..9c02844a4ae8ca9c2e73c369d3c5aa665755396e 100644 (file)
@@ -1,3 +1,21 @@
+2010-07-11  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Implement animation-related methods for WebKitTestRunner
+        https://bugs.webkit.org/show_bug.cgi?id=42053
+        
+        Implemented numberOfActiveAnimatiosn and pauseAnimationAtTimeOnElementWithId. Many
+        animation tests were hanging otherwise.
+
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
+        (WTR::LayoutTestController::numberOfActiveAnimations):
+        (WTR::LayoutTestController::pauseAnimationAtTimeOnElementWithId):
+        (WTR::numberOfActiveAnimationsCallback):
+        (WTR::pauseAnimationAtTimeOnElementWithIdCallback):
+        (WTR::LayoutTestController::staticFunctions):
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.h:
+
 2010-07-11  Daniel Bates  <dbates@rim.com>
 
         Reviewed by David Kilzer.
index 88308a4df09324f852e699e718793151fcb3c429..cf3e0fbd6cacca297016b91a917b19dfcdaab39d 100644 (file)
 #include "InjectedBundlePage.h"
 
 #include <JavaScriptCore/JSRetainPtr.h>
+#include <WebKit2/WKBundleFrame.h>
+#include <WebKit2/WKRetainPtr.h>
+#include <WebKit2/WKStringCF.h>
+#include <WebKit2/WebKit2.h>
 
 namespace WTR {
 
@@ -88,6 +92,23 @@ void LayoutTestController::notifyDone()
     m_waitToDump = false;
 }
 
+unsigned LayoutTestController::numberOfActiveAnimations() const
+{
+    WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
+    return WKBundleFrameGetNumberOfActiveAnimations(mainFrame);
+}
+
+bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId)
+{
+    RetainPtr<CFStringRef> idCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, elementId));
+    WKRetainPtr<WKStringRef> idWK(AdoptWK, WKStringCreateWithCFString(idCF.get()));
+    RetainPtr<CFStringRef> nameCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, animationName));
+    WKRetainPtr<WKStringRef> nameWK(AdoptWK, WKStringCreateWithCFString(nameCF.get()));
+
+    WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
+    return WKBundleFramePauseAnimationOnElementWithId(mainFrame, nameWK.get(), idWK.get(), time);
+}
+
 static JSValueRef dumpAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
@@ -109,6 +130,31 @@ static JSValueRef notifyDoneCallback(JSContextRef context, JSObjectRef function,
     return JSValueMakeUndefined(context);
 }
 
+static JSValueRef numberOfActiveAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount)
+        return JSValueMakeUndefined(context);
+
+    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    return JSValueMakeNumber(context, controller->numberOfActiveAnimations());
+}
+
+static JSValueRef pauseAnimationAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount != 3)
+        return JSValueMakeUndefined(context);
+
+    JSRetainPtr<JSStringRef> animationName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    ASSERT(!*exception);
+    double time = JSValueToNumber(context, arguments[1], exception);
+    ASSERT(!*exception);
+    JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
+    ASSERT(!*exception);
+
+    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    return JSValueMakeBoolean(context, controller->pauseAnimationAtTimeOnElementWithId(animationName.get(), time, elementId.get()));
+}
+
 // Object Finalization
 
 static void layoutTestControllerObjectFinalize(JSObjectRef object)
@@ -147,6 +193,8 @@ JSStaticFunction* LayoutTestController::staticFunctions()
     static JSStaticFunction staticFunctions[] = {
         { "dumpAsText", dumpAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "waitUntilDone", waitUntilDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { 0, 0, 0 }
     };
index 12bd94a53b838f2fcc71a7953f5a0fe2e8b64d96..203f35857955d63180ee568bec7b3db676f8dc5f 100644 (file)
@@ -50,6 +50,9 @@ public:
     void invalidateWaitToDumpWatchdog();
     void notifyDone();
 
+    unsigned numberOfActiveAnimations() const;
+    bool pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId);
+
 private:
     LayoutTestController(const std::string& testPathOrURL);