Title: [138632] trunk
Revision
138632
Author
[email protected]
Date
2013-01-02 12:31:44 -0800 (Wed, 02 Jan 2013)

Log Message

Transitions and animations do not apply to CSS ::before and ::after pseudo-elements
https://bugs.webkit.org/show_bug.cgi?id=92591

Reviewed by Eric Seidel.

.:

Expose Element::pseudoElement for Internals.

* Source/autotools/symbols.filter:

Source/WebCore:

The new DOM based :before and :after pseudo elements support animations
and transitions already, but I had disabled support so we could turn them
on in a separate step. This patch just removes the checks and adds tests.

This also adds two methods to internals to allow pausing animations and
transitions on pseudo elements at predictable locations so the tests
are not flaky.

Tests: fast/css-generated-content/pseudo-animation.html
       fast/css-generated-content/pseudo-transition.html

* WebCore.exp.in:
* page/animation/AnimationController.cpp:
(WebCore::AnimationController::updateAnimations):
* testing/Internals.cpp:
(WebCore::Internals::pauseAnimationAtTimeOnPseudoElement):
(WebCore::Internals::pauseTransitionAtTimeOnPseudoElement):
* testing/Internals.h:
(Internals):
* testing/Internals.idl:

LayoutTests:

Add tests that check if animations and transitions play for pseudo
:before and :after pseudo elements.

* fast/css-generated-content/pseudo-animation-expected.txt: Added.
* fast/css-generated-content/pseudo-animation.html: Added.
* fast/css-generated-content/pseudo-transition-expected.txt: Added.
* fast/css-generated-content/pseudo-transition.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (138631 => 138632)


--- trunk/ChangeLog	2013-01-02 20:27:40 UTC (rev 138631)
+++ trunk/ChangeLog	2013-01-02 20:31:44 UTC (rev 138632)
@@ -1,3 +1,14 @@
+2013-01-02  Elliott Sprehn  <[email protected]>
+
+        Transitions and animations do not apply to CSS ::before and ::after pseudo-elements
+        https://bugs.webkit.org/show_bug.cgi?id=92591
+
+        Reviewed by Eric Seidel.
+
+        Expose Element::pseudoElement for Internals.
+
+        * Source/autotools/symbols.filter:
+
 2013-01-01  KwangYong Choi  <[email protected]>
 
         [EFL] Enable MHTML feature

Modified: trunk/LayoutTests/ChangeLog (138631 => 138632)


--- trunk/LayoutTests/ChangeLog	2013-01-02 20:27:40 UTC (rev 138631)
+++ trunk/LayoutTests/ChangeLog	2013-01-02 20:31:44 UTC (rev 138632)
@@ -1,3 +1,18 @@
+2013-01-02  Elliott Sprehn  <[email protected]>
+
+        Transitions and animations do not apply to CSS ::before and ::after pseudo-elements
+        https://bugs.webkit.org/show_bug.cgi?id=92591
+
+        Reviewed by Eric Seidel.
+
+        Add tests that check if animations and transitions play for pseudo
+        :before and :after pseudo elements.
+
+        * fast/css-generated-content/pseudo-animation-expected.txt: Added.
+        * fast/css-generated-content/pseudo-animation.html: Added.
+        * fast/css-generated-content/pseudo-transition-expected.txt: Added.
+        * fast/css-generated-content/pseudo-transition.html: Added.
+
 2013-01-02  Chris Rogers  <[email protected]>
 
         Implement WebIDL-style string constants in WebAudio

Added: trunk/LayoutTests/fast/css-generated-content/pseudo-animation-expected.txt (0 => 138632)


--- trunk/LayoutTests/fast/css-generated-content/pseudo-animation-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css-generated-content/pseudo-animation-expected.txt	2013-01-02 20:31:44 UTC (rev 138632)
@@ -0,0 +1,15 @@
+Animations on :before and :after pseudo elements should run
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS div.offsetWidth is 52
+PASS div.offsetWidth is 20
+PASS div.offsetWidth is 12
+PASS div.offsetWidth is 52
+PASS div.offsetWidth is 20
+PASS div.offsetWidth is 12
+PASS successfullyParsed is true
+
+TEST COMPLETE
+ 

Added: trunk/LayoutTests/fast/css-generated-content/pseudo-animation.html (0 => 138632)


--- trunk/LayoutTests/fast/css-generated-content/pseudo-animation.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css-generated-content/pseudo-animation.html	2013-01-02 20:31:44 UTC (rev 138632)
@@ -0,0 +1,100 @@
+<!DOCTYPE html>
+
+<script src=""
+
+<style>
+@-webkit-keyframes example {
+  from {
+    width: 50px;
+    height: 50px;
+  }
+  to {
+    width: 10px;
+    height: 10px;
+  }
+}
+
+@keyframes example {
+  from {
+    width: 50px;
+    height: 50px;
+  }
+  to {
+    width: 10px;
+    height: 10px;
+  }
+}
+
+#after:after,
+#before:before {
+    content: "";
+    display: block;
+    height: 50px;
+    width: 50px;
+}
+
+#after.animate:after,
+#before.animate:before {
+    width: 10px;
+    height: 10px;
+    -webkit-animation: example 2s;
+    -moz-animation: example 2s;
+    animation: example 2s;
+}
+
+#before,
+#after {
+    display: inline-block;
+    border: 1px solid black;
+    background: red;
+}
+
+#before.animate,
+#after.animate {
+    background: green;
+}
+</style>
+
+<div id="before"></div>
+<div id="after"></div>
+
+<script>
+description('Animations on :before and :after pseudo elements should run');
+
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+function testAnimation(id)
+{
+    var div = document.getElementById(id);
+    div.className = 'animate';
+    window.div = div;
+    shouldBe('div.offsetWidth', '52');
+    if (window.internals) {
+        internals.pauseAnimationAtTimeOnPseudoElement('example', 1.0, div, id);
+        shouldBe('div.offsetWidth', '20');
+        internals.pauseAnimationAtTimeOnPseudoElement('example', 2.0, div, id);
+        shouldBe('div.offsetWidth', '12');
+    } else {
+        // This will be flaky, but it's a reasonable approximation for testing
+        // in a browser instead of DRT.
+        setTimeout(function() {
+            window.div = div;
+            shouldBe('div.offsetWidth', '20');
+        }, 1000);
+        setTimeout(function() {
+            window.div = div;
+            shouldBe('div.offsetWidth', '12');
+        }, 2000);
+    }
+}
+
+_onload_ = function() {
+    testAnimation('before');
+    testAnimation('after');
+    if (window.internals)
+        isSuccessfullyParsed();
+    else
+        setTimeout(isSuccessfullyParsed, 2000);
+};
+</script>

Added: trunk/LayoutTests/fast/css-generated-content/pseudo-transition-expected.txt (0 => 138632)


--- trunk/LayoutTests/fast/css-generated-content/pseudo-transition-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css-generated-content/pseudo-transition-expected.txt	2013-01-02 20:31:44 UTC (rev 138632)
@@ -0,0 +1,15 @@
+Transitions on :before and :after pseudo elements should run
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS div.offsetWidth is 52
+PASS div.offsetWidth is 20
+PASS div.offsetWidth is 12
+PASS div.offsetWidth is 52
+PASS div.offsetWidth is 20
+PASS div.offsetWidth is 12
+PASS successfullyParsed is true
+
+TEST COMPLETE
+ 

Added: trunk/LayoutTests/fast/css-generated-content/pseudo-transition.html (0 => 138632)


--- trunk/LayoutTests/fast/css-generated-content/pseudo-transition.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css-generated-content/pseudo-transition.html	2013-01-02 20:31:44 UTC (rev 138632)
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+
+<script src=""
+
+<style>
+#before:before,
+#after:after {
+    content: "";
+    display: block;
+    height: 50px;
+    width: 50px;
+    -webkit-transition: width 2s;
+    -moz-transition: width 2s;
+    transition: width 2s;
+}
+
+#before.transition:before,
+#after.transition:after {
+    height: 10px;
+    width: 10px;
+}
+
+#before,
+#after {
+    display: inline-block;
+    border: 1px solid black;
+    background: red;
+}
+
+#after.transition,
+#before.transition {
+    background: green;
+}
+</style>
+
+<div id="before"></div>
+<div id="after"></div>
+
+<script>
+description('Transitions on :before and :after pseudo elements should run');
+
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+function testTransition(id)
+{
+    var div = document.getElementById(id);
+    div.className = 'transition';
+    window.div = div;
+    shouldBe('div.offsetWidth', '52');
+    if (window.internals) {
+        internals.pauseTransitionAtTimeOnPseudoElement('width', 1.0, div, id);
+        shouldBe('div.offsetWidth', '20');
+        internals.pauseTransitionAtTimeOnPseudoElement('width', 2.0, div, id);
+        shouldBe('div.offsetWidth', '12');
+    } else {
+        // This will be flaky, but it's a reasonable approximation for testing
+        // in a browser instead of DRT.
+        setTimeout(function() {
+            window.div = div;
+            shouldBe('div.offsetWidth', '20');
+        }, 1000);
+        setTimeout(function() {
+            window.div = div;
+            shouldBe('div.offsetWidth', '12');
+        }, 2000);
+    }
+}
+
+_onload_ = function() {
+    testTransition('before');
+    testTransition('after');
+    if (window.internals)
+        isSuccessfullyParsed();
+    else
+        setTimeout(isSuccessfullyParsed, 2000);
+};
+</script>

Modified: trunk/Source/WebCore/ChangeLog (138631 => 138632)


--- trunk/Source/WebCore/ChangeLog	2013-01-02 20:27:40 UTC (rev 138631)
+++ trunk/Source/WebCore/ChangeLog	2013-01-02 20:31:44 UTC (rev 138632)
@@ -1,3 +1,31 @@
+2013-01-02  Elliott Sprehn  <[email protected]>
+
+        Transitions and animations do not apply to CSS ::before and ::after pseudo-elements
+        https://bugs.webkit.org/show_bug.cgi?id=92591
+
+        Reviewed by Eric Seidel.
+
+        The new DOM based :before and :after pseudo elements support animations
+        and transitions already, but I had disabled support so we could turn them
+        on in a separate step. This patch just removes the checks and adds tests.
+
+        This also adds two methods to internals to allow pausing animations and
+        transitions on pseudo elements at predictable locations so the tests
+        are not flaky.
+
+        Tests: fast/css-generated-content/pseudo-animation.html
+               fast/css-generated-content/pseudo-transition.html
+
+        * WebCore.exp.in:
+        * page/animation/AnimationController.cpp:
+        (WebCore::AnimationController::updateAnimations):
+        * testing/Internals.cpp:
+        (WebCore::Internals::pauseAnimationAtTimeOnPseudoElement):
+        (WebCore::Internals::pauseTransitionAtTimeOnPseudoElement):
+        * testing/Internals.h:
+        (Internals):
+        * testing/Internals.idl:
+
 2013-01-02  Chris Rogers  <[email protected]>
 
         Implement WebIDL-style string constants in WebAudio

Modified: trunk/Source/WebCore/WebCore.exp.in (138631 => 138632)


--- trunk/Source/WebCore/WebCore.exp.in	2013-01-02 20:27:40 UTC (rev 138631)
+++ trunk/Source/WebCore/WebCore.exp.in	2013-01-02 20:31:44 UTC (rev 138632)
@@ -892,6 +892,7 @@
 __ZN7WebCore7Element21boundsInRootViewSpaceEv
 __ZN7WebCore7Element9innerTextEv
 __ZN7WebCore7Element9setPseudoERKN3WTF12AtomicStringE
+__ZNK7WebCore7Element13pseudoElementENS_8PseudoIdE
 __ZN7WebCore7IntRect5scaleEf
 __ZN7WebCore7IntRect5uniteERKS0_
 __ZN7WebCore7IntRect9intersectERKS0_

Modified: trunk/Source/WebCore/page/animation/AnimationController.cpp (138631 => 138632)


--- trunk/Source/WebCore/page/animation/AnimationController.cpp	2013-01-02 20:27:40 UTC (rev 138631)
+++ trunk/Source/WebCore/page/animation/AnimationController.cpp	2013-01-02 20:31:44 UTC (rev 138632)
@@ -510,10 +510,6 @@
     if (!renderer->document() || renderer->document()->inPageCache())
         return newStyle;
 
-    // FIXME: We do not animate generated content yet.
-    if (renderer->isPseudoElement())
-        return newStyle;
-
     RenderStyle* oldStyle = renderer->style();
 
     if ((!oldStyle || (!oldStyle->animations() && !oldStyle->transitions())) && (!newStyle->animations() && !newStyle->transitions()))
@@ -527,8 +523,10 @@
     // against the animations in the style and make sure we're in sync.  If destination values
     // have changed, we reset the animation.  We then do a blend to get new values and we return
     // a new style.
-    ASSERT(renderer->node() && !renderer->isPseudoElement()); // FIXME: We do not animate generated content yet.
 
+    // We don't support anonymous pseudo elements like :first-line or :first-letter.
+    ASSERT(renderer->node());
+
     RefPtr<CompositeAnimation> rendererAnimations = m_data->accessCompositeAnimation(renderer);
     RefPtr<RenderStyle> blendedStyle = rendererAnimations->animate(renderer, oldStyle, newStyle);
 

Modified: trunk/Source/WebCore/testing/Internals.cpp (138631 => 138632)


--- trunk/Source/WebCore/testing/Internals.cpp	2013-01-02 20:27:40 UTC (rev 138631)
+++ trunk/Source/WebCore/testing/Internals.cpp	2013-01-02 20:31:44 UTC (rev 138632)
@@ -68,6 +68,7 @@
 #include "NodeRenderingContext.h"
 #include "Page.h"
 #include "PrintContext.h"
+#include "PseudoElement.h"
 #include "Range.h"
 #include "RenderObject.h"
 #include "RenderTreeAsText.h"
@@ -387,6 +388,48 @@
     return false;
 }
 
+bool Internals::pauseAnimationAtTimeOnPseudoElement(const String& animationName, double pauseTime, Element* element, const String& pseudoId, ExceptionCode& ec)
+{
+    if (!element || pauseTime < 0) {
+        ec = INVALID_ACCESS_ERR;
+        return false;
+    }
+
+    if (pseudoId != "before" && pseudoId != "after") {
+        ec = INVALID_ACCESS_ERR;
+        return false;
+    }
+
+    PseudoElement* pseudoElement = element->pseudoElement(pseudoId == "before" ? BEFORE : AFTER);
+    if (!pseudoElement) {
+        ec = INVALID_ACCESS_ERR;
+        return false;
+    }
+
+    return frame()->animation()->pauseAnimationAtTime(pseudoElement->renderer(), animationName, pauseTime);
+}
+
+bool Internals::pauseTransitionAtTimeOnPseudoElement(const String& property, double pauseTime, Element* element, const String& pseudoId, ExceptionCode& ec)
+{
+    if (!element || pauseTime < 0) {
+        ec = INVALID_ACCESS_ERR;
+        return false;
+    }
+
+    if (pseudoId != "before" && pseudoId != "after") {
+        ec = INVALID_ACCESS_ERR;
+        return false;
+    }
+
+    PseudoElement* pseudoElement = element->pseudoElement(pseudoId == "before" ? BEFORE : AFTER);
+    if (!pseudoElement) {
+        ec = INVALID_ACCESS_ERR;
+        return false;
+    }
+
+    return frame()->animation()->pauseTransitionAtTime(pseudoElement->renderer(), property, pauseTime);
+}
+
 bool Internals::hasShadowInsertionPoint(const Node* root, ExceptionCode& ec) const
 {
     if (root && root->isShadowRoot())

Modified: trunk/Source/WebCore/testing/Internals.h (138631 => 138632)


--- trunk/Source/WebCore/testing/Internals.h	2013-01-02 20:27:40 UTC (rev 138631)
+++ trunk/Source/WebCore/testing/Internals.h	2013-01-02 20:31:44 UTC (rev 138632)
@@ -94,6 +94,9 @@
     String shadowPseudoId(Element*, ExceptionCode&);
     void setShadowPseudoId(Element*, const String&, ExceptionCode&);
 
+    bool pauseAnimationAtTimeOnPseudoElement(const String& animationName, double pauseTime, Element*, const String& pseudoId, ExceptionCode&);
+    bool pauseTransitionAtTimeOnPseudoElement(const String& property, double pauseTime, Element*, const String& pseudoId, ExceptionCode&);
+
     PassRefPtr<Element> createContentElement(Document*, ExceptionCode&);
     bool isValidContentSelect(Element* insertionPoint, ExceptionCode&);
     Node* treeScopeRootNode(Node*, ExceptionCode&);

Modified: trunk/Source/WebCore/testing/Internals.idl (138631 => 138632)


--- trunk/Source/WebCore/testing/Internals.idl	2013-01-02 20:27:40 UTC (rev 138631)
+++ trunk/Source/WebCore/testing/Internals.idl	2013-01-02 20:31:44 UTC (rev 138632)
@@ -65,6 +65,9 @@
     boolean hasSelectorForAttributeInShadow(in Element host, in DOMString attributeName) raises (DOMException);
     boolean hasSelectorForPseudoClassInShadow(in Element host, in DOMString pseudoClass) raises (DOMException);
 
+    boolean pauseAnimationAtTimeOnPseudoElement(in DOMString animationName, in double pauseTime, in Element element, in DOMString pseudoId) raises (DOMException);
+    boolean pauseTransitionAtTimeOnPseudoElement(in DOMString property, in double pauseTime, in Element element, in DOMString pseudoId) raises (DOMException);
+
     Node nextSiblingByWalker(in Node node) raises(DOMException);
     Node firstChildByWalker(in Node node) raises(DOMException);
     Node lastChildByWalker(in Node node) raises(DOMException);

Modified: trunk/Source/autotools/symbols.filter (138631 => 138632)


--- trunk/Source/autotools/symbols.filter	2013-01-02 20:27:40 UTC (rev 138631)
+++ trunk/Source/autotools/symbols.filter	2013-01-02 20:31:44 UTC (rev 138632)
@@ -124,6 +124,7 @@
 _ZN7WebCore6toNodeEN3JSC7JSValueE;
 _ZN7WebCore7Element20removeShadowRootListEv;
 _ZN7WebCore7Element9setPseudoERKN3WTF12AtomicStringE;
+_ZNK7WebCore7Element13pseudoElementENS_8PseudoIdE;
 _ZN7WebCore7jsArrayEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEN3WTF10PassRefPtrINS_13DOMStringListEEE;
 _ZN7WebCore7toRangeEN3JSC7JSValueE;
 _ZN7WebCore9DOMWindow4openERKN3WTF6StringERKNS1_12AtomicStringES4_PS0_S8_;
@@ -157,6 +158,8 @@
 _ZN7WebCore8Document16isPageBoxVisibleEi;
 _ZN7WebCore19AnimationController17suspendAnimationsEv;
 _ZN7WebCore19AnimationController16resumeAnimationsEv;
+_ZN7WebCore19AnimationController20pauseAnimationAtTimeEPNS_12RenderObjectERKN3WTF6StringEd;
+_ZN7WebCore19AnimationController21pauseTransitionAtTimeEPNS_12RenderObjectERKN3WTF6StringEd;
 _ZN7WebCore19InspectorController18setProfilerEnabledEb;
 _ZN7WebCore19InspectorController15profilerEnabledEv;
 _ZNK7WebCore19InspectorController12getHighlightEPNS_9HighlightE;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to