Title: [97468] trunk/Source/WebCore
Revision
97468
Author
[email protected]
Date
2011-10-14 08:32:57 -0700 (Fri, 14 Oct 2011)

Log Message

Stricter management of WebKitCSSKeyframeRules.
https://bugs.webkit.org/show_bug.cgi?id=70109

Reviewed by Antti Koivisto.

Covered by existing tests.

* css/CSSParser.h:
* css/CSSParser.cpp:
(WebCore::CSSParser::parseKeyframeRule):

    Return a WebKitCSSKeyframeRule instead of a CSSRule.

* css/CSSRuleList.cpp:
(WebCore::CSSRuleList::deleteRule):
* css/WebKitCSSKeyframesRule.cpp:
(WebCore::WebKitCSSKeyframesRule::deleteRule):

    Moved style sheet orphaning logic for @-webkit-keyframe
    from CSSRuleList into WebKitCSSKeyframesRule::deleteRule()
    since that's the only caller operating on those rules.

* css/WebKitCSSKeyframesRule.cpp:
(WebCore::WebKitCSSKeyframesRule::~WebKitCSSKeyframesRule):
(WebCore::WebKitCSSKeyframesRule::length):
(WebCore::WebKitCSSKeyframesRule::item):
(WebCore::WebKitCSSKeyframesRule::insertRule):

    Change isKeyframeRule() checks to assertions since we know
    our rules are always WebKitCSSKeyframeRules. Also tidied up.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (97467 => 97468)


--- trunk/Source/WebCore/ChangeLog	2011-10-14 15:10:22 UTC (rev 97467)
+++ trunk/Source/WebCore/ChangeLog	2011-10-14 15:32:57 UTC (rev 97468)
@@ -1,5 +1,38 @@
 2011-10-14  Andreas Kling  <[email protected]>
 
+        Stricter management of WebKitCSSKeyframeRules.
+        https://bugs.webkit.org/show_bug.cgi?id=70109
+
+        Reviewed by Antti Koivisto.
+
+        Covered by existing tests.
+
+        * css/CSSParser.h:
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseKeyframeRule):
+
+            Return a WebKitCSSKeyframeRule instead of a CSSRule.
+
+        * css/CSSRuleList.cpp:
+        (WebCore::CSSRuleList::deleteRule):
+        * css/WebKitCSSKeyframesRule.cpp:
+        (WebCore::WebKitCSSKeyframesRule::deleteRule):
+
+            Moved style sheet orphaning logic for @-webkit-keyframe
+            from CSSRuleList into WebKitCSSKeyframesRule::deleteRule()
+            since that's the only caller operating on those rules.
+
+        * css/WebKitCSSKeyframesRule.cpp:
+        (WebCore::WebKitCSSKeyframesRule::~WebKitCSSKeyframesRule):
+        (WebCore::WebKitCSSKeyframesRule::length):
+        (WebCore::WebKitCSSKeyframesRule::item):
+        (WebCore::WebKitCSSKeyframesRule::insertRule):
+
+            Change isKeyframeRule() checks to assertions since we know
+            our rules are always WebKitCSSKeyframeRules. Also tidied up.
+
+2011-10-14  Andreas Kling  <[email protected]>
+
         Unreviewed, actually remove StyleList.* after r97640.
 
         * css/StyleList.cpp: Removed.

Modified: trunk/Source/WebCore/css/CSSParser.cpp (97467 => 97468)


--- trunk/Source/WebCore/css/CSSParser.cpp	2011-10-14 15:10:22 UTC (rev 97467)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2011-10-14 15:32:57 UTC (rev 97468)
@@ -285,7 +285,7 @@
     return m_rule.release();
 }
 
-PassRefPtr<CSSRule> CSSParser::parseKeyframeRule(CSSStyleSheet *sheet, const String &string)
+PassRefPtr<WebKitCSSKeyframeRule> CSSParser::parseKeyframeRule(CSSStyleSheet *sheet, const String &string)
 {
     setStyleSheet(sheet);
     setupParser("@-webkit-keyframe-rule{ ", string, "} ");

Modified: trunk/Source/WebCore/css/CSSParser.h (97467 => 97468)


--- trunk/Source/WebCore/css/CSSParser.h	2011-10-14 15:10:22 UTC (rev 97467)
+++ trunk/Source/WebCore/css/CSSParser.h	2011-10-14 15:32:57 UTC (rev 97468)
@@ -65,7 +65,7 @@
 
     void parseSheet(CSSStyleSheet*, const String&, int startLineNumber = 0, StyleRuleRangeMap* ruleRangeMap = 0);
     PassRefPtr<CSSRule> parseRule(CSSStyleSheet*, const String&);
-    PassRefPtr<CSSRule> parseKeyframeRule(CSSStyleSheet*, const String&);
+    PassRefPtr<WebKitCSSKeyframeRule> parseKeyframeRule(CSSStyleSheet*, const String&);
     static bool parseValue(CSSMutableStyleDeclaration*, int propId, const String&, bool important, bool strict);
     static bool parseColor(RGBA32& color, const String&, bool strict = false);
     static bool parseSystemColor(RGBA32& color, const String&, Document*);
@@ -258,7 +258,7 @@
     int m_id;
     CSSStyleSheet* m_styleSheet;
     RefPtr<CSSRule> m_rule;
-    RefPtr<CSSRule> m_keyframe;
+    RefPtr<WebKitCSSKeyframeRule> m_keyframe;
     OwnPtr<MediaQuery> m_mediaQuery;
     CSSParserValueList* m_valueList;
     CSSProperty** m_parsedProperties;

Modified: trunk/Source/WebCore/css/CSSRuleList.cpp (97467 => 97468)


--- trunk/Source/WebCore/css/CSSRuleList.cpp	2011-10-14 15:10:22 UTC (rev 97467)
+++ trunk/Source/WebCore/css/CSSRuleList.cpp	2011-10-14 15:32:57 UTC (rev 97468)
@@ -75,11 +75,6 @@
     if (index >= m_lstCSSRules.size())
         return;
 
-    if (m_lstCSSRules[index]->isKeyframeRule()) {
-        if (CSSMutableStyleDeclaration* style = static_cast<WebKitCSSKeyframeRule*>(m_lstCSSRules[index].get())->style())
-            style->setParent(0);
-    }
-
     m_lstCSSRules[index]->setParent(0);
     m_lstCSSRules.remove(index);
 }

Modified: trunk/Source/WebCore/css/WebKitCSSKeyframesRule.cpp (97467 => 97468)


--- trunk/Source/WebCore/css/WebKitCSSKeyframesRule.cpp	2011-10-14 15:10:22 UTC (rev 97467)
+++ trunk/Source/WebCore/css/WebKitCSSKeyframesRule.cpp	2011-10-14 15:32:57 UTC (rev 97468)
@@ -42,16 +42,11 @@
 
 WebKitCSSKeyframesRule::~WebKitCSSKeyframesRule()
 {
-    int length = m_lstCSSRules->length();
-    if (length == 0)
-        return;
-        
-    for (int i = 0; i < length; i++) {
-        if (m_lstCSSRules->item(i)->isKeyframeRule()) {
-            if (CSSMutableStyleDeclaration* style = static_cast<WebKitCSSKeyframeRule*>(m_lstCSSRules->item(i))->style())
-                style->setParent(0);
-        }
-        m_lstCSSRules->item(i)->setParent(0);
+    for (unsigned i = 0; i < length(); ++i) {
+        WebKitCSSKeyframeRule* rule = item(i);
+        if (CSSMutableStyleDeclaration* style = rule->style())
+            style->setParent(0);
+        rule->setParent(0);
     }
 }
 
@@ -72,19 +67,21 @@
 
 unsigned WebKitCSSKeyframesRule::length() const
 {
-    return m_lstCSSRules.get()->length();
+    return m_lstCSSRules->length();
 }
 
 WebKitCSSKeyframeRule* WebKitCSSKeyframesRule::item(unsigned index)
 {
-    CSSRule* rule = m_lstCSSRules.get()->item(index);
-    return (rule && rule->isKeyframeRule()) ? static_cast<WebKitCSSKeyframeRule*>(rule) : 0;
+    CSSRule* rule = m_lstCSSRules->item(index);
+    ASSERT(rule->isKeyframeRule());
+    return static_cast<WebKitCSSKeyframeRule*>(rule);
 }
 
 const WebKitCSSKeyframeRule* WebKitCSSKeyframesRule::item(unsigned index) const
 {
-    CSSRule* rule = m_lstCSSRules.get()->item(index);
-    return (rule && rule->isKeyframeRule()) ? static_cast<const WebKitCSSKeyframeRule*>(rule) : 0;
+    const CSSRule* rule = m_lstCSSRules->item(index);
+    ASSERT(rule->isKeyframeRule());
+    return static_cast<const WebKitCSSKeyframeRule*>(rule);
 }
 
 void WebKitCSSKeyframesRule::append(WebKitCSSKeyframeRule* rule)
@@ -102,16 +99,22 @@
 void WebKitCSSKeyframesRule::insertRule(const String& rule)
 {
     CSSParser p(useStrictParsing());
-    RefPtr<CSSRule> newRule = p.parseKeyframeRule(parentStyleSheet(), rule);
-    if (newRule.get() && newRule.get()->isKeyframeRule())
-        append(static_cast<WebKitCSSKeyframeRule*>(newRule.get()));
+    RefPtr<WebKitCSSKeyframeRule> newRule = p.parseKeyframeRule(parentStyleSheet(), rule);
+    if (newRule)
+        append(newRule.get());
 }
 
 void WebKitCSSKeyframesRule::deleteRule(const String& s)
 {
     int i = findRuleIndex(s);
-    if (i >= 0)
-        m_lstCSSRules.get()->deleteRule(i);
+    if (i < 0)
+        return;
+
+    WebKitCSSKeyframeRule* rule = item(i);
+    if (CSSMutableStyleDeclaration* style = rule->style())
+        style->setParent(0);
+
+    m_lstCSSRules->deleteRule(i);
 }
 
 WebKitCSSKeyframeRule* WebKitCSSKeyframesRule::findRule(const String& s)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to