WebKitCSSKeyframeRule.style.parentRule should point to the keyframe rule.
<http://webkit.org/b/75336>
Reviewed by Antti Koivisto.
Source/WebCore:
Let CSS animation keyframe rules .style.parentRule point back to the keyframe
board, rather than the keyframes rule containing it.
Test: fast/css/css-keyframe-style-parentRule.html
* css/CSSParser.cpp:
(WebCore::CSSParser::createKeyframeRule):
* css/WebKitCSSKeyframeRule.cpp:
(WebCore::WebKitCSSKeyframeRule::setDeclaration):
Set the CSSMutableStyleDeclaration's parent rule when creating it instead
of in WebKitCSSKeyframeRule::setDeclaration(). Add assertion to make sure
it's only called with declarations already parented to the keyframe rule.
* css/WebKitCSSKeyframesRule.cpp:
(WebCore::WebKitCSSKeyframesRule::~WebKitCSSKeyframesRule):
(WebCore::WebKitCSSKeyframesRule::append):
(WebCore::WebKitCSSKeyframesRule::deleteRule):
Stop reparenting keyframe rules' style declarations to the keyframes rule.
LayoutTests:
* fast/css/css-keyframe-style-parentRule-expected.txt: Added.
* fast/css/css-keyframe-style-parentRule.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@103844 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 3220d1a..e9859a5 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2011-12-30 Andreas Kling <awesomekling@apple.com>
+
+ WebKitCSSKeyframeRule.style.parentRule should point to the keyframe rule.
+ <http://webkit.org/b/75336>
+
+ Reviewed by Antti Koivisto.
+
+ * fast/css/css-keyframe-style-parentRule-expected.txt: Added.
+ * fast/css/css-keyframe-style-parentRule.html: Added.
+
2011-12-30 Mikhail Naganov <mnaganov@chromium.org>
[Chromium] Unreviewed test expectations change for nested-reflection tests.
diff --git a/LayoutTests/fast/css/css-keyframe-style-parentRule-expected.txt b/LayoutTests/fast/css/css-keyframe-style-parentRule-expected.txt
new file mode 100644
index 0000000..90feae3
--- /dev/null
+++ b/LayoutTests/fast/css/css-keyframe-style-parentRule-expected.txt
@@ -0,0 +1,11 @@
+This test verifies that a keyframe rule's 'parentRule' points back to the keyframe rule.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rules[0][0].parentRule is rules[0]
+PASS rules[0][0].style.parentRule is rules[0][0]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/css/css-keyframe-style-parentRule.html b/LayoutTests/fast/css/css-keyframe-style-parentRule.html
new file mode 100644
index 0000000..89e7416
--- /dev/null
+++ b/LayoutTests/fast/css/css-keyframe-style-parentRule.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src="../js/resources/js-test-pre.js"></script>
+<style>
+ @-webkit-keyframes anim {
+ from {
+ color: green;
+ }
+ }
+</style>
+</head>
+<body>
+<script>
+
+description("This test verifies that a keyframe rule's 'parentRule' points back to the keyframe rule.");
+
+var rules = document.styleSheets[1].cssRules;
+
+shouldBe("rules[0][0].parentRule", "rules[0]");
+shouldBe("rules[0][0].style.parentRule", "rules[0][0]");
+
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 3b62923..f6d225c 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,31 @@
+2011-12-30 Andreas Kling <awesomekling@apple.com>
+
+ WebKitCSSKeyframeRule.style.parentRule should point to the keyframe rule.
+ <http://webkit.org/b/75336>
+
+ Reviewed by Antti Koivisto.
+
+ Let CSS animation keyframe rules .style.parentRule point back to the keyframe
+ board, rather than the keyframes rule containing it.
+
+ Test: fast/css/css-keyframe-style-parentRule.html
+
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::createKeyframeRule):
+ * css/WebKitCSSKeyframeRule.cpp:
+ (WebCore::WebKitCSSKeyframeRule::setDeclaration):
+
+ Set the CSSMutableStyleDeclaration's parent rule when creating it instead
+ of in WebKitCSSKeyframeRule::setDeclaration(). Add assertion to make sure
+ it's only called with declarations already parented to the keyframe rule.
+
+ * css/WebKitCSSKeyframesRule.cpp:
+ (WebCore::WebKitCSSKeyframesRule::~WebKitCSSKeyframesRule):
+ (WebCore::WebKitCSSKeyframesRule::append):
+ (WebCore::WebKitCSSKeyframesRule::deleteRule):
+
+ Stop reparenting keyframe rules' style declarations to the keyframes rule.
+
2011-12-30 Yury Semikhatsky <yurys@chromium.org>
Web Inspector: use typed front-end API in the memory agent
diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp
index 0176d00..7940b27 100644
--- a/Source/WebCore/css/CSSParser.cpp
+++ b/Source/WebCore/css/CSSParser.cpp
@@ -7829,7 +7829,7 @@
RefPtr<WebKitCSSKeyframeRule> keyframe = WebKitCSSKeyframeRule::create(m_styleSheet);
keyframe->setKeyText(keyString);
- keyframe->setDeclaration(CSSMutableStyleDeclaration::create(0, m_parsedProperties, m_numParsedProperties));
+ keyframe->setDeclaration(CSSMutableStyleDeclaration::create(keyframe.get(), m_parsedProperties, m_numParsedProperties));
clearProperties();
diff --git a/Source/WebCore/css/WebKitCSSKeyframeRule.cpp b/Source/WebCore/css/WebKitCSSKeyframeRule.cpp
index e9a2c6f..d53b1a3 100644
--- a/Source/WebCore/css/WebKitCSSKeyframeRule.cpp
+++ b/Source/WebCore/css/WebKitCSSKeyframeRule.cpp
@@ -54,8 +54,8 @@
void WebKitCSSKeyframeRule::setDeclaration(PassRefPtr<CSSMutableStyleDeclaration> style)
{
+ ASSERT(style->parentRule() == this);
m_style = style;
- m_style->setParentRule(this);
}
/* static */
diff --git a/Source/WebCore/css/WebKitCSSKeyframesRule.cpp b/Source/WebCore/css/WebKitCSSKeyframesRule.cpp
index c08122f..486cf1f 100644
--- a/Source/WebCore/css/WebKitCSSKeyframesRule.cpp
+++ b/Source/WebCore/css/WebKitCSSKeyframesRule.cpp
@@ -44,8 +44,6 @@
{
for (unsigned i = 0; i < length(); ++i) {
WebKitCSSKeyframeRule* rule = item(i);
- if (CSSMutableStyleDeclaration* style = rule->style())
- style->setParentRule(0);
rule->setParentRule(0);
}
}
@@ -81,9 +79,6 @@
m_lstCSSRules->append(rule);
rule->setParentRule(this);
-
- if (CSSMutableStyleDeclaration* style = rule->style())
- style->setParentRule(this);
}
void WebKitCSSKeyframesRule::insertRule(const String& rule)
@@ -101,9 +96,6 @@
return;
WebKitCSSKeyframeRule* rule = item(i);
- if (CSSMutableStyleDeclaration* style = rule->style())
- style->setParentRule(0);
-
rule->setParentRule(0);
m_lstCSSRules->deleteRule(i);
}