Changeset 76677 in webkit


Ignore:
Timestamp:
Jan 26, 2011 1:18:17 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-01-26 James Robinson <jamesr@chromium.org>

Reviewed by Nate Chapin.

Add a DOMTimeStamp parameter to the requestAnimationFrame callback
https://bugs.webkit.org/show_bug.cgi?id=53142

Adds a test for the parameter passed to the requestAnimationFrame callback.

  • fast/animation/request-animation-frame-timestamps-expected.txt: Added.
  • fast/animation/request-animation-frame-timestamps.html: Added.
  • fast/animation/script-tests/request-animation-frame-timestamps.js: Added.

2011-01-26 James Robinson <jamesr@chromium.org>

Reviewed by Nate Chapin.

Add a DOMTimeStamp parameter to the requestAnimationFrame callback
https://bugs.webkit.org/show_bug.cgi?id=53142

This adds a DOMTimeStamp parameter to the requestAnimationFrame callback to more
closely match mozilla's proposal. This is useful if the page has multiple imperative animations
and wants to ensure that they all remain synchronized. If each callback used Date.now() to
update its animation state, they would potentially be out of sync with each other. If they use
the timestamp then all callbacks for the same "frame" will update to the same state.

Test: fast/animation/request-animation-frame-timestamps.html

  • bindings/scripts/CodeGeneratorV8.pm:
  • bindings/scripts/test/V8/V8TestCallback.cpp: (WebCore::V8TestCallback::callbackWithClass2Param):
  • dom/Document.cpp: (WebCore::Document::serviceScriptedAnimations):
  • dom/Document.h:
  • dom/RequestAnimationFrameCallback.h:
  • dom/RequestAnimationFrameCallback.idl:
  • page/FrameView.cpp: (WebCore::FrameView::serviceScriptedAnimations):
  • page/FrameView.h:

2011-01-26 James Robinson <jamesr@chromium.org>

Reviewed by Nate Chapin.

Add a DOMTimeStamp parameter to the requestAnimationFrame callback
https://bugs.webkit.org/show_bug.cgi?id=53142

Provides a timestamp to use for imperative animation callbacks. In this patch the timestamp is
just the current time at the start of the callback invocation algorithm. In the future we
could enhance this to try to take the compositing delay into effect to try to synchronize
imperative animations more closely with declarative ones, but this should do for now.

  • src/WebViewImpl.cpp: (WebKit::WebViewImpl::animate):
Location:
trunk
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r76675 r76677  
     12011-01-26  James Robinson  <jamesr@chromium.org>
     2
     3        Reviewed by Nate Chapin.
     4
     5        Add a DOMTimeStamp parameter to the requestAnimationFrame callback
     6        https://bugs.webkit.org/show_bug.cgi?id=53142
     7
     8        Adds a test for the parameter passed to the requestAnimationFrame callback.
     9
     10        * fast/animation/request-animation-frame-timestamps-expected.txt: Added.
     11        * fast/animation/request-animation-frame-timestamps.html: Added.
     12        * fast/animation/script-tests/request-animation-frame-timestamps.js: Added.
     13
    1142011-01-25  Yuzo Fujishima  <yuzo@google.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r76676 r76677  
     12011-01-26  James Robinson  <jamesr@chromium.org>
     2
     3        Reviewed by Nate Chapin.
     4
     5        Add a DOMTimeStamp parameter to the requestAnimationFrame callback
     6        https://bugs.webkit.org/show_bug.cgi?id=53142
     7
     8        This adds a DOMTimeStamp parameter to the requestAnimationFrame callback to more
     9        closely match mozilla's proposal.  This is useful if the page has multiple imperative animations
     10        and wants to ensure that they all remain synchronized.  If each callback used Date.now() to
     11        update its animation state, they would potentially be out of sync with each other.  If they use
     12        the timestamp then all callbacks for the same "frame" will update to the same state.
     13
     14        Test: fast/animation/request-animation-frame-timestamps.html
     15
     16        * bindings/scripts/CodeGeneratorV8.pm:
     17        * bindings/scripts/test/V8/V8TestCallback.cpp:
     18        (WebCore::V8TestCallback::callbackWithClass2Param):
     19        * dom/Document.cpp:
     20        (WebCore::Document::serviceScriptedAnimations):
     21        * dom/Document.h:
     22        * dom/RequestAnimationFrameCallback.h:
     23        * dom/RequestAnimationFrameCallback.idl:
     24        * page/FrameView.cpp:
     25        (WebCore::FrameView::serviceScriptedAnimations):
     26        * page/FrameView.h:
     27
    1282011-01-25  Yuzo Fujishima  <yuzo@google.com>
    229
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r76531 r76677  
    23942394            foreach my $param (@params) {
    23952395                my $paramName = $param->name;
    2396                 push(@implContent, "    v8::Handle<v8::Value> ${paramName}Handle = toV8(${paramName});\n");
     2396                push(@implContent, "    v8::Handle<v8::Value> ${paramName}Handle = " . NativeToJSValue($param, $paramName) . ";\n");
    23972397                push(@implContent, "    if (${paramName}Handle.IsEmpty()) {\n");
    23982398                push(@implContent, "        CRASH();\n");
     
    30903090
    30913091
    3092 sub ReturnNativeToJSValue
     3092sub NativeToJSValue
    30933093{
    30943094    my $signature = shift;
     
    30973097    my $type = GetTypeFromSignature($signature);
    30983098
    3099     return "return v8Boolean($value)" if $type eq "boolean";
    3100     return "return v8::Handle<v8::Value>()" if $type eq "void";     # equivalent to v8::Undefined()
     3099    return "v8Boolean($value)" if $type eq "boolean";
     3100    return "v8::Handle<v8::Value>()" if $type eq "void";     # equivalent to v8::Undefined()
    31013101
    31023102    # HTML5 says that unsigned reflected attributes should be in the range
     
    31053105    if ($signature->extendedAttributes->{"Reflect"} and ($type eq "unsigned long" or $type eq "unsigned short")) {
    31063106        $value =~ s/getUnsignedIntegralAttribute/getIntegralAttribute/g;
    3107         return "return v8::Integer::NewFromUnsigned(std::max(0, " . $value . "))";
     3107        return "v8::Integer::NewFromUnsigned(std::max(0, " . $value . "))";
    31083108    }
    31093109
     
    31113111    # we use Integer::New which has a fast Smi conversion check.
    31123112    my $nativeType = GetNativeType($type);
    3113     return "return v8::Integer::New($value)" if $nativeType eq "int";
    3114     return "return v8::Integer::NewFromUnsigned($value)" if $nativeType eq "unsigned";
    3115 
    3116     return "return v8DateOrNull($value)" if $type eq "Date";
     3113    return "v8::Integer::New($value)" if $nativeType eq "int";
     3114    return "v8::Integer::NewFromUnsigned($value)" if $nativeType eq "unsigned";
     3115
     3116    return "v8DateOrNull($value)" if $type eq "Date";
    31173117    # long long and unsigned long long are not representable in ECMAScript.
    3118     return "return v8::Number::New(static_cast<double>($value))" if $type eq "long long" or $type eq "unsigned long long" or $type eq "DOMTimeStamp";
    3119     return "return v8::Number::New($value)" if $codeGenerator->IsPrimitiveType($type) or $type eq "SVGPaintType";
    3120     return "return $value.v8Value()" if $nativeType eq "ScriptValue";
     3118    return "v8::Number::New(static_cast<double>($value))" if $type eq "long long" or $type eq "unsigned long long" or $type eq "DOMTimeStamp";
     3119    return "v8::Number::New($value)" if $codeGenerator->IsPrimitiveType($type) or $type eq "SVGPaintType";
     3120    return "$value.v8Value()" if $nativeType eq "ScriptValue";
    31213121
    31223122    if ($codeGenerator->IsStringType($type)) {
    31233123        my $conv = $signature->extendedAttributes->{"ConvertNullStringTo"};
    31243124        if (defined $conv) {
    3125             return "return v8StringOrNull($value)" if $conv eq "Null";
    3126             return "return v8StringOrUndefined($value)" if $conv eq "Undefined";
    3127             return "return v8StringOrFalse($value)" if $conv eq "False";
     3125            return "v8StringOrNull($value)" if $conv eq "Null";
     3126            return "v8StringOrUndefined($value)" if $conv eq "Undefined";
     3127            return "v8StringOrFalse($value)" if $conv eq "False";
    31283128
    31293129            die "Unknown value for ConvertNullStringTo extended attribute";
    31303130        }
    31313131        $conv = $signature->extendedAttributes->{"ConvertScriptString"};
    3132         return "return v8StringOrNull($value)" if $conv;
    3133         return "return v8String($value)";
     3132        return "v8StringOrNull($value)" if $conv;
     3133        return "v8String($value)";
    31343134    }
    31353135
     
    31383138    # special case for non-DOM node interfaces
    31393139    if (IsDOMNodeType($type)) {
    3140         return "return toV8(${value}" . ($signature->extendedAttributes->{"ReturnsNew"} ? ", true)" : ")");
     3140        return "toV8(${value}" . ($signature->extendedAttributes->{"ReturnsNew"} ? ", true)" : ")");
    31413141    }
    31423142
    31433143    if ($type eq "EventTarget") {
    3144         return "return V8DOMWrapper::convertEventTargetToV8Object($value)";
     3144        return "V8DOMWrapper::convertEventTargetToV8Object($value)";
    31453145    }
    31463146
    31473147    if ($type eq "EventListener") {
    31483148        $implIncludes{"V8AbstractEventListener.h"} = 1;
    3149         return "return ${value} ? v8::Handle<v8::Value>(static_cast<V8AbstractEventListener*>(${value})->getListenerObject(imp->scriptExecutionContext())) : v8::Handle<v8::Value>(v8::Null())";
     3149        return "${value} ? v8::Handle<v8::Value>(static_cast<V8AbstractEventListener*>(${value})->getListenerObject(imp->scriptExecutionContext())) : v8::Handle<v8::Value>(v8::Null())";
    31503150    }
    31513151
    31523152    if ($type eq "SerializedScriptValue") {
    31533153        $implIncludes{"$type.h"} = 1;
    3154         return "return $value->deserialize()";
     3154        return "$value->deserialize()";
    31553155    }
    31563156
     
    31593159    $implIncludes{"wtf/GetPtr.h"} = 1;
    31603160
    3161     return "return toV8($value)";
     3161    return "toV8($value)";
     3162}
     3163
     3164sub ReturnNativeToJSValue
     3165{
     3166    return "return " . NativeToJSValue(@_);
    31623167}
    31633168
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp

    r76277 r76677  
    3030#include "V8DOMString.h"
    3131#include "V8Proxy.h"
     32#include <wtf/GetPtr.h>
     33#include <wtf/RefCounted.h>
     34#include <wtf/RefPtr.h>
    3235
    3336#include <wtf/Assertions.h>
     
    114117        return true;
    115118    }
    116     v8::Handle<v8::Value> strArgHandle = toV8(strArg);
     119    v8::Handle<v8::Value> strArgHandle = v8String(strArg);
    117120    if (strArgHandle.IsEmpty()) {
    118121        CRASH();
  • trunk/Source/WebCore/dom/Document.cpp

    r76278 r76677  
    49874987}
    49884988
    4989 void Document::serviceScriptedAnimations()
     4989void Document::serviceScriptedAnimations(DOMTimeStamp time)
    49904990{
    49914991    if (!m_requestAnimationFrameCallbacks)
     
    50155015            if (!callback->m_firedOrCancelled && (!callback->m_element || callback->m_element->renderer())) {
    50165016                callback->m_firedOrCancelled = true;
    5017                 callback->handleEvent();
     5017                callback->handleEvent(time);
    50185018                firedCallback = true;
    50195019                callbacks.remove(i);
  • trunk/Source/WebCore/dom/Document.h

    r76278 r76677  
    3333#include "Color.h"
    3434#include "ContainerNode.h"
     35#include "DOMTimeStamp.h"
    3536#include "DocumentTiming.h"
    3637#include "QualifiedName.h"
     
    10791080    int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>, Element*);
    10801081    void webkitCancelRequestAnimationFrame(int id);
    1081     void serviceScriptedAnimations();
     1082    void serviceScriptedAnimations(DOMTimeStamp);
    10821083#endif
    10831084
  • trunk/Source/WebCore/dom/RequestAnimationFrameCallback.h

    r76278 r76677  
    4141public:
    4242    virtual ~RequestAnimationFrameCallback() { }
    43     virtual bool handleEvent() = 0;
     43    virtual bool handleEvent(DOMTimeStamp) = 0;
    4444
    4545    RefPtr<Element> m_element;
  • trunk/Source/WebCore/dom/RequestAnimationFrameCallback.idl

    r76278 r76677  
    3333        Callback=FunctionOnly,Conditional=REQUEST_ANIMATION_FRAME
    3434    ] RequestAnimationFrameCallback{
    35         boolean handleEvent();
     35        boolean handleEvent(in DOMTimeStamp time);
    3636    };
    3737}
  • trunk/Source/WebCore/page/FrameView.cpp

    r76437 r76677  
    16521652
    16531653#if ENABLE(REQUEST_ANIMATION_FRAME)
    1654 void FrameView::serviceScriptedAnimations()
     1654void FrameView::serviceScriptedAnimations(DOMTimeStamp time)
    16551655{
    16561656    for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNext())
    1657         frame->document()->serviceScriptedAnimations();
     1657        frame->document()->serviceScriptedAnimations(time);
    16581658}
    16591659#endif
  • trunk/Source/WebCore/page/FrameView.h

    r76378 r76677  
    102102
    103103#if ENABLE(REQUEST_ANIMATION_FRAME)
    104     void serviceScriptedAnimations();
     104    void serviceScriptedAnimations(DOMTimeStamp);
    105105#endif
    106106
  • trunk/Source/WebKit/chromium/ChangeLog

    r76668 r76677  
     12011-01-26  James Robinson  <jamesr@chromium.org>
     2
     3        Reviewed by Nate Chapin.
     4
     5        Add a DOMTimeStamp parameter to the requestAnimationFrame callback
     6        https://bugs.webkit.org/show_bug.cgi?id=53142
     7
     8        Provides a timestamp to use for imperative animation callbacks.  In this patch the timestamp is
     9        just the current time at the start of the callback invocation algorithm.  In the future we
     10        could enhance this to try to take the compositing delay into effect to try to synchronize
     11        imperative animations more closely with declarative ones, but this should do for now.
     12
     13        * src/WebViewImpl.cpp:
     14        (WebKit::WebViewImpl::animate):
     15
    1162011-01-25  Kent Tamura  <tkent@chromium.org>
    217
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r76340 r76677  
    122122#include "WebViewClient.h"
    123123#include <wtf/ByteArray.h>
     124#include <wtf/CurrentTime.h>
    124125#include <wtf/RefPtr.h>
    125126
     
    980981        FrameView* view = webframe->frameView();
    981982        if (view)
    982             view->serviceScriptedAnimations();
     983            view->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(currentTime()));
    983984    }
    984985#endif
Note: See TracChangeset for help on using the changeset viewer.