Changeset 71424 in webkit


Ignore:
Timestamp:
Nov 5, 2010 9:38:46 AM (13 years ago)
Author:
cmarrin@apple.com
Message:

2010-11-05 Chris Marrin <cmarrin@apple.com>

Reviewed by Simon Fraser.

Make suspendAnimations/resumeAnimations and setCSSAnimations traverse through subframes and remember state
https://bugs.webkit.org/show_bug.cgi?id=46945

Add new funtions to suspend and resume animations. The go through all subframes and suspend or resume them
recursively.

Test: animations/stop-animation-on-suspend.html

  • WebCore.exp.in:
  • page/Frame.cpp: (WebCore::Frame::suspendAnimations): (WebCore::Frame::resumeAnimations):
  • page/Frame.h:
Location:
trunk
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r71422 r71424  
     12010-11-05  Chris Marrin  <cmarrin@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Make suspendAnimations/resumeAnimations and setCSSAnimations traverse through subframes and remember state
     6        https://bugs.webkit.org/show_bug.cgi?id=46945
     7
     8        New test which starts animations in the page an in an iframe. Makes sure both animations
     9        stop when suspendAnimations is called. I also added dot notation syntax to animation-test-helpers.js
     10        that can dig down into iframes to values for testing.
     11
     12        * animations/animation-test-helpers.js:
     13        (checkExpectedValue):
     14        * animations/stop-animation-on-suspend-expected.txt: Added.
     15        * animations/stop-animation-on-suspend.html: Added.
     16
    1172010-11-05  Stephen White  <senorblanco@chromium.org>
    218
  • trunk/LayoutTests/animations/animation-test-helpers.js

    r65107 r71424  
    2424    are the ids of 2 elements, whose values are compared for equality. In this case the expected value is ignored
    2525    but the tolerance is used in the comparison.
     26   
     27    If a string with a '.' is passed, this is an element in an iframe. The string before the dot is the iframe id
     28    and the string after the dot is the element name in that iframe.
    2629
    2730    [3] If the CSS property name is "webkitTransform", expected value must be an array of 1 or more numbers corresponding to the matrix elements,
     
    6669        compareElements = true;
    6770    }
     71   
     72    // Check for a dot separated string
     73    var iframeId;
     74    if (!compareElements) {
     75        var array = elementId.split('.');
     76        if (array.length == 2) {
     77            iframeId = array[0];
     78            elementId = array[1];
     79        }
     80    }
    6881
    6982    if (animationName && hasPauseAnimationAPI && !layoutTestController.pauseAnimationAtTimeOnElementWithId(animationName, time, elementId)) {
     
    8093    var pass = true;
    8194    if (!property.indexOf("webkitTransform")) {
    82         computedValue = window.getComputedStyle(document.getElementById(elementId)).webkitTransform;
     95        var element;
     96        if (iframeId)
     97            element = document.getElementById(iframeId).contentDocument.getElementById(elementId);
     98        else
     99            element = document.getElementById(elementId);
     100           
     101        computedValue = window.getComputedStyle(element).webkitTransform;
    83102        if (compareElements) {
    84103            computedValue2 = window.getComputedStyle(document.getElementById(elementId2)).webkitTransform;
     
    109128        }
    110129    } else if (property == "lineHeight") {
    111         computedValue = parseInt(window.getComputedStyle(document.getElementById(elementId)).lineHeight);
     130        var element;
     131        if (iframeId)
     132            element = document.getElementById(iframeId).contentDocument.getElementById(elementId);
     133        else
     134            element = document.getElementById(elementId);
     135           
     136        computedValue = parseInt(window.getComputedStyle(element).lineHeight);
    112137        if (compareElements) {
    113138            computedValue2 = parseInt(window.getComputedStyle(document.getElementById(elementId2)).lineHeight);
     
    117142            pass = isCloseEnough(computedValue, expectedValue, tolerance);
    118143    } else {
    119         var computedStyle = window.getComputedStyle(document.getElementById(elementId)).getPropertyCSSValue(property);
     144        var element;
     145        if (iframeId)
     146            element = document.getElementById(iframeId).contentDocument.getElementById(elementId);
     147        else
     148            element = document.getElementById(elementId);
     149
     150        var computedStyle = window.getComputedStyle(element).getPropertyCSSValue(property);
    120151        computedValue = computedStyle.getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
    121152        if (compareElements) {
     
    130161    if (compareElements) {
    131162        if (pass)
    132             result += "PASS - \"" + property + "\" property for \"" + elementId + "\" and \"" + elementId2 + "\" elements at " + time + "s are close enough to each other" + "<br>";
    133         else
    134             result += "FAIL - \"" + property + "\" property for \"" + elementId + "\" and \"" + elementId2 + "\" elements at " + time + "s saw: \"" + computedValue + "\" and \"" + computedValue2 + "\" which are not close enough to each other" + "<br>";
     163            result += "PASS - \"" + property + "\" property for \"" + elementId + "\" and \"" + elementId2 +
     164                            "\" elements at " + time + "s are close enough to each other" + "<br>";
     165        else
     166            result += "FAIL - \"" + property + "\" property for \"" + elementId + "\" and \"" + elementId2 +
     167                            "\" elements at " + time + "s saw: \"" + computedValue + "\" and \"" + computedValue2 +
     168                                            "\" which are not close enough to each other" + "<br>";
    135169    } else {
     170        var elementName;
     171        if (iframeId)
     172            elementName = iframeId + '.' + elementId;
     173        else
     174            elementName = elementId;
    136175        if (pass)
    137             result += "PASS - \"" + property + "\" property for \"" + elementId + "\" element at " + time + "s saw something close to: " + expectedValue + "<br>";
    138         else
    139             result += "FAIL - \"" + property + "\" property for \"" + elementId + "\" element at " + time + "s expected: " + expectedValue + " but saw: " + computedValue + "<br>";
     176            result += "PASS - \"" + property + "\" property for \"" + elementName + "\" element at " + time +
     177                            "s saw something close to: " + expectedValue + "<br>";
     178        else
     179            result += "FAIL - \"" + property + "\" property for \"" + elementName + "\" element at " + time +
     180                            "s expected: " + expectedValue + " but saw: " + computedValue + "<br>";
    140181    }
    141182}
  • trunk/WebCore/ChangeLog

    r71415 r71424  
     12010-11-05  Chris Marrin  <cmarrin@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Make suspendAnimations/resumeAnimations and setCSSAnimations traverse through subframes and remember state
     6        https://bugs.webkit.org/show_bug.cgi?id=46945
     7
     8        Add new funtions to suspend and resume animations. The go through all subframes and suspend or resume them
     9        recursively.
     10
     11        Test: animations/stop-animation-on-suspend.html
     12
     13        * WebCore.exp.in:
     14        * page/Frame.cpp:
     15        (WebCore::Frame::suspendAnimations):
     16        (WebCore::Frame::resumeAnimations):
     17        * page/Frame.h:
     18
    1192010-11-05  Pavel Feldman  <pfeldman@chromium.org>
    220
  • trunk/WebCore/WebCore.exp.in

    r71041 r71424  
    635635__ZN7WebCore5Frame10createViewERKNS_7IntSizeERKNS_5ColorEbS3_bNS_13ScrollbarModeEbS7_b
    636636__ZN7WebCore5Frame14frameForWidgetEPKNS_6WidgetE
     637__ZN7WebCore5Frame16resumeAnimationsEv
    637638__ZN7WebCore5Frame17setPageZoomFactorEf
    638639__ZN7WebCore5Frame17setTextZoomFactorEf
     640__ZN7WebCore5Frame17suspendAnimationsEv
    639641__ZN7WebCore5Frame23visiblePositionForPointERKNS_8IntPointE
    640642__ZN7WebCore5Frame25matchLabelsAgainstElementEP7NSArrayPNS_7ElementE
  • trunk/WebCore/page/Frame.cpp

    r71339 r71424  
    990990}
    991991
     992void Frame::suspendAnimations()
     993{
     994    animation()->suspendAnimations(document());
     995   
     996    // Handle subframes
     997    for (Frame* child = tree()->firstChild(); child; child = child->tree()->nextSibling())
     998        child->suspendAnimations();
     999}
     1000
     1001void Frame::resumeAnimations()
     1002{
     1003    animation()->resumeAnimations(document());
     1004   
     1005    // Handle subframes
     1006    for (Frame* child = tree()->firstChild(); child; child = child->tree()->nextSibling())
     1007        child->resumeAnimations();
     1008}
     1009
    9921010} // namespace WebCore
  • trunk/WebCore/page/Frame.h

    r70716 r71424  
    9999        AnimationController* animation() const;
    100100        ScriptController* script();
     101       
     102        void suspendAnimations();
     103        void resumeAnimations();
    101104
    102105        RenderView* contentRenderer() const; // Root of the render tree for the document contained in this frame.
  • trunk/WebKit/gtk/ChangeLog

    r71217 r71424  
     12010-11-05  Chris Marrin  <cmarrin@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Make suspendAnimations/resumeAnimations and setCSSAnimations traverse through subframes and remember state
     6        https://bugs.webkit.org/show_bug.cgi?id=46945
     7
     8        * webkit/webkitwebframe.cpp:
     9        (webkit_web_frame_suspend_animations):
     10        (webkit_web_frame_resume_animations):
     11
    1122010-11-03  Daniel Bates  <dbates@rim.com>
    213
  • trunk/WebKit/gtk/webkit/webkitwebframe.cpp

    r71217 r71424  
    10601060        return;
    10611061
    1062     AnimationController* controller = coreFrame->animation();
    1063     if (!controller)
     1062    frame->suspendAnimations();
     1063}
     1064
     1065void webkit_web_frame_resume_animations(WebKitWebFrame* frame)
     1066{
     1067    Frame* coreFrame = core(frame);
     1068    if (!coreFrame)
    10641069        return;
    10651070
    1066     controller->suspendAnimations(coreFrame->document());
    1067 }
    1068 
    1069 void webkit_web_frame_resume_animations(WebKitWebFrame* frame)
    1070 {
    1071     Frame* coreFrame = core(frame);
    1072     if (!coreFrame)
    1073         return;
    1074 
    1075     AnimationController* controller = coreFrame->animation();
    1076     if (!controller)
    1077         return;
    1078 
    1079     controller->resumeAnimations(coreFrame->document());
     1071    frame->resumeAnimations();
    10801072}
    10811073
  • trunk/WebKit/mac/ChangeLog

    r71385 r71424  
     12010-11-05  Chris Marrin  <cmarrin@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Make suspendAnimations/resumeAnimations and setCSSAnimations traverse through subframes and remember state
     6        https://bugs.webkit.org/show_bug.cgi?id=46945
     7
     8        * WebView/WebFrame.mm:
     9        (-[WebFrame _suspendAnimations]):
     10        (-[WebFrame _resumeAnimations]):
     11
    1122010-11-04  Jia Pu  <jpu@apple.com>
    213
  • trunk/WebKit/mac/WebView/WebFrame.mm

    r71216 r71424  
    11371137    if (!frame)
    11381138        return;
    1139 
    1140     AnimationController* controller = frame->animation();
    1141     if (!controller)
    1142         return;
    1143 
    1144     controller->suspendAnimations(frame->document());
     1139       
     1140    frame->suspendAnimations();
    11451141}
    11461142
     
    11511147        return;
    11521148
    1153     AnimationController* controller = frame->animation();
    1154     if (!controller)
    1155         return;
    1156 
    1157     controller->resumeAnimations(frame->document());
     1149    frame->resumeAnimations();
    11581150}
    11591151
  • trunk/WebKit/win/ChangeLog

    r71401 r71424  
     12010-11-05  Chris Marrin  <cmarrin@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Make suspendAnimations/resumeAnimations and setCSSAnimations traverse through subframes and remember state
     6        https://bugs.webkit.org/show_bug.cgi?id=46945
     7
     8        * WebFrame.cpp:
     9        (WebFrame::suspendAnimations):
     10        (WebFrame::resumeAnimations):
     11
    1122010-11-05  Patrick Gansterer  <paroga@webkit.org>
    213
  • trunk/WebKit/win/WebFrame.cpp

    r71216 r71424  
    13001300        return E_FAIL;
    13011301
    1302     AnimationController* controller = frame->animation();
    1303     if (!controller)
    1304         return E_FAIL;
    1305 
    1306     controller->suspendAnimations(frame->document());
     1302    frame->suspendAnimations();
    13071303    return S_OK;
    13081304}
     
    13141310        return E_FAIL;
    13151311
    1316     AnimationController* controller = frame->animation();
    1317     if (!controller)
    1318         return E_FAIL;
    1319 
    1320     controller->resumeAnimations(frame->document());
     1312    frame->resumeAnimations();
    13211313    return S_OK;
    13221314}
Note: See TracChangeset for help on using the changeset viewer.