Diff
Modified: trunk/LayoutTests/ChangeLog (96720 => 96721)
--- trunk/LayoutTests/ChangeLog 2011-10-05 17:39:01 UTC (rev 96720)
+++ trunk/LayoutTests/ChangeLog 2011-10-05 17:41:52 UTC (rev 96721)
@@ -1,3 +1,21 @@
+2011-10-05 Sachin Puranik <jcq...@motorola.com>
+
+ Spec change - option.label should be reflected like option.value
+ https://bugs.webkit.org/show_bug.cgi?id=68684
+
+ Reviewed by Darin Adler.
+
+ 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.
+
2011-10-05 Ilya Tikhonovsky <loi...@chromium.org>
Unreviewed. Reduce test flakyness.
Added: trunk/LayoutTests/fast/forms/option-label-trim-html-spaces-expected.txt (0 => 96721)
--- trunk/LayoutTests/fast/forms/option-label-trim-html-spaces-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/option-label-trim-html-spaces-expected.txt 2011-10-05 17:41:52 UTC (rev 96721)
@@ -0,0 +1,13 @@
+Test for space striping .label attribute of OPTION element
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS o1.label is "text with extra while spaces"
+PASS o2.label is "text"
+PASS o3.label is " test text "
+PASS o4.label is "test text"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/option-label-trim-html-spaces.html (0 => 96721)
--- trunk/LayoutTests/fast/forms/option-label-trim-html-spaces.html (rev 0)
+++ trunk/LayoutTests/fast/forms/option-label-trim-html-spaces.html 2011-10-05 17:41:52 UTC (rev 96721)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<select>
+<option id="o1"> text with extra while spaces </option>
+<option id="o2"> text </option>
+<option id="o3"> test text </option>
+<option id="o4"> test text </option>
+</select>
+
+<script>
+description('Test for space striping .label attribute of OPTION element');
+
+var o1 = document.getElementById('o1');
+shouldBe('o1.label', '"text with extra while spaces"');
+
+var o2 = document.getElementById('o2');
+shouldBe('o2.label', '"text"');
+
+
+var o3 = document.getElementById('o3');
+var expected = '\u00A0'+'test'+'\u00A0'+ 'text'+'\u00A0';
+shouldBe('o3.label','"'+expected+'"');
+
+var o4 = document.getElementById('o4');
+var expected = 'test'+'\u00A0\u00A0'+ 'text';
+shouldBe('o4.label', '"'+expected+'"');
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/option-value-and-label-changed-by-js-expected.txt (0 => 96721)
--- trunk/LayoutTests/fast/forms/option-value-and-label-changed-by-js-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/option-value-and-label-changed-by-js-expected.txt 2011-10-05 17:41:52 UTC (rev 96721)
@@ -0,0 +1,17 @@
+Test for .value and .label of OPTION element
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS o1.value is "newValue"
+PASS o1.label is "newLabel"
+PASS o2.value is "newValue"
+PASS o2.label is "newLabel"
+PASS o3.value is "newValue"
+PASS o3.label is "newLabel"
+PASS o4.value is "newValue"
+PASS o4.label is "newLabel"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Copied: trunk/LayoutTests/fast/forms/option-value-and-label-changed-by-js.html (from rev 96720, trunk/LayoutTests/fast/forms/option-value-and-label.html) (0 => 96721)
--- trunk/LayoutTests/fast/forms/option-value-and-label-changed-by-js.html (rev 0)
+++ trunk/LayoutTests/fast/forms/option-value-and-label-changed-by-js.html 2011-10-05 17:41:52 UTC (rev 96721)
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<select>
+<option id="o1"> text </option>
+<option id="o2" value="value"> text </option>
+<option id="o3" label="label"> text </option>
+<option id="o4" value="value" label="label">text</option>
+</select>
+
+<script>
+description('Test for .value and .label of OPTION element');
+
+var o1 = document.getElementById('o1');
+o1.label = "newLabel"
+o1.value = "newValue"
+shouldBe('o1.value', '"newValue"');
+shouldBe('o1.label', '"newLabel"');
+
+var o2 = document.getElementById('o2');
+o2.label = "newLabel"
+o2.value = "newValue"
+shouldBe('o2.value', '"newValue"');
+shouldBe('o2.label', '"newLabel"');
+
+var o3 = document.getElementById('o3');
+o3.label = "newLabel"
+o3.value = "newValue"
+shouldBe('o3.value', '"newValue"');
+shouldBe('o3.label', '"newLabel"');
+
+var o4 = document.getElementById('o4');
+o4.label = "newLabel"
+o4.value = "newValue"
+shouldBe('o4.value', '"newValue"');
+shouldBe('o4.label', '"newLabel"');
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/fast/forms/option-value-and-label-expected.txt (96720 => 96721)
--- trunk/LayoutTests/fast/forms/option-value-and-label-expected.txt 2011-10-05 17:39:01 UTC (rev 96720)
+++ trunk/LayoutTests/fast/forms/option-value-and-label-expected.txt 2011-10-05 17:41:52 UTC (rev 96721)
@@ -4,9 +4,9 @@
PASS o1.value is "text"
-PASS o1.label is ""
+PASS o1.label is "text"
PASS o2.value is "value"
-PASS o2.label is ""
+PASS o2.label is "text"
PASS o3.value is "text"
PASS o3.label is "label"
PASS o4.value is "value"
Modified: trunk/LayoutTests/fast/forms/option-value-and-label.html (96720 => 96721)
--- trunk/LayoutTests/fast/forms/option-value-and-label.html 2011-10-05 17:39:01 UTC (rev 96720)
+++ trunk/LayoutTests/fast/forms/option-value-and-label.html 2011-10-05 17:41:52 UTC (rev 96721)
@@ -20,11 +20,11 @@
var o1 = document.getElementById('o1');
shouldBe('o1.value', '"text"');
-shouldBe('o1.label', '""');
+shouldBe('o1.label', '"text"');
var o2 = document.getElementById('o2');
shouldBe('o2.value', '"value"');
-shouldBe('o2.label', '""');
+shouldBe('o2.label', '"text"');
var o3 = document.getElementById('o3');
shouldBe('o3.value', '"text"');
Modified: trunk/Source/WebCore/ChangeLog (96720 => 96721)
--- trunk/Source/WebCore/ChangeLog 2011-10-05 17:39:01 UTC (rev 96720)
+++ trunk/Source/WebCore/ChangeLog 2011-10-05 17:41:52 UTC (rev 96721)
@@ -1,3 +1,27 @@
+2011-10-05 Sachin Puranik <jcq...@motorola.com>
+
+ Spec change - option.label should be reflected like option.value
+ https://bugs.webkit.org/show_bug.cgi?id=68684
+
+ Reviewed by Darin Adler.
+
+ 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
+
2011-10-05 Rémi Duraffort <remi.duraff...@st.com>
[GTK] Fix compilation with gtk v2.20.1
Modified: trunk/Source/WebCore/dom/OptionElement.cpp (96720 => 96721)
--- trunk/Source/WebCore/dom/OptionElement.cpp 2011-10-05 17:39:01 UTC (rev 96720)
+++ trunk/Source/WebCore/dom/OptionElement.cpp 2011-10-05 17:41:52 UTC (rev 96721)
@@ -24,8 +24,8 @@
#include "Document.h"
#include "Element.h"
#include "HTMLNames.h"
+#include "HTMLOptionElement.h"
#include "HTMLParserIdioms.h"
-#include "HTMLOptionElement.h"
#include "OptionGroupElement.h"
#include "ScriptElement.h"
#include "SelectElement.h"
@@ -100,7 +100,7 @@
// In WinIE, leading and trailing whitespace is ignored in options and optgroups. We match this behavior.
text = text.stripWhiteSpace(isHTMLSpace);
- // We want to collapse our whitespace too. This will match other browsers.
+ // We want to collapse our whitespace too. This will match other browsers.
text = text.simplifyWhiteSpace(isHTMLSpace);
return text;
Modified: trunk/Source/WebCore/dom/OptionElement.h (96720 => 96721)
--- trunk/Source/WebCore/dom/OptionElement.h 2011-10-05 17:39:01 UTC (rev 96720)
+++ trunk/Source/WebCore/dom/OptionElement.h 2011-10-05 17:41:52 UTC (rev 96721)
@@ -48,8 +48,8 @@
static String collectOptionLabelOrText(const OptionElementData&, const Element*);
static String collectOptionTextRespectingGroupLabel(const OptionElementData&, const Element*);
static String collectOptionValue(const OptionElementData&, const Element*);
+ static String collectOptionInnerText(const Element*);
private:
- static String collectOptionInnerText(const Element*);
static String normalizeText(const Document*, const String&);
};
Modified: trunk/Source/WebCore/html/HTMLOptionElement.cpp (96720 => 96721)
--- trunk/Source/WebCore/html/HTMLOptionElement.cpp 2011-10-05 17:39:01 UTC (rev 96720)
+++ trunk/Source/WebCore/html/HTMLOptionElement.cpp 2011-10-05 17:41:52 UTC (rev 96721)
@@ -5,6 +5,7 @@
* (C) 2006 Alexey Proskuryakov (a...@nypop.com)
* Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Motorola Mobility, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -31,6 +32,7 @@
#include "Document.h"
#include "ExceptionCode.h"
#include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
#include "HTMLSelectElement.h"
#include "NodeRenderStyle.h"
#include "NodeRenderingContext.h"
@@ -216,9 +218,21 @@
String HTMLOptionElement::label() const
{
- return m_data.label();
+ String label = m_data.label();
+ if (!label.isNull())
+ return label;
+
+ label = collectOptionInnerText(this).stripWhiteSpace(isHTMLSpace);
+ label = label.simplifyWhiteSpace(isHTMLSpace);
+
+ return label;
}
+void HTMLOptionElement::setLabel(const String& label)
+{
+ setAttribute(labelAttr, label);
+}
+
void HTMLOptionElement::setRenderStyle(PassRefPtr<RenderStyle> newStyle)
{
m_style = newStyle;
Modified: trunk/Source/WebCore/html/HTMLOptionElement.h (96720 => 96721)
--- trunk/Source/WebCore/html/HTMLOptionElement.h 2011-10-05 17:39:01 UTC (rev 96720)
+++ trunk/Source/WebCore/html/HTMLOptionElement.h 2011-10-05 17:41:52 UTC (rev 96721)
@@ -58,6 +58,7 @@
void setDefaultSelected(bool);
String label() const;
+ void setLabel(const String&);
bool ownElementDisabled() const { return HTMLFormControlElement::disabled(); }
@@ -92,6 +93,6 @@
RefPtr<RenderStyle> m_style;
};
-} //namespace
+} // namespace
#endif
Modified: trunk/Source/WebCore/html/HTMLOptionElement.idl (96720 => 96721)
--- trunk/Source/WebCore/html/HTMLOptionElement.idl 2011-10-05 17:39:01 UTC (rev 96720)
+++ trunk/Source/WebCore/html/HTMLOptionElement.idl 2011-10-05 17:41:52 UTC (rev 96721)
@@ -32,7 +32,7 @@
#endif
readonly attribute long index;
attribute [Reflect] boolean disabled;
- attribute [Reflect] DOMString label;
+ attribute [ConvertNullToNullString] DOMString label;
attribute boolean selected;
attribute [ConvertNullToNullString] DOMString value;
};