Changeset 156912 in webkit


Ignore:
Timestamp:
Oct 4, 2013 1:46:57 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Inserting a JS generated keyframe animation shouldn't trigger a whole document style recalc
https://bugs.webkit.org/show_bug.cgi?id=119479

Patch by Ralph Thomas <ralpht@gmail.com> on 2013-10-04
Reviewed by Antti Koivisto.

Change CSSStyleSheet::didMutateRules to not invalidate all node's styles when inserting a
@-webkit-keyframes rule, and to instead insert the rule directly into the StyleResolver.

Test: animation/keyframes-dynamic.html: adds and removes keyframe rules using JavaScript and
validates that the correct elements are animated.

  • css/CSSStyleSheet.cpp:

(WebCore::CSSStyleSheet::didMutateRules):
(WebCore::CSSStyleSheet::insertRule):

  • css/CSSStyleSheet.h:
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r156909 r156912  
     12013-10-04  Ralph Thomas  <ralpht@gmail.com>
     2
     3        Inserting a JS generated keyframe animation shouldn't trigger a whole document style recalc
     4        https://bugs.webkit.org/show_bug.cgi?id=119479
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Change CSSStyleSheet::didMutateRules to not invalidate all node's styles when inserting a
     9        @-webkit-keyframes rule, and to instead insert the rule directly into the StyleResolver.
     10
     11        Test: animation/keyframes-dynamic.html: adds and removes keyframe rules using JavaScript and
     12        validates that the correct elements are animated.
     13
     14        * css/CSSStyleSheet.cpp:
     15        (WebCore::CSSStyleSheet::didMutateRules):
     16        (WebCore::CSSStyleSheet::insertRule):
     17        * css/CSSStyleSheet.h:
     18
    1192013-10-04  Zan Dobersek  <zdobersek@igalia.com>
    220
  • trunk/Source/WebCore/css/CSSStyleSheet.cpp

    r156550 r156912  
    3838#include "SVGNames.h"
    3939#include "SecurityOrigin.h"
     40#include "StyleResolver.h"
    4041#include "StyleRule.h"
    4142#include "StyleSheetContents.h"
     43#include "WebKitCSSKeyframesRule.h"
    4244#include <wtf/text/StringBuilder.h>
    4345
     
    158160}
    159161
    160 void CSSStyleSheet::didMutateRules(RuleMutationType mutationType, WhetherContentsWereClonedForMutation contentsWereClonedForMutation)
     162void CSSStyleSheet::didMutateRules(RuleMutationType mutationType, WhetherContentsWereClonedForMutation contentsWereClonedForMutation, StyleRuleKeyframes* insertedKeyframesRule)
    161163{
    162164    ASSERT(m_contents->isMutable());
     
    168170
    169171    if (mutationType == RuleInsertion && !contentsWereClonedForMutation && !owner->styleSheetCollection().activeStyleSheetsContains(this)) {
     172        if (insertedKeyframesRule) {
     173            if (StyleResolver* resolver = owner->styleResolverIfExists())
     174                resolver->addKeyframeStyle(insertedKeyframesRule);
     175            return;
     176        }
    170177        owner->scheduleOptimizedStyleSheetUpdate();
    171178        return;
     
    296303    }
    297304
    298     RuleMutationScope mutationScope(this, RuleInsertion);
     305    RuleMutationScope mutationScope(this, RuleInsertion, rule->type() == StyleRuleBase::Keyframes ? static_cast<StyleRuleKeyframes*>(rule.get()) : 0);
    299306
    300307    bool success = m_contents->wrapperInsertRule(rule, index);
     
    402409}
    403410
    404 CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSStyleSheet* sheet, RuleMutationType mutationType)
     411CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSStyleSheet* sheet, RuleMutationType mutationType, StyleRuleKeyframes* insertedKeyframesRule)
    405412    : m_styleSheet(sheet)
    406413    , m_mutationType(mutationType)
     414    , m_insertedKeyframesRule(insertedKeyframesRule)
    407415{
    408416    ASSERT(m_styleSheet);
     
    414422    , m_mutationType(OtherMutation)
    415423    , m_contentsWereClonedForMutation(ContentsWereNotClonedForMutation)
     424    , m_insertedKeyframesRule(nullptr)
    416425{
    417426    if (m_styleSheet)
     
    422431{
    423432    if (m_styleSheet)
    424         m_styleSheet->didMutateRules(m_mutationType, m_contentsWereClonedForMutation);
    425 }
    426 
    427 }
     433        m_styleSheet->didMutateRules(m_mutationType, m_contentsWereClonedForMutation, m_insertedKeyframesRule);
     434}
     435
     436}
  • trunk/Source/WebCore/css/CSSStyleSheet.h

    r156550 r156912  
    4141class MediaQuerySet;
    4242class SecurityOrigin;
     43class StyleRuleKeyframes;
    4344class StyleSheetContents;
    4445
     
    9293        WTF_MAKE_NONCOPYABLE(RuleMutationScope);
    9394    public:
    94         RuleMutationScope(CSSStyleSheet*, RuleMutationType = OtherMutation);
     95        RuleMutationScope(CSSStyleSheet*, RuleMutationType = OtherMutation, StyleRuleKeyframes* insertedKeyframesRule = nullptr);
    9596        RuleMutationScope(CSSRule*);
    9697        ~RuleMutationScope();
     
    100101        RuleMutationType m_mutationType;
    101102        WhetherContentsWereClonedForMutation m_contentsWereClonedForMutation;
     103        StyleRuleKeyframes* m_insertedKeyframesRule;
    102104    };
    103105
    104106    WhetherContentsWereClonedForMutation willMutateRules();
    105     void didMutateRules(RuleMutationType, WhetherContentsWereClonedForMutation);
     107    void didMutateRules(RuleMutationType, WhetherContentsWereClonedForMutation, StyleRuleKeyframes* insertedKeyframesRule);
    106108    void didMutateRuleFromCSSStyleDeclaration();
    107109    void didMutate();
Note: See TracChangeset for help on using the changeset viewer.