Commit 9301b766 authored by yosin@chromium.org's avatar yosin@chromium.org

REGRESSION(r109729): The optgroup element's "disabled" attribute has no effect...

REGRESSION(r109729): The optgroup element's "disabled" attribute has no effect to rendering and selection
https://bugs.webkit.org/show_bug.cgi?id=87614

Reviewed by Kent Tamura.

Source/WebCore:

This patch adds HTMLOptGroupElement::disabled and isEnabledFormControl
methods which was implemented in HTMLFormControlElement at r109729 and
updates CSS pseudo class checker to check "optgroup" element.

Tests: fast/forms/select/optgroup-clicking.html
       fast/forms/select/optgroup-disabled.html
       fast/forms/select/optgroup-rendering.html

* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOneSelector): On disabled and enabled pseudo class checker.
We checked tag name "optgroup" in addition isFormControlElement.
* css/StyleResolver.cpp:
(WebCore::StyleResolver::canShareStyleWithElement): Checks optgroup.disabled.
* html/HTMLOptGroupElement.cpp:
(WebCore::HTMLOptGroupElement::disabled): Added.
* html/HTMLOptGroupElement.h:
(HTMLOptGroupElement): Added isEnabledFormControl.

LayoutTests:

Note: An image for optgroup-rendering.html will be change due by
BUG-87719. Color of option elements should be blue (:enabled
pseudo class) instead of green.

* fast/forms/select/optgroup-clicking-expected.txt: Added.
* fast/forms/select/optgroup-clicking.html: Added.
* fast/forms/select/optgroup-disabled-expected.txt: Added.
* fast/forms/select/optgroup-disabled.html: Added.
* fast/forms/select/optgroup-rendering.html: Added.
* platform/chromium/test_expectations.txt: Add MISSING entry for optgroup-rendering.html.
* platform/chromium-linux/fast/forms/select/optgroup-rendering-expected.png: Added.
* platform/chromium-linux/fast/forms/select/optgroup-rendering-expected.txt: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@118772 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 01ab5a08
2012-05-29 Yoshifumi Inoue <yosin@chromium.org>
REGRESSION(r109729): The optgroup element's "disabled" attribute has no effect to rendering and selection
https://bugs.webkit.org/show_bug.cgi?id=87614
Reviewed by Kent Tamura.
Note: An image for optgroup-rendering.html will be change due by
BUG-87719. Color of option elements should be blue (:enabled
pseudo class) instead of green.
* fast/forms/select/optgroup-clicking-expected.txt: Added.
* fast/forms/select/optgroup-clicking.html: Added.
* fast/forms/select/optgroup-disabled-expected.txt: Added.
* fast/forms/select/optgroup-disabled.html: Added.
* fast/forms/select/optgroup-rendering.html: Added.
* platform/chromium/test_expectations.txt: Add MISSING entry for optgroup-rendering.html.
* platform/chromium-linux/fast/forms/select/optgroup-rendering-expected.png: Added.
* platform/chromium-linux/fast/forms/select/optgroup-rendering-expected.txt: Added.
2012-05-29 Ádám Kallai <kadam@inf.u-szeged.hu>
REGRESSION(r118742): It made inspector/profiler/heap-snapshot-loader.html fail on Lion, Qt
......
Test clicking with optgroup element
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Click enabled option
PASS $("listbox").selectedIndex is 1
Click disabled option - doesn't change selectedIndex
PASS $("listbox").selectedIndex is 1
Menu list with arrow key
PASS $("menulist").selectedIndex is 8
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<body onload="test()">
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../resources/common.js"></script>
<form id="form">
<select size="10" id="listbox">
<optgroup label="Enabled" id="listbox_optgroup_enabled">
<option value="listbox_e1" id="listbox_option_enabled">One</option>
<option value="listbox_e2">Two</option>
<option value="listbox_e3">Three</option>
<option value="listbox_e4">Four</option>
</optgroup>
<optgroup label="Disabled" disabled id="listbox_optgroup_disabled">
<option value="listbox_d1" id="listbox_option_disabled">One</option>
<option value="listbox_d2">Two</option>
<option value="listbox_d3">Three</option>
<option value="listbox_d4">Four</option>
</optgroup>
</select>
<br />
<select size="1" id="menulist">
<optgroup label="Enabled" id="menulist_optgroup_enabled">
<option value="listbox_e1" id="menulist_option_enabled">One</option>
<option value="listbox_e2">Two</option>
<option value="listbox_e3">Three</option>
<option value="listbox_e4">Four</option>
</optgroup>
<optgroup label="Disabled" disabled id="menulist_optgroup_disabled">
<option value="menulist_d1" id="menulist_option_disabled">One</option>
<option value="menulist_d2">Two</option>
<option value="menulist_d3">Three</option>
<option value="menulist_d4">Four</option>
</optgroup>
<optgroup label="Enabled2">
<option value="listbox_e21">One</option>
<option value="listbox_e22">Two</option>
<option value="listbox_e23">Three</option>
<option value="listbox_e24">Four</option>
</optgroup>
</select>
</form>
<script>
description('Test clicking with optgroup element');
window.jsTestIsAsync = true;
function test()
{
if (!window.layoutTestController) {
debug("This test needs layoutTestController.");
return;
}
layoutTestController.dumpAsText();
debug("\nClick enabled option");
$("listbox").selectedIndex = 2;
mouseMoveToIndexInListbox(1 + 1, 'listbox'); // +1 for optgroup
eventSender.mouseDown();
eventSender.mouseUp();
shouldBe('$("listbox").selectedIndex', '1');
debug("\nClick disabled option - doesn't change selectedIndex");
mouseMoveToIndexInListbox(5 + 2, 'listbox'); // +2 for optgroup's
eventSender.mouseDown();
eventSender.mouseUp();
shouldBe('$("listbox").selectedIndex', '1');
debug("\nMenu list with arrow key");
$("menulist").selectedIndex = 3;
$("menulist").focus();
eventSender.keyDown("downArrow");
eventSender.keyDown("\n");
shouldBe('$("menulist").selectedIndex', '8');
finishJSTest();
}
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
Test disabled attribute of optgroup element
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Check :disabled pseudo-class
PASS disabledSet["listbox_optgroup_disabled"] is true
PASS disabledSet["listbox_d1"] is true
PASS disabledSet["listbox_d2"] is true
PASS disabledSet["listbox_d3"] is true
PASS disabledSet["listbox_d4"] is true
PASS disabledSet["menulist_optgroup_disabled"] is true
PASS disabledSet["menulist_d1"] is true
PASS disabledSet["menulist_d2"] is true
PASS disabledSet["menulist_d3"] is true
PASS disabledSet["menulist_d4"] is true
PASS enabledSet["listbox_optgroup_enabled"] is true
PASS enabledSet["menulist_optgroup_enabled"] is true
Check IDL attribute
PASS $("listbox_optgroup_disabled").disabled is true
PASS $("listbox_optgroup_enabled").disabled is false
PASS $("menulist_optgroup_disabled").disabled is true
PASS $("menulist_optgroup_enabled").disabled is false
select.disabled doesn't affect optgroup.disabled
PASS $("listbox_optgroup_disabled").disabled is true
PASS $("listbox_optgroup_enabled").disabled is false
PASS $("menulist_optgroup_disabled").disabled is true
PASS $("menulist_optgroup_enabled").disabled is false
select.disabled doesn't affect pseudo-class :disabled
PASS disabledSet["listbox_optgroup_disabled"] is true
PASS disabledSet["menulist_optgroup_disabled"] is true
PASS disabledSet["listbox_optgroup_enabled"] is undefined.
PASS disabledSet["menulist_optgroup_enabled"] is undefined.
form.disabled doesn't affect optgroup.disabled
PASS $("listbox_optgroup_disabled").disabled is true
PASS $("listbox_optgroup_enabled").disabled is false
PASS $("menulist_optgroup_disabled").disabled is true
PASS $("menulist_optgroup_enabled").disabled is false
form.disabled doesn't affect pseudo-class :disabled
PASS disabledSet["listbox_optgroup_disabled"] is true
PASS disabledSet["menulist_optgroup_disabled"] is true
PASS disabledSet["listbox_optgroup_enabled"] is undefined.
PASS disabledSet["menulist_optgroup_enabled"] is undefined.
Check IDL [Reflect]
PASS $("listbox_optgroup_disabled").disabled is false
PASS $("menulist_optgroup_disabled").disabled is false
PASS $("listbox_optgroup_disabled").disabled is true
PASS $("menulist_optgroup_disabled").disabled is true
optgroup.disabled doesn't affect option.selected
PASS $("listbox").selectedIndex is 0
PASS $("listbox").selectedIndex is 4
PASS $("menulist").selectedIndex is 0
PASS $("menulist").selectedIndex is 4
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<body>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../resources/common.js"></script>
<form id="form">
<select size="10" id="listbox">
<optgroup label="Enabled" id="listbox_optgroup_enabled">
<option value="listbox_e1" id="listbox_option_enabled">One</option>
<option value="listbox_e2">Two</option>
<option value="listbox_e3">Three</option>
<option value="listbox_e4">Four</option>
</optgroup>
<optgroup label="Disabled" disabled id="listbox_optgroup_disabled">
<option value="listbox_d1" id="listbox_option_disabled">One</option>
<option value="listbox_d2">Two</option>
<option value="listbox_d3">Three</option>
<option value="listbox_d4">Four</option>
</optgroup>
</select>
<br />
<select size="1" id="menulist">
<optgroup label="Enabled" id="menulist_optgroup_enabled">
<option value="listbox_e1" id="menulist_option_enabled">One</option>
<option value="listbox_e2">Two</option>
<option value="listbox_e3">Three</option>
<option value="listbox_e4">Four</option>
</optgroup>
<optgroup label="Disabled" disabled id="menulist_optgroup_disabled">
<option value="menulist_d1" id="menulist_option_disabled">One</option>
<option value="menulist_d2">Two</option>
<option value="menulist_d3">Three</option>
<option value="menulist_d4">Four</option>
</optgroup>
</select>
</form>
<script>
description('Test disabled attribute of optgroup element');
var disabledSet;
var enabledSet;
function querySelectorAll(selector)
{
var set = {};
var elements = document.querySelectorAll(selector);
for (var i = 0; i < elements.length; ++i) {
var element = elements[i];
set[element.value || element.id] = true;
}
return set;
}
debug('Check :disabled pseudo-class');
disabledSet = querySelectorAll(":disabled");
shouldBeTrue('disabledSet["listbox_optgroup_disabled"]');
shouldBeTrue('disabledSet["listbox_d1"]');
shouldBeTrue('disabledSet["listbox_d2"]');
shouldBeTrue('disabledSet["listbox_d3"]');
shouldBeTrue('disabledSet["listbox_d4"]');
shouldBeTrue('disabledSet["menulist_optgroup_disabled"]');
shouldBeTrue('disabledSet["menulist_d1"]');
shouldBeTrue('disabledSet["menulist_d2"]');
shouldBeTrue('disabledSet["menulist_d3"]');
shouldBeTrue('disabledSet["menulist_d4"]');
enabledSet = querySelectorAll(':enabled');
shouldBeTrue('enabledSet["listbox_optgroup_enabled"]');
shouldBeTrue('enabledSet["menulist_optgroup_enabled"]');
debug('Check IDL attribute');
shouldBeTrue('$("listbox_optgroup_disabled").disabled');
shouldBeFalse('$("listbox_optgroup_enabled").disabled');
shouldBeTrue('$("menulist_optgroup_disabled").disabled');
shouldBeFalse('$("menulist_optgroup_enabled").disabled');
debug("select.disabled doesn't affect optgroup.disabled");
$("listbox").disabled = true;
$("menulist").disabled = true;
shouldBeTrue('$("listbox_optgroup_disabled").disabled');
shouldBeFalse('$("listbox_optgroup_enabled").disabled');
shouldBeTrue('$("menulist_optgroup_disabled").disabled');
shouldBeFalse('$("menulist_optgroup_enabled").disabled');
debug("select.disabled doesn't affect pseudo-class :disabled");
disabledSet = querySelectorAll(':disabled');
shouldBeTrue('disabledSet["listbox_optgroup_disabled"]');
shouldBeTrue('disabledSet["menulist_optgroup_disabled"]');
shouldBeUndefined('disabledSet["listbox_optgroup_enabled"]');
shouldBeUndefined('disabledSet["menulist_optgroup_enabled"]');
debug("form.disabled doesn't affect optgroup.disabled");
$("form").disabled = true;
shouldBeTrue('$("listbox_optgroup_disabled").disabled');
shouldBeFalse('$("listbox_optgroup_enabled").disabled');
shouldBeTrue('$("menulist_optgroup_disabled").disabled');
shouldBeFalse('$("menulist_optgroup_enabled").disabled');
$("form").disabled = false;
debug("form.disabled doesn't affect pseudo-class :disabled");
disabledSet = querySelectorAll(':disabled');
shouldBeTrue('disabledSet["listbox_optgroup_disabled"]');
shouldBeTrue('disabledSet["menulist_optgroup_disabled"]');
shouldBeUndefined('disabledSet["listbox_optgroup_enabled"]');
shouldBeUndefined('disabledSet["menulist_optgroup_enabled"]');
debug("Check IDL [Reflect]");
$("listbox_optgroup_disabled").removeAttribute("disabled");
$("menulist_optgroup_disabled").removeAttribute("disabled");
shouldBeFalse('$("listbox_optgroup_disabled").disabled');
shouldBeFalse('$("menulist_optgroup_disabled").disabled');
$("listbox_optgroup_disabled").setAttribute("disabled", "");
$("menulist_optgroup_disabled").setAttribute("disabled", "");
shouldBeTrue('$("listbox_optgroup_disabled").disabled');
shouldBeTrue('$("menulist_optgroup_disabled").disabled');
debug("optgroup.disabled doesn't affect option.selected");
$("listbox_option_enabled").selected = true;
shouldBe('$("listbox").selectedIndex', '0');
$("listbox_option_disabled").selected = true;
shouldBe('$("listbox").selectedIndex', '4');
$("menulist_option_enabled").selected = true;
shouldBe('$("menulist").selectedIndex', '0');
$("menulist_option_disabled").selected = true;
shouldBe('$("menulist").selectedIndex', '4');
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
optgroup:disabled { color: pink; }
optgroup:enabled { color: green; }
option:disabled { color: red; }
option:enabled { color: blue; }
</style>
</head>
<body>
<form>
<select size="20">
<optgroup label="Enabled">
<option value="listbox_e11">One</option>
<option value="listbox_e12">Two</option>
<option value="listbox_e13">Three</option>
<option value="listbox_e14">Four</option>
</optgroup>
<optgroup label="Disabled" disabled>
<option value="listbox_d1">One</option>
<option value="listbox_d2">Two</option>
<option value="listbox_d3">Three</option>
<option value="listbox_d4">Four</option>
</optgroup>
<optgroup label="Enabled2">
<option value="listbox_e21">One</option>
<option value="listbox_e22" disabled>Two</option>
<option value="listbox_e23" selected>Three</option>
<option value="listbox_e24">Four</option>
</optgroup>
</select>
<br />
<select size="1">
<optgroup label="Enabled">
<option value="listbox_e1">One</option>
<option value="listbox_e2">Two</option>
<option value="listbox_e3">Three</option>
<option value="listbox_e4">Four</option>
</optgroup>
<optgroup label="Disabled" disabled>
<option value="menulist_d1">One</option>
<option value="menulist_d2">Two</option>
<option value="menulist_d3">Three</option>
<option value="menulist_d4">Four</option>
</optgroup>
<optgroup label="Enabled2">
<option value="listbox_e21">One</option>
<option value="listbox_e22" disabled>Two</option>
<option value="listbox_e23" selected>Three</option>
<option value="listbox_e24">Four</option>
</optgroup>
</select>
</form>
</body>
</html>
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x385
RenderBlock {HTML} at (0,0) size 800x385
RenderBody {BODY} at (8,8) size 784x369
RenderBlock {FORM} at (0,0) size 784x369
RenderListBox {SELECT} at (2,2) size 80x341 [bgcolor=#DDDDDD] [border: (1px inset #808080)]
RenderText {#text} at (84,323) size 4x19
text run at (84,323) width 4: " "
RenderBR {BR} at (88,323) size 0x19
RenderMenuList {SELECT} at (2,347) size 73x20 [bgcolor=#DDDDDD] [border: (1px solid #000000)]
RenderBlock (anonymous) at (1,1) size 71x18
RenderText at (4,1) size 32x16
text run at (4,1) width 32: "Three"
RenderText {#text} at (0,0) size 0x0
......@@ -3775,6 +3775,9 @@ BUGWK87364 DEBUG : fast/dom/shadow/drop-event-in-shadow.html = TEXT PASS
BUGWK76809 SKIP : editing/pasteboard/data-transfer-items-drag-drop-entry.html = FAIL
BUGWK76809 SKIP : fast/filesystem/cross-filesystem-op.html = FAIL
// BUG-87719 will change image.
BUGWK87614 : fast/forms/select/optgroup-rendering.html = FAIL MISSING
// Requires setUseDeferredFrameLoading() API from LayoutTestController.
BUGWK87652 SKIP : http/tests/appcache/load-from-appcache-defer-resume-crash.html = FAIL
......
2012-05-29 Yoshifumi Inoue <yosin@chromium.org>
REGRESSION(r109729): The optgroup element's "disabled" attribute has no effect to rendering and selection
https://bugs.webkit.org/show_bug.cgi?id=87614
Reviewed by Kent Tamura.
This patch adds HTMLOptGroupElement::disabled and isEnabledFormControl
methods which was implemented in HTMLFormControlElement at r109729 and
updates CSS pseudo class checker to check "optgroup" element.
Tests: fast/forms/select/optgroup-clicking.html
fast/forms/select/optgroup-disabled.html
fast/forms/select/optgroup-rendering.html
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOneSelector): On disabled and enabled pseudo class checker.
We checked tag name "optgroup" in addition isFormControlElement.
* css/StyleResolver.cpp:
(WebCore::StyleResolver::canShareStyleWithElement): Checks optgroup.disabled.
* html/HTMLOptGroupElement.cpp:
(WebCore::HTMLOptGroupElement::disabled): Added.
* html/HTMLOptGroupElement.h:
(HTMLOptGroupElement): Added isEnabledFormControl.
2012-05-29 Alexander Pavlov <apavlov@chromium.org>
[Chromium] [Regression] SELECT popup misplaced when there is not enough vertical space
......
......@@ -1051,7 +1051,7 @@ bool SelectorChecker::checkOneSelector(const SelectorCheckingContext& context, P
}
break;
case CSSSelector::PseudoEnabled:
if (element && element->isFormControlElement())
if (element && (element->isFormControlElement() || element->hasTagName(optgroupTag)))
return element->isEnabledFormControl();
break;
case CSSSelector::PseudoFullPageMedia:
......@@ -1060,7 +1060,7 @@ bool SelectorChecker::checkOneSelector(const SelectorCheckingContext& context, P
case CSSSelector::PseudoDefault:
return element && element->isDefaultButtonForForm();
case CSSSelector::PseudoDisabled:
if (element && (element->isFormControlElement() || element->hasTagName(optionTag)))
if (element && (element->isFormControlElement() || element->hasTagName(optionTag) || element->hasTagName(optgroupTag)))
return !element->isEnabledFormControl();
break;
case CSSSelector::PseudoReadOnly:
......
......@@ -1392,6 +1392,9 @@ bool StyleResolver::canShareStyleWithElement(StyledElement* element) const
if (element->hasTagName(optionTag))
return false;
if (element->hasTagName(optgroupTag) && m_element->disabled() != element->disabled())
return false;
bool isControl = element->isFormControlElement();
if (isControl != m_element->isFormControlElement())
......
......@@ -49,6 +49,11 @@ PassRefPtr<HTMLOptGroupElement> HTMLOptGroupElement::create(const QualifiedName&
return adoptRef(new HTMLOptGroupElement(tagName, document));
}
bool HTMLOptGroupElement::disabled() const
{
return fastHasAttribute(disabledAttr);
}
bool HTMLOptGroupElement::supportsFocus() const
{
return HTMLElement::supportsFocus();
......
......@@ -34,6 +34,7 @@ class HTMLOptGroupElement : public HTMLElement {
public:
static PassRefPtr<HTMLOptGroupElement> create(const QualifiedName&, Document*);
virtual bool disabled() const OVERRIDE;
HTMLSelectElement* ownerSelectElement() const;
String groupLabelText() const;
......@@ -44,6 +45,7 @@ private:
virtual const AtomicString& formControlType() const;
virtual bool supportsFocus() const;
virtual bool isFocusable() const;
virtual bool isEnabledFormControl() const OVERRIDE { return !disabled(); }
virtual void parseAttribute(const Attribute&) OVERRIDE;
virtual bool rendererIsNeeded(const NodeRenderingContext&) { return false; }
virtual void attach();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment