https://bugs.webkit.org/show_bug.cgi?id=101901
Reviewed by Hajime Morita.
Source/WebCore:
We have to invalidate distribution when pseudo-class (:disabled) is changed.
According to the HTML5 spec, :disabled will match button, input, select, textarea, optgroup,
option, command, li, and fieldset. However, command is not implemented yet, we skip li and command. li might
have 'disabled' state, but we need a command element to make it 'disabled' state.
Tests: fast/dom/shadow/pseudoclass-update-disabled-button.html
fast/dom/shadow/pseudoclass-update-disabled-fieldset.html
fast/dom/shadow/pseudoclass-update-disabled-input.html
fast/dom/shadow/pseudoclass-update-disabled-optgroup.html
fast/dom/shadow/pseudoclass-update-disabled-option.html
fast/dom/shadow/pseudoclass-update-disabled-select.html
fast/dom/shadow/pseudoclass-update-disabled-textarea.html
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::disabledAttributeChanged):
* html/HTMLOptGroupElement.cpp:
(WebCore::HTMLOptGroupElement::parseAttribute):
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::parseAttribute):
LayoutTests:
* fast/dom/shadow/pseudoclass-update-disabled-button-expected.html: Added.
* fast/dom/shadow/pseudoclass-update-disabled-button.html: Added.
* fast/dom/shadow/pseudoclass-update-disabled-fieldset-expected.html: Added.
* fast/dom/shadow/pseudoclass-update-disabled-fieldset.html: Added.
* fast/dom/shadow/pseudoclass-update-disabled-input-expected.html: Added.
* fast/dom/shadow/pseudoclass-update-disabled-input.html: Added.
* fast/dom/shadow/pseudoclass-update-disabled-optgroup-expected.txt: Added.
* fast/dom/shadow/pseudoclass-update-disabled-optgroup.html: Added.
* fast/dom/shadow/pseudoclass-update-disabled-option-expected.txt: Added.
* fast/dom/shadow/pseudoclass-update-disabled-option.html: Added.
* fast/dom/shadow/pseudoclass-update-disabled-select-expected.html: Added.
* fast/dom/shadow/pseudoclass-update-disabled-select.html: Added.
* fast/dom/shadow/pseudoclass-update-disabled-textarea-expected.html: Added.
* fast/dom/shadow/pseudoclass-update-disabled-textarea.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@134748
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-11-14 Shinya Kawanaka <shinyak@chromium.org>
+
+ Changing pseudoClass (:disabled) should cause distribution.
+ https://bugs.webkit.org/show_bug.cgi?id=101901
+
+ Reviewed by Hajime Morita.
+
+ * fast/dom/shadow/pseudoclass-update-disabled-button-expected.html: Added.
+ * fast/dom/shadow/pseudoclass-update-disabled-button.html: Added.
+ * fast/dom/shadow/pseudoclass-update-disabled-fieldset-expected.html: Added.
+ * fast/dom/shadow/pseudoclass-update-disabled-fieldset.html: Added.
+ * fast/dom/shadow/pseudoclass-update-disabled-input-expected.html: Added.
+ * fast/dom/shadow/pseudoclass-update-disabled-input.html: Added.
+ * fast/dom/shadow/pseudoclass-update-disabled-optgroup-expected.txt: Added.
+ * fast/dom/shadow/pseudoclass-update-disabled-optgroup.html: Added.
+ * fast/dom/shadow/pseudoclass-update-disabled-option-expected.txt: Added.
+ * fast/dom/shadow/pseudoclass-update-disabled-option.html: Added.
+ * fast/dom/shadow/pseudoclass-update-disabled-select-expected.html: Added.
+ * fast/dom/shadow/pseudoclass-update-disabled-select.html: Added.
+ * fast/dom/shadow/pseudoclass-update-disabled-textarea-expected.html: Added.
+ * fast/dom/shadow/pseudoclass-update-disabled-textarea.html: Added.
+
2012-11-14 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r134691, r134703, r134715, r134716,
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+
+<body>
+
+<p>When the 'disabled' state of a button tag is changed, we have to invalidate distribution.</p>
+
+<div id="host1"><button disabled>Button 2</button></div>
+
+<div id="host2"><button disabled>Button 3</button></div>
+
+</body>
+</html>
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/polyfill.js"></script>
+</head>
+
+<body>
+
+<p>When the 'disabled' 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=":disabled"></content>';
+new WebKitShadowRoot(host2).innerHTML = '<content select=":disabled"></content>';
+
+setTimeout(function() {
+ button2.setAttribute('disabled', true);
+ button4.removeAttribute('disabled');
+ testRunner.notifyDone();
+}, 0);
+
+</script>
+</body>
+</html>
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+
+<body>
+
+<p>When the 'disabled' state of a fieldset tag is changed, we have to invalidate distribution.</p>
+
+<div id="host1"><fieldset id="fieldset2" disabled>Fieldset 2</fieldset></div>
+
+<div id="host2"><fieldset id="fieldset3" disabled>Fieldset 3</fieldset></div>
+
+</body>
+</html>
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/polyfill.js"></script>
+</head>
+
+<body>
+
+<p>When the 'disabled' 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=":disabled"></content>';
+new WebKitShadowRoot(host2).innerHTML = '<content select=":disabled"></content>';
+
+setTimeout(function() {
+ fieldset2.setAttribute('disabled', true);
+ fieldset4.removeAttribute('disabled');
+ testRunner.notifyDone();
+}, 0);
+
+</script>
+</body>
+</html>
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+
+<body>
+
+<p>When the 'disabled' state of an input tag is changed, we have to invalidate distribution.</p>
+
+<div id="host1"><input id="input2" value="Input 2" disabled></div>
+
+<div id="host2"><input id="input3" value="Input 3" disabled></div>
+
+</body>
+</html>
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/polyfill.js"></script>
+</head>
+
+<body>
+
+<p>When the 'disabled' 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=":disabled"></content>';
+new WebKitShadowRoot(host2).innerHTML = '<content select=":disabled"></content>';
+
+setTimeout(function() {
+ input2.setAttribute('disabled', true);
+ input4.removeAttribute('disabled');
+ testRunner.notifyDone();
+}, 0);
+
+</script>
+</body>
+</html>
+
--- /dev/null
+When an optgroup element became 'disabled' or not-'disabled', 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 2"
+PASS nodes2.length is 1
+PASS nodes2.item(0).innerHTML is "optgroup 3"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!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 'disabled' or not-'disabled', 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=":disabled">';
+shadowRoot2.innerHTML = '<content select=":disabled">';
+
+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 2"');
+
+ nodes2 = content2.getDistributedNodes();
+ shouldBe('nodes2.length', '1');
+ shouldBe('nodes2.item(0).innerHTML', '"optgroup 3"');
+
+ container.innerHTML = "";
+ finishJSTest();
+}, 0);
+
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
--- /dev/null
+When an option element became 'disabled' or not-'disabled', 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 2"
+PASS nodes2.length is 1
+PASS nodes2.item(0).innerHTML is "option 3"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!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 'disabled' or not-'disabled', 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=":disabled">';
+shadowRoot2.innerHTML = '<content select=":disabled">';
+
+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 2"');
+
+ nodes2 = content2.getDistributedNodes();
+ shouldBe('nodes2.length', '1');
+ shouldBe('nodes2.item(0).innerHTML', '"option 3"');
+
+ container.innerHTML = "";
+ finishJSTest();
+}, 0);
+
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+
+<body>
+
+<p>When the 'disabled' state of a select tag is changed, we have to invalidate distribution.</p>
+
+<div id="host1"><select disabled><option>Select 2</option></select></div>
+
+<div id="host2"><select disabled><option>Select 3</option></select></div>
+
+</body>
+</html>
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/polyfill.js"></script>
+</head>
+
+<body>
+
+<p>When the 'disabled' 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=":disabled"></content>';
+new WebKitShadowRoot(host2).innerHTML = '<content select=":disabled"></content>';
+
+setTimeout(function() {
+ select2.setAttribute('disabled', true);
+ select4.removeAttribute('disabled');
+ testRunner.notifyDone();
+}, 0);
+
+</script>
+</body>
+</html>
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+
+<body>
+
+<p>When the 'disabled' state of a textarea tag is changed, we have to invalidate distribution.</p>
+
+<div id="host1"><textarea disabled>Textarea 2</textarea></div>
+
+<div id="host2"><textarea disabled>Textarea 3</textarea></div>
+
+</body>
+</html>
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/polyfill.js"></script>
+</head>
+
+<body>
+
+<p>When the 'disabled' 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=":disabled"></content>';
+new WebKitShadowRoot(host2).innerHTML = '<content select=":disabled"></content>';
+
+setTimeout(function() {
+ textarea2.setAttribute('disabled', true);
+ textarea4.removeAttribute('disabled');
+ testRunner.notifyDone();
+}, 0);
+
+</script>
+</body>
+</html>
+
+2012-11-14 Shinya Kawanaka <shinyak@chromium.org>
+
+ Changing pseudoClass (:disabled) should cause distribution.
+ https://bugs.webkit.org/show_bug.cgi?id=101901
+
+ Reviewed by Hajime Morita.
+
+ We have to invalidate distribution when pseudo-class (:disabled) is changed.
+
+ According to the HTML5 spec, :disabled will match button, input, select, textarea, optgroup,
+ option, command, li, and fieldset. However, command is not implemented yet, we skip li and command. li might
+ have 'disabled' state, but we need a command element to make it 'disabled' state.
+
+ Tests: fast/dom/shadow/pseudoclass-update-disabled-button.html
+ fast/dom/shadow/pseudoclass-update-disabled-fieldset.html
+ fast/dom/shadow/pseudoclass-update-disabled-input.html
+ fast/dom/shadow/pseudoclass-update-disabled-optgroup.html
+ fast/dom/shadow/pseudoclass-update-disabled-option.html
+ fast/dom/shadow/pseudoclass-update-disabled-select.html
+ fast/dom/shadow/pseudoclass-update-disabled-textarea.html
+
+ * html/HTMLFormControlElement.cpp:
+ (WebCore::HTMLFormControlElement::disabledAttributeChanged):
+ * html/HTMLOptGroupElement.cpp:
+ (WebCore::HTMLOptGroupElement::parseAttribute):
+ * html/HTMLOptionElement.cpp:
+ (WebCore::HTMLOptionElement::parseAttribute):
+
2012-11-14 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r134691, r134703, r134715, r134716,
{
setNeedsWillValidateCheck();
setNeedsStyleRecalc();
+ invalidateParentDistributionIfNecessary(this, SelectRuleFeatureSet::RuleFeatureDisabled);
if (renderer() && renderer()->style()->hasAppearance())
renderer()->theme()->stateChanged(renderer(), EnabledState);
}
{
HTMLElement::parseAttribute(attribute);
recalcSelectOptions();
+
+ if (attribute.name() == disabledAttr)
+ invalidateParentDistributionIfNecessary(this, SelectRuleFeatureSet::RuleFeatureDisabled);
}
void HTMLOptGroupElement::recalcSelectOptions()
m_disabled = !attribute.isNull();
if (oldDisabled != m_disabled) {
setNeedsStyleRecalc();
+ invalidateParentDistributionIfNecessary(this, SelectRuleFeatureSet::RuleFeatureDisabled);
if (renderer() && renderer()->style()->hasAppearance())
renderer()->theme()->stateChanged(renderer(), EnabledState);
}