- Revision
- 213542
- Author
- [email protected]
- Date
- 2017-03-07 14:24:19 -0800 (Tue, 07 Mar 2017)
Log Message
Label of an <option> element should not be displayed in quirks mode
https://bugs.webkit.org/show_bug.cgi?id=169296
<rdar://problem/30900751>
Reviewed by Simon Fraser.
Source/WebCore:
Label of an <option> element should not be displayed in quirks mode, to
match Chrome and Firefox. However, we should still display the label in
strict mode, as per the HTML specification:
- https://html.spec.whatwg.org/multipage/rendering.html#the-select-element-2
Chrome renders the label in strict mode, same as us. Firefox does not:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1345242
Tests: fast/dom/HTMLOptionElement/option-label-quirksmode.html
fast/dom/HTMLOptionElement/option-label-quirksmode2.html
fast/dom/HTMLOptionElement/option-label-strictmode.html
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::displayLabel):
(WebCore::HTMLOptionElement::textIndentedToRespectGroupLabel):
* html/HTMLOptionElement.h:
LayoutTests:
Add layout test coverage.
* fast/dom/HTMLOptionElement/option-label-quirksmode-expected.html: Added.
* fast/dom/HTMLOptionElement/option-label-quirksmode.html: Added.
* fast/dom/HTMLOptionElement/option-label-quirksmode2-expected.html: Added.
* fast/dom/HTMLOptionElement/option-label-quirksmode2.html: Added.
* fast/dom/HTMLOptionElement/option-label-strictmode-expected.html: Added.
* fast/dom/HTMLOptionElement/option-label-strictmode.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (213541 => 213542)
--- trunk/LayoutTests/ChangeLog 2017-03-07 22:23:33 UTC (rev 213541)
+++ trunk/LayoutTests/ChangeLog 2017-03-07 22:24:19 UTC (rev 213542)
@@ -1,3 +1,20 @@
+2017-03-07 Chris Dumez <[email protected]>
+
+ Label of an <option> element should not be displayed in quirks mode
+ https://bugs.webkit.org/show_bug.cgi?id=169296
+ <rdar://problem/30900751>
+
+ Reviewed by Simon Fraser.
+
+ Add layout test coverage.
+
+ * fast/dom/HTMLOptionElement/option-label-quirksmode-expected.html: Added.
+ * fast/dom/HTMLOptionElement/option-label-quirksmode.html: Added.
+ * fast/dom/HTMLOptionElement/option-label-quirksmode2-expected.html: Added.
+ * fast/dom/HTMLOptionElement/option-label-quirksmode2.html: Added.
+ * fast/dom/HTMLOptionElement/option-label-strictmode-expected.html: Added.
+ * fast/dom/HTMLOptionElement/option-label-strictmode.html: Added.
+
2017-03-07 Ryan Haddad <[email protected]>
Mark media/modern-media-controls/seek-backward-support/seek-backward-support.html as flaky.
Added: trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-quirksmode-expected.html (0 => 213542)
--- trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-quirksmode-expected.html (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-quirksmode-expected.html 2017-03-07 22:24:19 UTC (rev 213542)
@@ -0,0 +1,9 @@
+<html>
+<body>
+<p>Tests that the option's label is not displayed in quirks mode.</p>
+<select>
+ <option value="X"></option>
+ <option value="-" >-</option>
+</select>
+</body>
+</html>
Added: trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-quirksmode.html (0 => 213542)
--- trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-quirksmode.html (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-quirksmode.html 2017-03-07 22:24:19 UTC (rev 213542)
@@ -0,0 +1,9 @@
+<html>
+<body>
+<p>Tests that the option's label is not displayed in quirks mode.</p>
+<select>
+ <option value="X" label="X"></option>
+ <option value="-" >-</option>
+</select>
+</body>
+</html>
Added: trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-quirksmode2-expected.html (0 => 213542)
--- trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-quirksmode2-expected.html (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-quirksmode2-expected.html 2017-03-07 22:24:19 UTC (rev 213542)
@@ -0,0 +1,9 @@
+<html>
+<body>
+<p>Tests that the option's label is not displayed in quirks mode.</p>
+<select>
+ <option value="X">X</option>
+ <option value="-" >-</option>
+</select>
+</body>
+</html>
Added: trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-quirksmode2.html (0 => 213542)
--- trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-quirksmode2.html (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-quirksmode2.html 2017-03-07 22:24:19 UTC (rev 213542)
@@ -0,0 +1,9 @@
+<html>
+<body>
+<p>Tests that the option's label is not displayed in quirks mode.</p>
+<select>
+ <option value="X" label="Y">X</option>
+ <option value="-" >-</option>
+</select>
+</body>
+</html>
Added: trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-strictmode-expected.html (0 => 213542)
--- trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-strictmode-expected.html (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-strictmode-expected.html 2017-03-07 22:24:19 UTC (rev 213542)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>Tests that the option's label is displayed in strict mode.</p>
+<select>
+ <option value="X">Y</option>
+ <option value="-" >-</option>
+</select>
+</body>
+</html>
Added: trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-strictmode.html (0 => 213542)
--- trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-strictmode.html (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLOptionElement/option-label-strictmode.html 2017-03-07 22:24:19 UTC (rev 213542)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>Tests that the option's label is displayed in strict mode.</p>
+<select>
+ <option value="X" label="Y">X</option>
+ <option value="-" >-</option>
+</select>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (213541 => 213542)
--- trunk/Source/WebCore/ChangeLog 2017-03-07 22:23:33 UTC (rev 213541)
+++ trunk/Source/WebCore/ChangeLog 2017-03-07 22:24:19 UTC (rev 213542)
@@ -1,3 +1,28 @@
+2017-03-07 Chris Dumez <[email protected]>
+
+ Label of an <option> element should not be displayed in quirks mode
+ https://bugs.webkit.org/show_bug.cgi?id=169296
+ <rdar://problem/30900751>
+
+ Reviewed by Simon Fraser.
+
+ Label of an <option> element should not be displayed in quirks mode, to
+ match Chrome and Firefox. However, we should still display the label in
+ strict mode, as per the HTML specification:
+ - https://html.spec.whatwg.org/multipage/rendering.html#the-select-element-2
+
+ Chrome renders the label in strict mode, same as us. Firefox does not:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1345242
+
+ Tests: fast/dom/HTMLOptionElement/option-label-quirksmode.html
+ fast/dom/HTMLOptionElement/option-label-quirksmode2.html
+ fast/dom/HTMLOptionElement/option-label-strictmode.html
+
+ * html/HTMLOptionElement.cpp:
+ (WebCore::HTMLOptionElement::displayLabel):
+ (WebCore::HTMLOptionElement::textIndentedToRespectGroupLabel):
+ * html/HTMLOptionElement.h:
+
2017-03-07 Dean Jackson <[email protected]>
Add GPUDevice implementation and WebGPULayer
Modified: trunk/Source/WebCore/html/HTMLOptionElement.cpp (213541 => 213542)
--- trunk/Source/WebCore/html/HTMLOptionElement.cpp 2017-03-07 22:23:33 UTC (rev 213541)
+++ trunk/Source/WebCore/html/HTMLOptionElement.cpp 2017-03-07 22:24:19 UTC (rev 213542)
@@ -276,6 +276,14 @@
return collectOptionInnerText().stripWhiteSpace(isHTMLSpace).simplifyWhiteSpace(isHTMLSpace);
}
+// Same as label() but ignores the label content attribute in quirks mode for compatibility with other browsers.
+String HTMLOptionElement::displayLabel() const
+{
+ if (document().inQuirksMode())
+ return collectOptionInnerText().stripWhiteSpace(isHTMLSpace).simplifyWhiteSpace(isHTMLSpace);
+ return label();
+}
+
void HTMLOptionElement::setLabel(const String& label)
{
setAttributeWithoutSynchronization(labelAttr, label);
@@ -295,8 +303,8 @@
{
ContainerNode* parent = parentNode();
if (is<HTMLOptGroupElement>(parent))
- return " " + label();
- return label();
+ return " " + displayLabel();
+ return displayLabel();
}
bool HTMLOptionElement::isDisabledFormControl() const
Modified: trunk/Source/WebCore/html/HTMLOptionElement.h (213541 => 213542)
--- trunk/Source/WebCore/html/HTMLOptionElement.h 2017-03-07 22:23:33 UTC (rev 213541)
+++ trunk/Source/WebCore/html/HTMLOptionElement.h 2017-03-07 22:24:19 UTC (rev 213542)
@@ -54,6 +54,7 @@
HTMLSelectElement* ownerSelectElement() const;
WEBCORE_EXPORT String label() const;
+ String displayLabel() const;
WEBCORE_EXPORT void setLabel(const String&);
bool ownElementDisabled() const { return m_disabled; }