<!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>[173012] 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/173012">173012</a></dd>
<dt>Author</dt> <dd>benjamin@webkit.org</dd>
<dt>Date</dt> <dd>2014-08-27 12:16:51 -0700 (Wed, 27 Aug 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Updating attributes on HTML elements do not invalidate the style correctly unless the attribute name is lowercase in the stylesheet
https://bugs.webkit.org/show_bug.cgi?id=136270
Source/WebCore:


Patch by Benjamin Poulain &lt;bpoulain@apple.com&gt; on 2014-08-27
Reviewed by Andreas Kling.

In HTML, WebKit treats every attribute name lowercase to implement case-insensitive matching.
When invalidating style, the StyleResolver was ignoring HTML and always using the XML names.

This patch split the names on RuleFeatureSet in two sets: one for XML, one for HTML.
In StyleResolver, the name used depends on the type of the element being updated.

This patch also adds nodeNeedsStyleRecalc() to Internals to test the optimization and various cases
of style update.

Tests: fast/css/attribute-for-content-property-style-update-html.html
       fast/css/attribute-for-content-property-style-update-xhtml.xhtml
       fast/css/attribute-style-invalidation-optimization-html.html
       fast/css/attribute-style-invalidation-optimization-xhtml.xhtml
       fast/css/attribute-style-update-html.html
       fast/selectors/attribute-style-update-html.html
       fast/selectors/attribute-style-update-svg-in-html.html
       fast/selectors/attribute-style-update-xhtml.xhtml

* css/RuleFeature.cpp:
(WebCore::RuleFeatureSet::collectFeaturesFromSelector):
(WebCore::RuleFeatureSet::add):
(WebCore::RuleFeatureSet::clear):
* css/RuleFeature.h:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyProperty):
* css/StyleResolver.h:
(WebCore::StyleResolver::hasSelectorForAttribute):
* dom/Element.cpp:
(WebCore::Element::willModifyAttribute):
* testing/Internals.cpp:
(WebCore::Internals::address):
(WebCore::Internals::nodeNeedsStyleRecalc):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

rdar://problem/16190617

Patch by Benjamin Poulain &lt;bpoulain@apple.com&gt; on 2014-08-27
Reviewed by Andreas Kling.

The test coverage for attribute update was abysmal. This adds the basic cases for HTML and XML.

* fast/css/attribute-for-content-property-style-update-html-expected.html: Added.
* fast/css/attribute-for-content-property-style-update-html.html: Added.
* fast/css/attribute-for-content-property-style-update-xhtml-expected.html: Added.
* fast/css/attribute-for-content-property-style-update-xhtml.xhtml: Added.
* fast/css/attribute-style-invalidation-optimization-html-expected.txt: Added.
* fast/css/attribute-style-invalidation-optimization-html.html: Added.
* fast/css/attribute-style-invalidation-optimization-xhtml-expected.txt: Added.
* fast/css/attribute-style-invalidation-optimization-xhtml.xhtml: Added.
* fast/css/attribute-style-update-html-expected.html: Added.
* fast/css/attribute-style-update-html.html: Added.
* fast/selectors/attribute-style-update-html-expected.txt: Added.
* fast/selectors/attribute-style-update-html.html: Added.
* fast/selectors/attribute-style-update-svg-in-html-expected.txt: Added.
* fast/selectors/attribute-style-update-svg-in-html.html: Added.
* fast/selectors/attribute-style-update-xhtml-expected.txt: Added.
* fast/selectors/attribute-style-update-xhtml.xhtml: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssRuleFeaturecpp">trunk/Source/WebCore/css/RuleFeature.cpp</a></li>
<li><a href="#trunkSourceWebCorecssRuleFeatureh">trunk/Source/WebCore/css/RuleFeature.h</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolvercpp">trunk/Source/WebCore/css/StyleResolver.cpp</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolverh">trunk/Source/WebCore/css/StyleResolver.h</a></li>
<li><a href="#trunkSourceWebCoredomElementcpp">trunk/Source/WebCore/dom/Element.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcssattributeforcontentpropertystyleupdatehtmlexpectedhtml">trunk/LayoutTests/fast/css/attribute-for-content-property-style-update-html-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastcssattributeforcontentpropertystyleupdatehtmlhtml">trunk/LayoutTests/fast/css/attribute-for-content-property-style-update-html.html</a></li>
<li><a href="#trunkLayoutTestsfastcssattributeforcontentpropertystyleupdatexhtmlexpectedhtml">trunk/LayoutTests/fast/css/attribute-for-content-property-style-update-xhtml-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastcssattributeforcontentpropertystyleupdatexhtmlxhtml">trunk/LayoutTests/fast/css/attribute-for-content-property-style-update-xhtml.xhtml</a></li>
<li><a href="#trunkLayoutTestsfastcssattributestyleinvalidationoptimizationhtmlexpectedtxt">trunk/LayoutTests/fast/css/attribute-style-invalidation-optimization-html-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcssattributestyleinvalidationoptimizationhtmlhtml">trunk/LayoutTests/fast/css/attribute-style-invalidation-optimization-html.html</a></li>
<li><a href="#trunkLayoutTestsfastcssattributestyleinvalidationoptimizationxhtmlexpectedtxt">trunk/LayoutTests/fast/css/attribute-style-invalidation-optimization-xhtml-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcssattributestyleinvalidationoptimizationxhtmlxhtml">trunk/LayoutTests/fast/css/attribute-style-invalidation-optimization-xhtml.xhtml</a></li>
<li><a href="#trunkLayoutTestsfastcssattributestyleupdatehtmlexpectedhtml">trunk/LayoutTests/fast/css/attribute-style-update-html-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastcssattributestyleupdatehtmlhtml">trunk/LayoutTests/fast/css/attribute-style-update-html.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsattributestyleupdatehtmlexpectedtxt">trunk/LayoutTests/fast/selectors/attribute-style-update-html-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsattributestyleupdatehtmlhtml">trunk/LayoutTests/fast/selectors/attribute-style-update-html.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsattributestyleupdatesvginhtmlexpectedtxt">trunk/LayoutTests/fast/selectors/attribute-style-update-svg-in-html-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsattributestyleupdatesvginhtmlhtml">trunk/LayoutTests/fast/selectors/attribute-style-update-svg-in-html.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsattributestyleupdatexhtmlexpectedtxt">trunk/LayoutTests/fast/selectors/attribute-style-update-xhtml-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsattributestyleupdatexhtmlxhtml">trunk/LayoutTests/fast/selectors/attribute-style-update-xhtml.xhtml</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (173011 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-08-27 19:15:52 UTC (rev 173011)
+++ trunk/LayoutTests/ChangeLog        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2014-08-27  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
+
+        Updating attributes on HTML elements do not invalidate the style correctly unless the attribute name is lowercase in the stylesheet
+        https://bugs.webkit.org/show_bug.cgi?id=136270
+        rdar://problem/16190617
+
+        Reviewed by Andreas Kling.
+
+        The test coverage for attribute update was abysmal. This adds the basic cases for HTML and XML.
+
+        * fast/css/attribute-for-content-property-style-update-html-expected.html: Added.
+        * fast/css/attribute-for-content-property-style-update-html.html: Added.
+        * fast/css/attribute-for-content-property-style-update-xhtml-expected.html: Added.
+        * fast/css/attribute-for-content-property-style-update-xhtml.xhtml: Added.
+        * fast/css/attribute-style-invalidation-optimization-html-expected.txt: Added.
+        * fast/css/attribute-style-invalidation-optimization-html.html: Added.
+        * fast/css/attribute-style-invalidation-optimization-xhtml-expected.txt: Added.
+        * fast/css/attribute-style-invalidation-optimization-xhtml.xhtml: Added.
+        * fast/css/attribute-style-update-html-expected.html: Added.
+        * fast/css/attribute-style-update-html.html: Added.
+        * fast/selectors/attribute-style-update-html-expected.txt: Added.
+        * fast/selectors/attribute-style-update-html.html: Added.
+        * fast/selectors/attribute-style-update-svg-in-html-expected.txt: Added.
+        * fast/selectors/attribute-style-update-svg-in-html.html: Added.
+        * fast/selectors/attribute-style-update-xhtml-expected.txt: Added.
+        * fast/selectors/attribute-style-update-xhtml.xhtml: Added.
+
</ins><span class="cx"> 2014-08-27  Mihnea Ovidenie  &lt;mihnea@adobe.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CSS Regions] Move generated content tests into fast/regions/generated-content
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssattributeforcontentpropertystyleupdatehtmlexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/attribute-for-content-property-style-update-html-expected.html (0 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/attribute-for-content-property-style-update-html-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/css/attribute-for-content-property-style-update-html-expected.html        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+.valid::before {
+    content: &quot;WebKit!&quot;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;p&gt;This test checks the styling and style update of attributes that are only used by the &quot;content&quot; propery of a rule. HTML should match the attribute regardless of the case.&lt;/p&gt;
+    &lt;div id=&quot;initial&quot;&gt;
+        &lt;target&gt;No attribute&lt;/target&gt;
+
+        &lt;target class=&quot;valid&quot;&gt;CamelCase initial attribute&lt;/target&gt;
+        &lt;target class=&quot;valid&quot;&gt;camelcase initial attribute&lt;/target&gt;
+        &lt;target class=&quot;valid&quot;&gt;CAMELCASE initial attribute&lt;/target&gt;
+    &lt;/div&gt;
+    &lt;div id=&quot;dynamic&quot;&gt;
+        &lt;target&gt;No attribute&lt;/target&gt;
+
+        &lt;target class=&quot;valid&quot;&gt;CamelCase initial attribute&lt;/target&gt;
+        &lt;target class=&quot;valid&quot;&gt;camelcase initial attribute&lt;/target&gt;
+        &lt;target class=&quot;valid&quot;&gt;CAMELCASE initial attribute&lt;/target&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssattributeforcontentpropertystyleupdatehtmlhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/attribute-for-content-property-style-update-html.html (0 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/attribute-for-content-property-style-update-html.html                                (rev 0)
+++ trunk/LayoutTests/fast/css/attribute-for-content-property-style-update-html.html        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+target::before {
+    content: attr(CamelCase)
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;p&gt;This test checks the styling and style update of attributes that are only used by the &quot;content&quot; propery of a rule. HTML should match the attribute regardless of the case.&lt;/p&gt;
+    &lt;div id=&quot;initial&quot;&gt;
+        &lt;target&gt;No attribute&lt;/target&gt;
+
+        &lt;target CamelCase=&quot;WebKit!&quot;&gt;CamelCase initial attribute&lt;/target&gt;
+        &lt;target camelcase=&quot;WebKit!&quot;&gt;camelcase initial attribute&lt;/target&gt;
+        &lt;target CAMELCASE=&quot;WebKit!&quot;&gt;CAMELCASE initial attribute&lt;/target&gt;
+    &lt;/div&gt;
+    &lt;div id=&quot;dynamic&quot;&gt;
+        &lt;target&gt;No attribute&lt;/target&gt;
+
+        &lt;target&gt;CamelCase initial attribute&lt;/target&gt;
+        &lt;target&gt;camelcase initial attribute&lt;/target&gt;
+        &lt;target&gt;CAMELCASE initial attribute&lt;/target&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+window.addEventListener(&quot;load&quot;, function() {
+    forcedLayout = document.documentElement.offsetTop;
+
+    var allDynamicTargets = document.querySelectorAll(&quot;#dynamic&gt;target&quot;);
+    allDynamicTargets[1].setAttribute(&quot;CamelCase&quot;, &quot;WebKit!&quot;);
+    allDynamicTargets[2].setAttribute(&quot;camelcase&quot;, &quot;WebKit!&quot;);
+    allDynamicTargets[3].setAttribute(&quot;CAMELCASE&quot;, &quot;WebKit!&quot;);
+});
+&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssattributeforcontentpropertystyleupdatexhtmlexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/attribute-for-content-property-style-update-xhtml-expected.html (0 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/attribute-for-content-property-style-update-xhtml-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/css/attribute-for-content-property-style-update-xhtml-expected.html        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
+&lt;head&gt;
+&lt;style&gt;
+.valid::before {
+    content: &quot;WebKit!&quot;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;p&gt;This test checks the styling and style update of attributes that are only used by the &quot;content&quot; propery of a rule.&lt;/p&gt;
+    &lt;div id=&quot;initial&quot;&gt;
+        &lt;target&gt;No attribute&lt;/target&gt;
+
+        &lt;target class=&quot;valid&quot;&gt;CamelCase initial attribute&lt;/target&gt;
+        &lt;target&gt;camelcase initial attribute&lt;/target&gt;
+        &lt;target&gt;CAMELCASE initial attribute&lt;/target&gt;
+    &lt;/div&gt;
+    &lt;div id=&quot;dynamic&quot;&gt;
+        &lt;target&gt;No attribute&lt;/target&gt;
+
+        &lt;target class=&quot;valid&quot;&gt;CamelCase initial attribute&lt;/target&gt;
+        &lt;target&gt;camelcase initial attribute&lt;/target&gt;
+        &lt;target&gt;CAMELCASE initial attribute&lt;/target&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssattributeforcontentpropertystyleupdatexhtmlxhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/attribute-for-content-property-style-update-xhtml.xhtml (0 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/attribute-for-content-property-style-update-xhtml.xhtml                                (rev 0)
+++ trunk/LayoutTests/fast/css/attribute-for-content-property-style-update-xhtml.xhtml        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
+&lt;head&gt;
+&lt;style&gt;
+target::before {
+    content: attr(CamelCase)
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;p&gt;This test checks the styling and style update of attributes that are only used by the &quot;content&quot; propery of a rule.&lt;/p&gt;
+    &lt;div id=&quot;initial&quot;&gt;
+        &lt;target&gt;No attribute&lt;/target&gt;
+
+        &lt;target CamelCase=&quot;WebKit!&quot;&gt;CamelCase initial attribute&lt;/target&gt;
+        &lt;target camelcase=&quot;WebKit!&quot;&gt;camelcase initial attribute&lt;/target&gt;
+        &lt;target CAMELCASE=&quot;WebKit!&quot;&gt;CAMELCASE initial attribute&lt;/target&gt;
+    &lt;/div&gt;
+    &lt;div id=&quot;dynamic&quot;&gt;
+        &lt;target&gt;No attribute&lt;/target&gt;
+
+        &lt;target&gt;CamelCase initial attribute&lt;/target&gt;
+        &lt;target&gt;camelcase initial attribute&lt;/target&gt;
+        &lt;target&gt;CAMELCASE initial attribute&lt;/target&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;&lt;![CDATA[
+window.addEventListener(&quot;load&quot;, function() {
+    forcedLayout = document.documentElement.offsetTop;
+
+    var allDynamicTargets = document.querySelectorAll(&quot;#dynamic&gt;target&quot;);
+    allDynamicTargets[1].setAttribute(&quot;CamelCase&quot;, &quot;WebKit!&quot;);
+    allDynamicTargets[2].setAttribute(&quot;camelcase&quot;, &quot;WebKit!&quot;);
+    allDynamicTargets[3].setAttribute(&quot;CAMELCASE&quot;, &quot;WebKit!&quot;);
+});
+]]&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssattributestyleinvalidationoptimizationhtmlexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/attribute-style-invalidation-optimization-html-expected.txt (0 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/attribute-style-invalidation-optimization-html-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/css/attribute-style-invalidation-optimization-html-expected.txt        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+Test that we only invalidate the style when changing an attribute referenced by a stylesheet. This test requires the internals object to work properly.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is false
+Changing the attribute 'foo', it is not referenced by any stylesheet and should not cause any invalidation.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is false
+Changing the attribute 'CamelCase'. It is used by the stylesheet and should cause the target to be invalidated.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is true
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is true
+Getting the computed style should for the style to be resolved.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is false
+Removing the attribute should also invalidate the style.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is true
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is true
+Getting the computed style should for the style to be resolved.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is false
+Changing the attribute 'camelcase'. It is not used as such by the stylesheet, but in HTML attribute names are case-insensitive and we should still invalidate the style.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is true
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is true
+Getting the computed style should for the style to be resolved.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is false
+Removing the attribute should also invalidate the style.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is true
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is true
+Getting the computed style should for the style to be resolved.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is false
+Changing the attribute 'CAMELCASE'. It is not used as such by the stylesheet, but in HTML attribute names are case-insensitive and we should still invalidate the style.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is true
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssattributestyleinvalidationoptimizationhtmlhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/attribute-style-invalidation-optimization-html.html (0 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/attribute-style-invalidation-optimization-html.html                                (rev 0)
+++ trunk/LayoutTests/fast/css/attribute-style-invalidation-optimization-html.html        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -0,0 +1,97 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;style&gt;
+* {
+    color: black;
+}
+[CamelCase] {
+    color: pink;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div&gt;
+        &lt;!-- With renderer --&gt;
+        &lt;target&gt;&lt;/target&gt;
+    &lt;/div&gt;
+    &lt;div style=&quot;display:none;&quot;&gt;
+        &lt;!-- Without renderer --&gt;
+        &lt;target&gt;&lt;/target&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+// It is okay to increase the amount of invalidation in this test for correctness if necessary.
+description('Test that we only invalidate the style when changing an attribute referenced by a stylesheet. This test requires the internals object to work properly.');
+
+function shouldNeedStyleRecalc(expected) {
+    var testFunction = expected ? shouldBeTrue : shouldBeFalse;
+    testFunction(&quot;window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\&quot;target\&quot;)[0])&quot;);
+    testFunction(&quot;window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\&quot;target\&quot;)[1])&quot;);
+}
+
+function setAttribute(name, value) {
+    var allTargets = document.querySelectorAll(&quot;target&quot;);
+    allTargets[0].setAttribute(name, value);
+    allTargets[1].setAttribute(name, value);
+}
+
+function removeAttribute(name) {
+    var allTargets = document.querySelectorAll(&quot;target&quot;);
+    allTargets[0].removeAttribute(name);
+    allTargets[1].removeAttribute(name);
+}
+
+function getStyle() {
+    var allTargets = document.querySelectorAll(&quot;target&quot;);
+    getComputedStyle(allTargets[0]).color;
+    getComputedStyle(allTargets[1]).color;
+}
+
+// Force a layout to ensure we don't have dirty styles.
+var offsetTop = document.documentElement.offsetTop;
+shouldNeedStyleRecalc(false);
+
+debug(&quot;Changing the attribute 'foo', it is not referenced by any stylesheet and should not cause any invalidation.&quot;);
+setAttribute(&quot;foo&quot;, &quot;bar&quot;);
+shouldNeedStyleRecalc(false);
+
+debug(&quot;Changing the attribute 'CamelCase'. It is used by the stylesheet and should cause the target to be invalidated.&quot;);
+setAttribute(&quot;CamelCase&quot;, &quot;&quot;);
+shouldNeedStyleRecalc(true);
+
+debug(&quot;Getting the computed style should for the style to be resolved.&quot;);
+getStyle();
+shouldNeedStyleRecalc(false);
+
+debug(&quot;Removing the attribute should also invalidate the style.&quot;);
+removeAttribute(&quot;CamelCase&quot;);
+shouldNeedStyleRecalc(true);
+
+debug(&quot;Getting the computed style should for the style to be resolved.&quot;);
+getStyle();
+shouldNeedStyleRecalc(false)
+
+debug(&quot;Changing the attribute 'camelcase'. It is not used as such by the stylesheet, but in HTML attribute names are case-insensitive and we should still invalidate the style.&quot;);
+setAttribute(&quot;camelcase&quot;, &quot;&quot;);
+shouldNeedStyleRecalc(true);
+
+debug(&quot;Getting the computed style should for the style to be resolved.&quot;);
+getStyle();
+shouldNeedStyleRecalc(false);
+
+debug(&quot;Removing the attribute should also invalidate the style.&quot;);
+removeAttribute(&quot;CamelCase&quot;);
+shouldNeedStyleRecalc(true);
+
+debug(&quot;Getting the computed style should for the style to be resolved.&quot;);
+getStyle();
+shouldNeedStyleRecalc(false)
+
+debug(&quot;Changing the attribute 'CAMELCASE'. It is not used as such by the stylesheet, but in HTML attribute names are case-insensitive and we should still invalidate the style.&quot;);
+setAttribute(&quot;CAMELCASE&quot;, &quot;&quot;);
+shouldNeedStyleRecalc(true);
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssattributestyleinvalidationoptimizationxhtmlexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/attribute-style-invalidation-optimization-xhtml-expected.txt (0 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/attribute-style-invalidation-optimization-xhtml-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/css/attribute-style-invalidation-optimization-xhtml-expected.txt        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+Test that we only invalidate the style when changing an attribute referenced by a stylesheet. This test requires the internals object to work properly.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is false
+Changing the attribute 'foo', it is not referenced by any stylesheet and should not cause any invalidation.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is false
+Changing the attribute 'CamelCase'. It is used by the stylesheet and should cause the target to be invalidated.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is true
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is true
+Getting the computed style should for the style to be resolved.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is false
+Removing the attribute should also invalidate the style.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is true
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is true
+Getting the computed style should for the style to be resolved.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is false
+Changing the attribute 'camelcase'. Since XML attributes are case sensitive, this does not invalidate the style since it is a different attribute.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is false
+Changing the attribute 'CAMELCASE'. Same deal, this is a different attribute.
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[0]) is false
+PASS window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(&quot;target&quot;)[1]) is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssattributestyleinvalidationoptimizationxhtmlxhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/attribute-style-invalidation-optimization-xhtml.xhtml (0 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/attribute-style-invalidation-optimization-xhtml.xhtml                                (rev 0)
+++ trunk/LayoutTests/fast/css/attribute-style-invalidation-optimization-xhtml.xhtml        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -0,0 +1,85 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;style&gt;
+* {
+    color: black;
+}
+[CamelCase] {
+    color: pink;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div&gt;
+        &lt;!-- With renderer --&gt;
+        &lt;target&gt;&lt;/target&gt;
+    &lt;/div&gt;
+    &lt;div style=&quot;display:none;&quot;&gt;
+        &lt;!-- Without renderer --&gt;
+        &lt;target&gt;&lt;/target&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;&lt;![CDATA[
+// It is okay to increase the amount of invalidation in this test for correctness if necessary.
+description('Test that we only invalidate the style when changing an attribute referenced by a stylesheet. This test requires the internals object to work properly.');
+
+function shouldNeedStyleRecalc(expected) {
+    var testFunction = expected ? shouldBeTrue : shouldBeFalse;
+    testFunction(&quot;window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\&quot;target\&quot;)[0])&quot;);
+    testFunction(&quot;window.internals.nodeNeedsStyleRecalc(document.querySelectorAll(\&quot;target\&quot;)[1])&quot;);
+}
+
+function setAttribute(name, value) {
+    var allTargets = document.querySelectorAll(&quot;target&quot;);
+    allTargets[0].setAttribute(name, value);
+    allTargets[1].setAttribute(name, value);
+}
+
+function removeAttribute(name) {
+    var allTargets = document.querySelectorAll(&quot;target&quot;);
+    allTargets[0].removeAttribute(name);
+    allTargets[1].removeAttribute(name);
+}
+
+function getStyle() {
+    var allTargets = document.querySelectorAll(&quot;target&quot;);
+    getComputedStyle(allTargets[0]).color;
+    getComputedStyle(allTargets[1]).color;
+}
+
+// Force a layout to ensure we don't have dirty styles.
+var offsetTop = document.documentElement.offsetTop;
+shouldNeedStyleRecalc(false);
+
+debug(&quot;Changing the attribute 'foo', it is not referenced by any stylesheet and should not cause any invalidation.&quot;);
+setAttribute(&quot;foo&quot;, &quot;bar&quot;);
+shouldNeedStyleRecalc(false);
+
+debug(&quot;Changing the attribute 'CamelCase'. It is used by the stylesheet and should cause the target to be invalidated.&quot;);
+setAttribute(&quot;CamelCase&quot;, &quot;&quot;);
+shouldNeedStyleRecalc(true);
+
+debug(&quot;Getting the computed style should for the style to be resolved.&quot;);
+getStyle();
+shouldNeedStyleRecalc(false);
+
+debug(&quot;Removing the attribute should also invalidate the style.&quot;);
+removeAttribute(&quot;CamelCase&quot;);
+shouldNeedStyleRecalc(true);
+
+debug(&quot;Getting the computed style should for the style to be resolved.&quot;);
+getStyle();
+shouldNeedStyleRecalc(false)
+
+debug(&quot;Changing the attribute 'camelcase'. Since XML attributes are case sensitive, this does not invalidate the style since it is a different attribute.&quot;);
+setAttribute(&quot;camelcase&quot;, &quot;&quot;);
+shouldNeedStyleRecalc(false);
+
+debug(&quot;Changing the attribute 'CAMELCASE'. Same deal, this is a different attribute.&quot;);
+setAttribute(&quot;CAMELCASE&quot;, &quot;&quot;);
+shouldNeedStyleRecalc(false);
+]]&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssattributestyleupdatehtmlexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/attribute-style-update-html-expected.html (0 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/attribute-style-update-html-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/css/attribute-style-update-html-expected.html        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+* {
+    background-color: white;
+    color: black;
+    fill-opacity: 1;
+}
+.background {
+    background-color: rgb(1, 2, 3);
+}
+.border {
+    border: 1px black solid;
+}
+.color {
+    color: pink;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;p&gt;This test checks the styling of elements based on their attributes. Since HTML processes attribute as case-insensitive, any case varation should work. This test passes if every triplet looks the same in both series and if it matches the reference.&lt;/p&gt;
+    &lt;div&gt;
+        &lt;target&gt;No attribute&lt;/target&gt;
+        &lt;target class=&quot;background&quot;&gt;lowercase initial attribute&lt;/target&gt;
+        &lt;target class=&quot;background&quot;&gt;LOWERCASE initial attribute&lt;/target&gt;
+        &lt;target class=&quot;background&quot;&gt;LowerCase initial attribute&lt;/target&gt;
+
+        &lt;target class=&quot;border&quot;&gt;UPPERCASE initial attribute&lt;/target&gt;
+        &lt;target class=&quot;border&quot;&gt;uppercase initial attribute&lt;/target&gt;
+        &lt;target class=&quot;border&quot;&gt;UpperCase initial attribute&lt;/target&gt;
+
+        &lt;target class=&quot;color&quot;&gt;CamelCase initial attribute&lt;/target&gt;
+        &lt;target class=&quot;color&quot;&gt;camelcase initial attribute&lt;/target&gt;
+        &lt;target class=&quot;color&quot;&gt;CAMELCASE initial attribute&lt;/target&gt;
+
+        &lt;target class=&quot;background border color&quot;&gt;LowerCase UpperCase CAMELCASE initial attributes&lt;/target&gt;
+        &lt;target class=&quot;background border color&quot;&gt;LowerCase UpperCase CAMELCASE initial attributes&lt;/target&gt;
+        &lt;target class=&quot;background border color&quot;&gt;LowerCase UpperCase CAMELCASE initial attributes&lt;/target&gt;
+    &lt;/div&gt;
+    &lt;div&gt;
+        &lt;target&gt;No attribute&lt;/target&gt;
+        &lt;target class=&quot;background&quot;&gt;lowercase dynamic attribute&lt;/target&gt;
+        &lt;target class=&quot;background&quot;&gt;LOWERCASE dynamic attribute&lt;/target&gt;
+        &lt;target class=&quot;background&quot;&gt;LowerCase dynamic attribute&lt;/target&gt;
+
+        &lt;target class=&quot;border&quot;&gt;UPPERCASE dynamic attribute&lt;/target&gt;
+        &lt;target class=&quot;border&quot;&gt;uppercase dynamic attribute&lt;/target&gt;
+        &lt;target class=&quot;border&quot;&gt;UpperCase dynamic attribute&lt;/target&gt;
+
+        &lt;target class=&quot;color&quot;&gt;CamelCase dynamic attribute&lt;/target&gt;
+        &lt;target class=&quot;color&quot;&gt;camelcase dynamic attribute&lt;/target&gt;
+        &lt;target class=&quot;color&quot;&gt;CAMELCASE dynamic attribute&lt;/target&gt;
+
+        &lt;target class=&quot;background border color&quot;&gt;LowerCase UpperCase CAMELCASE dynamic attributes&lt;/target&gt;
+        &lt;target class=&quot;background border color&quot;&gt;LowerCase UpperCase CAMELCASE dynamic attributes&lt;/target&gt;
+        &lt;target class=&quot;background border color&quot;&gt;LowerCase UpperCase CAMELCASE dynamic attributes&lt;/target&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssattributestyleupdatehtmlhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/attribute-style-update-html.html (0 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/attribute-style-update-html.html                                (rev 0)
+++ trunk/LayoutTests/fast/css/attribute-style-update-html.html        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -0,0 +1,88 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+* {
+    background-color: white;
+    color: black;
+    fill-opacity: 1;
+}
+[lowercase] {
+    background-color: rgb(1, 2, 3);
+}
+[UPPERCASE] {
+    border: 1px black solid;
+}
+[CamelCase] {
+    color: pink;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;p&gt;This test checks the styling of elements based on their attributes. Since HTML processes attribute as case-insensitive, any case varation should work. This test passes if every triplet looks the same in both series and if it matches the reference.&lt;/p&gt;
+    &lt;div id=&quot;initial&quot;&gt;
+        &lt;target&gt;No attribute&lt;/target&gt;
+        &lt;target lowercase&gt;lowercase initial attribute&lt;/target&gt;
+        &lt;target LOWERCASE&gt;LOWERCASE initial attribute&lt;/target&gt;
+        &lt;target LowerCase&gt;LowerCase initial attribute&lt;/target&gt;
+
+        &lt;target UPPERCASE&gt;UPPERCASE initial attribute&lt;/target&gt;
+        &lt;target uppercase&gt;uppercase initial attribute&lt;/target&gt;
+        &lt;target UpperCase&gt;UpperCase initial attribute&lt;/target&gt;
+
+        &lt;target CamelCase&gt;CamelCase initial attribute&lt;/target&gt;
+        &lt;target camelcase&gt;camelcase initial attribute&lt;/target&gt;
+        &lt;target CAMELCASE&gt;CAMELCASE initial attribute&lt;/target&gt;
+
+        &lt;target lowercase UPPERCASE CamelCase&gt;LowerCase UpperCase CAMELCASE initial attributes&lt;/target&gt;
+        &lt;target LOWERCASE uppercase camelcase&gt;LowerCase UpperCase CAMELCASE initial attributes&lt;/target&gt;
+        &lt;target LowerCase UpperCase CAMELCASE&gt;LowerCase UpperCase CAMELCASE initial attributes&lt;/target&gt;
+    &lt;/div&gt;
+    &lt;div id=&quot;dynamic&quot;&gt;
+        &lt;target&gt;No attribute&lt;/target&gt;
+        &lt;target&gt;lowercase dynamic attribute&lt;/target&gt;
+        &lt;target&gt;LOWERCASE dynamic attribute&lt;/target&gt;
+        &lt;target&gt;LowerCase dynamic attribute&lt;/target&gt;
+
+        &lt;target&gt;UPPERCASE dynamic attribute&lt;/target&gt;
+        &lt;target&gt;uppercase dynamic attribute&lt;/target&gt;
+        &lt;target&gt;UpperCase dynamic attribute&lt;/target&gt;
+
+        &lt;target&gt;CamelCase dynamic attribute&lt;/target&gt;
+        &lt;target&gt;camelcase dynamic attribute&lt;/target&gt;
+        &lt;target&gt;CAMELCASE dynamic attribute&lt;/target&gt;
+
+        &lt;target&gt;LowerCase UpperCase CAMELCASE dynamic attributes&lt;/target&gt;
+        &lt;target&gt;LowerCase UpperCase CAMELCASE dynamic attributes&lt;/target&gt;
+        &lt;target&gt;LowerCase UpperCase CAMELCASE dynamic attributes&lt;/target&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+window.addEventListener(&quot;load&quot;, function() {
+    forcedLayout = document.documentElement.offsetTop;
+
+    var allDynamicTargets = document.querySelectorAll(&quot;#dynamic&gt;target&quot;);
+    allDynamicTargets[1].setAttribute(&quot;lowercase&quot;, &quot;&quot;);
+    allDynamicTargets[2].setAttribute(&quot;LOWERCASE&quot;, &quot;&quot;);
+    allDynamicTargets[3].setAttribute(&quot;LowerCase&quot;, &quot;&quot;);
+
+    allDynamicTargets[4].setAttribute(&quot;UPPERCASE&quot;, &quot;&quot;);
+    allDynamicTargets[5].setAttribute(&quot;uppercase&quot;, &quot;&quot;);
+    allDynamicTargets[6].setAttribute(&quot;UpperCase&quot;, &quot;&quot;);
+
+    allDynamicTargets[7].setAttribute(&quot;CamelCase&quot;, &quot;&quot;);
+    allDynamicTargets[8].setAttribute(&quot;camelcase&quot;, &quot;&quot;);
+    allDynamicTargets[9].setAttribute(&quot;CAMELCASE&quot;, &quot;&quot;);
+
+    allDynamicTargets[10].setAttribute(&quot;lowercase&quot;, &quot;&quot;);
+    allDynamicTargets[10].setAttribute(&quot;UPPERCASE&quot;, &quot;&quot;);
+    allDynamicTargets[10].setAttribute(&quot;CamelCase&quot;, &quot;&quot;);
+    allDynamicTargets[11].setAttribute(&quot;LOWERCASE&quot;, &quot;&quot;);
+    allDynamicTargets[11].setAttribute(&quot;uppercase&quot;, &quot;&quot;);
+    allDynamicTargets[11].setAttribute(&quot;camelcase&quot;, &quot;&quot;);
+    allDynamicTargets[12].setAttribute(&quot;LowerCase&quot;, &quot;&quot;);
+    allDynamicTargets[12].setAttribute(&quot;UpperCase&quot;, &quot;&quot;);
+    allDynamicTargets[12].setAttribute(&quot;CAMELCASE&quot;, &quot;&quot;);
+});
+&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsattributestyleupdatehtmlexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/attribute-style-update-html-expected.txt (0 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/attribute-style-update-html-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/attribute-style-update-html-expected.txt        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -0,0 +1,121 @@
</span><ins>+Test the basic cases of style update for attribute selectors for HTML.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Initial state does not match anything, there are no attributes on the targets.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;lowercase&quot;, the background-color should match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Removing &quot;lowercase&quot;, the background-color should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;LOWERCASE&quot;, the background-color should match because the document is HTML and has case-insensitive attribute matching.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Removing &quot;LOWERCASE&quot;, the background-color should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;LowerCase&quot;, the background-color should match because the document is HTML and has case-insensitive attribute matching.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;UPPERCASE&quot;, the fill-opacity should match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Removing &quot;UPPERCASE&quot;, the fill-opacity should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;uppercase&quot;, the fill-opacity should match because the document is HTML and has case-insensitive attribute matching.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Removing &quot;uppercase&quot;, the fill-opacity should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;UpperCase&quot;, the fill-opacity should match because the document is HTML and has case-insensitive attribute matching.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;CamelCase&quot;, the color should match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(4, 5, 6)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(4, 5, 6)&quot;
+Removing &quot;CamelCase&quot;, the color should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;camelcase&quot;, the color should match because the document is HTML and has case-insensitive attribute matching.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(4, 5, 6)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(4, 5, 6)&quot;
+Removing &quot;camelcase&quot;, the color should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;CAMELCASE&quot;, the color should match because the document is HTML and has case-insensitive attribute matching.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(4, 5, 6)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(4, 5, 6)&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsattributestyleupdatehtmlhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/attribute-style-update-html.html (0 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/attribute-style-update-html.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/attribute-style-update-html.html        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -0,0 +1,129 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;style&gt;
+* {
+    background-color: white;
+    color: black;
+    fill-opacity: 1;
+}
+[lowercase] {
+    background-color: rgb(1, 2, 3);
+}
+[UPPERCASE] {
+    fill-opacity: 0.5;
+}
+[CamelCase] {
+    color: rgb(4, 5, 6);
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div&gt;
+        &lt;!-- With renderer --&gt;
+        &lt;target&gt;&lt;/target&gt;
+    &lt;/div&gt;
+    &lt;div style=&quot;display:none;&quot;&gt;
+        &lt;!-- Without renderer --&gt;
+        &lt;target&gt;&lt;/target&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test the basic cases of style update for attribute selectors for HTML.');
+
+var noMatch = 0;
+var matchLowerCase = 1;
+var matchUpperCase = 1 &lt;&lt; 1;
+var matchCamelCase = 1 &lt;&lt; 2;
+
+function testColor(mask) {
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor', (mask &amp; matchLowerCase) ? 'rgb(1, 2, 3)' : 'rgb(255, 255, 255)');
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor', (mask &amp; matchLowerCase) ? 'rgb(1, 2, 3)' : 'rgb(255, 255, 255)');
+
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity', (mask &amp; matchUpperCase) ? '0.5' : '1');
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity', (mask &amp; matchUpperCase) ? '0.5' : '1');
+
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color', (mask &amp; matchCamelCase) ? 'rgb(4, 5, 6)' : 'rgb(0, 0, 0)');
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color', (mask &amp; matchCamelCase) ? 'rgb(4, 5, 6)' : 'rgb(0, 0, 0)');
+}
+
+function setAttribute(attribute, value) {
+    var allTargets = document.querySelectorAll(&quot;target&quot;);
+    for (var i = 0; i &lt; allTargets.length; ++i)
+        allTargets[i].setAttribute(attribute, value);
+}
+
+function removeAttribute(attribute) {
+    var allTargets = document.querySelectorAll(&quot;target&quot;);
+    for (var i = 0; i &lt; allTargets.length; ++i)
+        allTargets[i].removeAttribute(attribute);
+}
+
+debug(&quot;Initial state does not match anything, there are no attributes on the targets.&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;lowercase\&quot;, the background-color should match.&quot;);
+setAttribute(&quot;lowercase&quot;);
+testColor(matchLowerCase);
+
+debug(&quot;Removing \&quot;lowercase\&quot;, the background-color should no longer match.&quot;);
+removeAttribute(&quot;lowercase&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;LOWERCASE\&quot;, the background-color should match because the document is HTML and has case-insensitive attribute matching.&quot;);
+setAttribute(&quot;LOWERCASE&quot;);
+testColor(matchLowerCase);
+
+debug(&quot;Removing \&quot;LOWERCASE\&quot;, the background-color should no longer match.&quot;);
+removeAttribute(&quot;LOWERCASE&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;LowerCase\&quot;, the background-color should match because the document is HTML and has case-insensitive attribute matching.&quot;);
+setAttribute(&quot;LOWERCASE&quot;);
+testColor(matchLowerCase);
+
+
+debug(&quot;Adding \&quot;UPPERCASE\&quot;, the fill-opacity should match.&quot;);
+setAttribute(&quot;UPPERCASE&quot;);
+testColor(matchLowerCase | matchUpperCase);
+
+debug(&quot;Removing \&quot;UPPERCASE\&quot;, the fill-opacity should no longer match.&quot;);
+removeAttribute(&quot;UPPERCASE&quot;);
+testColor(matchLowerCase);
+
+debug(&quot;Adding \&quot;uppercase\&quot;, the fill-opacity should match because the document is HTML and has case-insensitive attribute matching.&quot;);
+setAttribute(&quot;uppercase&quot;);
+testColor(matchLowerCase | matchUpperCase);
+
+debug(&quot;Removing \&quot;uppercase\&quot;, the fill-opacity should no longer match.&quot;);
+removeAttribute(&quot;uppercase&quot;);
+testColor(matchLowerCase);
+
+debug(&quot;Adding \&quot;UpperCase\&quot;, the fill-opacity should match because the document is HTML and has case-insensitive attribute matching.&quot;);
+setAttribute(&quot;UpperCase&quot;);
+testColor(matchLowerCase | matchUpperCase);
+
+
+debug(&quot;Adding \&quot;CamelCase\&quot;, the color should match.&quot;);
+setAttribute(&quot;CamelCase&quot;);
+testColor(matchLowerCase | matchUpperCase | matchCamelCase);
+
+debug(&quot;Removing \&quot;CamelCase\&quot;, the color should no longer match.&quot;);
+removeAttribute(&quot;CamelCase&quot;);
+testColor(matchLowerCase | matchUpperCase);
+
+debug(&quot;Adding \&quot;camelcase\&quot;, the color should match because the document is HTML and has case-insensitive attribute matching.&quot;);
+setAttribute(&quot;camelcase&quot;);
+testColor(matchLowerCase | matchUpperCase | matchCamelCase);
+
+debug(&quot;Removing \&quot;camelcase\&quot;, the color should no longer match.&quot;);
+removeAttribute(&quot;camelcase&quot;);
+testColor(matchLowerCase | matchUpperCase);
+
+debug(&quot;Adding \&quot;CAMELCASE\&quot;, the color should match because the document is HTML and has case-insensitive attribute matching.&quot;);
+setAttribute(&quot;CAMELCASE&quot;);
+testColor(matchLowerCase | matchUpperCase | matchCamelCase);
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsattributestyleupdatesvginhtmlexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/attribute-style-update-svg-in-html-expected.txt (0 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/attribute-style-update-svg-in-html-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/attribute-style-update-svg-in-html-expected.txt        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -0,0 +1,121 @@
</span><ins>+Test the basic cases of style update for attribute selectors for SVG inside a HTML document.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Initial state does not match anything, there are no attributes on the targets.
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;lowercase&quot;, the background-color should match.
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Removing &quot;lowercase&quot;, the background-color should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;LOWERCASE&quot;, the background-color should not match because SVG elements are XML, their attribute names are case sensitive.
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Removing &quot;LOWERCASE&quot;, the background-color should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;LowerCase&quot;, the background-color should not match because SVG elements are XML, their attribute names are case sensitive.
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;UPPERCASE&quot;, the fill-opacity should match.
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Removing &quot;UPPERCASE&quot;, the fill-opacity should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;uppercase&quot;, the fill-opacity should not match because SVG elements are XML, their attribute names are case sensitive.
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Removing &quot;uppercase&quot;, the fill-opacity should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;UpperCase&quot;, the fill-opacity should not match because SVG elements are XML, their attribute names are case sensitive.
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;CamelCase&quot;, the color should match.
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color is &quot;rgb(4, 5, 6)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color is &quot;rgb(4, 5, 6)&quot;
+Removing &quot;CamelCase&quot;, the color should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;camelcase&quot;, the color should not match because SVG elements are XML, their attribute names are case sensitive.
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Removing &quot;camelcase&quot;, the color should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;CAMELCASE&quot;, the color should not match because SVG elements are XML, their attribute names are case sensitive.
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsattributestyleupdatesvginhtmlhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/attribute-style-update-svg-in-html.html (0 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/attribute-style-update-svg-in-html.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/attribute-style-update-svg-in-html.html        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -0,0 +1,133 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;style&gt;
+* {
+    background-color: white;
+    color: black;
+    fill-opacity: 1;
+}
+[lowercase] {
+    background-color: rgb(1, 2, 3);
+}
+[UPPERCASE] {
+    fill-opacity: 0.5;
+}
+[CamelCase] {
+    color: rgb(4, 5, 6);
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div&gt;
+        &lt;!-- With renderer --&gt;
+        &lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; version=&quot;1.1&quot; viewBox=&quot;0 0 100 100&quot; style=&quot;margin-top:50px&quot;&gt;
+            &lt;rect id=rect2 x=&quot;0&quot; y=&quot;0&quot; width=&quot;50&quot; height=&quot;50&quot; style=&quot;fill:green&quot; /&gt;
+        &lt;/svg&gt;
+    &lt;/div&gt;
+    &lt;div style=&quot;display:none;&quot;&gt;
+        &lt;!-- Without renderer --&gt;
+        &lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; version=&quot;1.1&quot; viewBox=&quot;0 0 100 100&quot; style=&quot;margin-top:50px&quot;&gt;
+            &lt;rect id=rect2 x=&quot;0&quot; y=&quot;0&quot; width=&quot;50&quot; height=&quot;50&quot; style=&quot;fill:green&quot; /&gt;
+        &lt;/svg&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test the basic cases of style update for attribute selectors for SVG inside a HTML document.');
+
+var noMatch = 0;
+var matchLowerCase = 1;
+var matchUpperCase = 1 &lt;&lt; 1;
+var matchCamelCase = 1 &lt;&lt; 2;
+
+function testColor(mask) {
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).backgroundColor', (mask &amp; matchLowerCase) ? 'rgb(1, 2, 3)' : 'rgb(255, 255, 255)');
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).backgroundColor', (mask &amp; matchLowerCase) ? 'rgb(1, 2, 3)' : 'rgb(255, 255, 255)');
+
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).fillOpacity', (mask &amp; matchUpperCase) ? '0.5' : '1');
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).fillOpacity', (mask &amp; matchUpperCase) ? '0.5' : '1');
+
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[0]).color', (mask &amp; matchCamelCase) ? 'rgb(4, 5, 6)' : 'rgb(0, 0, 0)');
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;rect&quot;)[1]).color', (mask &amp; matchCamelCase) ? 'rgb(4, 5, 6)' : 'rgb(0, 0, 0)');
+}
+
+function setAttribute(attribute, value) {
+    var allTargets = document.querySelectorAll(&quot;rect&quot;);
+    for (var i = 0; i &lt; allTargets.length; ++i)
+        allTargets[i].setAttribute(attribute, value);
+}
+
+function removeAttribute(attribute) {
+    var allTargets = document.querySelectorAll(&quot;rect&quot;);
+    for (var i = 0; i &lt; allTargets.length; ++i)
+        allTargets[i].removeAttribute(attribute);
+}
+
+debug(&quot;Initial state does not match anything, there are no attributes on the targets.&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;lowercase\&quot;, the background-color should match.&quot;);
+setAttribute(&quot;lowercase&quot;);
+testColor(matchLowerCase);
+
+debug(&quot;Removing \&quot;lowercase\&quot;, the background-color should no longer match.&quot;);
+removeAttribute(&quot;lowercase&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;LOWERCASE\&quot;, the background-color should not match because SVG elements are XML, their attribute names are case sensitive.&quot;);
+setAttribute(&quot;LOWERCASE&quot;);
+testColor(noMatch);
+
+debug(&quot;Removing \&quot;LOWERCASE\&quot;, the background-color should no longer match.&quot;);
+removeAttribute(&quot;LOWERCASE&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;LowerCase\&quot;, the background-color should not match because SVG elements are XML, their attribute names are case sensitive.&quot;);
+setAttribute(&quot;LOWERCASE&quot;);
+testColor(noMatch);
+
+
+debug(&quot;Adding \&quot;UPPERCASE\&quot;, the fill-opacity should match.&quot;);
+setAttribute(&quot;UPPERCASE&quot;);
+testColor(matchUpperCase);
+
+debug(&quot;Removing \&quot;UPPERCASE\&quot;, the fill-opacity should no longer match.&quot;);
+removeAttribute(&quot;UPPERCASE&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;uppercase\&quot;, the fill-opacity should not match because SVG elements are XML, their attribute names are case sensitive.&quot;);
+setAttribute(&quot;uppercase&quot;);
+testColor(noMatch);
+
+debug(&quot;Removing \&quot;uppercase\&quot;, the fill-opacity should no longer match.&quot;);
+removeAttribute(&quot;uppercase&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;UpperCase\&quot;, the fill-opacity should not match because SVG elements are XML, their attribute names are case sensitive.&quot;);
+setAttribute(&quot;UpperCase&quot;);
+testColor(noMatch);
+
+
+debug(&quot;Adding \&quot;CamelCase\&quot;, the color should match.&quot;);
+setAttribute(&quot;CamelCase&quot;);
+testColor(matchCamelCase);
+
+debug(&quot;Removing \&quot;CamelCase\&quot;, the color should no longer match.&quot;);
+removeAttribute(&quot;CamelCase&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;camelcase\&quot;, the color should not match because SVG elements are XML, their attribute names are case sensitive.&quot;);
+setAttribute(&quot;camelcase&quot;);
+testColor(noMatch);
+
+debug(&quot;Removing \&quot;camelcase\&quot;, the color should no longer match.&quot;);
+removeAttribute(&quot;camelcase&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;CAMELCASE\&quot;, the color should not match because SVG elements are XML, their attribute names are case sensitive.&quot;);
+setAttribute(&quot;CAMELCASE&quot;);
+testColor(noMatch);
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsattributestyleupdatexhtmlexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/attribute-style-update-xhtml-expected.txt (0 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/attribute-style-update-xhtml-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/attribute-style-update-xhtml-expected.txt        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -0,0 +1,121 @@
</span><ins>+Test the basic cases of style update for attribute selectors for XHTML. Unlike HTML, XHTML attribute matching is case sensitive.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Initial state does not match anything, there are no attributes on the targets.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;lowercase&quot;, the background-color should match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(1, 2, 3)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Removing &quot;lowercase&quot;, the background-color should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;LOWERCASE&quot;, the background-color should match because XML uses case-sensitive attributes.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Removing &quot;LOWERCASE&quot;, the background-color should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;LowerCase&quot;, the background-color should match because XML uses case-sensitive attributes.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;UPPERCASE&quot;, the fill-opacity should match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;0.5&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Removing &quot;UPPERCASE&quot;, the fill-opacity should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;uppercase&quot;, the fill-opacity should match because XML uses case-sensitive attributes.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Removing &quot;uppercase&quot;, the fill-opacity should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;UpperCase&quot;, the fill-opacity should match because XML uses case-sensitive attributes.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;CamelCase&quot;, the color should match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(4, 5, 6)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(4, 5, 6)&quot;
+Removing &quot;CamelCase&quot;, the color should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;camelcase&quot;, the color should match because XML uses case-sensitive attributes.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Removing &quot;camelcase&quot;, the color should no longer match.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+Adding &quot;CAMELCASE&quot;, the color should match because XML uses case-sensitive attributes.
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity is &quot;1&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsattributestyleupdatexhtmlxhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/attribute-style-update-xhtml.xhtml (0 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/attribute-style-update-xhtml.xhtml                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/attribute-style-update-xhtml.xhtml        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -0,0 +1,129 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;style&gt;
+* {
+    background-color: white;
+    color: black;
+    fill-opacity: 1;
+}
+[lowercase] {
+    background-color: rgb(1, 2, 3);
+}
+[UPPERCASE] {
+    fill-opacity: 0.5;
+}
+[CamelCase] {
+    color: rgb(4, 5, 6);
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div&gt;
+        &lt;!-- With renderer --&gt;
+        &lt;target&gt;&lt;/target&gt;
+    &lt;/div&gt;
+    &lt;div style=&quot;display:none;&quot;&gt;
+        &lt;!-- Without renderer --&gt;
+        &lt;target&gt;&lt;/target&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;&lt;![CDATA[
+description('Test the basic cases of style update for attribute selectors for XHTML. Unlike HTML, XHTML attribute matching is case sensitive.');
+
+var noMatch = 0;
+var matchLowerCase = 1;
+var matchUpperCase = 1 &lt;&lt; 1;
+var matchCamelCase = 1 &lt;&lt; 2;
+
+function testColor(mask) {
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).backgroundColor', (mask &amp; matchLowerCase) ? 'rgb(1, 2, 3)' : 'rgb(255, 255, 255)');
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).backgroundColor', (mask &amp; matchLowerCase) ? 'rgb(1, 2, 3)' : 'rgb(255, 255, 255)');
+
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).fillOpacity', (mask &amp; matchUpperCase) ? '0.5' : '1');
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).fillOpacity', (mask &amp; matchUpperCase) ? '0.5' : '1');
+
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;target&quot;)[0]).color', (mask &amp; matchCamelCase) ? 'rgb(4, 5, 6)' : 'rgb(0, 0, 0)');
+    shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;target&quot;)[1]).color', (mask &amp; matchCamelCase) ? 'rgb(4, 5, 6)' : 'rgb(0, 0, 0)');
+}
+
+function setAttribute(attribute, value) {
+    var allTargets = document.querySelectorAll(&quot;target&quot;);
+    for (var i = 0; i &lt; allTargets.length; ++i)
+        allTargets[i].setAttribute(attribute, value);
+}
+
+function removeAttribute(attribute) {
+    var allTargets = document.querySelectorAll(&quot;target&quot;);
+    for (var i = 0; i &lt; allTargets.length; ++i)
+        allTargets[i].removeAttribute(attribute);
+}
+
+debug(&quot;Initial state does not match anything, there are no attributes on the targets.&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;lowercase\&quot;, the background-color should match.&quot;);
+setAttribute(&quot;lowercase&quot;);
+testColor(matchLowerCase);
+
+debug(&quot;Removing \&quot;lowercase\&quot;, the background-color should no longer match.&quot;);
+removeAttribute(&quot;lowercase&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;LOWERCASE\&quot;, the background-color should match because XML uses case-sensitive attributes.&quot;);
+setAttribute(&quot;LOWERCASE&quot;);
+testColor(noMatch);
+
+debug(&quot;Removing \&quot;LOWERCASE\&quot;, the background-color should no longer match.&quot;);
+removeAttribute(&quot;LOWERCASE&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;LowerCase\&quot;, the background-color should match because XML uses case-sensitive attributes.&quot;);
+setAttribute(&quot;LOWERCASE&quot;);
+testColor(noMatch);
+
+
+debug(&quot;Adding \&quot;UPPERCASE\&quot;, the fill-opacity should match.&quot;);
+setAttribute(&quot;UPPERCASE&quot;);
+testColor(matchUpperCase);
+
+debug(&quot;Removing \&quot;UPPERCASE\&quot;, the fill-opacity should no longer match.&quot;);
+removeAttribute(&quot;UPPERCASE&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;uppercase\&quot;, the fill-opacity should match because XML uses case-sensitive attributes.&quot;);
+setAttribute(&quot;uppercase&quot;);
+testColor(noMatch);
+
+debug(&quot;Removing \&quot;uppercase\&quot;, the fill-opacity should no longer match.&quot;);
+removeAttribute(&quot;uppercase&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;UpperCase\&quot;, the fill-opacity should match because XML uses case-sensitive attributes.&quot;);
+setAttribute(&quot;UpperCase&quot;);
+testColor(noMatch);
+
+
+debug(&quot;Adding \&quot;CamelCase\&quot;, the color should match.&quot;);
+setAttribute(&quot;CamelCase&quot;);
+testColor(matchCamelCase);
+
+debug(&quot;Removing \&quot;CamelCase\&quot;, the color should no longer match.&quot;);
+removeAttribute(&quot;CamelCase&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;camelcase\&quot;, the color should match because XML uses case-sensitive attributes.&quot;);
+setAttribute(&quot;camelcase&quot;);
+testColor(noMatch);
+
+debug(&quot;Removing \&quot;camelcase\&quot;, the color should no longer match.&quot;);
+removeAttribute(&quot;camelcase&quot;);
+testColor(noMatch);
+
+debug(&quot;Adding \&quot;CAMELCASE\&quot;, the color should match because XML uses case-sensitive attributes.&quot;);
+setAttribute(&quot;CAMELCASE&quot;);
+testColor(noMatch);
+]]&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (173011 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-08-27 19:15:52 UTC (rev 173011)
+++ trunk/Source/WebCore/ChangeLog        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -1,5 +1,47 @@
</span><span class="cx"> 2014-08-27  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Updating attributes on HTML elements do not invalidate the style correctly unless the attribute name is lowercase in the stylesheet
+        https://bugs.webkit.org/show_bug.cgi?id=136270
+
+        Reviewed by Andreas Kling.
+
+        In HTML, WebKit treats every attribute name lowercase to implement case-insensitive matching.
+        When invalidating style, the StyleResolver was ignoring HTML and always using the XML names.
+
+        This patch split the names on RuleFeatureSet in two sets: one for XML, one for HTML.
+        In StyleResolver, the name used depends on the type of the element being updated.
+
+        This patch also adds nodeNeedsStyleRecalc() to Internals to test the optimization and various cases
+        of style update.
+
+        Tests: fast/css/attribute-for-content-property-style-update-html.html
+               fast/css/attribute-for-content-property-style-update-xhtml.xhtml
+               fast/css/attribute-style-invalidation-optimization-html.html
+               fast/css/attribute-style-invalidation-optimization-xhtml.xhtml
+               fast/css/attribute-style-update-html.html
+               fast/selectors/attribute-style-update-html.html
+               fast/selectors/attribute-style-update-svg-in-html.html
+               fast/selectors/attribute-style-update-xhtml.xhtml
+
+        * css/RuleFeature.cpp:
+        (WebCore::RuleFeatureSet::collectFeaturesFromSelector):
+        (WebCore::RuleFeatureSet::add):
+        (WebCore::RuleFeatureSet::clear):
+        * css/RuleFeature.h:
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::applyProperty):
+        * css/StyleResolver.h:
+        (WebCore::StyleResolver::hasSelectorForAttribute):
+        * dom/Element.cpp:
+        (WebCore::Element::willModifyAttribute):
+        * testing/Internals.cpp:
+        (WebCore::Internals::address):
+        (WebCore::Internals::nodeNeedsStyleRecalc):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
+2014-08-27  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
+
</ins><span class="cx">         Update the CSS Grammar selector names to get closer to the latest terminology
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=136277
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecssRuleFeaturecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/RuleFeature.cpp (173011 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/RuleFeature.cpp        2014-08-27 19:15:52 UTC (rev 173011)
+++ trunk/Source/WebCore/css/RuleFeature.cpp        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -39,9 +39,10 @@
</span><span class="cx">         idsInRules.add(selector-&gt;value().impl());
</span><span class="cx">     else if (selector-&gt;m_match == CSSSelector::Class)
</span><span class="cx">         classesInRules.add(selector-&gt;value().impl());
</span><del>-    else if (selector-&gt;isAttributeSelector())
-        attrsInRules.add(selector-&gt;attribute().localName().impl());
-    else if (selector-&gt;m_match == CSSSelector::PseudoElement) {
</del><ins>+    else if (selector-&gt;isAttributeSelector()) {
+        attributeCanonicalLocalNamesInRules.add(selector-&gt;attributeCanonicalLocalName().impl());
+        attributeLocalNamesInRules.add(selector-&gt;attribute().localName().impl());
+    } else if (selector-&gt;m_match == CSSSelector::PseudoElement) {
</ins><span class="cx">         switch (selector-&gt;pseudoElementType()) {
</span><span class="cx">         case CSSSelector::PseudoElementFirstLine:
</span><span class="cx">             usesFirstLineRules = true;
</span><span class="lines">@@ -61,15 +62,10 @@
</span><span class="cx"> 
</span><span class="cx"> void RuleFeatureSet::add(const RuleFeatureSet&amp; other)
</span><span class="cx"> {
</span><del>-    HashSet&lt;AtomicStringImpl*&gt;::const_iterator end = other.idsInRules.end();
-    for (HashSet&lt;AtomicStringImpl*&gt;::const_iterator it = other.idsInRules.begin(); it != end; ++it)
-        idsInRules.add(*it);
-    end = other.classesInRules.end();
-    for (HashSet&lt;AtomicStringImpl*&gt;::const_iterator it = other.classesInRules.begin(); it != end; ++it)
-        classesInRules.add(*it);
-    end = other.attrsInRules.end();
-    for (HashSet&lt;AtomicStringImpl*&gt;::const_iterator it = other.attrsInRules.begin(); it != end; ++it)
-        attrsInRules.add(*it);
</del><ins>+    idsInRules.add(other.idsInRules.begin(), other.idsInRules.end());
+    classesInRules.add(other.classesInRules.begin(), other.classesInRules.end());
+    attributeCanonicalLocalNamesInRules.add(other.attributeCanonicalLocalNamesInRules.begin(), other.attributeCanonicalLocalNamesInRules.end());
+    attributeLocalNamesInRules.add(other.attributeLocalNamesInRules.begin(), other.attributeLocalNamesInRules.end());
</ins><span class="cx">     siblingRules.appendVector(other.siblingRules);
</span><span class="cx">     uncommonAttributeRules.appendVector(other.uncommonAttributeRules);
</span><span class="cx">     usesFirstLineRules = usesFirstLineRules || other.usesFirstLineRules;
</span><span class="lines">@@ -81,7 +77,8 @@
</span><span class="cx"> {
</span><span class="cx">     idsInRules.clear();
</span><span class="cx">     classesInRules.clear();
</span><del>-    attrsInRules.clear();
</del><ins>+    attributeCanonicalLocalNamesInRules.clear();
+    attributeLocalNamesInRules.clear();
</ins><span class="cx">     siblingRules.clear();
</span><span class="cx">     uncommonAttributeRules.clear();
</span><span class="cx">     usesFirstLineRules = false;
</span></span></pre></div>
<a id="trunkSourceWebCorecssRuleFeatureh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/RuleFeature.h (173011 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/RuleFeature.h        2014-08-27 19:15:52 UTC (rev 173011)
+++ trunk/Source/WebCore/css/RuleFeature.h        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -58,7 +58,8 @@
</span><span class="cx"> 
</span><span class="cx">     HashSet&lt;AtomicStringImpl*&gt; idsInRules;
</span><span class="cx">     HashSet&lt;AtomicStringImpl*&gt; classesInRules;
</span><del>-    HashSet&lt;AtomicStringImpl*&gt; attrsInRules;
</del><ins>+    HashSet&lt;AtomicStringImpl*&gt; attributeCanonicalLocalNamesInRules;
+    HashSet&lt;AtomicStringImpl*&gt; attributeLocalNamesInRules;
</ins><span class="cx">     Vector&lt;RuleFeature&gt; siblingRules;
</span><span class="cx">     Vector&lt;RuleFeature&gt; uncommonAttributeRules;
</span><span class="cx">     bool usesFirstLineRules;
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.cpp (173011 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.cpp        2014-08-27 19:15:52 UTC (rev 173011)
+++ trunk/Source/WebCore/css/StyleResolver.cpp        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -2147,7 +2147,8 @@
</span><span class="cx">                     state.style()-&gt;setContent(value.isNull() ? emptyAtom : value.impl(), didSet);
</span><span class="cx">                     didSet = true;
</span><span class="cx">                     // Register the fact that the attribute value affects the style.
</span><del>-                    m_ruleSets.features().attrsInRules.add(attr.localName().impl());
</del><ins>+                    m_ruleSets.features().attributeCanonicalLocalNamesInRules.add(attr.localName().impl());
+                    m_ruleSets.features().attributeLocalNamesInRules.add(attr.localName().impl());
</ins><span class="cx">                 } else if (contentValue-&gt;isCounter()) {
</span><span class="cx">                     Counter* counterValue = contentValue-&gt;getCounterValue();
</span><span class="cx">                     EListStyleType listStyleType = NoneListStyle;
</span><span class="lines">@@ -2202,7 +2203,8 @@
</span><span class="cx">                 state.style()-&gt;setContentAltText(value.isNull() ? emptyAtom : value.impl());
</span><span class="cx">                 didSet = true;
</span><span class="cx">                 // Register the fact that the attribute value affects the style.
</span><del>-                m_ruleSets.features().attrsInRules.add(attr.localName().impl());
</del><ins>+                m_ruleSets.features().attributeCanonicalLocalNamesInRules.add(attr.localName().impl());
+                m_ruleSets.features().attributeLocalNamesInRules.add(attr.localName().impl());
</ins><span class="cx">             }
</span><span class="cx">             if (!didSet)
</span><span class="cx">                 state.style()-&gt;setContentAltText(emptyAtom);
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.h (173011 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.h        2014-08-27 19:15:52 UTC (rev 173011)
+++ trunk/Source/WebCore/css/StyleResolver.h        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -214,7 +214,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool hasSelectorForId(const AtomicString&amp;) const;
</span><span class="cx">     bool hasSelectorForClass(const AtomicString&amp;) const;
</span><del>-    bool hasSelectorForAttribute(const AtomicString&amp;) const;
</del><ins>+    bool hasSelectorForAttribute(const Element&amp;, const AtomicString&amp;) const;
</ins><span class="cx"> 
</span><span class="cx">     CSSFontSelector* fontSelector() const { return m_fontSelector.get(); }
</span><span class="cx"> #if ENABLE(CSS_DEVICE_ADAPTATION)
</span><span class="lines">@@ -547,10 +547,12 @@
</span><span class="cx">     friend bool operator!=(const MatchRanges&amp;, const MatchRanges&amp;);
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-inline bool StyleResolver::hasSelectorForAttribute(const AtomicString &amp;attributeName) const
</del><ins>+inline bool StyleResolver::hasSelectorForAttribute(const Element&amp; element, const AtomicString &amp;attributeName) const
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!attributeName.isEmpty());
</span><del>-    return m_ruleSets.features().attrsInRules.contains(attributeName.impl());
</del><ins>+    if (element.isHTMLElement())
+        return m_ruleSets.features().attributeCanonicalLocalNamesInRules.contains(attributeName.impl());
+    return m_ruleSets.features().attributeLocalNamesInRules.contains(attributeName.impl());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline bool StyleResolver::hasSelectorForClass(const AtomicString&amp; classValue) const
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.cpp (173011 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.cpp        2014-08-27 19:15:52 UTC (rev 173011)
+++ trunk/Source/WebCore/dom/Element.cpp        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -2707,7 +2707,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (oldValue != newValue) {
</span><span class="cx">         auto styleResolver = document().styleResolverIfExists();
</span><del>-        if (styleResolver &amp;&amp; styleResolver-&gt;hasSelectorForAttribute(name.localName()))
</del><ins>+        if (styleResolver &amp;&amp; styleResolver-&gt;hasSelectorForAttribute(*this, name.localName()))
</ins><span class="cx">             setNeedsStyleRecalc();
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (173011 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2014-08-27 19:15:52 UTC (rev 173011)
+++ trunk/Source/WebCore/testing/Internals.cpp        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -347,10 +347,17 @@
</span><span class="cx"> 
</span><span class="cx"> String Internals::address(Node* node)
</span><span class="cx"> {
</span><del>-    char buf[32];
-    sprintf(buf, &quot;%p&quot;, node);
</del><ins>+    return String::format(&quot;%p&quot;, node);
+}
</ins><span class="cx"> 
</span><del>-    return String(buf);
</del><ins>+bool Internals::nodeNeedsStyleRecalc(Node* node, ExceptionCode&amp; exception)
+{
+    if (!node) {
+        exception = INVALID_ACCESS_ERR;
+        return false;
+    }
+
+    return node-&gt;needsStyleRecalc();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> String Internals::description(Deprecated::ScriptValue value)
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (173011 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h        2014-08-27 19:15:52 UTC (rev 173011)
+++ trunk/Source/WebCore/testing/Internals.h        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2012 Google Inc. All rights reserved.
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -75,6 +75,7 @@
</span><span class="cx">     String elementRenderTreeAsText(Element*, ExceptionCode&amp;);
</span><span class="cx"> 
</span><span class="cx">     String address(Node*);
</span><ins>+    bool nodeNeedsStyleRecalc(Node*, ExceptionCode&amp;);
</ins><span class="cx">     String description(Deprecated::ScriptValue);
</span><span class="cx"> 
</span><span class="cx">     bool isPreloaded(const String&amp; url);
</span><span class="lines">@@ -107,10 +108,6 @@
</span><span class="cx"> 
</span><span class="cx">     Node* treeScopeRootNode(Node*, ExceptionCode&amp;);
</span><span class="cx">     Node* parentTreeScope(Node*, ExceptionCode&amp;);
</span><del>-    bool hasSelectorForIdInShadow(Element* host, const String&amp; idValue, ExceptionCode&amp;);
-    bool hasSelectorForClassInShadow(Element* host, const String&amp; className, ExceptionCode&amp;);
-    bool hasSelectorForAttributeInShadow(Element* host, const String&amp; attributeName, ExceptionCode&amp;);
-    bool hasSelectorForPseudoClassInShadow(Element* host, const String&amp; pseudoClass, ExceptionCode&amp;);
</del><span class="cx"> 
</span><span class="cx">     bool attached(Node*, ExceptionCode&amp;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (173011 => 173012)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl        2014-08-27 19:15:52 UTC (rev 173011)
+++ trunk/Source/WebCore/testing/Internals.idl        2014-08-27 19:16:51 UTC (rev 173012)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2012 Google Inc. All rights reserved.
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx">     NoInterfaceObject,
</span><span class="cx"> ] interface Internals {
</span><span class="cx">     DOMString address(Node node);
</span><ins>+    [RaisesException] boolean nodeNeedsStyleRecalc(Node node);
</ins><span class="cx">     DOMString description(any value);
</span><span class="cx"> 
</span><span class="cx">     [RaisesException] DOMString elementRenderTreeAsText(Element element);
</span></span></pre>
</div>
</div>

</body>
</html>