REGRESSION(r102741): [Forms] In selects, when disabled, browser skips first option if not in optgroup, then selects first option in optgroup
https://bugs.webkit.org/show_bug.cgi?id=92833
Reviewed by Kent Tamura.
Source/WebCore:
This patch changes implementation of HTMLOptionElement::disabled() to
follow the "disabled" concept of option element in HTML5 specification[1],
the option element is disabled if option element has "disabled"
attribute or parent optgroup element has "disabled" attribute. Before
this patch, HTMLOptionElement::disabled() checks presenting "disabled"
attribute in option element itself and any parent element.
Before this patch, HTMLSelectElement::recalcListItems() didn't considers
non-disabled option as default selected option if select element is
disabled because HTMLOptionElement::disabled() returned true if select
element is disabled.
After this patch, HTMLOptionElement::disabled() is independent from
select element. HTMLSelectElement::recalcListItems() considers
non-disabled option as default selected option.
[1] http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#concept-option-disabled
Tests: fast/forms/basic-selects.html: Fixed expectation to right thing.
* css/html.css:
(select[disabled]>option): Added to render option elements in disabled
select element to disabled color as before this patch.
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::disabled): Changed to check parent element
is optgroup.
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::listBoxDefaultEventHandler): On mouse up
and down, don't update selection if select element is disabled.
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::paintItemForeground): Added checking select
element is disabled. Before this patch, it was done by HTMLOptionElement::disabled().
LayoutTests:
This patch updates test expectation of fast/forms/basic-selects.html
for Chromium-Linux and disables it for Chromium-Mac and Chromium-Win.
Note: We need to rebaseline for all ports expect for Chromium-Linux.
* platform/chromium-linux/fast/forms/basic-selects-expected.png: Changed for default selected option for disabled select element, "foo" to "bar" of second select element of "Line-height should be ignored" line.
* platform/chromium-linux/fast/forms/basic-selects-expected.txt:
* platform/chromium/TestExpectations: Disabled fast/forms/basic-selects.html for Chromium-Mac and Chromium-Win.
git-svn-id: svn://svn.chromium.org/blink/trunk@124416 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/Source/WebCore/css/html.css b/Source/WebCore/css/html.css
index 379b91a..b799eb5 100644
--- a/Source/WebCore/css/html.css
+++ b/Source/WebCore/css/html.css
@@ -691,7 +691,8 @@
input[type="button"]:disabled, input[type="submit"]:disabled, input[type="reset"]:disabled,
input[type="file"]:disabled::-webkit-file-upload-button, button:disabled,
-select:disabled, keygen:disabled, optgroup:disabled, option:disabled {
+select:disabled, keygen:disabled, optgroup:disabled, option:disabled,
+select[disabled]>option {
color: GrayText
}