<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[179197] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/179197">179197</a></dd>
<dt>Author</dt> <dd>dino@apple.com</dd>
<dt>Date</dt> <dd>2015-01-27 11:39:22 -0800 (Tue, 27 Jan 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>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 <galineau@adobe.com> 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:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsanimationskeyframesruleexpectedtxt">trunk/LayoutTests/animations/keyframes-rule-expected.txt</a></li>
<li><a href="#trunkLayoutTestsanimationskeyframesrulehtml">trunk/LayoutTests/animations/keyframes-rule.html</a></li>
<li><a href="#trunkLayoutTestsanimationsunprefixedkeyframesruleexpectedtxt">trunk/LayoutTests/animations/unprefixed-keyframes-rule-expected.txt</a></li>
<li><a href="#trunkLayoutTestsanimationsunprefixedkeyframesrulehtml">trunk/LayoutTests/animations/unprefixed-keyframes-rule.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssCSSKeyframeRulecpp">trunk/Source/WebCore/css/CSSKeyframeRule.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSKeyframeRuleh">trunk/Source/WebCore/css/CSSKeyframeRule.h</a></li>
<li><a href="#trunkSourceWebCorecssCSSKeyframesRulecpp">trunk/Source/WebCore/css/CSSKeyframesRule.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSParsercpp">trunk/Source/WebCore/css/CSSParser.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSParserh">trunk/Source/WebCore/css/CSSParser.h</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolvercpp">trunk/Source/WebCore/css/StyleResolver.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (179196 => 179197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-01-27 19:16:00 UTC (rev 179196)
+++ trunk/LayoutTests/ChangeLog        2015-01-27 19:39:22 UTC (rev 179197)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2015-01-26 Sylvain Galineau <galineau@adobe.com>
+
+ CSSKeyframesRule::findRule() and deleteRule() should delete the last matching rule, not the first
+ https://bugs.webkit.org/show_bug.cgi?id=139732
+
+ Reviewed by Dean Jackson and Darin Adler.
+
+ 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:
+
</ins><span class="cx"> 2015-01-27 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Unreviewed, rebaseline fast/css/css2-system-fonts.html on iOS.
</span></span></pre></div>
<a id="trunkLayoutTestsanimationskeyframesruleexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/animations/keyframes-rule-expected.txt (179196 => 179197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/animations/keyframes-rule-expected.txt        2015-01-27 19:16:00 UTC (rev 179196)
+++ trunk/LayoutTests/animations/keyframes-rule-expected.txt        2015-01-27 19:39:22 UTC (rev 179197)
</span><span class="lines">@@ -75,6 +75,41 @@
</span><span class="cx"> PASS rules2.item(0).keyText is '0%'
</span><span class="cx"> PASS rules2.item(1).keyText is '100%'
</span><span class="cx">
</span><ins>+findRule matching order: from last to first specified
+PASS keyframesFindLast.type is window.CSSRule.KEYFRAMES_RULE
+PASS keyframesFindLast.name is 'test-find-last'
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+PASS rule.cssText is '10% { left: 10px; }'
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+PASS rule.cssText is '10% { left: 10px; }'
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+FAIL rule.cssText should be 10%,20% { left: 10px; }. Was 10%,20% { left: 1020px; }.
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+FAIL rule.cssText should be 10%,20% { left: 10px; }. Was 10%,20% { left: 1020px; }.
+PASS rule is null
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+PASS rule.cssText is '0% { left: 0px; }'
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+PASS rule.cssText is '100% { left: 100px; }'
+
+deleteRule matching order: from last to first specified
+PASS keyframesDeleteLast.type is window.CSSRule.KEYFRAMES_RULE
+PASS keyframesDeleteLast.name is 'test-delete-last'
+PASS rulesDeleteLast.length is 8
+PASS rulesDeleteLast.length is 7
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+PASS rule.cssText is '10% { left: 10px; }'
+PASS rulesDeleteLast.length is 6
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+PASS rule.cssText is '10%,20% { left: 1020px; }'
+PASS rulesDeleteLast.length is 6
+PASS rulesDeleteLast.length is 5
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+PASS rule.cssText is '0% { left: 0px; }'
+PASS rulesDeleteLast.length is 4
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+PASS rule.cssText is '100% { left: 100px; }'
+
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx">
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsanimationskeyframesrulehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/animations/keyframes-rule.html (179196 => 179197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/animations/keyframes-rule.html        2015-01-27 19:16:00 UTC (rev 179196)
+++ trunk/LayoutTests/animations/keyframes-rule.html        2015-01-27 19:39:22 UTC (rev 179197)
</span><span class="lines">@@ -15,6 +15,27 @@
</span><span class="cx"> 50% { left: 30px; }
</span><span class="cx"> to { left: 20px; }
</span><span class="cx"> }
</span><ins>+ @-webkit-keyframes test-find-last {
+ from { left: -1px; }
+ 0% { left: 0px; }
+ 10% { left: -1px; }
+ 10% { left: 10px;}
+ 10%, 20% { left: -1px; }
+ 10%,20% { left: 1020px; }
+ 100% { left: -1px; }
+ to { left: 100px; }
+ }
+ @-webkit-keyframes test-delete-last {
+ from { left: 0px; }
+ 0% { left: -1px; }
+ 10% { left: 10px; }
+ 10% { left: -1px;}
+ 10%, 20% { left: 1020px; }
+ 10%,20% { left: -1px; }
+ 100% { left: 100px; }
+ to { left: -1px; }
+ }
+
</ins><span class="cx"> </style>
</span><span class="cx"> <script src="../resources/js-test-pre.js"></script>
</span><span class="cx"> </head>
</span><span class="lines">@@ -168,7 +189,69 @@
</span><span class="cx"> shouldBe("rules2.item(1).keyText", "'100%'");
</span><span class="cx">
</span><span class="cx"> debug("");
</span><ins>+debug("findRule matching order: from last to first specified");
</ins><span class="cx">
</span><ins>+var keyframesFindLast = document.styleSheets.item(0).cssRules.item(3);
+shouldBe("keyframesFindLast.type", "window.CSSRule.KEYFRAMES_RULE");
+shouldBe("keyframesFindLast.name", "'test-find-last'");
+
+
+rule = keyframesFindLast.findRule("10%");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'10% { left: 10px; }'");
+rule = keyframesFindLast.findRule("10.0%");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'10% { left: 10px; }'");
+rule = keyframesFindLast.findRule("10%,20%");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'10%,20% { left: 10px; }'");
+rule = keyframesFindLast.findRule(" 10%, 20% ");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'10%,20% { left: 10px; }'");
+rule = keyframesFindLast.findRule("20%, 10% ");
+shouldBe("rule", "null");
+rule = keyframesFindLast.findRule("from");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'0% { left: 0px; }'");
+rule = keyframesFindLast.findRule("100%");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'100% { left: 100px; }'");
+
+debug("");
+debug("deleteRule matching order: from last to first specified");
+
+var keyframesDeleteLast = document.styleSheets.item(0).cssRules.item(4);
+shouldBe("keyframesDeleteLast.type", "window.CSSRule.KEYFRAMES_RULE");
+shouldBe("keyframesDeleteLast.name", "'test-delete-last'");
+
+var rulesDeleteLast = keyframesDeleteLast.cssRules;
+shouldBe("rulesDeleteLast.length", "8");
+
+keyframesDeleteLast.deleteRule("10%");
+shouldBe("rulesDeleteLast.length", "7");
+rule = keyframesDeleteLast.findRule("10%");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'10% { left: 10px; }'");
+keyframesDeleteLast.deleteRule("10%,20%");
+shouldBe("rulesDeleteLast.length", "6");
+rule = keyframesDeleteLast.findRule("10%,20%");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'10%,20% { left: 1020px; }'");
+keyframesDeleteLast.deleteRule("20%, 10% ");
+shouldBe("rulesDeleteLast.length", "6");
+keyframesDeleteLast.deleteRule("from");
+shouldBe("rulesDeleteLast.length", "5");
+rule = keyframesDeleteLast.findRule("from");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'0% { left: 0px; }'");
+keyframesDeleteLast.deleteRule("100%");
+shouldBe("rulesDeleteLast.length", "4");
+rule = keyframesDeleteLast.findRule("100%");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'100% { left: 100px; }'");
+
+debug("");
+
</ins><span class="cx"> </script>
</span><span class="cx"> <script src="../resources/js-test-post.js"></script>
</span><span class="cx"> </body>
</span></span></pre></div>
<a id="trunkLayoutTestsanimationsunprefixedkeyframesruleexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/animations/unprefixed-keyframes-rule-expected.txt (179196 => 179197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/animations/unprefixed-keyframes-rule-expected.txt        2015-01-27 19:16:00 UTC (rev 179196)
+++ trunk/LayoutTests/animations/unprefixed-keyframes-rule-expected.txt        2015-01-27 19:39:22 UTC (rev 179197)
</span><span class="lines">@@ -75,6 +75,41 @@
</span><span class="cx"> PASS rules2.item(0).keyText is '0%'
</span><span class="cx"> PASS rules2.item(1).keyText is '100%'
</span><span class="cx">
</span><ins>+findRule matching order: from last to first specified
+PASS keyframesFindLast.type is window.CSSRule.KEYFRAMES_RULE
+PASS keyframesFindLast.name is 'test-find-last'
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+PASS rule.cssText is '10% { left: 10px; }'
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+PASS rule.cssText is '10% { left: 10px; }'
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+FAIL rule.cssText should be 10%,20% { left: 10px; }. Was 10%,20% { left: 1020px; }.
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+FAIL rule.cssText should be 10%,20% { left: 10px; }. Was 10%,20% { left: 1020px; }.
+PASS rule is null
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+PASS rule.cssText is '0% { left: 0px; }'
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+PASS rule.cssText is '100% { left: 100px; }'
+
+deleteRule matching order: from last to first specified
+PASS keyframesDeleteLast.type is window.CSSRule.KEYFRAMES_RULE
+PASS keyframesDeleteLast.name is 'test-delete-last'
+PASS rulesDeleteLast.length is 8
+PASS rulesDeleteLast.length is 7
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+PASS rule.cssText is '10% { left: 10px; }'
+PASS rulesDeleteLast.length is 6
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+PASS rule.cssText is '10%,20% { left: 1020px; }'
+PASS rulesDeleteLast.length is 6
+PASS rulesDeleteLast.length is 5
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+PASS rule.cssText is '0% { left: 0px; }'
+PASS rulesDeleteLast.length is 4
+PASS rule.type is window.CSSRule.KEYFRAME_RULE
+PASS rule.cssText is '100% { left: 100px; }'
+
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx">
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsanimationsunprefixedkeyframesrulehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/animations/unprefixed-keyframes-rule.html (179196 => 179197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/animations/unprefixed-keyframes-rule.html        2015-01-27 19:16:00 UTC (rev 179196)
+++ trunk/LayoutTests/animations/unprefixed-keyframes-rule.html        2015-01-27 19:39:22 UTC (rev 179197)
</span><span class="lines">@@ -15,6 +15,27 @@
</span><span class="cx"> 50% { left: 30px; }
</span><span class="cx"> to { left: 20px; }
</span><span class="cx"> }
</span><ins>+ @keyframes test-find-last {
+ from { left: -1px; }
+ 0% { left: 0px; }
+ 10% { left: -1px; }
+ 10% { left: 10px;}
+ 10%, 20% { left: -1px; }
+ 10%,20% { left: 1020px; }
+ 100% { left: -1px; }
+ to { left: 100px; }
+ }
+ @keyframes test-delete-last {
+ from { left: 0px; }
+ 0% { left: -1px; }
+ 10% { left: 10px; }
+ 10% { left: -1px;}
+ 10%, 20% { left: 1020px; }
+ 10%,20% { left: -1px; }
+ 100% { left: 100px; }
+ to { left: -1px; }
+ }
+
</ins><span class="cx"> </style>
</span><span class="cx"> <script src="../resources/js-test-pre.js"></script>
</span><span class="cx"> </head>
</span><span class="lines">@@ -168,7 +189,69 @@
</span><span class="cx"> shouldBe("rules2.item(1).keyText", "'100%'");
</span><span class="cx">
</span><span class="cx"> debug("");
</span><ins>+debug("findRule matching order: from last to first specified");
</ins><span class="cx">
</span><ins>+var keyframesFindLast = document.styleSheets.item(0).cssRules.item(3);
+shouldBe("keyframesFindLast.type", "window.CSSRule.KEYFRAMES_RULE");
+shouldBe("keyframesFindLast.name", "'test-find-last'");
+
+
+rule = keyframesFindLast.findRule("10%");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'10% { left: 10px; }'");
+rule = keyframesFindLast.findRule("10.0%");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'10% { left: 10px; }'");
+rule = keyframesFindLast.findRule("10%,20%");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'10%,20% { left: 10px; }'");
+rule = keyframesFindLast.findRule(" 10%, 20% ");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'10%,20% { left: 10px; }'");
+rule = keyframesFindLast.findRule("20%, 10% ");
+shouldBe("rule", "null");
+rule = keyframesFindLast.findRule("from");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'0% { left: 0px; }'");
+rule = keyframesFindLast.findRule("100%");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'100% { left: 100px; }'");
+
+debug("");
+debug("deleteRule matching order: from last to first specified");
+
+var keyframesDeleteLast = document.styleSheets.item(0).cssRules.item(4);
+shouldBe("keyframesDeleteLast.type", "window.CSSRule.KEYFRAMES_RULE");
+shouldBe("keyframesDeleteLast.name", "'test-delete-last'");
+
+var rulesDeleteLast = keyframesDeleteLast.cssRules;
+shouldBe("rulesDeleteLast.length", "8");
+
+keyframesDeleteLast.deleteRule("10%");
+shouldBe("rulesDeleteLast.length", "7");
+rule = keyframesDeleteLast.findRule("10%");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'10% { left: 10px; }'");
+keyframesDeleteLast.deleteRule("10%,20%");
+shouldBe("rulesDeleteLast.length", "6");
+rule = keyframesDeleteLast.findRule("10%,20%");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'10%,20% { left: 1020px; }'");
+keyframesDeleteLast.deleteRule("20%, 10% ");
+shouldBe("rulesDeleteLast.length", "6");
+keyframesDeleteLast.deleteRule("from");
+shouldBe("rulesDeleteLast.length", "5");
+rule = keyframesDeleteLast.findRule("from");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'0% { left: 0px; }'");
+keyframesDeleteLast.deleteRule("100%");
+shouldBe("rulesDeleteLast.length", "4");
+rule = keyframesDeleteLast.findRule("100%");
+shouldBe("rule.type", "window.CSSRule.KEYFRAME_RULE");
+shouldBe("rule.cssText", "'100% { left: 100px; }'");
+
+debug("");
+
</ins><span class="cx"> </script>
</span><span class="cx"> <script src="../resources/js-test-post.js"></script>
</span><span class="cx"> </body>
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (179196 => 179197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-01-27 19:16:00 UTC (rev 179196)
+++ trunk/Source/WebCore/ChangeLog        2015-01-27 19:39:22 UTC (rev 179197)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2015-01-26 Sylvain Galineau <galineau@adobe.com>
+
+ CSSKeyframesRule::findRule() and deleteRule() should delete the last matching rule, not the first
+ https://bugs.webkit.org/show_bug.cgi?id=139732
+
+ Reviewed by Dean Jackson and Darin Adler.
+
+ 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.
+
</ins><span class="cx"> 2015-01-26 Geoffrey Garen <ggaren@apple.com>
</span><span class="cx">
</span><span class="cx"> Use FastMalloc (bmalloc) instead of BlockAllocator for GC pages
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSKeyframeRulecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSKeyframeRule.cpp (179196 => 179197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSKeyframeRule.cpp        2015-01-27 19:16:00 UTC (rev 179196)
+++ trunk/Source/WebCore/css/CSSKeyframeRule.cpp        2015-01-27 19:39:22 UTC (rev 179197)
</span><span class="lines">@@ -49,33 +49,18 @@
</span><span class="cx"> return downcast<MutableStyleProperties>(m_properties.get());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-/* static */
-void StyleKeyframe::parseKeyString(const String& s, Vector<double>& keys)
</del><ins>+String StyleKeyframe::keyText() const
</ins><span class="cx"> {
</span><del>- keys.clear();
- Vector<String> strings;
- s.split(',', strings);
</del><ins>+ StringBuilder keyText;
</ins><span class="cx">
</span><del>- for (size_t i = 0; i < strings.size(); ++i) {
- double key = -1;
- String cur = strings[i].stripWhiteSpace();
-
- // For now the syntax MUST be 'xxx%' or 'from' or 'to', where xxx is a legal floating point number
- if (cur == "from")
- key = 0;
- else if (cur == "to")
- key = 1;
- else if (cur.endsWith('%')) {
- double k = cur.substring(0, cur.length() - 1).toDouble();
- if (k >= 0 && k <= 100)
- key = k / 100;
- }
- if (key < 0) {
- keys.clear();
- return;
- }
- keys.append(key);
</del><ins>+ for (size_t i = 0; i < m_keys.size(); ++i) {
+ if (i)
+ keyText.append(',');
+ keyText.appendNumber(m_keys.at(i) * 100);
+ keyText.append('%');
</ins><span class="cx"> }
</span><ins>+
+ return keyText.toString();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> String StyleKeyframe::cssText() const
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSKeyframeRuleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSKeyframeRule.h (179196 => 179197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSKeyframeRule.h        2015-01-27 19:16:00 UTC (rev 179196)
+++ trunk/Source/WebCore/css/CSSKeyframeRule.h        2015-01-27 19:39:22 UTC (rev 179197)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #ifndef CSSKeyframeRule_h
</span><span class="cx"> #define CSSKeyframeRule_h
</span><span class="cx">
</span><ins>+#include "CSSParser.h"
</ins><span class="cx"> #include "CSSRule.h"
</span><span class="cx"> #include "StyleProperties.h"
</span><span class="cx">
</span><span class="lines">@@ -44,25 +45,21 @@
</span><span class="cx"> }
</span><span class="cx"> ~StyleKeyframe();
</span><span class="cx">
</span><del>- String keyText() const { return m_key; }
- void setKeyText(const String& s) { m_key = s; }
</del><ins>+ String keyText() const;
+ void setKeyText(const String& text) { m_keys = CSSParser::parseKeyframeSelector(text); }
</ins><span class="cx">
</span><del>- void getKeys(Vector<double>& keys) const { parseKeyString(m_key, keys); }
-
</del><ins>+ const Vector<double>& keys() const { return m_keys; };
+
</ins><span class="cx"> const StyleProperties& properties() const { return m_properties; }
</span><span class="cx"> MutableStyleProperties& mutableProperties();
</span><del>-
</del><ins>+
</ins><span class="cx"> String cssText() const;
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> explicit StyleKeyframe(Ref<StyleProperties>&&);
</span><del>-
- static void parseKeyString(const String&, Vector<double>& keys);
-
</del><ins>+
</ins><span class="cx"> Ref<StyleProperties> m_properties;
</span><del>- // FIXME: This should be a parsed vector of floats.
- // comma separated list of keys
- String m_key;
</del><ins>+ Vector<double> m_keys;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> class CSSKeyframeRule final : public CSSRule {
</span><span class="lines">@@ -73,7 +70,7 @@
</span><span class="cx"> virtual void reattach(StyleRuleBase&) override;
</span><span class="cx">
</span><span class="cx"> String keyText() const { return m_keyframe->keyText(); }
</span><del>- void setKeyText(const String& s) { m_keyframe->setKeyText(s); }
</del><ins>+ void setKeyText(const String& text) { m_keyframe->setKeyText(text); }
</ins><span class="cx">
</span><span class="cx"> CSSStyleDeclaration& style();
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSKeyframesRulecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSKeyframesRule.cpp (179196 => 179197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSKeyframesRule.cpp        2015-01-27 19:16:00 UTC (rev 179196)
+++ trunk/Source/WebCore/css/CSSKeyframesRule.cpp        2015-01-27 19:39:22 UTC (rev 179197)
</span><span class="lines">@@ -72,18 +72,13 @@
</span><span class="cx">
</span><span class="cx"> int StyleRuleKeyframes::findKeyframeIndex(const String& key) const
</span><span class="cx"> {
</span><del>- String percentageString;
- if (equalIgnoringCase(key, "from"))
- percentageString = ASCIILiteral("0%");
- else if (equalIgnoringCase(key, "to"))
- percentageString = ASCIILiteral("100%");
- else
- percentageString = key;
-
- for (unsigned i = 0; i < m_keyframes.size(); ++i) {
- if (m_keyframes[i]->keyText() == percentageString)
</del><ins>+ Vector<double>&& keys = CSSParser::parseKeyframeSelector(key);
+
+ for (size_t i = m_keyframes.size(); i--; ) {
+ if (m_keyframes[i]->keys() == keys)
</ins><span class="cx"> return i;
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> return -1;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSParser.cpp (179196 => 179197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSParser.cpp        2015-01-27 19:16:00 UTC (rev 179196)
+++ trunk/Source/WebCore/css/CSSParser.cpp        2015-01-27 19:39:22 UTC (rev 179197)
</span><span class="lines">@@ -76,6 +76,8 @@
</span><span class="cx"> #include "RenderTheme.h"
</span><span class="cx"> #include "RuntimeEnabledFeatures.h"
</span><span class="cx"> #include "SVGParserUtilities.h"
</span><ins>+#include "SelectorChecker.h"
+#include "SelectorCheckerTestFunctions.h"
</ins><span class="cx"> #include "Settings.h"
</span><span class="cx"> #include "StyleProperties.h"
</span><span class="cx"> #include "StylePropertyShorthand.h"
</span><span class="lines">@@ -4682,6 +4684,36 @@
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/* static */
+Vector<double> CSSParser::parseKeyframeSelector(const String& selector) {
+ Vector<double> keys;
+ Vector<String> strings;
+ selector.split(',', strings);
+
+ for (size_t i = 0; i < strings.size(); ++i) {
+ double key = -1;
+ String cur = strings[i].stripWhiteSpace();
+
+ // For now the syntax MUST be 'xxx%' or 'from' or 'to', where xxx is a legal floating point number
+ if (equalIgnoringASCIICase(cur, "from"))
+ key = 0;
+ else if (equalIgnoringASCIICase(cur, "to"))
+ key = 1;
+ else if (cur.endsWith('%')) {
+ double k = cur.substring(0, cur.length() - 1).toDouble();
+ if (k >= 0 && k <= 100)
+ key = k / 100;
+ }
+ if (key < 0) {
+ keys.clear();
+ break;
+ }
+ keys.append(key);
+ }
+
+ return keys;
+}
+
</ins><span class="cx"> bool CSSParser::parseTransformOriginShorthand(RefPtr<CSSValue>& value1, RefPtr<CSSValue>& value2, RefPtr<CSSValue>& value3)
</span><span class="cx"> {
</span><span class="cx"> parse2ValuesFillPosition(*m_valueList, value1, value2);
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSParser.h (179196 => 179197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSParser.h        2015-01-27 19:16:00 UTC (rev 179196)
+++ trunk/Source/WebCore/css/CSSParser.h        2015-01-27 19:39:22 UTC (rev 179197)
</span><span class="lines">@@ -171,6 +171,7 @@
</span><span class="cx"> PassRefPtr<CSSValue> parseAnimationPlayState();
</span><span class="cx"> PassRefPtr<CSSValue> parseAnimationProperty(AnimationParseContext&);
</span><span class="cx"> PassRefPtr<CSSValue> parseAnimationTimingFunction();
</span><ins>+ static Vector<double> parseKeyframeSelector(const String&);
</ins><span class="cx">
</span><span class="cx"> bool parseTransformOriginShorthand(RefPtr<CSSValue>&, RefPtr<CSSValue>&, RefPtr<CSSValue>&);
</span><span class="cx"> bool parseCubicBezierTimingFunctionValue(CSSParserValueList& args, double& result);
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.cpp (179196 => 179197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.cpp        2015-01-27 19:16:00 UTC (rev 179196)
+++ trunk/Source/WebCore/css/StyleResolver.cpp        2015-01-27 19:39:22 UTC (rev 179197)
</span><span class="lines">@@ -890,10 +890,8 @@
</span><span class="cx"> keyframeValue.setStyle(styleForKeyframe(elementStyle, keyframe, keyframeValue));
</span><span class="cx">
</span><span class="cx"> // Add this keyframe style to all the indicated key times
</span><del>- Vector<double> keys;
- keyframe->getKeys(keys);
- for (size_t keyIndex = 0; keyIndex < keys.size(); ++keyIndex) {
- keyframeValue.setKey(keys[keyIndex]);
</del><ins>+ for (auto& key: keyframe->keys()) {
+ keyframeValue.setKey(key);
</ins><span class="cx"> list.insert(keyframeValue);
</span><span class="cx"> }
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>