<!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>[173441] 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/173441">173441</a></dd>
<dt>Author</dt> <dd>benjamin@webkit.org</dd>
<dt>Date</dt> <dd>2014-09-09 14:03:29 -0700 (Tue, 09 Sep 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add support for :read-write/:read-only matching editable content
https://bugs.webkit.org/show_bug.cgi?id=136668

Reviewed by Antti Koivisto.

Source/WebCore:

This is the second part of the update of :read-write/:read-only to the latest spec
(http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting.html#selectors).

The selectors :read-write/:read-only should match elements that are editable. The exact definition is:
&quot;elements that are editing hosts or editable and are neither input elements nor textarea elements&quot;.

Matching that definition is really easy. It was done by updating HTMLElement's matchesReadWritePseudoClass()
to consider both contentEditable and designMode.

The tricky part is making that efficient in all cases. Matching contentEditable is horribly inefficient
compared to the other primitives. We don't want to execute that for every element.

Since matchesReadWritePseudoClass() was used by the theming code, that code was adjusted to
-Avoid calling that on regular HTMLElement, limiting the query to &lt;input&gt; and &lt;textarea&gt; where it is fast.
-Avoid the call entirely when possible.

Tests: fast/css/read-only-read-write-contenteditable-basics.html
       fast/css/read-only-read-write-designmode-basics.html
       fast/css/read-only-read-write-webkit-user-modify.html
       fast/selectors/read-only-read-write-contenteditable-basics.html
       fast/selectors/read-only-read-write-contenteditable-svg-foreignObject.html
       fast/selectors/read-only-read-write-designmode-basics.html
       fast/selectors/read-only-read-write-style-update.html

* html/HTMLElement.cpp:
(WebCore::contentEditableType):
This code is a generalization of the code that was in HTMLElement::contentEditable().
It is used by both matchesReadWritePseudoClass() and contentEditable() to determine
a valid state from the value of contentEditable.

(WebCore::HTMLElement::matchesReadWritePseudoClass):
Per the definition of editable content, we first check if the current element is an editing host,
if not we look for an editing host. If there are none, test for designMode.

(WebCore::HTMLElement::contentEditable):

(WebCore::RenderTheme::isReadOnlyControl):
The old definition would only match &lt;input&gt; and &lt;textarea&gt;. The code was updated to keep the same
behavior after matchesReadWritePseudoClass() is udpated. This avoids the performance problem of calling
matchesReadWritePseudoClass() on regular HTMLElement.

* platform/ControlStates.h:
ReadOnlyState was only used by ThemeMac for convertControlStatesToThemeDrawState().
In turn, convertControlStatesToThemeDrawState() was only used for painting
&quot;-webkit-inner-spin-button&quot;. Buttons are not read-write to begin with.
The whole code looks like legacy from styling of input elements and was removed.

Removing ReadOnlyState removes the expensive part of extractControlStatesForRenderer().

* html/HTMLElement.h:
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::readOnlyAttributeChanged):
* platform/mac/ThemeMac.mm:
(WebCore::convertControlStatesToThemeDrawState):
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::extractControlStatesForRenderer):

LayoutTests:

* fast/css/read-only-read-write-contenteditable-basics-expected.html: Added.
* fast/css/read-only-read-write-contenteditable-basics.html: Added.
* fast/css/read-only-read-write-designmode-basics-expected.html: Added.
* fast/css/read-only-read-write-designmode-basics.html: Added.
* fast/css/read-only-read-write-webkit-user-modify-expected.txt: Added.
* fast/css/read-only-read-write-webkit-user-modify.html: Added.
* fast/selectors/read-only-read-write-contenteditable-basics-expected.txt: Added.
* fast/selectors/read-only-read-write-contenteditable-basics.html: Added.
* fast/selectors/read-only-read-write-contenteditable-svg-foreignObject-expected.txt: Added.
* fast/selectors/read-only-read-write-contenteditable-svg-foreignObject.html: Added.
* fast/selectors/read-only-read-write-designmode-basics-expected.txt: Added.
* fast/selectors/read-only-read-write-designmode-basics.html: Added.
* fast/selectors/read-only-read-write-style-update-expected.txt: Added.
* fast/selectors/read-only-read-write-style-update.html: 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="#trunkSourceWebCorehtmlHTMLElementcpp">trunk/Source/WebCore/html/HTMLElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLElementh">trunk/Source/WebCore/html/HTMLElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFormControlElementcpp">trunk/Source/WebCore/html/HTMLFormControlElement.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformControlStatesh">trunk/Source/WebCore/platform/ControlStates.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacThemeMacmm">trunk/Source/WebCore/platform/mac/ThemeMac.mm</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderThemecpp">trunk/Source/WebCore/rendering/RenderTheme.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcssreadonlyreadwritecontenteditablebasicsexpectedhtml">trunk/LayoutTests/fast/css/read-only-read-write-contenteditable-basics-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastcssreadonlyreadwritecontenteditablebasicshtml">trunk/LayoutTests/fast/css/read-only-read-write-contenteditable-basics.html</a></li>
<li><a href="#trunkLayoutTestsfastcssreadonlyreadwritedesignmodebasicsexpectedhtml">trunk/LayoutTests/fast/css/read-only-read-write-designmode-basics-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastcssreadonlyreadwritedesignmodebasicshtml">trunk/LayoutTests/fast/css/read-only-read-write-designmode-basics.html</a></li>
<li><a href="#trunkLayoutTestsfastcssreadonlyreadwritewebkitusermodifyexpectedtxt">trunk/LayoutTests/fast/css/read-only-read-write-webkit-user-modify-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcssreadonlyreadwritewebkitusermodifyhtml">trunk/LayoutTests/fast/css/read-only-read-write-webkit-user-modify.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsreadonlyreadwritecontenteditablebasicsexpectedtxt">trunk/LayoutTests/fast/selectors/read-only-read-write-contenteditable-basics-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsreadonlyreadwritecontenteditablebasicshtml">trunk/LayoutTests/fast/selectors/read-only-read-write-contenteditable-basics.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsreadonlyreadwritecontenteditablesvgforeignObjectexpectedtxt">trunk/LayoutTests/fast/selectors/read-only-read-write-contenteditable-svg-foreignObject-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsreadonlyreadwritecontenteditablesvgforeignObjecthtml">trunk/LayoutTests/fast/selectors/read-only-read-write-contenteditable-svg-foreignObject.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsreadonlyreadwritedesignmodebasicsexpectedtxt">trunk/LayoutTests/fast/selectors/read-only-read-write-designmode-basics-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsreadonlyreadwritedesignmodebasicshtml">trunk/LayoutTests/fast/selectors/read-only-read-write-designmode-basics.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsreadonlyreadwritestyleupdateexpectedtxt">trunk/LayoutTests/fast/selectors/read-only-read-write-style-update-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsreadonlyreadwritestyleupdatehtml">trunk/LayoutTests/fast/selectors/read-only-read-write-style-update.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (173440 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-09-09 20:56:55 UTC (rev 173440)
+++ trunk/LayoutTests/ChangeLog        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2014-09-09  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+        Add support for :read-write/:read-only matching editable content
+        https://bugs.webkit.org/show_bug.cgi?id=136668
+
+        Reviewed by Antti Koivisto.
+
+        * fast/css/read-only-read-write-contenteditable-basics-expected.html: Added.
+        * fast/css/read-only-read-write-contenteditable-basics.html: Added.
+        * fast/css/read-only-read-write-designmode-basics-expected.html: Added.
+        * fast/css/read-only-read-write-designmode-basics.html: Added.
+        * fast/css/read-only-read-write-webkit-user-modify-expected.txt: Added.
+        * fast/css/read-only-read-write-webkit-user-modify.html: Added.
+        * fast/selectors/read-only-read-write-contenteditable-basics-expected.txt: Added.
+        * fast/selectors/read-only-read-write-contenteditable-basics.html: Added.
+        * fast/selectors/read-only-read-write-contenteditable-svg-foreignObject-expected.txt: Added.
+        * fast/selectors/read-only-read-write-contenteditable-svg-foreignObject.html: Added.
+        * fast/selectors/read-only-read-write-designmode-basics-expected.txt: Added.
+        * fast/selectors/read-only-read-write-designmode-basics.html: Added.
+        * fast/selectors/read-only-read-write-style-update-expected.txt: Added.
+        * fast/selectors/read-only-read-write-style-update.html: Added.
+
</ins><span class="cx"> 2014-09-09  Jer Noble  &lt;jer.noble@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Mac] Unreviewed gardening. Mark two media-source tests as failing.
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssreadonlyreadwritecontenteditablebasicsexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/read-only-read-write-contenteditable-basics-expected.html (0 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/read-only-read-write-contenteditable-basics-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/css/read-only-read-write-contenteditable-basics-expected.html        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -0,0 +1,69 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+* {
+    background-color: pink;
+    color: black;
+}
+.read-write {
+    background-color: white;
+    color: green;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;!-- In the reference, we cannot use :read-only/:read-write for styling. The attributes must remain the same since they can be used by the theme. --&gt;
+    &lt;p&gt;This test checks the styling of element with :read-only and :read-write. Every element where text can be entered/changed should have green text over a white background. Every element that cannot be edited should have black text over pink background.&lt;/p&gt;
+    &lt;div&gt;
+        &lt;!-- Default is true --&gt;
+        &lt;div contenteditable class=&quot;read-write&quot;&gt;
+            &lt;div class=&quot;read-write&quot;&gt;WebKit rocks! Editable&lt;/div&gt;
+            &lt;div contenteditable=false&gt;
+                &lt;div&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- True is true :) --&gt;
+        &lt;div contenteditable=true class=&quot;read-write&quot;&gt;
+            &lt;div class=&quot;read-write&quot;&gt;Editable&lt;/div&gt;
+            &lt;div contenteditable=false&gt;
+                &lt;div&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- The case of the attribute's value is irrelevant. --&gt;
+        &lt;div contenteditable=&quot;TrUe&quot; class=&quot;read-write&quot;&gt;
+            &lt;div class=&quot;read-write&quot;&gt;Editable&lt;/div&gt;
+            &lt;div contenteditable=&quot;FaLsE&quot;&gt;
+                &lt;div&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- The value &quot;plaintext-only&quot; is a WebKit extension, it defines an editing host too. --&gt;
+        &lt;div contenteditable=&quot;plaintext-only&quot; class=&quot;read-write&quot;&gt;
+            &lt;div class=&quot;read-write&quot;&gt;Editable&lt;/div&gt;
+            &lt;div contenteditable=&quot;false&quot;&gt;
+                &lt;div&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+
+        &lt;!-- Per definition, the rules for editing host and editable elements do not apply do &lt;input&gt; elements. --&gt;
+        &lt;div contenteditable=true class=&quot;read-write&quot;&gt;
+            &lt;div class=&quot;read-write&quot;&gt;Editable&lt;/div&gt;
+            &lt;input type=&quot;text&quot; value=&quot;read-write input&quot; class=&quot;read-write&quot;&gt;
+            &lt;input type=&quot;text&quot; disabled value=&quot;read-only input&quot;&gt;
+            &lt;input type=&quot;text&quot; readonly value=&quot;read-only input&quot;&gt;
+        &lt;/div&gt;
+        &lt;input type=&quot;text&quot; contenteditable=true disabled value=&quot;read-only input&quot;&gt;
+        &lt;input type=&quot;text&quot; contenteditable=true readonly value=&quot;read-only input&quot;&gt;
+
+        &lt;!-- Same story for &lt;textarea&gt;, it has its own definition of :read-write/:read-only. The rules for editing host and editable elements do not apply must be ignored. --&gt;
+        &lt;div contenteditable=true class=&quot;read-write&quot;&gt;
+            &lt;div class=&quot;read-write&quot;&gt;Editable&lt;/div&gt;
+            &lt;textarea class=&quot;read-write&quot;&gt;Editable text area&lt;/textarea&gt;
+            &lt;textarea disabled&gt;Non editable text area&lt;/textarea&gt;
+            &lt;textarea readonly&gt;Non editable text area&lt;/textarea&gt;
+        &lt;/div&gt;
+        &lt;textarea contenteditable=true disabled&gt;Non editable text area&lt;/textarea&gt;
+        &lt;textarea contenteditable=true readonly&gt;Non editable text area&lt;/textarea&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssreadonlyreadwritecontenteditablebasicshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/read-only-read-write-contenteditable-basics.html (0 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/read-only-read-write-contenteditable-basics.html                                (rev 0)
+++ trunk/LayoutTests/fast/css/read-only-read-write-contenteditable-basics.html        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -0,0 +1,70 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+* {
+    background-color: white;
+    color: black;
+}
+:read-only {
+    background-color: pink;
+}
+:read-write {
+    color: green;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;p&gt;This test checks the styling of element with :read-only and :read-write. Every element where text can be entered/changed should have green text over a white background. Every element that cannot be edited should have black text over pink background.&lt;/p&gt;
+    &lt;div&gt;
+        &lt;!-- Default is true --&gt;
+        &lt;div contenteditable&gt;
+            &lt;div&gt;WebKit rocks! Editable&lt;/div&gt;
+            &lt;div contenteditable=false&gt;
+                &lt;div&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- True is true :) --&gt;
+        &lt;div contenteditable=true&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;div contenteditable=false&gt;
+                &lt;div&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- The case of the attribute's value is irrelevant. --&gt;
+        &lt;div contenteditable=&quot;TrUe&quot;&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;div contenteditable=&quot;FaLsE&quot;&gt;
+                &lt;div&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- The value &quot;plaintext-only&quot; is a WebKit extension, it defines an editing host too. --&gt;
+        &lt;div contenteditable=&quot;plaintext-only&quot;&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;div contenteditable=&quot;false&quot;&gt;
+                &lt;div id=&quot;non-editable-subblock-4&quot;&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+
+        &lt;!-- Per definition, the rules for editing host and editable elements do not apply do &lt;input&gt; elements. --&gt;
+        &lt;div contenteditable=true&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;input type=&quot;text&quot; value=&quot;read-write input&quot;&gt;
+            &lt;input type=&quot;text&quot; disabled value=&quot;read-only input&quot;&gt;
+            &lt;input type=&quot;text&quot; readonly value=&quot;read-only input&quot;&gt;
+        &lt;/div&gt;
+        &lt;input type=&quot;text&quot; contenteditable=true disabled value=&quot;read-only input&quot;&gt;
+        &lt;input type=&quot;text&quot; contenteditable=true readonly value=&quot;read-only input&quot;&gt;
+
+        &lt;!-- Same story for &lt;textarea&gt;, it has its own definition of :read-write/:read-only. The rules for editing host and editable elements do not apply must be ignored. --&gt;
+        &lt;div contenteditable=true&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;textarea&gt;Editable text area&lt;/textarea&gt;
+            &lt;textarea disabled&gt;Non editable text area&lt;/textarea&gt;
+            &lt;textarea readonly&gt;Non editable text area&lt;/textarea&gt;
+        &lt;/div&gt;
+        &lt;textarea contenteditable=true disabled&gt;Non editable text area&lt;/textarea&gt;
+        &lt;textarea contenteditable=true readonly&gt;Non editable text area&lt;/textarea&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssreadonlyreadwritedesignmodebasicsexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/read-only-read-write-designmode-basics-expected.html (0 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/read-only-read-write-designmode-basics-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/css/read-only-read-write-designmode-basics-expected.html        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -0,0 +1,69 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+* {
+    background-color: white;
+    color: green;
+}
+.read-only {
+    background-color: pink;
+    color: black;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;!-- In the reference, we cannot use :read-only/:read-write for styling. The attributes must remain the same since they can be used by the theme. --&gt;
+    &lt;p&gt;This test checks the styling of element with :read-only and :read-write. Every element where text can be entered/changed should have green text over a white background. Every element that cannot be edited should have black text over pink background.&lt;/p&gt;
+    &lt;div&gt;
+        &lt;!-- Default is true --&gt;
+        &lt;div contenteditable&gt;
+            &lt;div&gt;WebKit rocks! Editable&lt;/div&gt;
+            &lt;div contenteditable=false&gt;
+                &lt;div class=&quot;read-only&quot;&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- True is true :) --&gt;
+        &lt;div contenteditable=true&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;div contenteditable=false&gt;
+                &lt;div class=&quot;read-only&quot;&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- The case of the attribute's value is irrelevant. --&gt;
+        &lt;div contenteditable=&quot;TrUe&quot;&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;div contenteditable=&quot;FaLsE&quot;&gt;
+                &lt;div class=&quot;read-only&quot;&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- The value &quot;plaintext-only&quot; is a WebKit extension, it defines an editing host too. --&gt;
+        &lt;div contenteditable=&quot;plaintext-only&quot;&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;div contenteditable=&quot;false&quot;&gt;
+                &lt;div class=&quot;read-only&quot;&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+
+        &lt;!-- Per definition, the rules for editing host and editable elements do not apply do &lt;input&gt; elements. --&gt;
+        &lt;div contenteditable=true&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;input type=&quot;text&quot; value=&quot;read-write input&quot;&gt;
+            &lt;input class=&quot;read-only&quot; type=&quot;text&quot; disabled value=&quot;read-only input&quot;&gt;
+            &lt;input class=&quot;read-only&quot; type=&quot;text&quot; readonly value=&quot;read-only input&quot;&gt;
+        &lt;/div&gt;
+        &lt;input class=&quot;read-only&quot; type=&quot;text&quot; contenteditable=true disabled value=&quot;read-only input&quot;&gt;
+        &lt;input class=&quot;read-only&quot; type=&quot;text&quot; contenteditable=true readonly value=&quot;read-only input&quot;&gt;
+
+        &lt;!-- Same story for &lt;textarea&gt;, it has its own definition of :read-write/:read-only. The rules for editing host and editable elements do not apply must be ignored. --&gt;
+        &lt;div contenteditable=true&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;textarea&gt;Editable text area&lt;/textarea&gt;
+            &lt;textarea class=&quot;read-only&quot; disabled&gt;Non editable text area&lt;/textarea&gt;
+            &lt;textarea class=&quot;read-only&quot; readonly&gt;Non editable text area&lt;/textarea&gt;
+        &lt;/div&gt;
+        &lt;textarea class=&quot;read-only&quot; contenteditable=true disabled&gt;Non editable text area&lt;/textarea&gt;
+        &lt;textarea class=&quot;read-only&quot; contenteditable=true readonly&gt;Non editable text area&lt;/textarea&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssreadonlyreadwritedesignmodebasicshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/read-only-read-write-designmode-basics.html (0 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/read-only-read-write-designmode-basics.html                                (rev 0)
+++ trunk/LayoutTests/fast/css/read-only-read-write-designmode-basics.html        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -0,0 +1,73 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+* {
+    background-color: white;
+    color: black;
+}
+:read-only {
+    background-color: pink;
+}
+:read-write {
+    color: green;
+}
+&lt;/style&gt;
+&lt;script&gt;
+document.designMode = &quot;on&quot;;
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;p&gt;This test checks the styling of element with :read-only and :read-write. Every element where text can be entered/changed should have green text over a white background. Every element that cannot be edited should have black text over pink background.&lt;/p&gt;
+    &lt;div&gt;
+        &lt;!-- Default is true --&gt;
+        &lt;div contenteditable&gt;
+            &lt;div&gt;WebKit rocks! Editable&lt;/div&gt;
+            &lt;div contenteditable=false&gt;
+                &lt;div&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- True is true :) --&gt;
+        &lt;div contenteditable=true&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;div contenteditable=false&gt;
+                &lt;div&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- The case of the attribute's value is irrelevant. --&gt;
+        &lt;div contenteditable=&quot;TrUe&quot;&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;div contenteditable=&quot;FaLsE&quot;&gt;
+                &lt;div&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- The value &quot;plaintext-only&quot; is a WebKit extension, it defines an editing host too. --&gt;
+        &lt;div contenteditable=&quot;plaintext-only&quot;&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;div contenteditable=&quot;false&quot;&gt;
+                &lt;div&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+
+        &lt;!-- Per definition, the rules for editing host and editable elements do not apply do &lt;input&gt; elements. --&gt;
+        &lt;div contenteditable=true&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;input type=&quot;text&quot; value=&quot;read-write input&quot;&gt;
+            &lt;input type=&quot;text&quot; disabled value=&quot;read-only input&quot;&gt;
+            &lt;input type=&quot;text&quot; readonly value=&quot;read-only input&quot;&gt;
+        &lt;/div&gt;
+        &lt;input type=&quot;text&quot; contenteditable=true disabled value=&quot;read-only input&quot;&gt;
+        &lt;input type=&quot;text&quot; contenteditable=true readonly value=&quot;read-only input&quot;&gt;
+
+        &lt;!-- Same story for &lt;textarea&gt;, it has its own definition of :read-write/:read-only. The rules for editing host and editable elements do not apply must be ignored. --&gt;
+        &lt;div contenteditable=true&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;textarea&gt;Editable text area&lt;/textarea&gt;
+            &lt;textarea disabled&gt;Non editable text area&lt;/textarea&gt;
+            &lt;textarea readonly&gt;Non editable text area&lt;/textarea&gt;
+        &lt;/div&gt;
+        &lt;textarea contenteditable=true disabled&gt;Non editable text area&lt;/textarea&gt;
+        &lt;textarea contenteditable=true readonly&gt;Non editable text area&lt;/textarea&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssreadonlyreadwritewebkitusermodifyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/read-only-read-write-webkit-user-modify-expected.txt (0 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/read-only-read-write-webkit-user-modify-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/css/read-only-read-write-webkit-user-modify-expected.txt        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+The CSS Property (-webkit-)user-modify must not have any effect on the resolution of &quot;:read-write&quot; and &quot;:read-only&quot;. If a selector were to depend on a CSS property, it would create a style-depends-on-style loop and make a giant mess of querySelector.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[0]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[1]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[2]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[2]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[3]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[3]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[4]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[4]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[5]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[5]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[6]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[6]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[7]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[7]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[8]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[8]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[9]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[9]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[10]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[10]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[11]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[11]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[12]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[12]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[13]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[13]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[14]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[14]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[15]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[15]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;).length is 6
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[0].id is &quot;editing-host-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[1].id is &quot;editable-block-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[2].id is &quot;editing-host-2&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[3].id is &quot;read-write-input&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[4].id is &quot;editing-host-3&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[5].id is &quot;read-write-textarea&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;).length is 10
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[0].id is &quot;non-editable-block-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[1].id is &quot;non-editable-subblock-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[2].id is &quot;read-only-input-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[3].id is &quot;read-only-input-2&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[4].id is &quot;read-only-input-3&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[5].id is &quot;read-only-input-4&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[6].id is &quot;read-only-textarea-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[7].id is &quot;read-only-textarea-2&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[8].id is &quot;read-only-textarea-3&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[9].id is &quot;read-only-textarea-4&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssreadonlyreadwritewebkitusermodifyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/read-only-read-write-webkit-user-modify.html (0 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/read-only-read-write-webkit-user-modify.html                                (rev 0)
+++ trunk/LayoutTests/fast/css/read-only-read-write-webkit-user-modify.html        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -0,0 +1,100 @@
</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;
+#test-block * {
+    background-color: white;
+    color: black;
+}
+#test-block :read-only {
+    background-color: red;
+}
+#test-block :read-write {
+    color: lime;
+}
+* {
+    -webkit-user-modify: read-write;
+    -moz-user-modify: read-write;
+    user-modify: read-write;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div style=&quot;display:none;&quot; id=&quot;test-block&quot;&gt;
+        &lt;div id=&quot;editing-host-1&quot; contenteditable&gt;
+            &lt;div id=&quot;editable-block-1&quot;&gt;Editable&lt;/div&gt;
+            &lt;div id=&quot;non-editable-block-1&quot; contenteditable=false&gt;
+                &lt;div id=&quot;non-editable-subblock-1&quot;&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+
+        &lt;!-- Per definition, the rules for editing host and editable elements do not apply do &lt;input&gt; elements. --&gt;
+        &lt;div id=&quot;editing-host-2&quot; contenteditable=true&gt;
+            &lt;input type=&quot;text&quot; id=&quot;read-write-input&quot; value=&quot;read-write input&quot;&gt;
+            &lt;input type=&quot;text&quot; disabled id=&quot;read-only-input-1&quot; value=&quot;read-only input&quot;&gt;
+            &lt;input type=&quot;text&quot; readonly id=&quot;read-only-input-2&quot; value=&quot;read-only input&quot;&gt;
+        &lt;/div&gt;
+        &lt;input type=&quot;text&quot; contenteditable=true disabled id=&quot;read-only-input-3&quot; value=&quot;read-only input&quot;&gt;
+        &lt;input type=&quot;text&quot; contenteditable=true readonly id=&quot;read-only-input-4&quot; value=&quot;read-only input&quot;&gt;
+
+        &lt;!-- Same story for &lt;textarea&gt;, it has its own definition of :read-write/:read-only. The rules for editing host and editable elements do not apply must be ignored. --&gt;
+        &lt;div id=&quot;editing-host-3&quot; contenteditable=true&gt;
+            &lt;textarea id=&quot;read-write-textarea&quot;&gt;Editable text area&lt;/textarea&gt;
+            &lt;textarea disabled id=&quot;read-only-textarea-1&quot;&gt;Non editable text area&lt;/textarea&gt;
+            &lt;textarea readonly id=&quot;read-only-textarea-2&quot;&gt;Non editable text area&lt;/textarea&gt;
+        &lt;/div&gt;
+        &lt;textarea contenteditable=true disabled id=&quot;read-only-textarea-3&quot;&gt;Non editable text area&lt;/textarea&gt;
+        &lt;textarea contenteditable=true readonly id=&quot;read-only-textarea-4&quot;&gt;Non editable text area&lt;/textarea&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('The CSS Property (-webkit-)user-modify must not have any effect on the resolution of &quot;:read-write&quot; and &quot;:read-only&quot;. If a selector were to depend on a CSS property, it would create a style-depends-on-style loop and make a giant mess of querySelector.');
+
+var editableElements = [
+    &quot;editing-host-1&quot;,
+    &quot;editable-block-1&quot;,
+    &quot;editing-host-2&quot;,
+    &quot;read-write-input&quot;,
+    &quot;editing-host-3&quot;,
+    &quot;read-write-textarea&quot;,
+];
+
+var nonEditableElements = [
+    &quot;non-editable-block-1&quot;,
+    &quot;non-editable-subblock-1&quot;,
+    &quot;read-only-input-1&quot;,
+    &quot;read-only-input-2&quot;,
+    &quot;read-only-input-3&quot;,
+    &quot;read-only-input-4&quot;,
+    &quot;read-only-textarea-1&quot;,
+    &quot;read-only-textarea-2&quot;,
+    &quot;read-only-textarea-3&quot;,
+    &quot;read-only-textarea-4&quot;
+];
+
+function testQuerySelector(selector, expectedResults)
+{
+    shouldBe('document.querySelectorAll(&quot;' + selector + '&quot;).length', &quot;&quot; + expectedResults.length);
+    for (var i = 0; i &lt; expectedResults.length; ++i)
+        shouldBeEqualToString('document.querySelectorAll(&quot;' + selector + '&quot;)[' + i + '].id', expectedResults[i]);
+}
+
+function testStyling(expectedReadOnlyElements)
+{
+    var allTestCases = document.querySelectorAll('#test-block *');
+    for (var i = 0; i &lt; allTestCases.length; ++i) {
+        var isReadOnly = expectedReadOnlyElements.indexOf(allTestCases[i].id) &gt;= 0;
+        shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[' + i + ']).color', isReadOnly ? 'rgb(0, 0, 0)' : 'rgb(0, 255, 0)')
+        shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[' + i + ']).backgroundColor', isReadOnly ? 'rgb(255, 0, 0)' : 'rgb(255, 255, 255)')
+    }
+}
+
+testStyling(nonEditableElements);
+
+testQuerySelector(&quot;#test-block :read-write&quot;, editableElements);
+testQuerySelector(&quot;#test-block :read-only&quot;, nonEditableElements);
+
+&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="trunkLayoutTestsfastselectorsreadonlyreadwritecontenteditablebasicsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/read-only-read-write-contenteditable-basics-expected.txt (0 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/read-only-read-write-contenteditable-basics-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/read-only-read-write-contenteditable-basics-expected.txt        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -0,0 +1,95 @@
</span><ins>+Test the basic features of &quot;:read-only&quot;, &quot;:read-write&quot; on elements with the contenteditable attribute. The definition is that &quot;:read-write&quot; is matches for &quot;elements that are editing hosts or editable and are neither input elements nor textarea elements&quot;
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[0]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[0]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[1]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[1]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[2]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[2]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[3]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[3]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[4]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[4]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[5]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[5]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[6]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[6]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[7]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[7]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[8]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[8]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[9]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[9]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[10]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[10]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[11]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[11]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[12]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[12]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[13]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[13]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[14]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[14]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[15]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[15]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[16]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[16]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[17]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[17]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[18]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[18]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[19]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[19]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[20]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[20]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[21]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[21]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[22]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[22]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[23]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[23]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[24]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[24]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[25]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[25]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[26]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[26]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[27]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[27]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;).length is 12
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[0].id is &quot;editing-host-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[1].id is &quot;editable-block-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[2].id is &quot;editing-host-2&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[3].id is &quot;editable-block-2&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[4].id is &quot;editing-host-3&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[5].id is &quot;editable-block-3&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[6].id is &quot;editing-host-4&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[7].id is &quot;editable-block-4&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[8].id is &quot;editing-host-5&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[9].id is &quot;read-write-input&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[10].id is &quot;editing-host-6&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[11].id is &quot;read-write-textarea&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;).length is 16
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[0].id is &quot;non-editable-block-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[1].id is &quot;non-editable-subblock-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[2].id is &quot;non-editable-block-2&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[3].id is &quot;non-editable-subblock-2&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[4].id is &quot;non-editable-block-3&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[5].id is &quot;non-editable-subblock-3&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[6].id is &quot;non-editable-block-4&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[7].id is &quot;non-editable-subblock-4&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[8].id is &quot;read-only-input-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[9].id is &quot;read-only-input-2&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[10].id is &quot;read-only-input-3&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[11].id is &quot;read-only-input-4&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[12].id is &quot;read-only-textarea-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[13].id is &quot;read-only-textarea-2&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[14].id is &quot;read-only-textarea-3&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[15].id is &quot;read-only-textarea-4&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsreadonlyreadwritecontenteditablebasicshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/read-only-read-write-contenteditable-basics.html (0 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/read-only-read-write-contenteditable-basics.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/read-only-read-write-contenteditable-basics.html        2014-09-09 21:03:29 UTC (rev 173441)
</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;
+#test-block * {
+    background-color: white;
+    color: black;
+}
+#test-block :read-only {
+    background-color: red;
+}
+#test-block :read-write {
+    color: lime;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div style=&quot;display:none;&quot; id=&quot;test-block&quot;&gt;
+        &lt;!-- Default is true --&gt;
+        &lt;div id=&quot;editing-host-1&quot; contenteditable&gt;
+            &lt;div id=&quot;editable-block-1&quot;&gt;Editable&lt;/div&gt;
+            &lt;div id=&quot;non-editable-block-1&quot; contenteditable=false&gt;
+                &lt;div id=&quot;non-editable-subblock-1&quot;&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- True is true :) --&gt;
+        &lt;div id=&quot;editing-host-2&quot; contenteditable=true&gt;
+            &lt;div id=&quot;editable-block-2&quot;&gt;Editable&lt;/div&gt;
+            &lt;div id=&quot;non-editable-block-2&quot; contenteditable=false&gt;
+                &lt;div id=&quot;non-editable-subblock-2&quot;&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- The case of the attribute's value is irrelevant. --&gt;
+        &lt;div id=&quot;editing-host-3&quot; contenteditable=&quot;TrUe&quot;&gt;
+            &lt;div id=&quot;editable-block-3&quot;&gt;Editable&lt;/div&gt;
+            &lt;div id=&quot;non-editable-block-3&quot; contenteditable=&quot;FaLsE&quot;&gt;
+                &lt;div id=&quot;non-editable-subblock-3&quot;&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- The value &quot;plaintext-only&quot; is a WebKit extension, it defines an editing host too. --&gt;
+        &lt;div id=&quot;editing-host-4&quot; contenteditable=&quot;plaintext-only&quot;&gt;
+            &lt;div id=&quot;editable-block-4&quot;&gt;Editable&lt;/div&gt;
+            &lt;div id=&quot;non-editable-block-4&quot; contenteditable=&quot;false&quot;&gt;
+                &lt;div id=&quot;non-editable-subblock-4&quot;&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+
+        &lt;!-- Per definition, the rules for editing host and editable elements do not apply do &lt;input&gt; elements. --&gt;
+        &lt;div id=&quot;editing-host-5&quot; contenteditable=true&gt;
+            &lt;input type=&quot;text&quot; id=&quot;read-write-input&quot; value=&quot;read-write input&quot;&gt;
+            &lt;input type=&quot;text&quot; disabled id=&quot;read-only-input-1&quot; value=&quot;read-only input&quot;&gt;
+            &lt;input type=&quot;text&quot; readonly id=&quot;read-only-input-2&quot; value=&quot;read-only input&quot;&gt;
+        &lt;/div&gt;
+        &lt;input type=&quot;text&quot; contenteditable=true disabled id=&quot;read-only-input-3&quot; value=&quot;read-only input&quot;&gt;
+        &lt;input type=&quot;text&quot; contenteditable=true readonly id=&quot;read-only-input-4&quot; value=&quot;read-only input&quot;&gt;
+
+        &lt;!-- Same story for &lt;textarea&gt;, it has its own definition of :read-write/:read-only. The rules for editing host and editable elements do not apply must be ignored. --&gt;
+        &lt;div id=&quot;editing-host-6&quot; contenteditable=true&gt;
+            &lt;textarea id=&quot;read-write-textarea&quot;&gt;Editable text area&lt;/textarea&gt;
+            &lt;textarea disabled id=&quot;read-only-textarea-1&quot;&gt;Non editable text area&lt;/textarea&gt;
+            &lt;textarea readonly id=&quot;read-only-textarea-2&quot;&gt;Non editable text area&lt;/textarea&gt;
+        &lt;/div&gt;
+        &lt;textarea contenteditable=true disabled id=&quot;read-only-textarea-3&quot;&gt;Non editable text area&lt;/textarea&gt;
+        &lt;textarea contenteditable=true readonly id=&quot;read-only-textarea-4&quot;&gt;Non editable text area&lt;/textarea&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test the basic features of &quot;:read-only&quot;, &quot;:read-write&quot; on elements with the contenteditable attribute. The definition is that &quot;:read-write&quot; is matches for &quot;elements that are editing hosts or editable and are neither input elements nor textarea elements&quot;');
+
+var editableElements = [
+    &quot;editing-host-1&quot;,
+    &quot;editable-block-1&quot;,
+    &quot;editing-host-2&quot;,
+    &quot;editable-block-2&quot;,
+    &quot;editing-host-3&quot;,
+    &quot;editable-block-3&quot;,
+    &quot;editing-host-4&quot;,
+    &quot;editable-block-4&quot;,
+    &quot;editing-host-5&quot;,
+    &quot;read-write-input&quot;,
+    &quot;editing-host-6&quot;,
+    &quot;read-write-textarea&quot;,
+];
+
+var nonEditableElements = [
+    &quot;non-editable-block-1&quot;,
+    &quot;non-editable-subblock-1&quot;,
+    &quot;non-editable-block-2&quot;,
+    &quot;non-editable-subblock-2&quot;,
+    &quot;non-editable-block-3&quot;,
+    &quot;non-editable-subblock-3&quot;,
+    &quot;non-editable-block-4&quot;,
+    &quot;non-editable-subblock-4&quot;,
+    &quot;read-only-input-1&quot;,
+    &quot;read-only-input-2&quot;,
+    &quot;read-only-input-3&quot;,
+    &quot;read-only-input-4&quot;,
+    &quot;read-only-textarea-1&quot;,
+    &quot;read-only-textarea-2&quot;,
+    &quot;read-only-textarea-3&quot;,
+    &quot;read-only-textarea-4&quot;
+];
+
+function testQuerySelector(selector, expectedResults)
+{
+    shouldBe('document.querySelectorAll(&quot;' + selector + '&quot;).length', &quot;&quot; + expectedResults.length);
+    for (var i = 0; i &lt; expectedResults.length; ++i)
+        shouldBeEqualToString('document.querySelectorAll(&quot;' + selector + '&quot;)[' + i + '].id', expectedResults[i]);
+}
+
+function testStyling(expectedReadOnlyElements)
+{
+    var allTestCases = document.querySelectorAll('#test-block *');
+    for (var i = 0; i &lt; allTestCases.length; ++i) {
+        var isReadOnly = expectedReadOnlyElements.indexOf(allTestCases[i].id) &gt;= 0;
+        shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[' + i + ']).color', isReadOnly ? 'rgb(0, 0, 0)' : 'rgb(0, 255, 0)')
+        shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[' + i + ']).backgroundColor', isReadOnly ? 'rgb(255, 0, 0)' : 'rgb(255, 255, 255)')
+    }
+}
+
+testStyling(nonEditableElements);
+
+testQuerySelector(&quot;#test-block :read-write&quot;, editableElements);
+testQuerySelector(&quot;#test-block :read-only&quot;, nonEditableElements);
+
+&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="trunkLayoutTestsfastselectorsreadonlyreadwritecontenteditablesvgforeignObjectexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/read-only-read-write-contenteditable-svg-foreignObject-expected.txt (0 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/read-only-read-write-contenteditable-svg-foreignObject-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/read-only-read-write-contenteditable-svg-foreignObject-expected.txt        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -0,0 +1,50 @@
</span><ins>+At the time of writing this test, there is no specification for contenteditable for SVG. Adding contenteditable on an SVG element does not create an editing host. This test verify that having a SVG or HTML attribute &quot;contenteditable&quot; does not interfere with the selectors :read-write and :read-only.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[0]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[0]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[1]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[1]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[2]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[2]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[3]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[3]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[4]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[4]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[5]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[5]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[6]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[6]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[7]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[7]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[8]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[8]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[9]).color is &quot;rgb(0, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[9]).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[10]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[10]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[11]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[11]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[12]).color is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[12]).backgroundColor is &quot;rgb(255, 255, 255)&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;).length is 6
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[0].id is &quot;editing-host-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[1].id is &quot;editable-block-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[2].id is &quot;editing-host-2&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[3].id is &quot;editable-block-2&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[4].id is &quot;nested-editing-host-2&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-write&quot;)[5].id is &quot;editable-block-3&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;).length is 7
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[0].id is &quot;svg-root-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[1].id is &quot;fake-contenteditable-group-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[2].id is &quot;foreign-object-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[3].id is &quot;non-editable-block-1&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[4].id is &quot;svg-root-2&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[5].id is &quot;fake-contenteditable-group-2&quot;
+PASS document.querySelectorAll(&quot;#test-block :read-only&quot;)[6].id is &quot;foreign-object-2&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsreadonlyreadwritecontenteditablesvgforeignObjecthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/read-only-read-write-contenteditable-svg-foreignObject.html (0 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/read-only-read-write-contenteditable-svg-foreignObject.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/read-only-read-write-contenteditable-svg-foreignObject.html        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -0,0 +1,94 @@
</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;
+#test-block * {
+    background-color: white;
+    color: black;
+}
+#test-block :read-only {
+    background-color: red;
+}
+#test-block :read-write {
+    color: lime;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div id=&quot;test-block&quot; style=&quot;display:none;&quot;&gt;
+        &lt;svg id=&quot;svg-root-1&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xhtml=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
+            &lt;g id=&quot;fake-contenteditable-group-1&quot; contenteditable xhtml:contenteditable&gt;
+                &lt;foreignObject id=&quot;foreign-object-1&quot; x=&quot;10&quot; y=&quot;10&quot; width=&quot;800&quot; height=&quot;150&quot;&gt;
+                    &lt;body xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
+                        &lt;div id=&quot;non-editable-block-1&quot;&gt;Not Editable&lt;/div&gt;
+                        &lt;div id=&quot;editing-host-1&quot; contenteditable&gt;
+                            &lt;div id=&quot;editable-block-1&quot;&gt;Editable&lt;/div&gt;
+                        &lt;/div&gt;
+                    &lt;/body&gt;
+                &lt;/foreignObject&gt;
+            &lt;/g&gt;
+        &lt;/svg&gt;
+        &lt;div contenteditable id=&quot;editing-host-2&quot;&gt;
+            &lt;svg id=&quot;svg-root-2&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;
+                &lt;g id=&quot;fake-contenteditable-group-2&quot; contenteditable=&quot;false&quot; xhtml:contenteditable=&quot;false&quot;&gt;
+                    &lt;foreignObject id=&quot;foreign-object-2&quot; x=&quot;10&quot; y=&quot;10&quot; width=&quot;800&quot; height=&quot;150&quot;&gt;
+                        &lt;body xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
+                            &lt;div id=&quot;editable-block-2&quot;&gt;Editable&lt;/div&gt;
+                            &lt;div id=&quot;nested-editing-host-2&quot; contenteditable&gt;
+                                &lt;div id=&quot;editable-block-3&quot;&gt;Editable&lt;/div&gt;
+                            &lt;/div&gt;
+                        &lt;/body&gt;
+                    &lt;/foreignObject&gt;
+                &lt;/g&gt;
+            &lt;/svg&gt;
+        &lt;/div&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('At the time of writing this test, there is no specification for contenteditable for SVG. Adding contenteditable on an SVG element does not create an editing host. This test verify that having a SVG or HTML attribute &quot;contenteditable&quot; does not interfere with the selectors :read-write and :read-only.');
+
+var editableElements = [
+    &quot;editing-host-1&quot;,
+    &quot;editable-block-1&quot;,
+    &quot;editing-host-2&quot;,
+    &quot;editable-block-2&quot;,
+    &quot;nested-editing-host-2&quot;,
+    &quot;editable-block-3&quot;,
+];
+
+var nonEditableElements = [
+    &quot;svg-root-1&quot;,
+    &quot;fake-contenteditable-group-1&quot;,
+    &quot;foreign-object-1&quot;,
+    &quot;non-editable-block-1&quot;,
+    &quot;svg-root-2&quot;,
+    &quot;fake-contenteditable-group-2&quot;,
+    &quot;foreign-object-2&quot;,
+];
+
+function testQuerySelector(selector, expectedResults)
+{
+    shouldBe('document.querySelectorAll(&quot;' + selector + '&quot;).length', &quot;&quot; + expectedResults.length);
+    for (var i = 0; i &lt; expectedResults.length; ++i)
+        shouldBeEqualToString('document.querySelectorAll(&quot;' + selector + '&quot;)[' + i + '].id', expectedResults[i]);
+}
+
+function testStyling(expectedReadOnlyElements)
+{
+    var allTestCases = document.querySelectorAll('#test-block *');
+    for (var i = 0; i &lt; allTestCases.length; ++i) {
+        var isReadOnly = expectedReadOnlyElements.indexOf(allTestCases[i].id) &gt;= 0;
+        shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[' + i + ']).color', isReadOnly ? 'rgb(0, 0, 0)' : 'rgb(0, 255, 0)')
+        shouldBeEqualToString('getComputedStyle(document.querySelectorAll(&quot;#test-block *&quot;)[' + i + ']).backgroundColor', isReadOnly ? 'rgb(255, 0, 0)' : 'rgb(255, 255, 255)')
+    }
+}
+
+testStyling(nonEditableElements);
+
+testQuerySelector(&quot;#test-block :read-write&quot;, editableElements);
+testQuerySelector(&quot;#test-block :read-only&quot;, nonEditableElements);
+
+&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="trunkLayoutTestsfastselectorsreadonlyreadwritedesignmodebasicsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/read-only-read-write-designmode-basics-expected.txt (0 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/read-only-read-write-designmode-basics-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/read-only-read-write-designmode-basics-expected.txt        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+Test the basic features of &quot;:read-only&quot;, &quot;:read-write&quot; on elements with the design mode enabled. The definition is that &quot;:read-write&quot; is matches for &quot;elements that are editing hosts or editable and are neither input elements nor textarea elements&quot;
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS testQuerySelector() is true
+PASS testStyling() is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsreadonlyreadwritedesignmodebasicshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/read-only-read-write-designmode-basics.html (0 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/read-only-read-write-designmode-basics.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/read-only-read-write-designmode-basics.html        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -0,0 +1,139 @@
</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 id=&quot;toNukeAfterTest&quot;&gt;
+* {
+    background-color: white;
+    color: black;
+}
+:read-only {
+    background-color: red;
+}
+:read-write {
+    color: lime;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div style=&quot;display:none;&quot; id=&quot;test-block&quot;&gt;
+        &lt;!-- Default is true --&gt;
+        &lt;div contenteditable&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;div id=&quot;non-editable-block-1&quot; contenteditable=false&gt;
+                &lt;div id=&quot;non-editable-subblock-1&quot;&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- True is true :) --&gt;
+        &lt;div contenteditable=true&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;div id=&quot;non-editable-block-2&quot; contenteditable=false&gt;
+                &lt;div id=&quot;non-editable-subblock-2&quot;&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- The case of the attribute's value is irrelevant. --&gt;
+        &lt;div contenteditable=&quot;TrUe&quot;&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;div id=&quot;non-editable-block-3&quot; contenteditable=&quot;FaLsE&quot;&gt;
+                &lt;div id=&quot;non-editable-subblock-3&quot;&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;!-- The value &quot;plaintext-only&quot; is a WebKit extension, it defines an editing host too. --&gt;
+        &lt;div contenteditable=&quot;plaintext-only&quot;&gt;
+            &lt;div&gt;Editable&lt;/div&gt;
+            &lt;div id=&quot;non-editable-block-4&quot; contenteditable=&quot;false&quot;&gt;
+                &lt;div id=&quot;non-editable-subblock-4&quot;&gt;Not editable&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+
+        &lt;!-- Per definition, the rules for editing host and editable elements do not apply do &lt;input&gt; elements. --&gt;
+        &lt;div contenteditable=true&gt;
+            &lt;input type=&quot;text&quot; id=&quot;read-write-input&quot; value=&quot;read-write input&quot;&gt;
+            &lt;input type=&quot;text&quot; disabled id=&quot;read-only-input-1&quot; value=&quot;read-only input&quot;&gt;
+            &lt;input type=&quot;text&quot; readonly id=&quot;read-only-input-2&quot; value=&quot;read-only input&quot;&gt;
+        &lt;/div&gt;
+        &lt;input type=&quot;text&quot; contenteditable=true disabled id=&quot;read-only-input-3&quot; value=&quot;read-only input&quot;&gt;
+        &lt;input type=&quot;text&quot; contenteditable=true readonly id=&quot;read-only-input-4&quot; value=&quot;read-only input&quot;&gt;
+
+        &lt;!-- Same story for &lt;textarea&gt;, it has its own definition of :read-write/:read-only. The rules for editing host and editable elements do not apply must be ignored. --&gt;
+        &lt;div contenteditable=true&gt;
+            &lt;textarea id=&quot;read-write-textarea&quot;&gt;Editable text area&lt;/textarea&gt;
+            &lt;textarea disabled id=&quot;read-only-textarea-1&quot;&gt;Non editable text area&lt;/textarea&gt;
+            &lt;textarea readonly id=&quot;read-only-textarea-2&quot;&gt;Non editable text area&lt;/textarea&gt;
+        &lt;/div&gt;
+        &lt;textarea contenteditable=true disabled id=&quot;read-only-textarea-3&quot;&gt;Non editable text area&lt;/textarea&gt;
+        &lt;textarea contenteditable=true readonly id=&quot;read-only-textarea-4&quot;&gt;Non editable text area&lt;/textarea&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test the basic features of &quot;:read-only&quot;, &quot;:read-write&quot; on elements with the design mode enabled. The definition is that &quot;:read-write&quot; is matches for &quot;elements that are editing hosts or editable and are neither input elements nor textarea elements&quot;');
+
+// This test is derivative from the contenteditable test. Unlike that one, here designMode is enabled, everything is editable unless explicitely disabled.
+document.designMode = &quot;on&quot;;
+
+var nonEditableElements = [
+    &quot;non-editable-block-1&quot;,
+    &quot;non-editable-subblock-1&quot;,
+    &quot;non-editable-block-2&quot;,
+    &quot;non-editable-subblock-2&quot;,
+    &quot;non-editable-block-3&quot;,
+    &quot;non-editable-subblock-3&quot;,
+    &quot;non-editable-block-4&quot;,
+    &quot;non-editable-subblock-4&quot;,
+    &quot;read-only-input-1&quot;,
+    &quot;read-only-input-2&quot;,
+    &quot;read-only-input-3&quot;,
+    &quot;read-only-input-4&quot;,
+    &quot;read-only-textarea-1&quot;,
+    &quot;read-only-textarea-2&quot;,
+    &quot;read-only-textarea-3&quot;,
+    &quot;read-only-textarea-4&quot;
+];
+
+// Since altering the DOM changes the results, everything needs to be done prior to showing the results.
+function testQuerySelector()
+{
+    var allReadWrite = document.querySelectorAll(&quot;:read-write&quot;);
+    for (var i = 0; i &lt; allReadWrite.length; ++i) {
+        if (nonEditableElements.indexOf(allReadWrite[i].id) &gt;= 0) {
+            debug(&quot;Element i = &quot; + i + &quot; id = &quot; + allReadWrite[i].id + &quot;was expected to be read-write.&quot;);
+            return false;
+        }
+    }
+
+    var allReadOnly = document.querySelectorAll(&quot;:read-only&quot;);
+    for (var i = 0; i &lt; allReadOnly.length; ++i) {
+        if (nonEditableElements.indexOf(allReadOnly[i].id) === -1) {
+            debug(&quot;Element i = &quot; + i + &quot; id = &quot; + allReadWrite[i].id + &quot;was expected to be read-only.&quot;);
+            return false;
+        }
+    }
+    return true;
+}
+shouldBeTrue(&quot;testQuerySelector()&quot;);
+
+function testStyling()
+{
+    var allTestCases = document.querySelectorAll('*');
+    for (var i = 0; i &lt; allTestCases.length; ++i) {
+        var isReadOnly = nonEditableElements.indexOf(allTestCases[i].id) &gt;= 0;
+        var expectedColor = isReadOnly ? 'rgb(0, 0, 0)' : 'rgb(0, 255, 0)';
+        if (getComputedStyle(allTestCases[i]).color != expectedColor) {
+            debug(&quot;Expected color &quot; + expectedColor + &quot; on element i = &quot; + i + &quot; id = \&quot;&quot; + allTestCases[i].id + &quot;\&quot;. Got &quot; + getComputedStyle(allTestCases[i]).color);
+            return false;
+        }
+
+        var expectedBackgroundColor = isReadOnly ? 'rgb(255, 0, 0)' : 'rgb(255, 255, 255)';
+        if (getComputedStyle(allTestCases[i]).backgroundColor != expectedBackgroundColor) {
+            debug(&quot;Expected background color &quot; + expectedBackgroundColor + &quot;on element i = &quot; + i + &quot; id = &quot; + allTestCases[i].id + &quot;. Got &quot; + getComputedStyle(allTestCases[i]).backgroundColor);
+            return false;
+        }
+    }
+    return true;
+}
+shouldBeTrue(&quot;testStyling()&quot;);
+
+document.getElementById(&quot;toNukeAfterTest&quot;).innerHTML = &quot;&quot;; // To style the results properly.
+&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="trunkLayoutTestsfastselectorsreadonlyreadwritestyleupdateexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/read-only-read-write-style-update-expected.txt (0 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/read-only-read-write-style-update-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/read-only-read-write-style-update-expected.txt        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+Test that the style is invalidated and updated properly when properties causing :read-only/:read-write change.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Initially, the target should be read only.
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+Changing content editable via the API.
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+Changing content editable via the attributes.
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+Changing content editable on the parent via the API.
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+Changing content editable via the attributes.
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(0, 255, 0)&quot;
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+Moving the document to design mode.
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(0, 255, 0)&quot;
+Setting the target's contenteditable to true should not change a thing now.
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(0, 255, 0)&quot;
+Setting the target's contenteditable to false should still be respected in design mode.
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+Let's remove the contenteditable attribute on the target, we should still be read-write because of design mode.
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(0, 255, 0)&quot;
+Disabling design mode.
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor is &quot;rgb(255, 0, 0)&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsreadonlyreadwritestyleupdatehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/read-only-read-write-style-update.html (0 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/read-only-read-write-style-update.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/read-only-read-write-style-update.html        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -0,0 +1,111 @@
</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;
+}
+target:read-only {
+    background-color: red;
+}
+target:read-write {
+    background-color: lime;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div style=&quot;display:none&quot;&gt;
+        &lt;target&gt;&lt;/target&gt;
+        &lt;target id=&quot;target&quot;&gt;&lt;/target&gt;
+        &lt;target&gt;&lt;/target&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test that the style is invalidated and updated properly when properties causing :read-only/:read-write change.');
+
+function testStyle(expectReadOnly)
+{
+    shouldBeEqualToString('getComputedStyle(document.getElementById(&quot;target&quot;)).backgroundColor', expectReadOnly ? 'rgb(255, 0, 0)' : 'rgb(0, 255, 0)');
+}
+
+debug(&quot;Initially, the target should be read only.&quot;);
+testStyle(true);
+
+debug(&quot;Changing content editable via the API.&quot;);
+var target = document.getElementById('target');
+target.contentEditable = &quot;true&quot;;
+testStyle(false);
+
+target.contentEditable = &quot;false&quot;;
+testStyle(true);
+
+target.contentEditable = &quot;plaintext-only&quot;;
+testStyle(false);
+
+target.contentEditable = false;
+testStyle(true);
+
+debug(&quot;Changing content editable via the attributes.&quot;);
+target.setAttribute(&quot;CoNtEnTeDiTaBlE&quot;, &quot;true&quot;);
+testStyle(false);
+
+target.setAttribute(&quot;CoNtEnTeDiTaBlE&quot;, &quot;false&quot;);
+testStyle(true);
+
+target.setAttribute(&quot;CoNtEnTeDiTaBlE&quot;, &quot;&quot;);
+testStyle(false);
+
+target.removeAttribute(&quot;contenteditable&quot;);
+testStyle(true);
+
+debug(&quot;Changing content editable on the parent via the API.&quot;);
+var parent = target.parentElement;
+parent.contentEditable = &quot;true&quot;;
+testStyle(false);
+
+parent.contentEditable = &quot;false&quot;;
+testStyle(true);
+
+parent.contentEditable = &quot;plaintext-only&quot;;
+testStyle(false);
+
+parent.contentEditable = false;
+testStyle(true);
+
+debug(&quot;Changing content editable via the attributes.&quot;);
+parent.setAttribute(&quot;CoNtEnTeDiTaBlE&quot;, &quot;true&quot;);
+testStyle(false);
+
+parent.setAttribute(&quot;CoNtEnTeDiTaBlE&quot;, &quot;false&quot;);
+testStyle(true);
+
+parent.setAttribute(&quot;CoNtEnTeDiTaBlE&quot;, &quot;&quot;);
+testStyle(false);
+
+parent.removeAttribute(&quot;contenteditable&quot;);
+testStyle(true);
+
+debug(&quot;Moving the document to design mode.&quot;);
+document.designMode = &quot;on&quot;;
+testStyle(false);
+
+debug(&quot;Setting the target's contenteditable to true should not change a thing now.&quot;);
+target.contentEditable = &quot;true&quot;;
+testStyle(false);
+
+debug(&quot;Setting the target's contenteditable to false should still be respected in design mode.&quot;);
+target.contentEditable = &quot;false&quot;;
+testStyle(true);
+
+debug(&quot;Let's remove the contenteditable attribute on the target, we should still be read-write because of design mode.&quot;);
+target.removeAttribute(&quot;contenteditable&quot;);
+testStyle(false);
+
+debug(&quot;Disabling design mode.&quot;);
+document.designMode = &quot;off&quot;;
+testStyle(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="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (173440 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-09-09 20:56:55 UTC (rev 173440)
+++ trunk/Source/WebCore/ChangeLog        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -1,3 +1,67 @@
</span><ins>+2014-09-09  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+        Add support for :read-write/:read-only matching editable content
+        https://bugs.webkit.org/show_bug.cgi?id=136668
+
+        Reviewed by Antti Koivisto.
+
+        This is the second part of the update of :read-write/:read-only to the latest spec
+        (http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting.html#selectors).
+
+        The selectors :read-write/:read-only should match elements that are editable. The exact definition is:
+        &quot;elements that are editing hosts or editable and are neither input elements nor textarea elements&quot;.
+
+        Matching that definition is really easy. It was done by updating HTMLElement's matchesReadWritePseudoClass()
+        to consider both contentEditable and designMode.
+
+        The tricky part is making that efficient in all cases. Matching contentEditable is horribly inefficient
+        compared to the other primitives. We don't want to execute that for every element.
+
+        Since matchesReadWritePseudoClass() was used by the theming code, that code was adjusted to
+        -Avoid calling that on regular HTMLElement, limiting the query to &lt;input&gt; and &lt;textarea&gt; where it is fast.
+        -Avoid the call entirely when possible.
+
+        Tests: fast/css/read-only-read-write-contenteditable-basics.html
+               fast/css/read-only-read-write-designmode-basics.html
+               fast/css/read-only-read-write-webkit-user-modify.html
+               fast/selectors/read-only-read-write-contenteditable-basics.html
+               fast/selectors/read-only-read-write-contenteditable-svg-foreignObject.html
+               fast/selectors/read-only-read-write-designmode-basics.html
+               fast/selectors/read-only-read-write-style-update.html
+
+        * html/HTMLElement.cpp:
+        (WebCore::contentEditableType):
+        This code is a generalization of the code that was in HTMLElement::contentEditable().
+        It is used by both matchesReadWritePseudoClass() and contentEditable() to determine
+        a valid state from the value of contentEditable.
+
+        (WebCore::HTMLElement::matchesReadWritePseudoClass):
+        Per the definition of editable content, we first check if the current element is an editing host,
+        if not we look for an editing host. If there are none, test for designMode.
+
+        (WebCore::HTMLElement::contentEditable):
+
+        (WebCore::RenderTheme::isReadOnlyControl):
+        The old definition would only match &lt;input&gt; and &lt;textarea&gt;. The code was updated to keep the same
+        behavior after matchesReadWritePseudoClass() is udpated. This avoids the performance problem of calling
+        matchesReadWritePseudoClass() on regular HTMLElement.
+
+        * platform/ControlStates.h:
+        ReadOnlyState was only used by ThemeMac for convertControlStatesToThemeDrawState().
+        In turn, convertControlStatesToThemeDrawState() was only used for painting
+        &quot;-webkit-inner-spin-button&quot;. Buttons are not read-write to begin with.
+        The whole code looks like legacy from styling of input elements and was removed.
+
+        Removing ReadOnlyState removes the expensive part of extractControlStatesForRenderer().
+
+        * html/HTMLElement.h:
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::HTMLFormControlElement::readOnlyAttributeChanged):
+        * platform/mac/ThemeMac.mm:
+        (WebCore::convertControlStatesToThemeDrawState):
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::extractControlStatesForRenderer):
+
</ins><span class="cx"> 2014-09-09  Jer Noble  &lt;jer.noble@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [MSE] media/media-source tests broken after r173318
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLElement.cpp (173440 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLElement.cpp        2014-09-09 20:56:55 UTC (rev 173440)
+++ trunk/Source/WebCore/html/HTMLElement.cpp        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -336,6 +336,55 @@
</span><span class="cx">         map.add(customTable[i].attributeName.localName().impl(), customTable[i].eventName);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+enum class ContentEditableType {
+    Inherit,
+    True,
+    False,
+    PlaintextOnly
+};
+
+static ContentEditableType contentEditableType(const HTMLElement&amp; element)
+{
+    const AtomicString&amp; value = element.fastGetAttribute(contenteditableAttr);
+
+    if (value.isNull())
+        return ContentEditableType::Inherit;
+    if (value.isEmpty() || equalIgnoringCase(value, &quot;true&quot;))
+        return ContentEditableType::True;
+    if (equalIgnoringCase(value, &quot;false&quot;))
+        return ContentEditableType::False;
+    if (equalIgnoringCase(value, &quot;plaintext-only&quot;))
+        return ContentEditableType::PlaintextOnly;
+
+    return ContentEditableType::Inherit;
+}
+
+bool HTMLElement::matchesReadWritePseudoClass() const
+{
+    const Element* currentElement = this;
+    do {
+        if (currentElement-&gt;isHTMLElement()) {
+            switch (contentEditableType(toHTMLElement(*currentElement))) {
+            case ContentEditableType::True:
+            case ContentEditableType::PlaintextOnly:
+                return true;
+            case ContentEditableType::False:
+                return false;
+            case ContentEditableType::Inherit:
+                break;
+            }
+        }
+        currentElement = currentElement-&gt;parentElement();
+    } while (currentElement);
+
+    const Document&amp; document = this-&gt;document();
+    if (document.isHTMLDocument()) {
+        const HTMLDocument&amp; htmlDocument = toHTMLDocument(document);
+        return htmlDocument.inDesignMode();
+    }
+    return false;
+}
+
</ins><span class="cx"> void HTMLElement::parseAttribute(const QualifiedName&amp; name, const AtomicString&amp; value)
</span><span class="cx"> {
</span><span class="cx">     if (name == HTMLNames::idAttr || name == HTMLNames::classAttr || name == HTMLNames::styleAttr)
</span><span class="lines">@@ -680,17 +729,16 @@
</span><span class="cx"> 
</span><span class="cx"> String HTMLElement::contentEditable() const
</span><span class="cx"> {
</span><del>-    const AtomicString&amp; value = fastGetAttribute(contenteditableAttr);
-
-    if (value.isNull())
</del><ins>+    switch (contentEditableType(*this)) {
+    case ContentEditableType::Inherit:
</ins><span class="cx">         return ASCIILiteral(&quot;inherit&quot;);
</span><del>-    if (value.isEmpty() || equalIgnoringCase(value, &quot;true&quot;))
</del><ins>+    case ContentEditableType::True:
</ins><span class="cx">         return ASCIILiteral(&quot;true&quot;);
</span><del>-    if (equalIgnoringCase(value, &quot;false&quot;))
</del><ins>+    case ContentEditableType::False:
</ins><span class="cx">         return ASCIILiteral(&quot;false&quot;);
</span><del>-    if (equalIgnoringCase(value, &quot;plaintext-only&quot;))
</del><ins>+    case ContentEditableType::PlaintextOnly:
</ins><span class="cx">         return ASCIILiteral(&quot;plaintext-only&quot;);
</span><del>-
</del><ins>+    }
</ins><span class="cx">     return ASCIILiteral(&quot;inherit&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLElement.h (173440 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLElement.h        2014-09-09 20:56:55 UTC (rev 173440)
+++ trunk/Source/WebCore/html/HTMLElement.h        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -111,6 +111,7 @@
</span><span class="cx">     void applyAlignmentAttributeToStyle(const AtomicString&amp;, MutableStyleProperties&amp;);
</span><span class="cx">     void applyBorderAttributeToStyle(const AtomicString&amp;, MutableStyleProperties&amp;);
</span><span class="cx"> 
</span><ins>+    virtual bool matchesReadWritePseudoClass() const;
</ins><span class="cx">     virtual void parseAttribute(const QualifiedName&amp;, const AtomicString&amp;) override;
</span><span class="cx">     virtual bool isPresentationAttribute(const QualifiedName&amp;) const override;
</span><span class="cx">     virtual void collectStyleForPresentationAttribute(const QualifiedName&amp;, const AtomicString&amp;, MutableStyleProperties&amp;) override;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFormControlElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (173440 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp        2014-09-09 20:56:55 UTC (rev 173440)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -162,8 +162,6 @@
</span><span class="cx"> {
</span><span class="cx">     setNeedsWillValidateCheck();
</span><span class="cx">     setNeedsStyleRecalc();
</span><del>-    if (renderer() &amp;&amp; renderer()-&gt;style().hasAppearance())
-        renderer()-&gt;theme().stateChanged(*renderer(), ControlStates::ReadOnlyState);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLFormControlElement::requiredAttributeChanged()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformControlStatesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ControlStates.h (173440 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ControlStates.h        2014-09-09 20:56:55 UTC (rev 173440)
+++ trunk/Source/WebCore/platform/ControlStates.h        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -45,11 +45,10 @@
</span><span class="cx">         FocusState = 1 &lt;&lt; 2,
</span><span class="cx">         EnabledState = 1 &lt;&lt; 3,
</span><span class="cx">         CheckedState = 1 &lt;&lt; 4,
</span><del>-        ReadOnlyState = 1 &lt;&lt; 5,
-        DefaultState = 1 &lt;&lt; 6,
-        WindowInactiveState = 1 &lt;&lt; 7,
-        IndeterminateState = 1 &lt;&lt; 8,
-        SpinUpState = 1 &lt;&lt; 9, // Sub-state for HoverState and PressedState.
</del><ins>+        DefaultState = 1 &lt;&lt; 5,
+        WindowInactiveState = 1 &lt;&lt; 6,
+        IndeterminateState = 1 &lt;&lt; 7,
+        SpinUpState = 1 &lt;&lt; 8, // Sub-state for HoverState and PressedState.
</ins><span class="cx">         AllStates = 0xffffffff
</span><span class="cx">     };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacThemeMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/ThemeMac.mm (173440 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/ThemeMac.mm        2014-09-09 20:56:55 UTC (rev 173440)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -243,12 +243,10 @@
</span><span class="cx"> {
</span><span class="cx">     ControlStates::States states = controlStates-&gt;states();
</span><span class="cx"> 
</span><del>-    if (states &amp; ControlStates::ReadOnlyState)
-        return kThemeStateUnavailableInactive;
</del><span class="cx">     if (!(states &amp; ControlStates::EnabledState))
</span><span class="cx">         return kThemeStateUnavailableInactive;
</span><span class="cx"> 
</span><del>-    // Do not process PressedState if !EnabledState or ReadOnlyState.
</del><ins>+    // Do not process PressedState if !EnabledState.
</ins><span class="cx">     if (states &amp; ControlStates::PressedState) {
</span><span class="cx">         if (kind == kThemeIncDecButton || kind == kThemeIncDecButtonSmall || kind == kThemeIncDecButtonMini)
</span><span class="cx">             return states &amp; ControlStates::SpinUpState ? kThemeStatePressedUp : kThemeStatePressedDown;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderThemecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (173440 => 173441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTheme.cpp        2014-09-09 20:56:55 UTC (rev 173440)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp        2014-09-09 21:03:29 UTC (rev 173441)
</span><span class="lines">@@ -752,8 +752,6 @@
</span><span class="cx">         states |= ControlStates::EnabledState;
</span><span class="cx">     if (isChecked(o))
</span><span class="cx">         states |= ControlStates::CheckedState;
</span><del>-    if (isReadOnlyControl(o))
-        states |= ControlStates::ReadOnlyState;
</del><span class="cx">     if (isDefault(o))
</span><span class="cx">         states |= ControlStates::DefaultState;
</span><span class="cx">     if (!isActive(o))
</span><span class="lines">@@ -845,7 +843,7 @@
</span><span class="cx"> bool RenderTheme::isReadOnlyControl(const RenderObject&amp; o) const
</span><span class="cx"> {
</span><span class="cx">     Node* node = o.node();
</span><del>-    if (!node || !node-&gt;isElementNode())
</del><ins>+    if (!node || !node-&gt;isElementNode() || !toElement(node)-&gt;isFormControlElement())
</ins><span class="cx">         return false;
</span><span class="cx">     return !toElement(node)-&gt;matchesReadWritePseudoClass();
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>