Changeset 36347 in webkit
- Timestamp:
- Sep 11, 2008 5:36:31 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r36343 r36347 1 2008-09-08 Chris Marrin <cmarrin@apple.com> 2 3 Reviewed by Dave Hyatt 4 5 Need to support comma separated list of key times in keyframes selectors 6 https://bugs.webkit.org/show_bug.cgi?id=20680 7 8 * animations/keyframes-comma-separated-expected.txt: Added. 9 * animations/keyframes-comma-separated.html: Added. 10 1 11 2008-09-11 Kevin McCullough <kmccullough@apple.com> 2 12 -
trunk/WebCore/ChangeLog
r36343 r36347 1 2008-09-08 Chris Marrin <cmarrin@apple.com> 2 3 Reviewed by Dave Hyatt 4 5 Need to support comma separated list of key times in keyframes selectors 6 https://bugs.webkit.org/show_bug.cgi?id=20680 7 8 Test: animations/keyframes-comma-separated.html 9 10 * css/CSSGrammar.y: 11 * css/CSSParser.cpp: 12 (WebCore::CSSParser::createKeyframeRule): 13 * css/CSSParser.h: 14 * css/CSSStyleSelector.cpp: 15 (WebCore::CSSStyleSelector::addKeyframeStyle): 16 * css/WebKitCSSKeyframeRule.cpp: 17 (WebCore::WebKitCSSKeyframeRule::WebKitCSSKeyframeRule): 18 (WebCore::WebKitCSSKeyframeRule::cssText): 19 (WebCore::WebKitCSSKeyframeRule::parseKeyString): 20 * css/WebKitCSSKeyframeRule.h: 21 (WebCore::WebKitCSSKeyframeRule::keyText): 22 (WebCore::WebKitCSSKeyframeRule::setKeyText): 23 (WebCore::WebKitCSSKeyframeRule::getKeys): 24 * css/WebKitCSSKeyframesRule.cpp: 25 (WebCore::WebKitCSSKeyframesRule::append): 26 (WebCore::WebKitCSSKeyframesRule::insertRule): 27 (WebCore::WebKitCSSKeyframesRule::deleteRule): 28 (WebCore::WebKitCSSKeyframesRule::findRule): 29 (WebCore::WebKitCSSKeyframesRule::findRuleIndex): 30 * css/WebKitCSSKeyframesRule.h: 31 * page/animation/AnimationBase.cpp: 32 (WebCore::AnimationBase::blendProperties): 33 1 34 2008-09-11 Kevin McCullough <kmccullough@apple.com> 2 35 -
trunk/WebCore/css/CSSGrammar.y
r36278 r36347 217 217 %type <keyframeRule> keyframe_rule 218 218 %type <keyframesRule> keyframes_rule 219 %type <val> key 219 %type <valueList> key_list 220 %type <value> key 220 221 221 222 %type <integer> property … … 698 699 $$ = $1; 699 700 if ($2) 700 $$-> insert($2);701 $$->append($2); 701 702 } 702 703 ; 703 704 704 705 keyframe_rule: 705 key maybe_space '{' maybe_space declaration_list '}' {706 key_list maybe_space '{' maybe_space declaration_list '}' { 706 707 $$ = static_cast<CSSParser*>(parser)->createKeyframeRule($1); 707 708 } 708 709 ; 709 710 711 key_list: 712 key { 713 CSSParser* p = static_cast<CSSParser*>(parser); 714 $$ = p->createFloatingValueList(); 715 $$->addValue(p->sinkFloatingValue($1)); 716 } 717 | key_list maybe_space ',' maybe_space key { 718 CSSParser* p = static_cast<CSSParser*>(parser); 719 $$ = $1; 720 if ($$) 721 $$->addValue(p->sinkFloatingValue($5)); 722 } 723 ; 724 710 725 key: 711 PERCENTAGE { $$ = (float) $1; }726 PERCENTAGE { $$.id = 0; $$.isInt = false; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_NUMBER; } 712 727 | IDENT { 713 $$ = -1;728 $$.id = 0; $$.isInt = false; $$.unit = CSSPrimitiveValue::CSS_NUMBER; 714 729 CSSParserString& str = $1; 715 730 if (equalIgnoringCase(static_cast<const String&>(str), "from")) 716 $$ = 0;731 $$.fValue = 0; 717 732 else if (equalIgnoringCase(static_cast<const String&>(str), "to")) 718 $$ = 100;733 $$.fValue = 100; 719 734 else 720 735 YYERROR; -
trunk/WebCore/css/CSSParser.cpp
r36046 r36347 4686 4686 } 4687 4687 4688 WebKitCSSKeyframeRule* CSSParser::createKeyframeRule(float key) 4689 { 4688 WebKitCSSKeyframeRule* CSSParser::createKeyframeRule(CSSParserValueList* keys) 4689 { 4690 // Create a key string from the passed keys 4691 String keyString; 4692 for (unsigned i = 0; i < keys->size(); ++i) { 4693 float key = (float) keys->valueAt(i)->fValue; 4694 if (i != 0) 4695 keyString += ","; 4696 keyString += String::number(key); 4697 keyString += "%"; 4698 } 4699 4690 4700 RefPtr<WebKitCSSKeyframeRule> keyframe = WebKitCSSKeyframeRule::create(m_styleSheet); 4691 4692 keyframe->setKey(key); 4701 keyframe->setKeyText(keyString); 4693 4702 keyframe->setDeclaration(CSSMutableStyleDeclaration::create(0, m_parsedProperties, m_numParsedProperties)); 4703 4694 4704 clearProperties(); 4695 4705 -
trunk/WebCore/css/CSSParser.h
r35910 r36347 166 166 CSSRule* createCharsetRule(const CSSParserString&); 167 167 CSSRule* createImportRule(const CSSParserString&, MediaList*); 168 WebKitCSSKeyframeRule* createKeyframeRule( float key);168 WebKitCSSKeyframeRule* createKeyframeRule(CSSParserValueList*); 169 169 WebKitCSSKeyframesRule* createKeyframesRule(); 170 170 CSSRule* createMediaRule(MediaList*, CSSRuleList*); -
trunk/WebCore/css/CSSStyleSelector.cpp
r36339 r36347 440 440 void CSSStyleSelector::addKeyframeStyle(Document* doc, const WebKitCSSKeyframesRule* rule) 441 441 { 442 // Create the keyframe list 442 443 AtomicString s(rule->name()); 443 444 RefPtr<KeyframeList> list; … … 450 451 list->clear(); 451 452 452 // Make sure there is a 0% and a 100% keyframe 453 if (rule->item(0)->key() || rule->item(rule->length() - 1)->key() != 1) 454 return; 455 453 // Add all the keyframes 456 454 for (unsigned i = 0; i < rule->length(); ++i) { 457 455 const WebKitCSSKeyframeRule* kf = rule->item(i); … … 460 458 CSSMutableStyleDeclaration* decl = kf->style(); 461 459 DeprecatedValueListConstIterator<CSSProperty> end; 460 461 // Record all the properties in this keyframe 462 462 for (DeprecatedValueListConstIterator<CSSProperty> it = decl->valuesIterator(); it != end; ++it) { 463 463 const CSSProperty& current = *it; … … 465 465 list->addProperty(current.id()); 466 466 } 467 list->insert(kf->key(), *m_style); 467 468 // Add this keyframe to all the indicated key times 469 Vector<float> keys; 470 kf->getKeys(keys); 471 472 for (size_t keyIndex = 0; keyIndex < keys.size(); ++keyIndex) { 473 float key = keys[keyIndex]; 474 list->insert(key, *m_style); 475 } 476 468 477 m_style->deref(doc->renderArena()); 469 478 m_style = 0; 479 } 480 481 // Make sure there is a 0% and a 100% keyframe 482 float first = list->beginKeyframes()->key; 483 float last = (list->endKeyframes()-1)->key; 484 if (first != 0 || last != 1) { 485 list->clear(); 486 return; 470 487 } 471 488 } -
trunk/WebCore/css/WebKitCSSKeyframeRule.cpp
r35580 r36347 33 33 WebKitCSSKeyframeRule::WebKitCSSKeyframeRule(CSSStyleSheet* parent) 34 34 : CSSRule(parent) 35 , m_key(0)36 35 { 37 36 } … … 43 42 } 44 43 45 String WebKitCSSKeyframeRule::keyText() const46 {47 return String::number(m_key) + "%";48 }49 50 void WebKitCSSKeyframeRule::setKeyText(const String& s)51 {52 m_key = keyStringToFloat(s);53 }54 55 44 String WebKitCSSKeyframeRule::cssText() const 56 45 { 57 String result = String::number(m_key);46 String result = m_key; 58 47 59 result += " %{ ";48 result += " { "; 60 49 result += m_style->cssText(); 61 50 result += "}"; … … 77 66 78 67 /* static */ 79 float WebKitCSSKeyframeRule::keyStringToFloat(const String&s)68 void WebKitCSSKeyframeRule::parseKeyString(const String& s, Vector<float>& keys) 80 69 { 81 float key = 0; 70 keys.clear(); 71 Vector<String> strings; 72 s.split(',', strings); 82 73 83 // for now the syntax MUST be 'xxx%' or 'from' or 'to', where xxx is a legal floating point number 84 if (s == "from") 85 key = 0; 86 else if (s == "to") 87 key = 100; 88 else { 89 if (s.endsWith("%")) { 90 float k = s.substring(0, s.length() - 1).toFloat(); 74 for (size_t i = 0; i < strings.size(); ++i) { 75 float key = -1; 76 String cur = strings[i].stripWhiteSpace(); 77 78 // For now the syntax MUST be 'xxx%' or 'from' or 'to', where xxx is a legal floating point number 79 if (cur == "from") 80 key = 0; 81 else if (cur == "to") 82 key = 1; 83 else if (cur.endsWith("%")) { 84 float k = cur.substring(0, cur.length() - 1).toFloat(); 91 85 if (k >= 0 && k <= 100) 92 key = k ;86 key = k/100; 93 87 } 88 89 if (key < 0) { 90 keys.clear(); 91 return; 92 } 93 else 94 keys.append(key); 94 95 } 95 96 return key;97 96 } 98 97 -
trunk/WebCore/css/WebKitCSSKeyframeRule.h
r35580 r36347 55 55 virtual unsigned short type() const { return WEBKIT_KEYFRAME_RULE; } 56 56 57 String keyText() const; 58 void setKeyText(const String& s); 57 String keyText() const { return m_key; } 58 void setKeyText(const String& s) { m_key = s; } 59 60 void getKeys(Vector<float>& keys) const { parseKeyString(m_key, keys); } 59 61 60 62 CSSMutableStyleDeclaration* style() const { return m_style.get(); } … … 65 67 virtual bool parseString(const String&, bool = false); 66 68 67 float key() const { return m_key/100; }68 float keyAsPercent() const { return m_key; }69 70 void setKey(float k) { m_key = k; }71 69 void setDeclaration(PassRefPtr<CSSMutableStyleDeclaration>); 72 70 … … 74 72 const CSSMutableStyleDeclaration* declaration() const { return m_style.get(); } 75 73 76 static float keyStringToFloat(const String& s);77 78 74 private: 75 static void parseKeyString(const String& s, Vector<float>& keys); 76 79 77 WebKitCSSKeyframeRule(CSSStyleSheet* parent); 80 78 81 79 RefPtr<CSSMutableStyleDeclaration> m_style; 82 float m_key; // 0 to 10080 String m_key; // comma separated list of keys 83 81 }; 84 82 -
trunk/WebCore/css/WebKitCSSKeyframesRule.cpp
r35580 r36347 82 82 } 83 83 84 void WebKitCSSKeyframesRule:: insert(WebKitCSSKeyframeRule* rule)84 void WebKitCSSKeyframesRule::append(WebKitCSSKeyframeRule* rule) 85 85 { 86 float key = rule->keyAsPercent();87 88 for (unsigned i = 0; i < length(); ++i) {89 if (item(i)->keyAsPercent() == key) {90 m_lstCSSRules.get()->deleteRule(i);91 m_lstCSSRules.get()->insertRule(rule, i);92 return;93 }94 if (item(i)->keyAsPercent() > key) {95 // insert before96 m_lstCSSRules.get()->insertRule(rule, i);97 return;98 }99 }100 101 // append102 86 m_lstCSSRules.get()->append(rule); 103 87 stylesheet()->styleSheetChanged(); … … 109 93 RefPtr<CSSRule> newRule = p.parseKeyframeRule(parentStyleSheet(), rule); 110 94 if (newRule.get() && newRule.get()->isKeyframeRule()) 111 insert(static_cast<WebKitCSSKeyframeRule*>(newRule.get()));95 append(static_cast<WebKitCSSKeyframeRule*>(newRule.get())); 112 96 } 113 97 114 98 void WebKitCSSKeyframesRule::deleteRule(const String& s) 115 99 { 116 float key = WebKitCSSKeyframeRule::keyStringToFloat(s); 117 int i = findRuleIndex(key); 100 int i = findRuleIndex(s); 118 101 if (i >= 0) { 119 102 m_lstCSSRules.get()->deleteRule(i); … … 124 107 WebKitCSSKeyframeRule* WebKitCSSKeyframesRule::findRule(const String& s) 125 108 { 126 float key = WebKitCSSKeyframeRule::keyStringToFloat(s); 127 int i = findRuleIndex(key); 109 int i = findRuleIndex(s); 128 110 return (i >= 0) ? item(i) : 0; 129 111 } 130 112 131 int WebKitCSSKeyframesRule::findRuleIndex( floatkey) const113 int WebKitCSSKeyframesRule::findRuleIndex(const String& key) const 132 114 { 133 115 for (unsigned i = 0; i < length(); ++i) { 134 if (item(i)->key AsPercent() == key)116 if (item(i)->keyText() == key) 135 117 return i; 136 118 } -
trunk/WebCore/css/WebKitCSSKeyframesRule.h
r35580 r36347 73 73 WebKitCSSKeyframeRule* item(unsigned index); 74 74 const WebKitCSSKeyframeRule* item(unsigned index) const; 75 void insert(WebKitCSSKeyframeRule* rule);75 void append(WebKitCSSKeyframeRule* rule); 76 76 77 77 private: 78 78 WebKitCSSKeyframesRule(CSSStyleSheet* parent); 79 79 80 int findRuleIndex( floatkey) const;80 int findRuleIndex(const String& key) const; 81 81 82 82 RefPtr<CSSRuleList> m_lstCSSRules; -
trunk/WebCore/page/animation/AnimationBase.cpp
r36322 r36347 419 419 ASSERT(prop != cAnimateAll); 420 420 // FIXME: Why can this happen? 421 422 ensurePropertyMap(); 421 423 if (prop == cAnimateAll) { 422 424 bool needsTimer = false;
Note: See TracChangeset
for help on using the changeset viewer.