Bug 85253 - Apply animations and transitions for first-letter element
Summary: Apply animations and transitions for first-letter element
Status: REOPENED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 23209
  Show dependency treegraph
 
Reported: 2012-04-30 18:18 PDT by Igor Trindade Oliveira
Modified: 2017-07-18 08:30 PDT (History)
10 users (show)

See Also:


Attachments
Patch V1. (20.36 KB, patch)
2012-04-30 18:23 PDT, Igor Trindade Oliveira
no flags Details | Formatted Diff | Diff
Patch V2. (20.68 KB, patch)
2012-04-30 19:56 PDT, Igor Trindade Oliveira
no flags Details | Formatted Diff | Diff
Patch V3 (20.88 KB, patch)
2012-05-01 14:53 PDT, Igor Trindade Oliveira
simon.fraser: review-
Details | Formatted Diff | Diff
Patch V4. (25.14 KB, patch)
2012-05-03 18:10 PDT, Igor Trindade Oliveira
simon.fraser: review-
Details | Formatted Diff | Diff
Patch V5. (29.34 KB, patch)
2012-05-30 17:52 PDT, Igor Trindade Oliveira
simon.fraser: review-
simon.fraser: commit-queue-
Details | Formatted Diff | Diff
Patch V6. (29.36 KB, patch)
2012-06-01 12:39 PDT, Igor Trindade Oliveira
no flags Details | Formatted Diff | Diff
Patch V7. (28.94 KB, patch)
2012-06-01 18:22 PDT, Igor Trindade Oliveira
simon.fraser: review-
Details | Formatted Diff | Diff
Patch v8. (28.99 KB, patch)
2012-06-11 15:28 PDT, Igor Trindade Oliveira
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Trindade Oliveira 2012-04-30 18:18:06 PDT
apply animations and transitions for first-letter element
Comment 1 Igor Trindade Oliveira 2012-04-30 18:23:01 PDT
Created attachment 139564 [details]
Patch V1.

Proposed patch V1.
Comment 2 Igor Trindade Oliveira 2012-04-30 18:26:51 PDT
Let's broke the animation generated content patch in small patches, each generated element has a different behavior when animated.
The bug https://bugs.webkit.org/show_bug.cgi?id=23209 will be the meta bug for the generated content animations bug.
Comment 3 Igor Trindade Oliveira 2012-04-30 19:56:30 PDT
Created attachment 139573 [details]
Patch V2.

Improve changelog.
Comment 4 Simon Fraser (smfr) 2012-05-01 11:01:04 PDT

*** This bug has been marked as a duplicate of bug 23209 ***
Comment 5 Simon Fraser (smfr) 2012-05-01 11:02:14 PDT
Comment on attachment 139573 [details]
Patch V2.

I didn't look at this patch, but please fix this under bug 23209 (which already has a WIP patch).
Comment 6 Igor Trindade Oliveira 2012-05-01 13:54:35 PDT
Reopening the bug, now it blocks the bug #85253.
Comment 7 Igor Trindade Oliveira 2012-05-01 14:53:29 PDT
Created attachment 139687 [details]
Patch V3

Proposed patch.
Comment 8 Simon Fraser (smfr) 2012-05-01 15:01:32 PDT
Comment on attachment 139687 [details]
Patch V3

View in context: https://bugs.webkit.org/attachment.cgi?id=139687&action=review

> LayoutTests/ChangeLog:11
> +        * animations/first-letter-animation-expected.txt: Added.
> +        * animations/first-letter-animation.html: Added.
> +        * transitions/first-letter-color-transition-expected.txt: Added.
> +        * transitions/first-letter-color-transition.html: Added.

I think you should also test:
* transition on both an element and its pseudoelement, of the same and different properties
* animation on an element and its pseudoelement, to check that they can be controlled independently.

> Source/WebCore/rendering/RenderBlock.cpp:5975
> +    RefPtr<RenderStyle> temporaryStyle = RenderStyle::create();
> +    temporaryStyle->inheritFrom(firstLetterBlock->style());
> +    firstLetter->setStyle(temporaryStyle);  
>      firstLetterContainer->addChild(firstLetter, currentChild);
> +    
> +    RefPtr<RenderStyle> pseudoElementStyle = animation()->updateAnimations(firstLetter, pseudoStyle);
> +    firstLetter->setStyle(pseudoElementStyle);

It seems odd to call updateAnimaitons explicitly here. I think this logic should be wrapped up in a RenderObject method that we can possibly use elsewhere.
Comment 9 Igor Trindade Oliveira 2012-05-03 18:10:59 PDT
Created attachment 140139 [details]
Patch V4.

Updated patch.
Comment 10 Simon Fraser (smfr) 2012-05-04 10:49:47 PDT
Comment on attachment 140139 [details]
Patch V4.

View in context: https://bugs.webkit.org/attachment.cgi?id=140139&action=review

Tests still need to be improved.

> LayoutTests/animations/first-letter-animation.html:13
> +    .box {
> +      position: relative;
> +      left: 400px;
> +      top: 100px;
> +      width: 100px;
> +      height: 100px;
> +      background: blue;
> +      -webkit-animation: boxAnim 1s linear;

A one second test is way too slow. Can this test be changed to use the pauseAPI? (though that might need fixing for pseudos).

> LayoutTests/animations/first-letter-animation.html:29
> +    @-webkit-keyframes firstLetterAnim {
> +      from { margin: 0px; }
> +      to { margin: 100px; }
> +    }
> +
> +    @-webkit-keyframes boxAnim {
> +      from { -webkit-transform: scale(1); }
> +      to { -webkit-transform: scale(3); }

The interesting case is the same property being animated (in different ways) on the element and the pseudo, but you're not testing that here.

You should also test that setting animation-play-state affects the correct animation.

> LayoutTests/transitions/first-letter-color-transition.html:15
> +      -webkit-transition: color 1s;

Ditto.

> LayoutTests/transitions/first-letter-transition.html:23
> +      -webkit-transition: color 1s;
> +    }
> +
> +    #first {
> +      -webkit-transition: left 1s;
> +    }
> +
> +    #second {
> +      -webkit-transition: color 1s;

This test is also way too slow. Can it use the transition-test-helpers.js?

You also need to test a transition of the same property on the element and the pseudo, preferably where the transitions begin at different times.
Comment 11 Igor Trindade Oliveira 2012-05-30 17:50:04 PDT
(In reply to comment #10)
> (From update of attachment 140139 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=140139&action=review
> 
> Tests still need to be improved.
> 
> > LayoutTests/animations/first-letter-animation.html:13
> > +    .box {
> > +      position: relative;
> > +      left: 400px;
> > +      top: 100px;
> > +      width: 100px;
> > +      height: 100px;
> > +      background: blue;
> > +      -webkit-animation: boxAnim 1s linear;
> 
> A one second test is way too slow. Can this test be changed to use the pauseAPI? (though that might need fixing for pseudos).
> 

Normally pauseAPI is implemented using Document::getElementById to get the
Node information, however pseudo elements do not have Node.

> > LayoutTests/animations/first-letter-animation.html:29
> > +    @-webkit-keyframes firstLetterAnim {
> > +      from { margin: 0px; }
> > +      to { margin: 100px; }
> > +    }
> > +
> > +    @-webkit-keyframes boxAnim {
> > +      from { -webkit-transform: scale(1); }
> > +      to { -webkit-transform: scale(3); }
> 
> The interesting case is the same property being animated (in different ways) on the element and the pseudo, but you're not testing that here.
> 

Ok

> You should also test that setting animation-play-state affects the correct animation.
> 

Sure.

> > LayoutTests/transitions/first-letter-color-transition.html:15
> > +      -webkit-transition: color 1s;
> 
> Ditto.
> 
> > LayoutTests/transitions/first-letter-transition.html:23
> > +      -webkit-transition: color 1s;
> > +    }
> > +
> > +    #first {
> > +      -webkit-transition: left 1s;
> > +    }
> > +
> > +    #second {
> > +      -webkit-transition: color 1s;
> 
> This test is also way too slow. Can it use the transition-test-helpers.js?

transition-test-helpers.js and also animation helpers use getElementById and it does not work with pseudo elements.


> 
> You also need to test a transition of the same property on the element and the pseudo, preferably where the transitions begin at different times.

Ok.
Comment 12 Igor Trindade Oliveira 2012-05-30 17:52:43 PDT
Created attachment 144960 [details]
Patch V5.

Proposed patch.
Comment 13 Simon Fraser (smfr) 2012-05-31 14:45:59 PDT
Comment on attachment 144960 [details]
Patch V5.

View in context: https://bugs.webkit.org/attachment.cgi?id=144960&action=review

r- pending answers to my questions.

> LayoutTests/animations/first-letter-animation.html:11
> +      -webkit-animation: boxAnimation 0.5s 0.2s linear;

0.5s is still pretty long for one test. Imagine 100 of these; you've eaten 50s of every developer's time who runs tests.

> LayoutTests/animations/first-letter-animation.html:28
> +           }

Style rules would suggest this paren be aligned with the 'from'.

> LayoutTests/animations/first-letter-play-state.html:5
> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
> +<html lang="en">
> +<head>
> +  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
> +  <title>Test of -webkit-animation-play-state</title>

Could be simplified at match the other test.

> Source/WebCore/ChangeLog:8
> +        Instead of call RenderOject::node() in the animations code,

"of calling"

> Source/WebCore/rendering/RenderBlock.cpp:6020
> -    RenderStyle* pseudoStyle = styleForFirstLetter(firstLetterBlock, firstLetterContainer);
> +    RefPtr<RenderStyle> pseudoStyle = animation()->updateAnimations(firstLetter, styleForFirstLetter(firstLetterBlock, firstLetterContainer));

Why do we have to call updateAnimations() explicitly in this case, but in createFirstLetterRenderer() we can rely on setAnimatableStyle() to call updateAnimations() for us?

> Source/WebCore/rendering/RenderObject.cpp:2227
> +Node* RenderObject::generatingNode() const
> +{
> +    Node* node = m_node == document() ? 0 : m_node;
> +    if (node)
> +        return node;
> +
> +    for (RenderObject* object = parent(); object; object = object->parent()) {
> +        if (Node* node = (object->node() == object->document() ? 0 : object->node()))
> +            return node;
> +    }
> +    return 0;
> +}

Does this behavior change affect other calls to generatingNode(), like the counter code?
Comment 14 Igor Trindade Oliveira 2012-06-01 12:39:51 PDT
Created attachment 145358 [details]
Patch V6.

Proposed patch.
Comment 15 Igor Trindade Oliveira 2012-06-01 12:45:16 PDT
(In reply to comment #13)
> (From update of attachment 144960 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=144960&action=review
> 
> r- pending answers to my questions.
> 
> > LayoutTests/animations/first-letter-animation.html:11
> > +      -webkit-animation: boxAnimation 0.5s 0.2s linear;
> 
> 0.5s is still pretty long for one test. Imagine 100 of these; you've eaten 50s of every developer's time who runs tests.
> 

urgh!

> > LayoutTests/animations/first-letter-animation.html:28
> > +           }
> 
> Style rules would suggest this paren be aligned with the 'from'.
> 

Ok.

> > LayoutTests/animations/first-letter-play-state.html:5
> > +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
> > +<html lang="en">
> > +<head>
> > +  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
> > +  <title>Test of -webkit-animation-play-state</title>
> 
> Could be simplified at match the other test.
> 

Done.

> > Source/WebCore/ChangeLog:8
> > +        Instead of call RenderOject::node() in the animations code,
> 
> "of calling"

Fixed.

> 
> > Source/WebCore/rendering/RenderBlock.cpp:6020
> > -    RenderStyle* pseudoStyle = styleForFirstLetter(firstLetterBlock, firstLetterContainer);
> > +    RefPtr<RenderStyle> pseudoStyle = animation()->updateAnimations(firstLetter, styleForFirstLetter(firstLetterBlock, firstLetterContainer));
> 
> Why do we have to call updateAnimations() explicitly in this case, but in createFirstLetterRenderer() we can rely on setAnimatableStyle() to call updateAnimations() for us?
> 

Done.

> > Source/WebCore/rendering/RenderObject.cpp:2227
> > +Node* RenderObject::generatingNode() const
> > +{
> > +    Node* node = m_node == document() ? 0 : m_node;
> > +    if (node)
> > +        return node;
> > +
> > +    for (RenderObject* object = parent(); object; object = object->parent()) {
> > +        if (Node* node = (object->node() == object->document() ? 0 : object->node()))
> > +            return node;
> > +    }
> > +    return 0;
> > +}
> 
> Does this behavior change affect other calls to generatingNode(), like the counter code?

I ran the tests and all worked and i am see any crash. However for the new patch i am not changing generatingNode() anymore because RenderCounter had/has lot of security bugs and it is better unify styledGeneratingNode and generatingNode in other patch.
Comment 16 Igor Trindade Oliveira 2012-06-01 18:22:49 PDT
Created attachment 145416 [details]
Patch V7.

Fix a crash in first-letter tests.
Comment 17 Simon Fraser (smfr) 2012-06-05 11:30:29 PDT
Comment on attachment 145416 [details]
Patch V7.

View in context: https://bugs.webkit.org/attachment.cgi?id=145416&action=review

I think this needs one more round, but it's close. If you rename generatingNode(), you should do it as a first step in a separate patch.

> LayoutTests/animations/first-letter-play-state.html:11
> +      -webkit-animation: "move1" 0.2s linear;

Keyframe names are IDENTS and should not be quoted.

> LayoutTests/animations/first-letter-play-state.html:17
> +    @-webkit-keyframes "move1" {

Ditto.

> LayoutTests/animations/first-letter-play-state.html:21
> +    @-webkit-keyframes "firstLetterAnimation" {

Ditto.

> LayoutTests/animations/first-letter-play-state.html:43
> +    function stop()
> +    {
> +        document.getElementById("box1").style.webkitAnimationPlayState = "paused";
> +    }
> +
> +    function start()
> +    {
> +        document.getElementById("box1").style.webkitAnimationPlayState = "running";
> +    }

This isn't testing play-state on the pseudo animation, which I think is the interesting thing.

> LayoutTests/animations/first-letter-play-state.html:61
> +        }
> +            
> +    }

Extra line here.

> LayoutTests/transitions/first-letter-color-transition.html:42
> +    window.addEventListener( 'webkitTransitionEnd', transitionEnded, false );

Extra spaces inside the parens.

> Source/WebCore/rendering/RenderObject.h:585
> +    Node* styledGeneratingNode() const;

The comment for generatingNode() seems totally wrong, so maybe that one should be renamed. I'm not a big fan of styledGeneratingNode().

> Source/WebCore/rendering/RenderObject.h:668
> +    void setAnimatableStyle(PassRefPtr<RenderStyle>, bool isGeneratedContent = false);

I don't like the boolean parameter here. It's hard to read at the call site. Maybe two methods would be clearer.
Comment 18 Igor Trindade Oliveira 2012-06-11 15:24:59 PDT
(In reply to comment #17)
> (From update of attachment 145416 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=145416&action=review
> 
> I think this needs one more round, but it's close. If you rename generatingNode(), you should do it as a first step in a separate patch.
> 

Ok i will open a bug.

> > LayoutTests/animations/first-letter-play-state.html:11
> > +      -webkit-animation: "move1" 0.2s linear;
> 
> Keyframe names are IDENTS and should not be quoted.
> 
> > LayoutTests/animations/first-letter-play-state.html:17
> > +    @-webkit-keyframes "move1" {
> 
> Ditto.
> 

Ok.

> > LayoutTests/animations/first-letter-play-state.html:21
> > +    @-webkit-keyframes "firstLetterAnimation" {
> 
> Ditto.

Ok.

> 
> > LayoutTests/animations/first-letter-play-state.html:43
> > +    function stop()
> > +    {
> > +        document.getElementById("box1").style.webkitAnimationPlayState = "paused";
> > +    }
> > +
> > +    function start()
> > +    {
> > +        document.getElementById("box1").style.webkitAnimationPlayState = "running";
> > +    }
> 
> This isn't testing play-state on the pseudo animation, which I think is the interesting thing.
> 

You were right. I found a bug testing play-state on the pseudo element.

> > LayoutTests/animations/first-letter-play-state.html:61
> > +        }
> > +            
> > +    }
> 
> Extra line here.

Ok.

> 
> > LayoutTests/transitions/first-letter-color-transition.html:42
> > +    window.addEventListener( 'webkitTransitionEnd', transitionEnded, false );
> 
> Extra spaces inside the parens.

Ok

> 
> > Source/WebCore/rendering/RenderObject.h:585
> > +    Node* styledGeneratingNode() const;
> 
> The comment for generatingNode() seems totally wrong, so maybe that one should be renamed. I'm not a big fan of styledGeneratingNode().
> 

I also am not a big fan of styledGeneratingNode(), however i am not have a better name. I will open a bug to unify generatingNode and styledGeneratingNode so we can remove styledGeneratingNode soon.

> > Source/WebCore/rendering/RenderObject.h:668
> > +    void setAnimatableStyle(PassRefPtr<RenderStyle>, bool isGeneratedContent = false);
> 
> I don't like the boolean parameter here. It's hard to read at the call site. Maybe two methods would be clearer.

Yeah, in fact we do not need anymore this method. I am not animating the RenderTextFragment directly.
Comment 19 Igor Trindade Oliveira 2012-06-11 15:28:05 PDT
Created attachment 146929 [details]
Patch v8.
Comment 20 WebKit Review Bot 2012-06-12 14:08:36 PDT
Comment on attachment 146929 [details]
Patch v8.

Clearing flags on attachment: 146929

Committed r120119: <http://trac.webkit.org/changeset/120119>
Comment 21 WebKit Review Bot 2012-06-12 14:08:42 PDT
All reviewed patches have been landed.  Closing bug.
Comment 22 Ojan Vafai 2012-06-12 16:30:12 PDT
Does this test need to have actual test in box1? That means that for any port that uses different text rendering (most ports), this test will output two FAIL lines.
Comment 23 Ojan Vafai 2012-06-12 16:31:30 PDT
(In reply to comment #22)
> Does this test need to have actual test in box1? That means that for any port that uses different text rendering (most ports), this test will output two FAIL lines.

I'm talking about animations/first-letter-play-state.html.
Comment 24 Ojan Vafai 2012-06-12 16:36:18 PDT
(In reply to comment #23)
> (In reply to comment #22)
> > Does this test need to have actual test in box1? That means that for any port that uses different text rendering (most ports), this test will output two FAIL lines.
> 
> I'm talking about animations/first-letter-play-state.html.

Ugh...spoke too soon. This has nothing to do with text content. The chromium bots are all getting different values than what's in the acceptable range. I can't tell at the moment whether it's a chromium bug or a bug in the test.


+FAIL - "left" property for "box1" element at 0.1s expected: 200 but saw: 264.8057861328125
+FAIL - "left" property for "box1" element at 0.13s expected: 200 but saw: 264.8057861328125


+FAIL - "left" property for "box1" element at 0.1s expected: 200 but saw: 250
+FAIL - "left" property for "box1" element at 0.13s expected: 200 but saw: 250
Comment 25 Ojan Vafai 2012-06-12 16:53:09 PDT
Tracking the failure in bug 88937.
Comment 26 Igor Trindade Oliveira 2012-06-18 16:16:35 PDT
Rolled it out: https://trac.webkit.org/changeset/120639
Comment 27 Igor Trindade Oliveira 2012-07-23 17:03:11 PDT
This patch was reverted because it caused several security bugs. These bugs happen because the first-letter element is just created when RenderBlock::layout is called and for animations it is too late. Before work again on this bug we need to move the creation of first-letter elements out of the RenderBlock::layout. Maybe for a pre layout step.

(In reply to comment #26)
> Rolled it out: https://trac.webkit.org/changeset/120639