Chaging pseudoClass (:enabled) should cause distribution
authorshinyak@chromium.org <shinyak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Nov 2012 03:54:35 +0000 (03:54 +0000)
committershinyak@chromium.org <shinyak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Nov 2012 03:54:35 +0000 (03:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=101900

Reviewed by Dimitri Glazkov.

Source/WebCore:

When element's 'enabled' state is changed, we have to invalidate distribution.

According to the spec, :enabled matches anchor/area/link element having href attribute,
and several form control elements which is not disabled. However, currently :enalbed does not match
anchor/area/link yet. See https://bugs.webkit.org/show_bug.cgi?id=102349

Tests: fast/dom/shadow/pseudoclass-update-enabled-anchor.html
       fast/dom/shadow/pseudoclass-update-enabled-area.html
       fast/dom/shadow/pseudoclass-update-enabled-button.html
       fast/dom/shadow/pseudoclass-update-enabled-fieldset.html
       fast/dom/shadow/pseudoclass-update-enabled-input.html
       fast/dom/shadow/pseudoclass-update-enabled-optgroup.html
       fast/dom/shadow/pseudoclass-update-enabled-option.html
       fast/dom/shadow/pseudoclass-update-enabled-select.html
       fast/dom/shadow/pseudoclass-update-enabled-textarea.html

* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::parseAttribute):
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::disabledAttributeChanged):
* html/HTMLOptGroupElement.cpp:
(WebCore::HTMLOptGroupElement::parseAttribute):
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::parseAttribute):

LayoutTests:

Currently :enabled matches an anchor/area/link element yet. I marked these tests as Failure.

* fast/dom/shadow/pseudoclass-update-enabled-anchor-expected.html: Added.
* fast/dom/shadow/pseudoclass-update-enabled-anchor.html: Added.
* fast/dom/shadow/pseudoclass-update-enabled-area-expected.html: Added.
* fast/dom/shadow/pseudoclass-update-enabled-area.html: Added.
* fast/dom/shadow/pseudoclass-update-enabled-button-expected.html: Added.
* fast/dom/shadow/pseudoclass-update-enabled-button.html: Added.
* fast/dom/shadow/pseudoclass-update-enabled-fieldset-expected.html: Added.
* fast/dom/shadow/pseudoclass-update-enabled-fieldset.html: Added.
* fast/dom/shadow/pseudoclass-update-enabled-input-expected.html: Added.
* fast/dom/shadow/pseudoclass-update-enabled-input.html: Added.
* fast/dom/shadow/pseudoclass-update-enabled-optgroup-expected.txt: Added.
* fast/dom/shadow/pseudoclass-update-enabled-optgroup.html: Added.
* fast/dom/shadow/pseudoclass-update-enabled-option-expected.txt: Added.
* fast/dom/shadow/pseudoclass-update-enabled-option.html: Added.
* fast/dom/shadow/pseudoclass-update-enabled-select-expected.html: Added.
* fast/dom/shadow/pseudoclass-update-enabled-select.html: Added.
* fast/dom/shadow/pseudoclass-update-enabled-textarea-expected.html: Added.
* fast/dom/shadow/pseudoclass-update-enabled-textarea.html: Added.
* platform/chromium/TestExpectations:
* platform/efl/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@134883 268f45cc-cd09-0410-ab3c-d52691b4dbfc

26 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-anchor-expected.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-anchor.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-area-expected.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-area.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-button-expected.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-button.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-fieldset-expected.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-fieldset.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-input-expected.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-input.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-optgroup-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-optgroup.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-option-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-option.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-select-expected.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-select.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-textarea-expected.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-textarea.html [new file with mode: 0644]
LayoutTests/platform/chromium/TestExpectations
LayoutTests/platform/efl/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLAnchorElement.cpp
Source/WebCore/html/HTMLFormControlElement.cpp
Source/WebCore/html/HTMLOptGroupElement.cpp
Source/WebCore/html/HTMLOptionElement.cpp

index 002a3fe..3026d26 100644 (file)
@@ -1,3 +1,33 @@
+2012-11-15  Shinya Kawanaka  <shinyak@chromium.org>
+
+        Chaging pseudoClass (:enabled) should cause distribution
+        https://bugs.webkit.org/show_bug.cgi?id=101900
+
+        Reviewed by Dimitri Glazkov.
+
+        Currently :enabled matches an anchor/area/link element yet. I marked these tests as Failure.
+
+        * fast/dom/shadow/pseudoclass-update-enabled-anchor-expected.html: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-anchor.html: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-area-expected.html: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-area.html: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-button-expected.html: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-button.html: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-fieldset-expected.html: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-fieldset.html: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-input-expected.html: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-input.html: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-optgroup-expected.txt: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-optgroup.html: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-option-expected.txt: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-option.html: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-select-expected.html: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-select.html: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-textarea-expected.html: Added.
+        * fast/dom/shadow/pseudoclass-update-enabled-textarea.html: Added.
+        * platform/chromium/TestExpectations:
+        * platform/efl/TestExpectations:
+
 2012-11-15  Erik Arvidsson  <arv@chromium.org>
 
         Update DOMException name: NamespaceError
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-anchor-expected.html b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-anchor-expected.html
new file mode 100644 (file)
index 0000000..fdfd826
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+
+<body>
+
+<p>When an anchor tag catch 'href' attribute or release 'href' attribute, distribution should happen.</p>
+
+<div><a id="anchor1" href="http://www.example.com/">Anchor 1</a></div>
+<div><a id="anchor4" href="http://www.example.com/">Anchor 4</a></div>
+
+</body>
+</html>
+
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-anchor.html b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-anchor.html
new file mode 100644 (file)
index 0000000..9691404
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/polyfill.js"></script>
+</head>
+
+<body>
+
+<p>When an anchor tag catch 'href' attribute or release 'href' attribute, distribution should happen.</p>
+
+<div id="host1">
+    <a id="anchor1" href="http://www.example.com/">Anchor 1</a>
+    <a id="anchor2" href="http://www.example.com/">Anchor 2</a>
+</div>
+
+<div id="host2">
+    <a id="anchor3">Anchor 3</a>
+    <a id="anchor4">Anchor 4</a>
+</div>
+
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+new WebKitShadowRoot(host1).innerHTML = '<content select=":enabled"></content>';
+new WebKitShadowRoot(host2).innerHTML = '<content select=":enabled"></content>';
+
+setTimeout(function() {
+    anchor2.removeAttribute('href');
+    anchor4.setAttribute('href', 'http://www.example.com/');
+    testRunner.notifyDone();
+}, 0);
+
+</script>
+</body>
+</html>
+
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-area-expected.html b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-area-expected.html
new file mode 100644 (file)
index 0000000..504548a
--- /dev/null
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+
+<body>
+
+<style>
+area {
+    display: inline;
+}
+</style>
+
+<p>When an anchor tag catch 'href' attribute or release 'href' attribute, distribution should happen.</p>
+
+<div id="host1"></div>
+<div id="host2"></div>
+
+<script>
+function createArea(href, textContent)
+{
+    var area = document.createElement('area');
+    if (href)
+        area.setAttribute('href', href);
+    area.appendChild(document.createTextNode(textContent));
+
+    return area;
+}
+
+var area1 = createArea('http://www.example.com/', 'Anchor 1');
+var area4 = createArea('http://www.example.com/', 'Anchor 4');
+
+host1.appendChild(area1);
+host2.appendChild(area4);
+</script>
+</body>
+</html>
+
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-area.html b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-area.html
new file mode 100644 (file)
index 0000000..1587bab
--- /dev/null
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/polyfill.js"></script>
+</head>
+
+<body>
+
+<style>
+area {
+    display: inline;
+}
+</style>
+
+<p>When an anchor tag catch 'href' attribute or release 'href' attribute, distribution should happen.</p>
+
+<div id="host1"></div>
+<div id="host2"></div>
+
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+function createArea(href, textContent)
+{
+    var area = document.createElement('area');
+    if (href)
+        area.setAttribute('href', href);
+    area.appendChild(document.createTextNode(textContent));
+
+    return area;
+}
+
+var area1 = createArea('http://www.example.com/', 'Anchor 1');
+var area2 = createArea('http://www.example.com/', 'Anchor 2');
+var area3 = createArea(null, 'Anchor 3');
+var area4 = createArea(null, 'Anchor 4');
+
+host1.appendChild(area1);
+host1.appendChild(area2);
+host2.appendChild(area3);
+host2.appendChild(area4);
+
+new WebKitShadowRoot(host1).innerHTML = '<content select="area:enabled"></content>';
+new WebKitShadowRoot(host2).innerHTML = '<content select="area:enabled"></content>';
+
+setTimeout(function() {
+    area2.removeAttribute('href');
+    area4.setAttribute('href', 'http://www.example.com/');
+    if (testRunner)
+        testRunner.notifyDone();
+}, 0);
+
+</script>
+</body>
+</html>
+
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-button-expected.html b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-button-expected.html
new file mode 100644 (file)
index 0000000..debd235
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+
+<body>
+
+<p>When the 'enabled' state of a button tag is changed, we have to invalidate distribution.</p>
+
+<div id="host1"><button>Button 1</button></div>
+
+<div id="host2"><button>Button 4</button></div>
+
+</body>
+</html>
+
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-button.html b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-button.html
new file mode 100644 (file)
index 0000000..d68a0f6
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/polyfill.js"></script>
+</head>
+
+<body>
+
+<p>When the 'enabled' state of a button tag is changed, we have to invalidate distribution.</p>
+
+<div id="host1">
+    <button id="button1">Button 1</button>
+    <button id="button2">Button 2</button>
+</div>
+
+<div id="host2">
+    <button id="button3" disabled>Button 3</button>
+    <button id="button4" disabled>Button 4</button>
+</div>
+
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+new WebKitShadowRoot(host1).innerHTML = '<content select=":enabled"></content>';
+new WebKitShadowRoot(host2).innerHTML = '<content select=":enabled"></content>';
+
+setTimeout(function() {
+    button2.setAttribute('disabled', true);
+    button4.removeAttribute('disabled');
+    testRunner.notifyDone();
+}, 0);
+
+</script>
+</body>
+</html>
+
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-fieldset-expected.html b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-fieldset-expected.html
new file mode 100644 (file)
index 0000000..1362070
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+
+<body>
+
+<p>When the 'enabled' state of a fieldset tag is changed, we have to invalidate distribution.</p>
+
+<div id="host1"><fieldset id="fieldset1" disabled>Fieldset 1</fieldset></div>
+
+<div id="host2"><fieldset id="fieldset4" disabled>Fieldset 4</fieldset></div>
+
+</body>
+</html>
+
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-fieldset.html b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-fieldset.html
new file mode 100644 (file)
index 0000000..d785f6b
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/polyfill.js"></script>
+</head>
+
+<body>
+
+<p>When the 'enabled' state of a fieldset tag is changed, we have to invalidate distribution.</p>
+
+<div id="host1">
+    <fieldset id="fieldset1">Fieldset 1</fieldset>
+    <fieldset id="fieldset2">Fieldset 2</fieldset>
+</div>
+
+<div id="host2">
+    <fieldset id="fieldset3" disabled>Fieldset 3</fieldset>
+    <fieldset id="fieldset4" disabled>Fieldset 4</fieldset>
+</div>
+
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+new WebKitShadowRoot(host1).innerHTML = '<content select=":enabled"></content>';
+new WebKitShadowRoot(host2).innerHTML = '<content select=":enabled"></content>';
+
+setTimeout(function() {
+    fieldset2.setAttribute('disabled', true);
+    fieldset4.removeAttribute('disabled');
+    testRunner.notifyDone();
+}, 0);
+
+</script>
+</body>
+</html>
+
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-input-expected.html b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-input-expected.html
new file mode 100644 (file)
index 0000000..9f43043
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+
+<body>
+
+<p>When the 'enabled' state of an input tag is changed, we have to invalidate distribution.</p>
+
+<div id="host1"><input value="Input 1"></div>
+
+<div id="host2"><input value="Input 4"></div>
+
+</body>
+</html>
+
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-input.html b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-input.html
new file mode 100644 (file)
index 0000000..091373c
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/polyfill.js"></script>
+</head>
+
+<body>
+
+<p>When the 'enabled' state of an input tag is changed, we have to invalidate distribution.</p>
+
+<div id="host1">
+    <input id="input1" value="Input 1">
+    <input id="input2" value="Input 2">
+</div>
+
+<div id="host2">
+    <input id="input3" value="Input 3" disabled>
+    <input id="input4" value="Input 4" disabled>
+</div>
+
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+new WebKitShadowRoot(host1).innerHTML = '<content select=":enabled"></content>';
+new WebKitShadowRoot(host2).innerHTML = '<content select=":enabled"></content>';
+
+setTimeout(function() {
+    input2.setAttribute('disabled', true);
+    input4.removeAttribute('disabled');
+    testRunner.notifyDone();
+}, 0);
+
+</script>
+</body>
+</html>
+
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-optgroup-expected.txt b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-optgroup-expected.txt
new file mode 100644 (file)
index 0000000..1692e97
--- /dev/null
@@ -0,0 +1,12 @@
+When an optgroup element became 'enabled' or not-'enabled', distribution should happen.
+
+Since an optgroup element does not create a renderer, we cannot check this using reftest.
+
+PASS nodes1.length is 1
+PASS nodes1.item(0).innerHTML is "optgroup 1"
+PASS nodes2.length is 1
+PASS nodes2.item(0).innerHTML is "optgroup 4"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-optgroup.html b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-optgroup.html
new file mode 100644 (file)
index 0000000..577057d
--- /dev/null
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/polyfill.js"></script>
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+
+<body>
+
+<p>When an optgroup element became 'enabled' or not-'enabled', distribution should happen.</p>
+<p>Since an optgroup element does not create a renderer, we cannot check this using reftest.</p>
+
+<div id="container">
+    <div id="host1">
+        <optgroup id="optgroup1">optgroup 1</optgroup>
+        <optgroup id="optgroup2">optgroup 2</optgroup>
+    </div>
+
+    <div id="host2">
+        <optgroup id="optgroup3" disabled>optgroup 3</optgroup>
+        <optgroup id="optgroup4" disabled>optgroup 4</optgroup>
+    </div>
+</div>
+
+<pre id="console"></pre>
+
+<script>
+jsTestIsAsync = true;
+
+var shadowRoot1 = new WebKitShadowRoot(host1);
+var shadowRoot2 = new WebKitShadowRoot(host2);
+
+shadowRoot1.innerHTML = '<content select=":enabled">';
+shadowRoot2.innerHTML = '<content select=":enabled">';
+
+var content1 = shadowRoot1.querySelector('content');
+var content2 = shadowRoot2.querySelector('content');
+
+setTimeout(function() {
+    optgroup2.setAttribute('disabled', true);
+    optgroup4.removeAttribute('disabled');
+
+    nodes1 = content1.getDistributedNodes();
+    shouldBe('nodes1.length', '1');
+    shouldBe('nodes1.item(0).innerHTML', '"optgroup 1"');
+
+    nodes2 = content2.getDistributedNodes();
+    shouldBe('nodes2.length', '1');
+    shouldBe('nodes2.item(0).innerHTML', '"optgroup 4"');
+
+    container.innerHTML = "";
+    finishJSTest();
+}, 0);
+
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-option-expected.txt b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-option-expected.txt
new file mode 100644 (file)
index 0000000..9bbf570
--- /dev/null
@@ -0,0 +1,12 @@
+When an option element became 'enabled' or not-'enabled', distribution should happen.
+
+Since an option element does not create a renderer, we cannot check this using reftest.
+
+PASS nodes1.length is 1
+PASS nodes1.item(0).innerHTML is "option 1"
+PASS nodes2.length is 1
+PASS nodes2.item(0).innerHTML is "option 4"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-option.html b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-option.html
new file mode 100644 (file)
index 0000000..455ed7d
--- /dev/null
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/polyfill.js"></script>
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+
+<body>
+
+<p>When an option element became 'enabled' or not-'enabled', distribution should happen.</p>
+<p>Since an option element does not create a renderer, we cannot check this using reftest.</p>
+
+<div id="container">
+    <div id="host1">
+        <option id="option1">option 1</option>
+        <option id="option2">option 2</option>
+    </div>
+
+    <div id="host2">
+        <option id="option3" disabled>option 3</option>
+        <option id="option4" disabled>option 4</option>
+    </div>
+</div>
+
+<pre id="console"></pre>
+
+<script>
+jsTestIsAsync = true;
+
+var shadowRoot1 = new WebKitShadowRoot(host1);
+var shadowRoot2 = new WebKitShadowRoot(host2);
+
+shadowRoot1.innerHTML = '<content select=":enabled">';
+shadowRoot2.innerHTML = '<content select=":enabled">';
+
+var content1 = shadowRoot1.querySelector('content');
+var content2 = shadowRoot2.querySelector('content');
+
+setTimeout(function() {
+    option2.setAttribute('disabled', true);
+    option4.removeAttribute('disabled');
+
+    nodes1 = content1.getDistributedNodes();
+    shouldBe('nodes1.length', '1');
+    shouldBe('nodes1.item(0).innerHTML', '"option 1"');
+
+    nodes2 = content2.getDistributedNodes();
+    shouldBe('nodes2.length', '1');
+    shouldBe('nodes2.item(0).innerHTML', '"option 4"');
+
+    container.innerHTML = "";
+    finishJSTest();
+}, 0);
+
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-select-expected.html b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-select-expected.html
new file mode 100644 (file)
index 0000000..fbcba5d
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+
+<body>
+
+<p>When the 'enabled' state of a select tag is changed, we have to invalidate distribution.</p>
+
+<div id="host1"><select><option>Select 1</option></select></div>
+
+<div id="host2"><select><option>Select 4</option></select></div>
+
+</body>
+</html>
+
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-select.html b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-select.html
new file mode 100644 (file)
index 0000000..80b1d6f
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/polyfill.js"></script>
+</head>
+
+<body>
+
+<p>When the 'enabled' state of a select tag is changed, we have to invalidate distribution.</p>
+
+<div id="host1">
+    <select id="select1"><option>Select 1</option></select>
+    <select id="select2"><option>Select 2</option></select>
+</div>
+
+<div id="host2">
+    <select id="select3" disabled><option>Select 3</option></select>
+    <select id="select4" disabled><option>Select 4</option></select>
+</div>
+
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+new WebKitShadowRoot(host1).innerHTML = '<content select=":enabled"></content>';
+new WebKitShadowRoot(host2).innerHTML = '<content select=":enabled"></content>';
+
+setTimeout(function() {
+    select2.setAttribute('disabled', true);
+    select4.removeAttribute('disabled');
+    testRunner.notifyDone();
+}, 0);
+
+</script>
+</body>
+</html>
+
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-textarea-expected.html b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-textarea-expected.html
new file mode 100644 (file)
index 0000000..ec45cd0
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+
+<body>
+
+<p>When the 'enabled' state of a textarea tag is changed, we have to invalidate distribution.</p>
+
+<div id="host1"><textarea>Textarea 1</textarea></div>
+
+<div id="host2"><textarea>Textarea 4</textarea></div>
+
+</body>
+</html>
+
diff --git a/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-textarea.html b/LayoutTests/fast/dom/shadow/pseudoclass-update-enabled-textarea.html
new file mode 100644 (file)
index 0000000..34c0bc3
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/polyfill.js"></script>
+</head>
+
+<body>
+
+<p>When the 'enabled' state of a textarea tag is changed, we have to invalidate distribution.</p>
+
+<div id="host1">
+    <textarea id="textarea1">Textarea 1</textarea>
+    <textarea id="textarea2">Textarea 2</textarea>
+</div>
+
+<div id="host2">
+    <textarea id="textarea3" disabled>Textarea 3</textarea>
+    <textarea id="textarea4" disabled>Textarea 4</textarea>
+</div>
+
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+new WebKitShadowRoot(host1).innerHTML = '<content select=":enabled"></content>';
+new WebKitShadowRoot(host2).innerHTML = '<content select=":enabled"></content>';
+
+setTimeout(function() {
+    textarea2.setAttribute('disabled', true);
+    textarea4.removeAttribute('disabled');
+    testRunner.notifyDone();
+}, 0);
+
+</script>
+</body>
+</html>
+
index 797bbb4..5f7d863 100644 (file)
@@ -3514,6 +3514,10 @@ webkit.org/b/91488 fast/dom/shadow/shadowdom-for-output-only-shadow.html [ Image
 webkit.org/b/91489 fast/dom/shadow/shadowdom-for-fieldset-complex-shadow.html [ ImageOnlyFailure ]
 webkit.org/b/91489 fast/dom/shadow/shadowdom-for-fieldset-only-shadow.html [ ImageOnlyFailure ]
 
+# a:enabled and area:enabled are not correctly implemented yet.
+webkit.org/b/102349 fast/dom/shadow/pseudoclass-update-enabled-anchor.html [ ImageOnlyFailure ]
+webkit.org/b/102349 fast/dom/shadow/pseudoclass-update-enabled-area.html [ ImageOnlyFailure ]
+
 # Requires setUseDeferredFrameLoading() API from LayoutTestController.
 webkit.org/b/87652 http/tests/appcache/load-from-appcache-defer-resume-crash.html
 
index f8d6ad6..1314b9e 100644 (file)
@@ -1287,6 +1287,10 @@ webkit.org/b/91489 fast/dom/shadow/shadowdom-for-fieldset-only-shadow.html [ Ima
 webkit.org/b/95439 fast/dom/shadow/shadowdom-for-textarea-complex-shadow.html [ ImageOnlyFailure ]
 webkit.org/b/95439 fast/dom/shadow/shadowdom-for-textarea-with-placeholder.html [ ImageOnlyFailure ]
 
+# a:enabled and area:enabled are not correctly implemented yet.
+webkit.org/b/102349 fast/dom/shadow/pseudoclass-update-enabled-anchor.html [ ImageOnlyFailure ]
+webkit.org/b/102349 fast/dom/shadow/pseudoclass-update-enabled-area.html [ ImageOnlyFailure ]
+
 # This test is specific to QuickTime media engine.
 Bug(EFL) media/video-does-not-loop.html
 
index fde610f..4eb00a8 100644 (file)
@@ -1,3 +1,35 @@
+2012-11-15  Shinya Kawanaka  <shinyak@chromium.org>
+
+        Chaging pseudoClass (:enabled) should cause distribution
+        https://bugs.webkit.org/show_bug.cgi?id=101900
+
+        Reviewed by Dimitri Glazkov.
+
+        When element's 'enabled' state is changed, we have to invalidate distribution.
+
+        According to the spec, :enabled matches anchor/area/link element having href attribute,
+        and several form control elements which is not disabled. However, currently :enalbed does not match
+        anchor/area/link yet. See https://bugs.webkit.org/show_bug.cgi?id=102349
+
+        Tests: fast/dom/shadow/pseudoclass-update-enabled-anchor.html
+               fast/dom/shadow/pseudoclass-update-enabled-area.html
+               fast/dom/shadow/pseudoclass-update-enabled-button.html
+               fast/dom/shadow/pseudoclass-update-enabled-fieldset.html
+               fast/dom/shadow/pseudoclass-update-enabled-input.html
+               fast/dom/shadow/pseudoclass-update-enabled-optgroup.html
+               fast/dom/shadow/pseudoclass-update-enabled-option.html
+               fast/dom/shadow/pseudoclass-update-enabled-select.html
+               fast/dom/shadow/pseudoclass-update-enabled-textarea.html
+
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::parseAttribute):
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::HTMLFormControlElement::disabledAttributeChanged):
+        * html/HTMLOptGroupElement.cpp:
+        (WebCore::HTMLOptGroupElement::parseAttribute):
+        * html/HTMLOptionElement.cpp:
+        (WebCore::HTMLOptionElement::parseAttribute):
+
 2012-11-15  Erik Arvidsson  <arv@chromium.org>
 
         Update DOMException name: ValidationError
index 78a92b2..fbed632 100644 (file)
@@ -221,7 +221,7 @@ void HTMLAnchorElement::parseAttribute(const Attribute& attribute)
         setIsLink(!attribute.isNull());
         if (wasLink != isLink()) {
             setNeedsStyleRecalc();
-            invalidateParentDistributionIfNecessary(this, SelectRuleFeatureSet::RuleFeatureLink | SelectRuleFeatureSet::RuleFeatureVisited);
+            invalidateParentDistributionIfNecessary(this, SelectRuleFeatureSet::RuleFeatureLink | SelectRuleFeatureSet::RuleFeatureVisited | SelectRuleFeatureSet::RuleFeatureEnabled);
         }
         if (isLink()) {
             String parsedURL = stripLeadingAndTrailingHTMLSpaces(attribute.value());
index 7b4ae3e..0062a18 100644 (file)
@@ -151,7 +151,7 @@ void HTMLFormControlElement::disabledAttributeChanged()
 {
     setNeedsWillValidateCheck();
     setNeedsStyleRecalc();
-    invalidateParentDistributionIfNecessary(this, SelectRuleFeatureSet::RuleFeatureDisabled);
+    invalidateParentDistributionIfNecessary(this, SelectRuleFeatureSet::RuleFeatureDisabled | SelectRuleFeatureSet::RuleFeatureEnabled);
     if (renderer() && renderer()->style()->hasAppearance())
         renderer()->theme()->stateChanged(renderer(), EnabledState);
 }
index 03c9e14..9547bcc 100644 (file)
@@ -84,7 +84,7 @@ void HTMLOptGroupElement::parseAttribute(const Attribute& attribute)
     recalcSelectOptions();
 
     if (attribute.name() == disabledAttr)
-        invalidateParentDistributionIfNecessary(this, SelectRuleFeatureSet::RuleFeatureDisabled);
+        invalidateParentDistributionIfNecessary(this, SelectRuleFeatureSet::RuleFeatureDisabled | SelectRuleFeatureSet::RuleFeatureEnabled);
 }
 
 void HTMLOptGroupElement::recalcSelectOptions()
index 38edc3e..4e48600 100644 (file)
@@ -203,7 +203,7 @@ void HTMLOptionElement::parseAttribute(const Attribute& attribute)
         m_disabled = !attribute.isNull();
         if (oldDisabled != m_disabled) {
             setNeedsStyleRecalc();
-            invalidateParentDistributionIfNecessary(this, SelectRuleFeatureSet::RuleFeatureDisabled);
+            invalidateParentDistributionIfNecessary(this, SelectRuleFeatureSet::RuleFeatureDisabled | SelectRuleFeatureSet::RuleFeatureEnabled);
             if (renderer() && renderer()->style()->hasAppearance())
                 renderer()->theme()->stateChanged(renderer(), EnabledState);
         }