Changeset 96721 in webkit


Ignore:
Timestamp:
Oct 5, 2011 10:41:52 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

Spec change - option.label should be reflected like option.value
https://bugs.webkit.org/show_bug.cgi?id=68684

Patch by Sachin Puranik <jcqt43@motorola.com> on 2011-10-05
Reviewed by Darin Adler.

Source/WebCore:

Incorporating the recent change in spec for label attribute of
option element. While retrieving the "Label" IDL attribute return
the "Label" content attribute if present , else return the
value of textContent attribute.

Tests: fast/forms/option-label-trim-html-spaces.html

fast/forms/option-value-and-label-changed-by-js.html

  • dom/OptionElement.cpp:

(WebCore::OptionElement::normalizeText):style fixes

  • dom/OptionElement.h: make collectOptionInnerText() protected.
  • html/HTMLOptionElement.cpp:

(WebCore::HTMLOptionElement::label): return innerText if label attribute un-available.
(WebCore::HTMLOptionElement::setLabel):setLabel() implementation.

  • html/HTMLOptionElement.h: add setLabel declaration.
  • html/HTMLOptionElement.idl: Change reflect to ConvertNullToNullString in idl

LayoutTests:

IDL "Label" attribute of option element should return textContent IDL attribute
if conetent attribute "Label" is unavailable. Changed the tests to match
above said behaviour. Added new tests.

  • fast/forms/option-label-trim-html-spaces-expected.txt: Html space triming test.
  • fast/forms/option-label-trim-html-spaces.html: Html space triming test.
  • fast/forms/option-value-and-label-changed-by-js-expected.txt: Attribute change from JS.
  • fast/forms/option-value-and-label-changed-by-js.html: Attribute change from JS.
  • fast/forms/option-value-and-label-expected.txt: Changed test case as per new spec.
  • fast/forms/option-value-and-label.html: Changed test case as per new spec.
Location:
trunk
Files:
3 added
9 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r96719 r96721  
     12011-10-05  Sachin Puranik  <jcqt43@motorola.com>
     2
     3        Spec change - option.label should be reflected like option.value
     4        https://bugs.webkit.org/show_bug.cgi?id=68684
     5
     6        Reviewed by Darin Adler.
     7
     8        IDL "Label" attribute of option element should return textContent IDL attribute
     9        if conetent attribute "Label" is unavailable. Changed the tests to match
     10        above said behaviour. Added new tests.
     11
     12        * fast/forms/option-label-trim-html-spaces-expected.txt: Html space triming test.
     13        * fast/forms/option-label-trim-html-spaces.html: Html space triming test.
     14        * fast/forms/option-value-and-label-changed-by-js-expected.txt: Attribute change from JS.
     15        * fast/forms/option-value-and-label-changed-by-js.html: Attribute change from JS.
     16        * fast/forms/option-value-and-label-expected.txt: Changed  test case as per new spec.
     17        * fast/forms/option-value-and-label.html: Changed test case as per new spec.
     18
    1192011-10-05  Ilya Tikhonovsky  <loislo@chromium.org>
    220
  • trunk/LayoutTests/fast/forms/option-value-and-label-changed-by-js.html

    r96720 r96721  
    1010
    1111<select>
    12 <option id="o1">text</option>
    13 <option id="o2" value="value">text</option>
    14 <option id="o3" label="label">text</option>
     12<option id="o1">  text  </option>
     13<option id="o2" value="value">  text  </option>
     14<option id="o3" label="label">  text  </option>
    1515<option id="o4" value="value" label="label">text</option>
    1616</select>
     
    2020
    2121var o1 = document.getElementById('o1');
    22 shouldBe('o1.value', '"text"');
    23 shouldBe('o1.label', '""');
     22o1.label = "newLabel"
     23o1.value = "newValue"
     24shouldBe('o1.value', '"newValue"');
     25shouldBe('o1.label', '"newLabel"');
    2426
    2527var o2 = document.getElementById('o2');
    26 shouldBe('o2.value', '"value"');
    27 shouldBe('o2.label', '""');
     28o2.label = "newLabel"
     29o2.value = "newValue"
     30shouldBe('o2.value', '"newValue"');
     31shouldBe('o2.label', '"newLabel"');
    2832
    2933var o3 = document.getElementById('o3');
    30 shouldBe('o3.value', '"text"');
    31 shouldBe('o3.label', '"label"');
     34o3.label = "newLabel"
     35o3.value = "newValue"
     36shouldBe('o3.value', '"newValue"');
     37shouldBe('o3.label', '"newLabel"');
    3238
    3339var o4 = document.getElementById('o4');
    34 shouldBe('o4.value', '"value"');
    35 shouldBe('o4.label', '"label"');
     40o4.label = "newLabel"
     41o4.value = "newValue"
     42shouldBe('o4.value', '"newValue"');
     43shouldBe('o4.label', '"newLabel"');
    3644
    3745var successfullyParsed = true;
  • trunk/LayoutTests/fast/forms/option-value-and-label-expected.txt

    r46524 r96721  
    55
    66PASS o1.value is "text"
    7 PASS o1.label is ""
     7PASS o1.label is "text"
    88PASS o2.value is "value"
    9 PASS o2.label is ""
     9PASS o2.label is "text"
    1010PASS o3.value is "text"
    1111PASS o3.label is "label"
  • trunk/LayoutTests/fast/forms/option-value-and-label.html

    r46524 r96721  
    2121var o1 = document.getElementById('o1');
    2222shouldBe('o1.value', '"text"');
    23 shouldBe('o1.label', '""');
     23shouldBe('o1.label', '"text"');
    2424
    2525var o2 = document.getElementById('o2');
    2626shouldBe('o2.value', '"value"');
    27 shouldBe('o2.label', '""');
     27shouldBe('o2.label', '"text"');
    2828
    2929var o3 = document.getElementById('o3');
  • trunk/Source/WebCore/ChangeLog

    r96720 r96721  
     12011-10-05  Sachin Puranik  <jcqt43@motorola.com>
     2
     3        Spec change - option.label should be reflected like option.value
     4        https://bugs.webkit.org/show_bug.cgi?id=68684
     5
     6        Reviewed by Darin Adler.
     7
     8        Incorporating the recent change in spec for label attribute of
     9        option element. While retrieving the "Label" IDL attribute return
     10        the "Label" content attribute if present , else return the
     11        value of textContent attribute.
     12
     13        Tests: fast/forms/option-label-trim-html-spaces.html
     14               fast/forms/option-value-and-label-changed-by-js.html
     15
     16        * dom/OptionElement.cpp:
     17        (WebCore::OptionElement::normalizeText):style fixes
     18        * dom/OptionElement.h: make collectOptionInnerText() protected.
     19        * html/HTMLOptionElement.cpp:
     20        (WebCore::HTMLOptionElement::label): return innerText if label attribute un-available.
     21        (WebCore::HTMLOptionElement::setLabel):setLabel() implementation.
     22        * html/HTMLOptionElement.h: add setLabel declaration.
     23        * html/HTMLOptionElement.idl: Change reflect to ConvertNullToNullString in idl
     24
    1252011-10-05  Rémi Duraffort  <remi.duraffort@st.com>
    226
  • trunk/Source/WebCore/dom/OptionElement.cpp

    r95901 r96721  
    2525#include "Element.h"
    2626#include "HTMLNames.h"
     27#include "HTMLOptionElement.h"
    2728#include "HTMLParserIdioms.h"
    28 #include "HTMLOptionElement.h"
    2929#include "OptionGroupElement.h"
    3030#include "ScriptElement.h"
     
    101101    text = text.stripWhiteSpace(isHTMLSpace);
    102102
    103     // We want to collapse our whitespace too.  This will match other browsers.
     103    // We want to collapse our whitespace too. This will match other browsers.
    104104    text = text.simplifyWhiteSpace(isHTMLSpace);
    105105
  • trunk/Source/WebCore/dom/OptionElement.h

    r95901 r96721  
    4949    static String collectOptionTextRespectingGroupLabel(const OptionElementData&, const Element*);
    5050    static String collectOptionValue(const OptionElementData&, const Element*);
     51    static String collectOptionInnerText(const Element*);
    5152private:
    52     static String collectOptionInnerText(const Element*);
    5353    static String normalizeText(const Document*, const String&);
    5454};
  • trunk/Source/WebCore/html/HTMLOptionElement.cpp

    r94659 r96721  
    66 * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
    77 * Copyright (C) 2010 Google Inc. All rights reserved.
     8 * Copyright (C) 2011 Motorola Mobility, Inc.  All rights reserved.
    89 *
    910 * This library is free software; you can redistribute it and/or
     
    3233#include "ExceptionCode.h"
    3334#include "HTMLNames.h"
     35#include "HTMLParserIdioms.h"
    3436#include "HTMLSelectElement.h"
    3537#include "NodeRenderStyle.h"
     
    217219String HTMLOptionElement::label() const
    218220{
    219     return m_data.label();
     221    String label = m_data.label();
     222    if (!label.isNull())
     223        return label;
     224 
     225    label = collectOptionInnerText(this).stripWhiteSpace(isHTMLSpace);
     226    label = label.simplifyWhiteSpace(isHTMLSpace);
     227
     228    return label;
     229}
     230
     231void HTMLOptionElement::setLabel(const String& label)
     232{
     233    setAttribute(labelAttr, label);
    220234}
    221235
  • trunk/Source/WebCore/html/HTMLOptionElement.h

    r91404 r96721  
    5959
    6060    String label() const;
     61    void setLabel(const String&);
    6162
    6263    bool ownElementDisabled() const { return HTMLFormControlElement::disabled(); }
     
    9394};
    9495
    95 } //namespace
     96} // namespace
    9697
    9798#endif
  • trunk/Source/WebCore/html/HTMLOptionElement.idl

    r89269 r96721  
    3333        readonly attribute long index;
    3434        attribute [Reflect] boolean disabled;
    35         attribute [Reflect] DOMString label;
     35        attribute [ConvertNullToNullString] DOMString label;
    3636        attribute boolean selected;
    3737        attribute [ConvertNullToNullString] DOMString value;
Note: See TracChangeset for help on using the changeset viewer.