Ignore:
Timestamp:
Jan 27, 2015, 11:39:22 AM (10 years ago)
Author:
[email protected]
Message:

CSSKeyframesRule::findRule() and deleteRule() should delete the last matching rule, not the first
https://bugs.webkit.org/show_bug.cgi?id=139732

Patch by Sylvain Galineau <[email protected]> on 2015-01-26
Reviewed by Dean Jackson and Darin Adler.

Source/WebCore:

No new tests because existing tests have been updated to verify this behavior.

  • css/CSSKeyframeRule.h:

(WebCore::StyleKeyframe::getKeys): Deleted.

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::keyframeStylesForAnimation): use StyleKeyframe::keys().

  • css/CSSKeyframeRule.cpp:

(WebCore::StyleKeyframe::parseKeyString): Deleted. Moved to CSSParser.
(WebCore::StyleKeyframe::keyText): Build keyframe selector from Vector<double> representation.

  • css/CSSKeyframeRule.h:

(WebCore::StyleKeyframe::setKeyText): parse keyframe selector into Vector<double>.
(WebCore::StyleKeyframe::keys): Added. Returns vector representation of selector keys.
(WebCore::StyleKeyframe::getKeys): Deleted. Now keys().

  • css/CSSKeyframesRule.cpp:

(WebCore::StyleRuleKeyframes::findKeyframeIndex): Return last matching rule.

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseKeyframeSelector): Added. Moved from StyleKeyframe.

  • css/CSSParser.h:

(WebCore::CSSParser::parseKeyframeSelector): Added. Moved from StyleKeyframe.

LayoutTests:

Update existing keyframes OM tests to check for findRule/deleteRule matching order i.e. find/delete last specified rule.

  • animations/keyframes-rule-expected.txt:
  • animations/keyframes-rule.html:
  • animations/unprefixed-keyframes-rule-expected.txt:
  • animations/unprefixed-keyframes-rule.html:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSKeyframeRule.cpp

    r177259 r179197  
    5050}
    5151
    52 /* static */
    53 void StyleKeyframe::parseKeyString(const String& s, Vector<double>& keys)
     52String StyleKeyframe::keyText() const
    5453{
    55     keys.clear();
    56     Vector<String> strings;
    57     s.split(',', strings);
     54    StringBuilder keyText;
    5855
    59     for (size_t i = 0; i < strings.size(); ++i) {
    60         double key = -1;
    61         String cur = strings[i].stripWhiteSpace();
     56    for (size_t i = 0; i < m_keys.size(); ++i) {
     57        if (i)
     58            keyText.append(',');
     59        keyText.appendNumber(m_keys.at(i) * 100);
     60        keyText.append('%');
     61    }
    6262
    63         // For now the syntax MUST be 'xxx%' or 'from' or 'to', where xxx is a legal floating point number
    64         if (cur == "from")
    65             key = 0;
    66         else if (cur == "to")
    67             key = 1;
    68         else if (cur.endsWith('%')) {
    69             double k = cur.substring(0, cur.length() - 1).toDouble();
    70             if (k >= 0 && k <= 100)
    71                 key = k / 100;
    72         }
    73         if (key < 0) {
    74             keys.clear();
    75             return;
    76         }
    77         keys.append(key);
    78     }
     63    return keyText.toString();
    7964}
    8065
Note: See TracChangeset for help on using the changeset viewer.