Changeset 120119 in webkit


Ignore:
Timestamp:
Jun 12, 2012 2:08:18 PM (12 years ago)
Author:
igor.o@sisa.samsung.com
Message:

Apply animations and transitions for first-letter element
https://bugs.webkit.org/show_bug.cgi?id=85253

Source/WebCore:

Add animations and transitions support for the first-letter
pseudo element.
Instead of calling RenderOject::node() in the animations code,
now we need to call RenderObject::styledGeneratingNode() because
pseudo elements does not have a Node associated with the
RenderObject.

Initial patch by Simon Fraser

Reviewed by Simon Fraser.

Tests: animations/first-letter-animation.html

animations/first-letter-play-state.html
transitions/first-letter-color-transition.html
transitions/first-letter-transition.html

  • page/animation/AnimationBase.cpp:

(WebCore::AnimationBase::updateStateMachine):

  • page/animation/AnimationController.cpp:

(WebCore::AnimationControllerPrivate::updateAnimations):
(WebCore::AnimationControllerPrivate::pauseAnimationAtTime):
(WebCore::AnimationControllerPrivate::pauseTransitionAtTime):
(WebCore::AnimationController::cancelAnimations):
(WebCore::AnimationController::updateAnimations):

  • page/animation/ImplicitAnimation.cpp:

(WebCore::ImplicitAnimation::pauseAnimation):
(WebCore::ImplicitAnimation::sendTransitionEvent):

  • page/animation/KeyframeAnimation.cpp:

(WebCore::KeyframeAnimation::KeyframeAnimation):
(WebCore::KeyframeAnimation::pauseAnimation):
(WebCore::KeyframeAnimation::endAnimation):
(WebCore::KeyframeAnimation::sendAnimationEvent):

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::updateFirstLetterStyle):
(WebCore::RenderBlock::createFirstLetterRenderer):

  • rendering/RenderInline.cpp:

(WebCore::RenderInline::clippedOverflowRectForRepaint):

  • rendering/RenderObject.cpp:

(WebCore::RenderObject::setAnimatableStyle):
(WebCore::RenderObject::styledGeneratingNode):
(WebCore):

  • rendering/RenderObject.h:

(RenderObject):

LayoutTests:

Reviewed by Simon Fraser.

  • animations/first-letter-animation-expected.txt: Added.
  • animations/first-letter-animation.html: Added.
  • animations/first-letter-play-state-expected.txt: Added.
  • animations/first-letter-play-state.html: Added.
  • transitions/first-letter-color-transition-expected.txt: Added.
  • transitions/first-letter-color-transition.html: Added.
  • transitions/first-letter-transition-expected.txt: Added.
  • transitions/first-letter-transition.html: Added.
Location:
trunk
Files:
8 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r120118 r120119  
     12012-06-12  Igor Oliveira  <igor.o@sisa.samsung.com>
     2
     3        Apply animations and transitions for first-letter element
     4        https://bugs.webkit.org/show_bug.cgi?id=85253
     5
     6        Reviewed by Simon Fraser.
     7
     8        * animations/first-letter-animation-expected.txt: Added.
     9        * animations/first-letter-animation.html: Added.
     10        * animations/first-letter-play-state-expected.txt: Added.
     11        * animations/first-letter-play-state.html: Added.
     12        * transitions/first-letter-color-transition-expected.txt: Added.
     13        * transitions/first-letter-color-transition.html: Added.
     14        * transitions/first-letter-transition-expected.txt: Added.
     15        * transitions/first-letter-transition.html: Added.
     16
    1172012-06-12  Kent Tamura  <tkent@chromium.org>
    218
  • trunk/Source/WebCore/ChangeLog

    r120118 r120119  
     12012-06-12  Igor Oliveira  <igor.o@sisa.samsung.com>
     2
     3        Apply animations and transitions for first-letter element
     4        https://bugs.webkit.org/show_bug.cgi?id=85253
     5
     6        Add animations and transitions support for the first-letter
     7        pseudo element.
     8        Instead of calling RenderOject::node() in the animations code,
     9        now we need to call RenderObject::styledGeneratingNode() because
     10        pseudo elements does not have a Node associated with the
     11        RenderObject.
     12
     13        Initial patch by Simon Fraser
     14
     15        Reviewed by Simon Fraser.
     16
     17        Tests: animations/first-letter-animation.html
     18               animations/first-letter-play-state.html
     19               transitions/first-letter-color-transition.html
     20               transitions/first-letter-transition.html
     21
     22        * page/animation/AnimationBase.cpp:
     23        (WebCore::AnimationBase::updateStateMachine):
     24        * page/animation/AnimationController.cpp:
     25        (WebCore::AnimationControllerPrivate::updateAnimations):
     26        (WebCore::AnimationControllerPrivate::pauseAnimationAtTime):
     27        (WebCore::AnimationControllerPrivate::pauseTransitionAtTime):
     28        (WebCore::AnimationController::cancelAnimations):
     29        (WebCore::AnimationController::updateAnimations):
     30        * page/animation/ImplicitAnimation.cpp:
     31        (WebCore::ImplicitAnimation::pauseAnimation):
     32        (WebCore::ImplicitAnimation::sendTransitionEvent):
     33        * page/animation/KeyframeAnimation.cpp:
     34        (WebCore::KeyframeAnimation::KeyframeAnimation):
     35        (WebCore::KeyframeAnimation::pauseAnimation):
     36        (WebCore::KeyframeAnimation::endAnimation):
     37        (WebCore::KeyframeAnimation::sendAnimationEvent):
     38        * rendering/RenderBlock.cpp:
     39        (WebCore::RenderBlock::updateFirstLetterStyle):
     40        (WebCore::RenderBlock::createFirstLetterRenderer):
     41        * rendering/RenderInline.cpp:
     42        (WebCore::RenderInline::clippedOverflowRectForRepaint):
     43        * rendering/RenderObject.cpp:
     44        (WebCore::RenderObject::setAnimatableStyle):
     45        (WebCore::RenderObject::styledGeneratingNode):
     46        (WebCore):
     47        * rendering/RenderObject.h:
     48        (RenderObject):
     49
    1502012-06-12  Kent Tamura  <tkent@chromium.org>
    251
  • trunk/Source/WebCore/page/animation/AnimationBase.cpp

    r115581 r120119  
    192192                // Trigger a render so we can start the animation
    193193                if (m_object)
    194                     m_compAnim->animationController()->addNodeChangeToDispatch(m_object->node());
     194                    m_compAnim->animationController()->addNodeChangeToDispatch(m_object->styledGeneratingNode());
    195195            } else {
    196196                ASSERT(!paused());
     
    253253                // Dispatch updateStyleIfNeeded so we can start the animation
    254254                if (m_object)
    255                     m_compAnim->animationController()->addNodeChangeToDispatch(m_object->node());
     255                    m_compAnim->animationController()->addNodeChangeToDispatch(m_object->styledGeneratingNode());
    256256            } else {
    257257                // We are pausing while waiting for a start response. Cancel the animation and wait. When
     
    299299
    300300                    // Fire off another style change so we can set the final value
    301                     m_compAnim->animationController()->addNodeChangeToDispatch(m_object->node());
     301                    m_compAnim->animationController()->addNodeChangeToDispatch(m_object->styledGeneratingNode());
    302302                }
    303303            } else {
  • trunk/Source/WebCore/page/animation/AnimationController.cpp

    r118052 r120119  
    101101            if (!timeToNextService) {
    102102                if (callSetChanged == CallSetChanged) {
    103                     Node* node = it->first->node();
     103                    Node* node = it->first->styledGeneratingNode();
    104104                    ASSERT(!node || (node->document() && !node->document()->inPageCache()));
    105105                    node->setNeedsStyleRecalc(SyntheticStyleChange);
     
    329329
    330330    if (compAnim->pauseAnimationAtTime(name, t)) {
    331         renderer->node()->setNeedsStyleRecalc(SyntheticStyleChange);
     331        renderer->styledGeneratingNode()->setNeedsStyleRecalc(SyntheticStyleChange);
    332332        startUpdateStyleIfNeededDispatcher();
    333333        return true;
     
    347347
    348348    if (compAnim->pauseTransitionAtTime(cssPropertyID(property), t)) {
    349         renderer->node()->setNeedsStyleRecalc(SyntheticStyleChange);
     349        renderer->styledGeneratingNode()->setNeedsStyleRecalc(SyntheticStyleChange);
    350350        startUpdateStyleIfNeededDispatcher();
    351351        return true;
     
    509509
    510510    if (m_data->clear(renderer)) {
    511         Node* node = renderer->node();
     511        Node* node = renderer->styledGeneratingNode();
    512512        ASSERT(!node || (node->document() && !node->document()->inPageCache()));
    513513        node->setNeedsStyleRecalc(SyntheticStyleChange);
     
    534534    // have changed, we reset the animation.  We then do a blend to get new values and we return
    535535    // a new style.
    536     ASSERT(renderer->node()); // FIXME: We do not animate generated content yet.
    537536
    538537    RefPtr<CompositeAnimation> rendererAnimations = m_data->accessCompositeAnimation(renderer);
  • trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp

    r115581 r120119  
    130130    // Restore the original (unanimated) style
    131131    if (!paused())
    132         setNeedsStyleRecalc(m_object->node());
     132        setNeedsStyleRecalc(m_object->styledGeneratingNode());
    133133}
    134134
     
    166166            // Dispatch the event
    167167            RefPtr<Element> element = 0;
    168             if (m_object->node() && m_object->node()->isElementNode())
    169                 element = static_cast<Element*>(m_object->node());
     168            if (m_object->styledGeneratingNode() && m_object->styledGeneratingNode()->isElementNode())
     169                element = static_cast<Element*>(m_object->styledGeneratingNode());
    170170
    171171            ASSERT(!element || (element->document() && !element->document()->inPageCache()));
  • trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp

    r115581 r120119  
    5252{
    5353    // Get the keyframe RenderStyles
    54     if (m_object && m_object->node() && m_object->node()->isElementNode())
    55         m_object->document()->styleResolver()->keyframeStylesForAnimation(static_cast<Element*>(m_object->node()), unanimatedStyle, m_keyframes);
     54    if (m_object && m_object->styledGeneratingNode() && m_object->styledGeneratingNode()->isElementNode())
     55        m_object->document()->styleResolver()->keyframeStylesForAnimation(static_cast<Element*>(m_object->styledGeneratingNode()), unanimatedStyle, m_keyframes);
    5656
    5757    // Update the m_transformFunctionListValid flag based on whether the function lists in the keyframes match.
     
    256256    // Restore the original (unanimated) style
    257257    if (!paused())
    258         setNeedsStyleRecalc(m_object->node());
     258        setNeedsStyleRecalc(m_object->styledGeneratingNode());
    259259}
    260260
     
    270270    // Restore the original (unanimated) style
    271271    if (!paused())
    272         setNeedsStyleRecalc(m_object->node());
     272        setNeedsStyleRecalc(m_object->styledGeneratingNode());
    273273}
    274274
     
    315315        // Dispatch the event
    316316        RefPtr<Element> element;
    317         if (m_object->node() && m_object->node()->isElementNode())
    318             element = static_cast<Element*>(m_object->node());
     317        if (m_object->styledGeneratingNode() && m_object->styledGeneratingNode()->isElementNode())
     318            element = static_cast<Element*>(m_object->styledGeneratingNode());
    319319
    320320        ASSERT(!element || (element->document() && !element->document()->inPageCache()));
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r119893 r120119  
    60526052        firstLetter = newFirstLetter;
    60536053        firstLetterContainer->addChild(firstLetter, nextSibling);
    6054     } else
    6055         firstLetter->setStyle(pseudoStyle);
     6054    }
     6055
     6056    firstLetter->setAnimatableStyle(pseudoStyle);
    60566057
    60576058    for (RenderObject* genChild = firstLetter->firstChild(); genChild; genChild = genChild->nextSibling()) {
    60586059        if (genChild->isText())
    6059             genChild->setStyle(pseudoStyle);
     6060            genChild->setStyle(firstLetter->style());
    60606061    }
    60616062}
     
    60706071    else
    60716072        firstLetter = new (renderArena()) RenderBlock(document());
    6072     firstLetter->setStyle(pseudoStyle);
     6073
     6074    RefPtr<RenderStyle> temporaryStyle = RenderStyle::create();
     6075    temporaryStyle->inheritFrom(firstLetterBlock->style());
     6076    firstLetter->setStyle(temporaryStyle); 
    60736077    firstLetterContainer->addChild(firstLetter, currentChild);
     6078   
     6079    firstLetter->setAnimatableStyle(pseudoStyle);
    60746080
    60756081    RenderText* textObj = toRenderText(currentChild);
     
    61196125        RenderTextFragment* letter =
    61206126            new (renderArena()) RenderTextFragment(remainingText->node() ? remainingText->node() : remainingText->document(), oldText.get(), 0, length);
    6121         letter->setStyle(pseudoStyle);
     6127        letter->setStyle(firstLetter->style());
    61226128        firstLetter->addChild(letter);
    61236129
  • trunk/Source/WebCore/rendering/RenderInline.cpp

    r119884 r120119  
    954954LayoutRect RenderInline::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const
    955955{
    956     // Only run-ins are allowed in here during layout.
    957     ASSERT(!view() || !view()->layoutStateEnabled() || isRunIn());
     956    // Only run-ins and first-letter elements are allowed in here during layout.
     957    ASSERT(!view() || !view()->layoutStateEnabled() || isRunIn() || style()->styleType() == FIRST_LETTER);
    958958
    959959    if (!firstLineBoxIncludingCulling() && !continuation())
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r119914 r120119  
    21352135}
    21362136
     2137Node* RenderObject::styledGeneratingNode() const
     2138{
     2139    Node* node = generatingNode();
     2140    if (node)
     2141        return node;
     2142
     2143    for (RenderObject* object = parent(); object; object = object->parent()) {
     2144        if (Node* node = object->generatingNode())
     2145            return node;
     2146    }
     2147
     2148    ASSERT_NOT_REACHED();
     2149    return 0;
     2150}
     2151
    21372152RenderObject* RenderObject::rendererForRootBackground()
    21382153{
  • trunk/Source/WebCore/rendering/RenderObject.h

    r119765 r120119  
    564564    Node* node() const { return isAnonymous() ? 0 : m_node; }
    565565
    566     // Returns the styled node that caused the generation of this renderer.
    567     // This is the same as node() except for renderers of :before and :after
     566    // This is the same as node() except for renderers of :before. :after and first-letter
    568567    // pseudo elements for which their parent node is returned.
    569568    Node* generatingNode() const { return m_node == document() ? 0 : m_node; }
     569
     570    // Returns the styled node that caused the generation of this renderer.
     571    // This is the same as node() except for anonymous renderers, for which
     572    // it returns the node whose style caused the generation of this renderer.
     573    // FIXME: merge with generatingNode()
     574    Node* styledGeneratingNode() const;
     575
    570576    void setNode(Node* node) { m_node = node; }
    571577
     
    649655
    650656    // Called to update a style that is allowed to trigger animations.
    651     // FIXME: Right now this will typically be called only when updating happens from the DOM on explicit elements.
    652     // We don't yet handle generated content animation such as first-letter or before/after (we'll worry about this later).
    653657    void setAnimatableStyle(PassRefPtr<RenderStyle>);
    654658
Note: See TracChangeset for help on using the changeset viewer.