Title: [97741] trunk
Revision
97741
Author
[email protected]
Date
2011-10-18 05:39:11 -0700 (Tue, 18 Oct 2011)

Log Message

Option.value should trim extra internal html spaces
https://bugs.webkit.org/show_bug.cgi?id=69455

Patch by Sachin Puranik <[email protected]> on 2011-10-18
Reviewed by Kent Tamura.

Currently option.value does not trim the internal white space as suggested by spec. This patch implements the same.

Source/WebCore:

Test: fast/forms/option-value-trim-html-spaces.html

* dom/OptionElement.cpp: Removed a function as this implementation is moved to the HTMLOptionElement.cpp file.
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::value): Implementation of .value function which will now trim the html white spaces.

LayoutTests:

* fast/forms/option-value-trim-html-spaces-expected.txt: Test case to test the text triming on the value attribute.
* fast/forms/option-value-trim-html-spaces.html: Test case to test the text triming on the value attribute.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (97740 => 97741)


--- trunk/LayoutTests/ChangeLog	2011-10-18 12:29:23 UTC (rev 97740)
+++ trunk/LayoutTests/ChangeLog	2011-10-18 12:39:11 UTC (rev 97741)
@@ -1,3 +1,15 @@
+2011-10-18  Sachin Puranik  <[email protected]>
+
+        Option.value should trim extra internal html spaces
+        https://bugs.webkit.org/show_bug.cgi?id=69455
+
+        Reviewed by Kent Tamura.
+
+        Currently option.value does not trim the internal white space as suggested by spec. This patch implements the same.
+
+        * fast/forms/option-value-trim-html-spaces-expected.txt: Test case to test the text triming on the value attribute.
+        * fast/forms/option-value-trim-html-spaces.html: Test case to test the text triming on the value attribute.
+
 2011-10-18  Mihnea Ovidenie  <[email protected]>
 
         [CSS Regions]Parse @-webkit-region rule

Added: trunk/LayoutTests/fast/forms/option-value-trim-html-spaces-expected.txt (0 => 97741)


--- trunk/LayoutTests/fast/forms/option-value-trim-html-spaces-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/option-value-trim-html-spaces-expected.txt	2011-10-18 12:39:11 UTC (rev 97741)
@@ -0,0 +1,13 @@
+Test for space striping .value attribute of OPTION element
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS o1.value is "text with extra while spaces"
+PASS o2.value is "text"
+PASS o3.value is " test text "
+PASS o4.value is "test  text"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/option-value-trim-html-spaces.html (0 => 97741)


--- trunk/LayoutTests/fast/forms/option-value-trim-html-spaces.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/option-value-trim-html-spaces.html	2011-10-18 12:39:11 UTC (rev 97741)
@@ -0,0 +1,40 @@
+<!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   with   extra   while   spaces  </option>
+<option id="o2">  text  </option>
+<option id="o3">&nbsp;test&nbsp;text&nbsp;</option>
+<option id="o4">   test&nbsp;&nbsp;text   </option>
+</select>
+
+<script>
+description('Test for space striping .value attribute of OPTION element');
+
+var o1 = document.getElementById('o1');
+shouldBe('o1.value', '"text with extra while spaces"');
+
+var o2 = document.getElementById('o2');
+shouldBe('o2.value', '"text"');
+
+
+var o3 = document.getElementById('o3');
+var expected = '\u00A0'+'test'+'\u00A0'+ 'text'+'\u00A0';
+shouldBe('o3.value','"'+expected+'"');
+
+var o4 = document.getElementById('o4');
+var expected = 'test'+'\u00A0\u00A0'+ 'text';
+shouldBe('o4.value', '"'+expected+'"');
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (97740 => 97741)


--- trunk/Source/WebCore/ChangeLog	2011-10-18 12:29:23 UTC (rev 97740)
+++ trunk/Source/WebCore/ChangeLog	2011-10-18 12:39:11 UTC (rev 97741)
@@ -1,3 +1,18 @@
+2011-10-18  Sachin Puranik  <[email protected]>
+
+        Option.value should trim extra internal html spaces
+        https://bugs.webkit.org/show_bug.cgi?id=69455
+
+        Reviewed by Kent Tamura.
+
+        Currently option.value does not trim the internal white space as suggested by spec. This patch implements the same.
+
+        Test: fast/forms/option-value-trim-html-spaces.html
+
+        * dom/OptionElement.cpp: Removed a function as this implementation is moved to the HTMLOptionElement.cpp file.
+        * html/HTMLOptionElement.cpp:
+        (WebCore::HTMLOptionElement::value): Implementation of .value function which will now trim the html white spaces.
+
 2011-10-18  Mihnea Ovidenie  <[email protected]>
 
         [CSS Regions]Parse @-webkit-region rule

Modified: trunk/Source/WebCore/dom/OptionElement.cpp (97740 => 97741)


--- trunk/Source/WebCore/dom/OptionElement.cpp	2011-10-18 12:29:23 UTC (rev 97740)
+++ trunk/Source/WebCore/dom/OptionElement.cpp	2011-10-18 12:39:11 UTC (rev 97741)
@@ -117,16 +117,6 @@
     return collectOptionLabelOrText(data, element);
 }
 
-String OptionElement::collectOptionValue(const OptionElementData& data, const Element* element)
-{
-    String value = data.value();
-    if (!value.isNull())
-        return value;
-
-    // Use the text if the value wasn't set.
-    return collectOptionInnerText(element).stripWhiteSpace();
-}
-
 // OptionElementData
 OptionElementData::OptionElementData()
     : m_selected(false)

Modified: trunk/Source/WebCore/html/HTMLOptionElement.cpp (97740 => 97741)


--- trunk/Source/WebCore/html/HTMLOptionElement.cpp	2011-10-18 12:29:23 UTC (rev 97740)
+++ trunk/Source/WebCore/html/HTMLOptionElement.cpp	2011-10-18 12:39:11 UTC (rev 97741)
@@ -155,7 +155,11 @@
 
 String HTMLOptionElement::value() const
 {
-    return OptionElement::collectOptionValue(m_data, this);
+    if (!m_data.value().isNull())
+        return m_data.value();
+
+    return collectOptionInnerText(this).stripWhiteSpace(isHTMLSpace).simplifyWhiteSpace(isHTMLSpace);
+
 }
 
 void HTMLOptionElement::setValue(const String& value)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to