Changeset 213542 in webkit


Ignore:
Timestamp:
Mar 7, 2017 2:24:19 PM (7 years ago)
Author:
Chris Dumez
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:

Chrome renders the label in strict mode, same as us. Firefox does not:

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.
Location:
trunk
Files:
6 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r213537 r213542  
     12017-03-07  Chris Dumez  <cdumez@apple.com>
     2
     3        Label of an <option> element should not be displayed in quirks mode
     4        https://bugs.webkit.org/show_bug.cgi?id=169296
     5        <rdar://problem/30900751>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Add layout test coverage.
     10
     11        * fast/dom/HTMLOptionElement/option-label-quirksmode-expected.html: Added.
     12        * fast/dom/HTMLOptionElement/option-label-quirksmode.html: Added.
     13        * fast/dom/HTMLOptionElement/option-label-quirksmode2-expected.html: Added.
     14        * fast/dom/HTMLOptionElement/option-label-quirksmode2.html: Added.
     15        * fast/dom/HTMLOptionElement/option-label-strictmode-expected.html: Added.
     16        * fast/dom/HTMLOptionElement/option-label-strictmode.html: Added.
     17
    1182017-03-07  Ryan Haddad  <ryanhaddad@apple.com>
    219
  • trunk/Source/WebCore/ChangeLog

    r213541 r213542  
     12017-03-07  Chris Dumez  <cdumez@apple.com>
     2
     3        Label of an <option> element should not be displayed in quirks mode
     4        https://bugs.webkit.org/show_bug.cgi?id=169296
     5        <rdar://problem/30900751>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Label of an <option> element should not be displayed in quirks mode, to
     10        match Chrome and Firefox. However, we should still display the label in
     11        strict mode, as per the HTML specification:
     12        - https://html.spec.whatwg.org/multipage/rendering.html#the-select-element-2
     13
     14        Chrome renders the label in strict mode, same as us. Firefox does not:
     15        - https://bugzilla.mozilla.org/show_bug.cgi?id=1345242
     16
     17        Tests: fast/dom/HTMLOptionElement/option-label-quirksmode.html
     18               fast/dom/HTMLOptionElement/option-label-quirksmode2.html
     19               fast/dom/HTMLOptionElement/option-label-strictmode.html
     20
     21        * html/HTMLOptionElement.cpp:
     22        (WebCore::HTMLOptionElement::displayLabel):
     23        (WebCore::HTMLOptionElement::textIndentedToRespectGroupLabel):
     24        * html/HTMLOptionElement.h:
     25
    1262017-03-07  Dean Jackson  <dino@apple.com>
    227
  • trunk/Source/WebCore/html/HTMLOptionElement.cpp

    r210319 r213542  
    277277}
    278278
     279// Same as label() but ignores the label content attribute in quirks mode for compatibility with other browsers.
     280String HTMLOptionElement::displayLabel() const
     281{
     282    if (document().inQuirksMode())
     283        return collectOptionInnerText().stripWhiteSpace(isHTMLSpace).simplifyWhiteSpace(isHTMLSpace);
     284    return label();
     285}
     286
    279287void HTMLOptionElement::setLabel(const String& label)
    280288{
     
    296304    ContainerNode* parent = parentNode();
    297305    if (is<HTMLOptGroupElement>(parent))
    298         return "    " + label();
    299     return label();
     306        return "    " + displayLabel();
     307    return displayLabel();
    300308}
    301309
  • trunk/Source/WebCore/html/HTMLOptionElement.h

    r208096 r213542  
    5555
    5656    WEBCORE_EXPORT String label() const;
     57    String displayLabel() const;
    5758    WEBCORE_EXPORT void setLabel(const String&);
    5859
Note: See TracChangeset for help on using the changeset viewer.