Title: [117263] trunk
Revision
117263
Author
[email protected]
Date
2012-05-16 04:55:20 -0700 (Wed, 16 May 2012)

Log Message

[chromium] Add WebKit API to access inner text value of input element
https://bugs.webkit.org/show_bug.cgi?id=85353

Reviewed by Kent Tamura.

.:

* Source/autotools/symbols.filter: Added HTMLInputElement::setEditingValue

Source/WebCore:

Test: fast/forms/editing-value.html

We need this to implement the datalist UI for  <input type=email multiple>.
HTMLInputElement.value gives you the sanitized value so the whitespace between values are trimmed.
We need to append the selected suggestion to the end without modifying the rest of the text.

* WebCore.exp.in: Added HTMLInputElement::setEditingValue
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::setEditingValue):
(WebCore):
* html/HTMLInputElement.h:
(HTMLInputElement):
* testing/Internals.cpp:
(WebCore::Internals::setEditingValue):
(WebCore):
* testing/Internals.h:
(Internals):
* testing/Internals.idl:

Source/WebKit/chromium:

* public/WebInputElement.h:
(WebInputElement):
* src/WebInputElement.cpp:
(WebKit::WebInputElement::editingValue):
(WebKit):
(WebKit::WebInputElement::setEditingValue):

Source/WebKit2:

* win/WebKit2.def: Added HTMLInputElement::setEditingValue
* win/WebKit2CFLite.def: Added HTMLInputElement::setEditingValue

LayoutTests:

* fast/forms/editing-value-expected.txt: Added.
* fast/forms/editing-value.html: Added. Tests that setting the editing value takes care of the style and placeholder, and that it fires an input event.

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (117262 => 117263)


--- trunk/ChangeLog	2012-05-16 11:47:13 UTC (rev 117262)
+++ trunk/ChangeLog	2012-05-16 11:55:20 UTC (rev 117263)
@@ -1,3 +1,12 @@
+2012-05-16  Keishi Hattori  <[email protected]>
+
+        [chromium] Add WebKit API to access inner text value of input element
+        https://bugs.webkit.org/show_bug.cgi?id=85353
+
+        Reviewed by Kent Tamura.
+
+        * Source/autotools/symbols.filter: Added HTMLInputElement::setEditingValue
+
 2012-05-15  Kihong Kwon  <[email protected]>
 
         [EFL] Enable Fullscreen API

Modified: trunk/LayoutTests/ChangeLog (117262 => 117263)


--- trunk/LayoutTests/ChangeLog	2012-05-16 11:47:13 UTC (rev 117262)
+++ trunk/LayoutTests/ChangeLog	2012-05-16 11:55:20 UTC (rev 117263)
@@ -1,3 +1,13 @@
+2012-05-16  Keishi Hattori  <[email protected]>
+
+        [chromium] Add WebKit API to access inner text value of input element
+        https://bugs.webkit.org/show_bug.cgi?id=85353
+
+        Reviewed by Kent Tamura.
+
+        * fast/forms/editing-value-expected.txt: Added.
+        * fast/forms/editing-value.html: Added. Tests that setting the editing value takes care of the style and placeholder, and that it fires an input event.
+
 2012-05-16  Ádám Kallai  <[email protected]>
 
         [Qt] Gardening. Skip failing test after 117246.

Added: trunk/LayoutTests/fast/forms/editing-value-expected.txt (0 => 117263)


--- trunk/LayoutTests/fast/forms/editing-value-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/editing-value-expected.txt	2012-05-16 11:55:20 UTC (rev 117263)
@@ -0,0 +1,13 @@
+This tests setting the editing value of an input.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS oninput event was fired.
+PASS input.value is "foo"
+PASS document.querySelector(":invalid") is input
+PASS onchange event was fired.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/editing-value.html (0 => 117263)


--- trunk/LayoutTests/fast/forms/editing-value.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/editing-value.html	2012-05-16 11:55:20 UTC (rev 117263)
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<input type="email" id="test" placeholder="FAIL: placeholder should disappear">
+
+<script>
+description('This tests setting the editing value of an input.');
+
+var input = document.getElementById('test');
+input._onchange_ = function() {
+    testPassed("onchange event was fired.");
+};
+input._oninput_ = function() {
+    testPassed("oninput event was fired.");
+};
+
+input.focus();
+if (window.internals) {
+    internals.setEditingValue(input, " foo ");
+} else {
+    debug('This test requires window.internals object.');
+}
+shouldBe('input.value', '"foo"');
+shouldBe('document.querySelector(":invalid")', 'input');
+input.blur();
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (117262 => 117263)


--- trunk/Source/WebCore/ChangeLog	2012-05-16 11:47:13 UTC (rev 117262)
+++ trunk/Source/WebCore/ChangeLog	2012-05-16 11:55:20 UTC (rev 117263)
@@ -1,3 +1,29 @@
+2012-05-16  Keishi Hattori  <[email protected]>
+
+        [chromium] Add WebKit API to access inner text value of input element
+        https://bugs.webkit.org/show_bug.cgi?id=85353
+
+        Reviewed by Kent Tamura.
+
+        Test: fast/forms/editing-value.html
+
+        We need this to implement the datalist UI for  <input type=email multiple>.
+        HTMLInputElement.value gives you the sanitized value so the whitespace between values are trimmed.
+        We need to append the selected suggestion to the end without modifying the rest of the text.
+
+        * WebCore.exp.in: Added HTMLInputElement::setEditingValue
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::setEditingValue):
+        (WebCore):
+        * html/HTMLInputElement.h:
+        (HTMLInputElement):
+        * testing/Internals.cpp:
+        (WebCore::Internals::setEditingValue):
+        (WebCore):
+        * testing/Internals.h:
+        (Internals):
+        * testing/Internals.idl:
+
 2012-05-16  Jason Liu  <[email protected]>
 
         [BlackBerry] Cookies should be checked during parsing to improve performance.

Modified: trunk/Source/WebCore/WebCore.exp.in (117262 => 117263)


--- trunk/Source/WebCore/WebCore.exp.in	2012-05-16 11:47:13 UTC (rev 117262)
+++ trunk/Source/WebCore/WebCore.exp.in	2012-05-16 11:55:20 UTC (rev 117263)
@@ -484,6 +484,7 @@
 __ZN7WebCore16HTMLInputElement13setAutofilledEb
 __ZN7WebCore16HTMLInputElement15setValueForUserERKN3WTF6StringE
 __ZN7WebCore16HTMLInputElement17setSuggestedValueERKN3WTF6StringE
+__ZN7WebCore16HTMLInputElement15setEditingValueERKN3WTF6StringE
 __ZN7WebCore16IconDatabaseBase28synchronousIconURLForPageURLERKN3WTF6StringE
 __ZN7WebCore16IconDatabaseBase4openERKN3WTF6StringES4_
 __ZN7WebCore16LegacyWebArchive19createFromSelectionEPNS_5FrameE

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (117262 => 117263)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-05-16 11:47:13 UTC (rev 117262)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-05-16 11:55:20 UTC (rev 117263)
@@ -889,6 +889,22 @@
     updateInnerTextValue();
 }
 
+void HTMLInputElement::setEditingValue(const String& value)
+{
+    if (!renderer() || !isTextField())
+        return;
+    setInnerTextValue(value);
+    subtreeHasChanged();
+
+    unsigned max = value.length();
+    if (focused())
+        setSelectionRange(max, max);
+    else
+        cacheSelectionInResponseToSetValue(max);
+
+    dispatchInputEvent();
+}
+
 void HTMLInputElement::setValue(const String& value, TextFieldEventBehavior eventBehavior)
 {
     if (!m_inputType->canSetValue(value))

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (117262 => 117263)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2012-05-16 11:47:13 UTC (rev 117262)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2012-05-16 11:55:20 UTC (rev 117263)
@@ -156,6 +156,8 @@
     const String& suggestedValue() const;
     void setSuggestedValue(const String&);
 
+    void setEditingValue(const String&);
+
     double valueAsDate() const;
     void setValueAsDate(double, ExceptionCode&);
 

Modified: trunk/Source/WebCore/testing/Internals.cpp (117262 => 117263)


--- trunk/Source/WebCore/testing/Internals.cpp	2012-05-16 11:47:13 UTC (rev 117262)
+++ trunk/Source/WebCore/testing/Internals.cpp	2012-05-16 11:55:20 UTC (rev 117263)
@@ -634,6 +634,22 @@
     inputElement->setSuggestedValue(value);
 }
 
+void Internals::setEditingValue(Element* element, const String& value, ExceptionCode& ec)
+{
+    if (!element) {
+        ec = INVALID_ACCESS_ERR;
+        return;
+    }
+
+    HTMLInputElement* inputElement = element->toInputElement();
+    if (!inputElement) {
+        ec = INVALID_NODE_TYPE_ERR;
+        return;
+    }
+
+    inputElement->setEditingValue(value);
+}
+
 void Internals::scrollElementToRect(Element* element, long x, long y, long w, long h, ExceptionCode& ec)
 {
     if (!element || !element->document() || !element->document()->view()) {

Modified: trunk/Source/WebCore/testing/Internals.h (117262 => 117263)


--- trunk/Source/WebCore/testing/Internals.h	2012-05-16 11:47:13 UTC (rev 117262)
+++ trunk/Source/WebCore/testing/Internals.h	2012-05-16 11:55:20 UTC (rev 117263)
@@ -113,6 +113,7 @@
     bool wasLastChangeUserEdit(Element* textField, ExceptionCode&);
     String suggestedValue(Element* inputElement, ExceptionCode&);
     void setSuggestedValue(Element* inputElement, const String&, ExceptionCode&);
+    void setEditingValue(Element* inputElement, const String&, ExceptionCode&);
     void scrollElementToRect(Element*, long x, long y, long w, long h, ExceptionCode&);
 
     void paintControlTints(Document*, ExceptionCode&);

Modified: trunk/Source/WebCore/testing/Internals.idl (117262 => 117263)


--- trunk/Source/WebCore/testing/Internals.idl	2012-05-16 11:47:13 UTC (rev 117262)
+++ trunk/Source/WebCore/testing/Internals.idl	2012-05-16 11:55:20 UTC (rev 117263)
@@ -85,6 +85,7 @@
         boolean wasLastChangeUserEdit(in Element textField) raises (DOMException);
         DOMString suggestedValue(in Element inputElement) raises (DOMException);
         void setSuggestedValue(in Element inputElement, in DOMString value) raises (DOMException);
+        void setEditingValue(in Element inputElement, in DOMString value) raises (DOMException);
 
         void paintControlTints(in Document document) raises (DOMException);
 

Modified: trunk/Source/WebKit/chromium/ChangeLog (117262 => 117263)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-05-16 11:47:13 UTC (rev 117262)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-05-16 11:55:20 UTC (rev 117263)
@@ -1,3 +1,17 @@
+2012-05-16  Keishi Hattori  <[email protected]>
+
+        [chromium] Add WebKit API to access inner text value of input element
+        https://bugs.webkit.org/show_bug.cgi?id=85353
+
+        Reviewed by Kent Tamura.
+
+        * public/WebInputElement.h:
+        (WebInputElement):
+        * src/WebInputElement.cpp:
+        (WebKit::WebInputElement::editingValue):
+        (WebKit):
+        (WebKit::WebInputElement::setEditingValue):
+
 2012-05-16  Hans Wennborg  <[email protected]>
 
         Speech _javascript_ API: pass WebSecurityOrigin to embedder

Modified: trunk/Source/WebKit/chromium/public/WebInputElement.h (117262 => 117263)


--- trunk/Source/WebKit/chromium/public/WebInputElement.h	2012-05-16 11:47:13 UTC (rev 117262)
+++ trunk/Source/WebKit/chromium/public/WebInputElement.h	2012-05-16 11:55:20 UTC (rev 117263)
@@ -74,6 +74,12 @@
         WEBKIT_EXPORT int size() const;
         WEBKIT_EXPORT void setValue(const WebString&, bool sendChangeEvent = false);
         WEBKIT_EXPORT WebString value() const;
+        // This returns the non-sanitized, exact value inside the text field.
+        WEBKIT_EXPORT WebString editingValue() const;
+        // Sets the value inside the text field without being sanitized.
+        // Can't be used if a renderer doesn't exist or on a non text field type.
+        // Caret will be moved to the end.
+        WEBKIT_EXPORT void setEditingValue(const WebString&);
         WEBKIT_EXPORT void setSuggestedValue(const WebString&);
         WEBKIT_EXPORT WebString suggestedValue() const;
         WEBKIT_EXPORT void setPlaceholder(const WebString&);

Modified: trunk/Source/WebKit/chromium/src/WebInputElement.cpp (117262 => 117263)


--- trunk/Source/WebKit/chromium/src/WebInputElement.cpp	2012-05-16 11:47:13 UTC (rev 117262)
+++ trunk/Source/WebKit/chromium/src/WebInputElement.cpp	2012-05-16 11:55:20 UTC (rev 117263)
@@ -98,6 +98,16 @@
     return constUnwrap<HTMLInputElement>()->value();
 }
 
+WebString WebInputElement::editingValue() const
+{
+    return constUnwrap<HTMLInputElement>()->innerTextValue();
+}
+
+void WebInputElement::setEditingValue(const WebString& value)
+{
+    unwrap<HTMLInputElement>()->setEditingValue(value);
+}
+
 void WebInputElement::setSuggestedValue(const WebString& value)
 {
     unwrap<HTMLInputElement>()->setSuggestedValue(value);

Modified: trunk/Source/WebKit2/ChangeLog (117262 => 117263)


--- trunk/Source/WebKit2/ChangeLog	2012-05-16 11:47:13 UTC (rev 117262)
+++ trunk/Source/WebKit2/ChangeLog	2012-05-16 11:55:20 UTC (rev 117263)
@@ -1,3 +1,13 @@
+2012-05-16  Keishi Hattori  <[email protected]>
+
+        [chromium] Add WebKit API to access inner text value of input element
+        https://bugs.webkit.org/show_bug.cgi?id=85353
+
+        Reviewed by Kent Tamura.
+
+        * win/WebKit2.def: Added HTMLInputElement::setEditingValue
+        * win/WebKit2CFLite.def: Added HTMLInputElement::setEditingValue
+
 2012-05-16  Zalan Bujtas  <[email protected]>
 
         [Qt][WK2] Move WebFrameNetworkingContext to WebKit namespace.

Modified: trunk/Source/WebKit2/win/WebKit2.def (117262 => 117263)


--- trunk/Source/WebKit2/win/WebKit2.def	2012-05-16 11:47:13 UTC (rev 117262)
+++ trunk/Source/WebKit2/win/WebKit2.def	2012-05-16 11:55:20 UTC (rev 117263)
@@ -224,6 +224,7 @@
         ?setSerifFontFamily@Settings@WebCore@@QAEXABVAtomicString@WTF@@W4UScriptCode@@@Z
         ?setStandardFontFamily@Settings@WebCore@@QAEXABVAtomicString@WTF@@W4UScriptCode@@@Z
         ?setSuggestedValue@HTMLInputElement@WebCore@@QAEXABVString@WTF@@@Z
+        ?setEditingValue@HTMLInputElement@WebCore@@QAEXABVString@WTF@@@Z
         ?settings@Document@WebCore@@QBEPAVSettings@2@XZ
         ?settings@Frame@WebCore@@QBEPAVSettings@2@XZ
         ?setFixedElementsLayoutRelativeToFrame@Settings@WebCore@@QAEX_N@Z

Modified: trunk/Source/WebKit2/win/WebKit2CFLite.def (117262 => 117263)


--- trunk/Source/WebKit2/win/WebKit2CFLite.def	2012-05-16 11:47:13 UTC (rev 117262)
+++ trunk/Source/WebKit2/win/WebKit2CFLite.def	2012-05-16 11:55:20 UTC (rev 117263)
@@ -217,6 +217,7 @@
         ?setSerifFontFamily@Settings@WebCore@@QAEXABVAtomicString@WTF@@W4UScriptCode@@@Z
         ?setStandardFontFamily@Settings@WebCore@@QAEXABVAtomicString@WTF@@W4UScriptCode@@@Z
         ?setSuggestedValue@HTMLInputElement@WebCore@@QAEXABVString@WTF@@@Z
+        ?setEditingValue@HTMLInputElement@WebCore@@QAEXABVString@WTF@@@Z
         ?settings@Document@WebCore@@QBEPAVSettings@2@XZ
         ?settings@Frame@WebCore@@QBEPAVSettings@2@XZ
         ?setFixedElementsLayoutRelativeToFrame@Settings@WebCore@@QAEX_N@Z

Modified: trunk/Source/autotools/symbols.filter (117262 => 117263)


--- trunk/Source/autotools/symbols.filter	2012-05-16 11:47:13 UTC (rev 117262)
+++ trunk/Source/autotools/symbols.filter	2012-05-16 11:55:20 UTC (rev 117263)
@@ -55,6 +55,7 @@
 _ZN7WebCore14ClientRectListD1Ev;
 _ZN7WebCore15setDOMExceptionEPN3JSC9ExecStateEi;
 _ZN7WebCore16HTMLInputElement17setSuggestedValueERKN3WTF6StringE;
+_ZN7WebCore16HTMLInputElement15setEditingValueERKN3WTF6StringE;
 _ZN7WebCore16jsStringSlowCaseEPN3JSC9ExecStateERN3WTF7HashMapIPNS3_10StringImplENS0_4WeakINS0_8JSStringEEENS3_10StringHashENS3_10HashTraitsIS6_EENSB_IS9_EEEES6_;
 _ZN7WebCore16scriptNameToCodeERKN3WTF6StringE;
 _ZN7WebCore17cacheDOMStructureEPNS_17JSDOMGlobalObjectEPN3JSC9StructureEPKNS2_9ClassInfoE;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to