WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-53160-20110303003040.patch (text/plain), 34.45 KB, created by
Ilya Sherman
on 2011-03-03 00:30:41 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Ilya Sherman
Created:
2011-03-03 00:30:41 PST
Size:
34.45 KB
patch
obsolete
>diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 0d17c17445b5492672ea566db386cc9b65a8a19a..d5fa2ba8204e0f12a1dcd51f6e45eac38038d4a4 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,16 @@ >+2011-03-02 Ilya Sherman <isherman@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ HTMLInputElement::setValue() should schedule change event when the element is focused >+ In service of https://code.google.com/p/chromium/issues/detail?id=42716 >+ https://bugs.webkit.org/show_bug.cgi?id=53160 >+ >+ * fast/forms/onchange-change-type-expected.txt: Added. >+ * fast/forms/onchange-change-type.html: Added. >+ * fast/forms/onchange-setvalueforuser-expected.txt: Added. >+ * fast/forms/onchange-setvalueforuser.html: Added. >+ > 2011-03-01 Pavel Feldman <pfeldman@chromium.org> > > Reviewed by Yury Semikhatsky. >diff --git a/LayoutTests/fast/forms/onchange-change-type-expected.txt b/LayoutTests/fast/forms/onchange-change-type-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..986f87f199d04274d13622066c93a4056cc18407 >--- /dev/null >+++ b/LayoutTests/fast/forms/onchange-change-type-expected.txt >@@ -0,0 +1,7 @@ >+This tests that onchange is not fired after a form field's type changes. >+ >+Should fire change event when type does not change. >+PASS true is true >+Should *not* fire change event when type does not change. >+PASS false is false >+ >diff --git a/LayoutTests/fast/forms/onchange-change-type.html b/LayoutTests/fast/forms/onchange-change-type.html >new file mode 100644 >index 0000000000000000000000000000000000000000..1d5dbfd7ce6e2f985feb3bbe0a4a7a2b4b0f5a89 >--- /dev/null >+++ b/LayoutTests/fast/forms/onchange-change-type.html >@@ -0,0 +1,48 @@ >+<html> >+<head> >+ <script src="../js/resources/js-test-pre.js"></script> >+ <script> >+ function sendText(element, text) { >+ var event = document.createEvent('TextEvent'); >+ event.initTextEvent('textInput', true, true, document.defaultView, text); >+ element.dispatchEvent(event); >+ } >+ >+ function test() { >+ var tf = document.getElementById('tf'); >+ >+ var didFireOnChange = false; >+ tf.onchange = function() { >+ didFireOnChange = true; >+ } >+ >+ if (window.layoutTestController) { >+ layoutTestController.dumpAsText(); >+ } >+ >+ tf.focus(); >+ sendText(tf, 'input value'); >+ tf.blur(); >+ >+ debug('Should fire change event when type does not change.'); >+ shouldBeTrue(didFireOnChange.toString()); >+ >+ didFireOnChange = false; >+ tf.focus(); >+ sendText(tf, 'new input value'); >+ tf.setAttribute('type', 'password'); >+ tf.blur(); >+ >+ debug('Should *not* fire change event when type does not change.'); >+ shouldBeFalse(didFireOnChange.toString()); >+ } >+ </script> >+</head> >+<body onload="test()"> >+ This tests that onchange is not fired after a form field's type changes.<br> >+ <form name="fm"> >+ <input type="text" id="tf" /> >+ </form> >+ <div id="console"></div> >+</body> >+</html> >diff --git a/LayoutTests/fast/forms/onchange-setvalueforuser-expected.txt b/LayoutTests/fast/forms/onchange-setvalueforuser-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..bc63a1dd386e10c8fa55cf7486c0b010009c0ef0 >--- /dev/null >+++ b/LayoutTests/fast/forms/onchange-setvalueforuser-expected.txt >@@ -0,0 +1,4 @@ >+This tests that onchange correctly fires after calling setValueForUser(). It can only be run using DumpRenderTree. >+ >+PASS >+ >diff --git a/LayoutTests/fast/forms/onchange-setvalueforuser.html b/LayoutTests/fast/forms/onchange-setvalueforuser.html >new file mode 100644 >index 0000000000000000000000000000000000000000..4dbb8f79e07666342a1ae6a379b27786f455453c >--- /dev/null >+++ b/LayoutTests/fast/forms/onchange-setvalueforuser.html >@@ -0,0 +1,44 @@ >+<html> >+<head> >+ <script src="../js/resources/js-test-pre.js"></script> >+ <script> >+ function test() { >+ var tf = document.getElementById('tf'); >+ >+ var didFireOnChange = false; >+ tf.onchange = function() { >+ didFireOnChange = true; >+ } >+ >+ if (window.layoutTestController) { >+ layoutTestController.dumpAsText(); >+ } >+ >+ tf.focus(); >+ if (window.layoutTestController) { >+ layoutTestController.setValueForUser(tf, 'Hello!'); >+ } >+ >+ // Should not fire the event until focus is lost. >+ if (didFireOnChange) { >+ testFailed('onchange fired too early'); >+ return; >+ } >+ >+ tf.blur(); >+ if (didFireOnChange) { >+ testPassed(''); >+ } else { >+ testFailed('onchange never fired') >+ } >+ } >+ </script> >+</head> >+<body onload="test()"> >+ This tests that onchange correctly fires after calling setValueForUser(). It can only be run using DumpRenderTree.<br> >+ <form name="fm"> >+ <input type="text" id="tf" /> >+ </form> >+ <div id="console"></div> >+</body> >+</html> >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 2956a651a2594449e994ad2fc8b1d843853c7705..9f2df3c4902b27e1ce57ac2ab6d72a5d298d4c4d 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,47 @@ >+2011-03-02 Ilya Sherman <isherman@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ HTMLInputElement::setValue() should schedule change event when the element is focused. >+ Refactored tracking of "changed since last change event" state from renderer to DOM.In service of https://code.google.com/p/chromium/issues >+ In service of https://code.google.com/p/chromium/issues/detail?id=42716 >+ https://bugs.webkit.org/show_bug.cgi?id=53160 >+ >+ Test: fast/forms/onchange-change-type.html >+ Test: fast/forms/onchange-setvalueforuser.html >+ >+ * WebCore.exp.in: >+ * dom/Document.cpp: >+ (WebCore::Document::setFocusedNode): >+ * html/HTMLFormControlElement.cpp: >+ (WebCore::HTMLTextFormControlElement::HTMLTextFormControlElement): >+ (WebCore::HTMLTextFormControlElement::wasChangedSinceLastChangeEvent): Added. >+ (WebCore::HTMLTextFormControlElement::setChangedSinceLastChangeEvent): Added. >+ (WebCore::HTMLTextFormControlElement::dispatchFormControlChangeEvent): Overridden to clear the "changed since last change event" flag. >+ * html/HTMLFormControlElement.h: >+ * html/HTMLInputElement.cpp: >+ (WebCore::HTMLInputElement::updateType): Also clear the "changed since last change event" flag. >+ (WebCore::HTMLInputElement::setValue): >+ For a focused text field, dispatch an input event, but delay the change event until the field loses focus. >+ (WebCore::HTMLInputElement::defaultEventHandler): >+ (WebCore::HTMLInputElement::stepUpFromRenderer): >+ * html/shadow/TextControlInnerElements.cpp: >+ (WebCore::SearchFieldCancelButtonElement::defaultEventHandler): >+ * rendering/RenderTextControl.cpp: >+ (WebCore::RenderTextControl::RenderTextControl): >+ (WebCore::RenderTextControl::subtreeHasChanged): >+ * rendering/RenderTextControl.h: >+ * rendering/RenderTextControlMultiLine.cpp: >+ (WebCore::RenderTextControlMultiLine::subtreeHasChanged): >+ * rendering/RenderTextControlSingleLine.cpp: >+ (WebCore::RenderTextControlSingleLine::subtreeHasChanged): >+ * wml/WMLInputElement.cpp: >+ (WebCore::WMLInputElement::WMLInputElement): >+ (WebCore::WMLInputElement::defaultEventHandler): >+ * wml/WMLInputElement.h: >+ (WebCore::WMLInputElement::wasChangedSinceLastChangeEvent): Added. >+ (WebCore::WMLInputElement::setChangedSinceLastChangeEvent): Added. >+ > 2011-03-01 Ilya Tikhonovsky <loislo@chromium.org> > > Reviewed by Pavel Feldman. >diff --git a/Source/WebCore/WebCore.exp.in b/Source/WebCore/WebCore.exp.in >index 99b5e84492d85de53726466d2f682b4a4c0c82eb..0b0a413c3336551ff9a0ff3e474e4a92f1b687af 100644 >--- a/Source/WebCore/WebCore.exp.in >+++ b/Source/WebCore/WebCore.exp.in >@@ -363,6 +363,7 @@ __ZN7WebCore14SecurityOrigin32removeOriginAccessWhitelistEntryERKS0_RKN3WTF6Stri > __ZN7WebCore14SecurityOrigin40setDomainRelaxationForbiddenForURLSchemeEbRKN3WTF6StringE > __ZN7WebCore14SecurityOrigin6createERKN3WTF6StringES4_i > __ZN7WebCore14SecurityOrigin6createERKNS_4KURLEi >+__ZN7WebCore14toInputElementEPNS_7ElementE > __ZN7WebCore15ArchiveResource6createEN3WTF10PassRefPtrINS_12SharedBufferEEERKNS_4KURLERKNS1_6StringESA_SA_RKNS_16ResourceResponseE > __ZN7WebCore15DOMWrapperWorld13clearWrappersEv > __ZN7WebCore15DOMWrapperWorldD1Ev >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index 5777b1513012e2bd363d156507e577911b3ec842..e72b15fe4c528b6ef3f75c2ff282646c4aa5f176 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -191,6 +191,7 @@ > #include "WMLDocument.h" > #include "WMLElement.h" > #include "WMLElementFactory.h" >+#include "WMLInputElement.h" > #include "WMLNames.h" > #endif > >@@ -3169,12 +3170,20 @@ bool Document::setFocusedNode(PassRefPtr<Node> newFocusedNode) > oldFocusedNode->setFocus(false); > > // Dispatch a change event for text fields or textareas that have been edited >- RenderObject* r = oldFocusedNode->renderer(); >- if (r && r->isTextControl() && toRenderTextControl(r)->wasChangedSinceLastChangeEvent()) { >- static_cast<Element*>(oldFocusedNode.get())->dispatchFormControlChangeEvent(); >- r = oldFocusedNode->renderer(); >- if (r && r->isTextControl()) >- toRenderTextControl(r)->setChangedSinceLastChangeEvent(false); >+ if (oldFocusedNode->isElementNode()) { >+ Element* element = static_cast<Element*>(oldFocusedNode.get()); >+ if (element->isTextFormControl()) { >+ bool wasChanged = false; >+ if (element->isHTMLElement()) >+ wasChanged = static_cast<HTMLTextFormControlElement*>(element)->wasChangedSinceLastChangeEvent(); >+#if ENABLE(WML) >+ else if (element->isWMLElement()) >+ wasChanged = static_cast<WMLInputElement*>(element)->wasChangedSinceLastChangeEvent(); >+#endif >+ >+ if (wasChanged) >+ element->dispatchFormControlChangeEvent(); >+ } > } > > // Dispatch the blur event and let the node do any other blur related activities (important for text fields) >diff --git a/Source/WebCore/html/HTMLFormControlElement.cpp b/Source/WebCore/html/HTMLFormControlElement.cpp >index 2f3db08f5576e9eb41ea86e09370b5eaf9071478..11f6bc4948d792ca7e3746541918ebe1cc27494d 100644 >--- a/Source/WebCore/html/HTMLFormControlElement.cpp >+++ b/Source/WebCore/html/HTMLFormControlElement.cpp >@@ -527,6 +527,7 @@ void HTMLFormControlElementWithState::defaultEventHandler(Event* event) > > HTMLTextFormControlElement::HTMLTextFormControlElement(const QualifiedName& tagName, Document* doc, HTMLFormElement* form) > : HTMLFormControlElementWithState(tagName, doc, form) >+ , m_wasChangedSinceLastChangeEvent(false) > { > } > >@@ -648,6 +649,22 @@ PassRefPtr<Range> HTMLTextFormControlElement::selection() const > return 0; > return toRenderTextControl(renderer())->selection(cachedSelectionStart(), cachedSelectionEnd()); > } >+ >+bool HTMLTextFormControlElement::wasChangedSinceLastChangeEvent() const >+{ >+ return m_wasChangedSinceLastChangeEvent; >+} >+ >+void HTMLTextFormControlElement::setChangedSinceLastChangeEvent(bool changed) >+{ >+ m_wasChangedSinceLastChangeEvent = changed; >+} >+ >+void HTMLTextFormControlElement::dispatchFormControlChangeEvent() >+{ >+ HTMLFormControlElement::dispatchFormControlChangeEvent(); >+ setChangedSinceLastChangeEvent(false); >+} > > void HTMLTextFormControlElement::parseMappedAttribute(Attribute* attr) > { >diff --git a/Source/WebCore/html/HTMLFormControlElement.h b/Source/WebCore/html/HTMLFormControlElement.h >index 368dcfad7f4d68503864e8aacdeffa4d85dc9b1e..c839e53c36501fea7791e2d1b57dd2be0731791c 100644 >--- a/Source/WebCore/html/HTMLFormControlElement.h >+++ b/Source/WebCore/html/HTMLFormControlElement.h >@@ -205,6 +205,10 @@ public: > virtual int maxLength() const = 0; > virtual String value() const = 0; > >+ virtual bool wasChangedSinceLastChangeEvent() const; >+ virtual void setChangedSinceLastChangeEvent(bool); >+ virtual void dispatchFormControlChangeEvent(); >+ > protected: > HTMLTextFormControlElement(const QualifiedName&, Document*, HTMLFormElement*); > >@@ -229,6 +233,8 @@ private: > virtual void handleBlurEvent() { } > > RenderTextControl* textRendererAfterUpdateLayout(); >+ >+ bool m_wasChangedSinceLastChangeEvent : 1; > }; > > } // namespace >diff --git a/Source/WebCore/html/HTMLInputElement.cpp b/Source/WebCore/html/HTMLInputElement.cpp >index a221d3e5a9ff2162340595affd1346b209f6be2f..86978256b7e424fc9e16ccfc739d5ed9dffe1f32 100644 >--- a/Source/WebCore/html/HTMLInputElement.cpp >+++ b/Source/WebCore/html/HTMLInputElement.cpp >@@ -489,6 +489,8 @@ void HTMLInputElement::updateType() > updateFocusAppearance(true); > } > >+ setChangedSinceLastChangeEvent(false); >+ > checkedRadioButtons().addButton(this); > > setNeedsValidityCheck(); >@@ -889,10 +891,15 @@ void HTMLInputElement::setValue(const String& value, bool sendChangeEvent) > } > m_inputType->valueChanged(); > >- // Don't dispatch the change event when focused, it will be dispatched >- // when the control loses focus. >- if (sendChangeEvent && document()->focusedNode() != this) >- dispatchFormControlChangeEvent(); >+ if (sendChangeEvent) { >+ // For text fields, don't dispatch the change event when focused. >+ // It will be dispatched when the control loses focus. >+ if (isTextField() && focused()) { >+ setChangedSinceLastChangeEvent(true); >+ dispatchFormControlInputEvent(); >+ } else >+ dispatchFormControlChangeEvent(); >+ } > > InputElement::notifyFormStateChanged(this); > } >@@ -1033,15 +1040,12 @@ void HTMLInputElement::defaultEventHandler(Event* evt) > addSearchResult(); > onSearch(); > } >- // Fire onChange for text fields. >- RenderObject* r = renderer(); >- if (r && r->isTextField() && toRenderTextControl(r)->wasChangedSinceLastChangeEvent()) { >+ // Dispatch a change event for text fields that have been edited prior >+ // to form submission. Normally this event is dispatched when the field >+ // loses focus, but form submission is another special case where we >+ // consider editing to have finished. >+ if (wasChangedSinceLastChangeEvent()) > dispatchFormControlChangeEvent(); >- // Refetch the renderer since arbitrary JS code run during onchange can do anything, including destroying it. >- r = renderer(); >- if (r && r->isTextField()) >- toRenderTextControl(r)->setChangedSinceLastChangeEvent(false); >- } > > RefPtr<HTMLFormElement> formForSubmission = m_inputType->formForSubmission(); > // Form may never have been present, or may have been destroyed by code responding to the change event. >@@ -1410,8 +1414,9 @@ void HTMLInputElement::stepUpFromRenderer(int n) > } > > if (currentStringValue != value()) { >- if (renderer() && renderer()->isTextField()) >- toRenderTextControl(renderer())->setChangedSinceLastChangeEvent(true); >+ if (isTextField()) >+ setChangedSinceLastChangeEvent(true); >+ > if (m_inputType->isRangeControl()) > dispatchFormControlChangeEvent(); > else >diff --git a/Source/WebCore/html/shadow/TextControlInnerElements.cpp b/Source/WebCore/html/shadow/TextControlInnerElements.cpp >index 07f539da54686df5f21c3300efc15ac1ea823ab6..968c5e485ae479fd1652ba34393ae367828f3177 100644 >--- a/Source/WebCore/html/shadow/TextControlInnerElements.cpp >+++ b/Source/WebCore/html/shadow/TextControlInnerElements.cpp >@@ -211,11 +211,7 @@ void SearchFieldCancelButtonElement::defaultEventHandler(Event* event) > } > if (hovered()) { > String oldValue = input->value(); >- input->setValue(""); >- if (!oldValue.isEmpty()) { >- toRenderTextControl(input->renderer())->setChangedSinceLastChangeEvent(true); >- input->dispatchFormControlInputEvent(); >- } >+ input->setValueForUser(""); > input->onSearch(); > event->setDefaultHandled(); > } >diff --git a/Source/WebCore/rendering/RenderTextControl.cpp b/Source/WebCore/rendering/RenderTextControl.cpp >index 37deec10adfeaf98d9519ed11b95b9ea91b81431..0263b0b9e39484b3b078c30661e0e267878b1c0b 100644 >--- a/Source/WebCore/rendering/RenderTextControl.cpp >+++ b/Source/WebCore/rendering/RenderTextControl.cpp >@@ -74,7 +74,6 @@ static Color disabledTextColor(const Color& textColor, const Color& backgroundCo > RenderTextControl::RenderTextControl(Node* node, bool placeholderVisible) > : RenderBlock(node) > , m_placeholderVisible(placeholderVisible) >- , m_wasChangedSinceLastChangeEvent(false) > , m_lastChangeWasUserEdit(false) > { > } >@@ -351,7 +350,6 @@ int RenderTextControl::indexForVisiblePosition(const VisiblePosition& pos) const > > void RenderTextControl::subtreeHasChanged() > { >- m_wasChangedSinceLastChangeEvent = true; > m_lastChangeWasUserEdit = true; > } > >diff --git a/Source/WebCore/rendering/RenderTextControl.h b/Source/WebCore/rendering/RenderTextControl.h >index cd8812e68697ff5937322798bde6369b351c10c0..0c30ed64a851b096985cda9b975c1fe8cae68702 100644 >--- a/Source/WebCore/rendering/RenderTextControl.h >+++ b/Source/WebCore/rendering/RenderTextControl.h >@@ -36,9 +36,6 @@ public: > > HTMLElement* innerTextElement() const; > >- bool wasChangedSinceLastChangeEvent() const { return m_wasChangedSinceLastChangeEvent; } >- void setChangedSinceLastChangeEvent(bool wasChangedSinceLastChangeEvent) { m_wasChangedSinceLastChangeEvent = wasChangedSinceLastChangeEvent; } >- > bool lastChangeWasUserEdit() const { return m_lastChangeWasUserEdit; } > void setLastChangeWasUserEdit(bool lastChangeWasUserEdit); > >@@ -115,7 +112,6 @@ private: > > void paintPlaceholder(PaintInfo&, int tx, int ty); > >- bool m_wasChangedSinceLastChangeEvent; > bool m_lastChangeWasUserEdit; > RefPtr<TextControlInnerTextElement> m_innerText; > }; >diff --git a/Source/WebCore/rendering/RenderTextControlMultiLine.cpp b/Source/WebCore/rendering/RenderTextControlMultiLine.cpp >index 0d512f3621007fc5756ae1615a9d16aaad7e3d6f..56bdf5da43dc4cea7b5c1f0e20e8f017c0b36bf7 100644 >--- a/Source/WebCore/rendering/RenderTextControlMultiLine.cpp >+++ b/Source/WebCore/rendering/RenderTextControlMultiLine.cpp >@@ -46,6 +46,7 @@ void RenderTextControlMultiLine::subtreeHasChanged() > { > RenderTextControl::subtreeHasChanged(); > HTMLTextAreaElement* textArea = static_cast<HTMLTextAreaElement*>(node()); >+ textArea->setChangedSinceLastChangeEvent(true); > textArea->setFormControlValueMatchesRenderer(false); > textArea->setNeedsValidityCheck(); > >diff --git a/Source/WebCore/rendering/RenderTextControlSingleLine.cpp b/Source/WebCore/rendering/RenderTextControlSingleLine.cpp >index 6ded0ea0cdf251e97e715c6b763fd7b6ffbd2c1c..9090e0879c0723b397a501ce636bb84ae4945999 100644 >--- a/Source/WebCore/rendering/RenderTextControlSingleLine.cpp >+++ b/Source/WebCore/rendering/RenderTextControlSingleLine.cpp >@@ -45,6 +45,10 @@ > #include "SimpleFontData.h" > #include "TextControlInnerElements.h" > >+#if ENABLE(WML) >+#include "WMLInputElement.h" >+#endif >+ > using namespace std; > > namespace WebCore { >@@ -181,9 +185,25 @@ void RenderTextControlSingleLine::hidePopup() > > void RenderTextControlSingleLine::subtreeHasChanged() > { >- bool wasChanged = wasChangedSinceLastChangeEvent(); > RenderTextControl::subtreeHasChanged(); > >+ ASSERT(node()->isElementNode()); >+ Element* element = static_cast<Element*>(node()); >+ ASSERT(element->isTextFormControl()); >+ bool wasChanged = false; >+ if (element->isHTMLElement()) { >+ HTMLTextFormControlElement* textFormControlElement = static_cast<HTMLTextFormControlElement*>(element); >+ wasChanged = textFormControlElement->wasChangedSinceLastChangeEvent(); >+ textFormControlElement->setChangedSinceLastChangeEvent(true); >+ } >+#if ENABLE(WML) >+ else if (element->isWMLElement()) { >+ WMLInputElement* wmlInput = static_cast<WMLInputElement*>(element); >+ wasChanged = wmlInput->wasChangedSinceLastChangeEvent(); >+ wmlInput->setChangedSinceLastChangeEvent(true); >+ } >+#endif >+ > InputElement* input = inputElement(); > // We don't need to call sanitizeUserInputValue() function here because > // InputElement::handleBeforeTextInsertedEvent() has already called >diff --git a/Source/WebCore/wml/WMLInputElement.cpp b/Source/WebCore/wml/WMLInputElement.cpp >index 687a387255b1010b5e91759ba60f5fe32a3e7269..22392f49582f5278bdc0a6836ea56b63f4581075 100644 >--- a/Source/WebCore/wml/WMLInputElement.cpp >+++ b/Source/WebCore/wml/WMLInputElement.cpp >@@ -41,6 +41,7 @@ WMLInputElement::WMLInputElement(const QualifiedName& tagName, Document* doc) > : WMLFormControlElement(tagName, doc) > , m_isPasswordField(false) > , m_isEmptyOk(false) >+ , m_wasChangedSinceLastChangeEvent(false) > , m_numOfCharsAllowedByMask(0) > { > } >@@ -296,14 +297,9 @@ void WMLInputElement::defaultEventHandler(Event* evt) > > if (clickDefaultFormButton) { > // Fire onChange for text fields. >- RenderObject* r = renderer(); >- if (r && toRenderTextControl(r)->wasChangedSinceLastChangeEvent()) { >+ if (wasChangedSinceLastChangeEvent()) { >+ setChangedSinceLastChangeEvent(false); > dispatchEvent(Event::create(eventNames().changeEvent, true, false)); >- >- // Refetch the renderer since arbitrary JS code run during onchange can do anything, including destroying it. >- r = renderer(); >- if (r) >- toRenderTextControl(r)->setChangedSinceLastChangeEvent(false); > } > > evt->setDefaultHandled(); >diff --git a/Source/WebCore/wml/WMLInputElement.h b/Source/WebCore/wml/WMLInputElement.h >index 6c66410bcf76a9effb18ee539db0a617989a253e..d3638855c83d43e3f1b37f665550e4f623c26c9e 100644 >--- a/Source/WebCore/wml/WMLInputElement.h >+++ b/Source/WebCore/wml/WMLInputElement.h >@@ -66,6 +66,9 @@ public: > virtual String visibleValue() const { return value(); } > virtual void setValueFromRenderer(const String&); > >+ virtual bool wasChangedSinceLastChangeEvent() const { return m_wasChangedSinceLastChangeEvent; } >+ virtual void setChangedSinceLastChangeEvent(bool changed) { m_wasChangedSinceLastChangeEvent = changed; } >+ > virtual bool saveFormControlState(String& value) const; > virtual void restoreFormControlState(const String&); > >@@ -109,6 +112,7 @@ private: > InputElementData m_data; > bool m_isPasswordField; > bool m_isEmptyOk; >+ bool m_wasChangedSinceLastChangeEvent; > String m_formatMask; > unsigned m_numOfCharsAllowedByMask; > }; >diff --git a/Source/WebKit/mac/ChangeLog b/Source/WebKit/mac/ChangeLog >index bff011be6057623b132cda63151c577fc1cd0317..5023a739089085e632a431793b034bde7705dc72 100644 >--- a/Source/WebKit/mac/ChangeLog >+++ b/Source/WebKit/mac/ChangeLog >@@ -1,3 +1,16 @@ >+2011-03-02 Ilya Sherman <isherman@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ HTMLInputElement::setValue() should schedule change event when the element is focused >+ In service of https://code.google.com/p/chromium/issues/detail?id=42716 >+ https://bugs.webkit.org/show_bug.cgi?id=53160 >+ >+ * WebView/WebView.mm: >+ (-[WebView _setValueForUser:forElement:withValue:]): Expose HTMLInputElement::setValueForUser() to tests >+ * WebView/WebViewInternal.h: >+ * WebView/WebViewPrivate.h: >+ > 2011-02-25 Steve Block <steveblock@google.com> > > Reviewed by Jeremy Orlow. >diff --git a/Source/WebKit/mac/WebView/WebView.mm b/Source/WebKit/mac/WebView/WebView.mm >index 8fb06d6644e79cdee0e5bfc1aecca92336470570..c0f947a015d57bceb2da156946269665a52fd28e 100644 >--- a/Source/WebKit/mac/WebView/WebView.mm >+++ b/Source/WebKit/mac/WebView/WebView.mm >@@ -107,6 +107,7 @@ > #import <Foundation/NSURLConnection.h> > #import <JavaScriptCore/APICast.h> > #import <JavaScriptCore/JSValueRef.h> >+#import <JavaScriptCore/OpaqueJSString.h> > #import <WebCore/AbstractDatabase.h> > #import <WebCore/ApplicationCacheStorage.h> > #import <WebCore/BackForwardListImpl.h> >@@ -131,6 +132,7 @@ > #import <WebCore/HTMLNames.h> > #import <WebCore/HistoryItem.h> > #import <WebCore/IconDatabase.h> >+#import <WebCore/InputElement.h> > #import <WebCore/JSCSSStyleDeclaration.h> > #import <WebCore/JSDocument.h> > #import <WebCore/JSElement.h> >@@ -6247,6 +6249,35 @@ static void glibContextIterationCallback(CFRunLoopObserverRef, CFRunLoopActivity > > @end > >+@implementation WebView (WebViewPrivateSetValueForUser) >+ >+- (void)_setValueForUser:(JSContextRef)context forElement:(JSValueRef)element withValue:(JSValueRef)value >+{ >+ if (!element || !value) >+ return; >+ >+ JSLock lock(SilenceAssertionsOnly); >+ ExecState* exec = toJS(context); >+ JSValue jsElementValue = toJS(exec, element); >+ if (!jsElementValue.inherits(&JSElement::s_info)) >+ return; >+ JSElement* jsElement = static_cast<JSElement*>(asObject(jsElementValue)); >+ Element* webcoreElement = jsElement->impl(); >+ InputElement* inputElement = toInputElement(webcoreElement); >+ if (!inputElement) >+ return; >+ >+ if (!JSValueIsString(context, value)) >+ return; >+ JSStringRef jsStringValue = JSValueToStringCopy(context, value, NULL); >+ String stringValue(jsStringValue->characters(), jsStringValue->length()); >+ >+ inputElement->setValueForUser(stringValue); >+ return; >+} >+ >+@end >+ > @implementation WebView (WebViewPrivateNodesFromRect) > > - (JSValueRef)_nodesFromRect:(JSContextRef)context forDocument:(JSValueRef)value x:(int)x y:(int)y top:(unsigned)top right:(unsigned)right bottom:(unsigned)bottom left:(unsigned)left ignoreClipping:(BOOL)ignoreClipping >diff --git a/Source/WebKit/mac/WebView/WebViewInternal.h b/Source/WebKit/mac/WebView/WebViewInternal.h >index 555c4d110ed0bfc9cfb65dc962f0b28110972787..a2310245ad9b0d427ccdf5392cdf64502982b4c3 100644 >--- a/Source/WebKit/mac/WebView/WebViewInternal.h >+++ b/Source/WebKit/mac/WebView/WebViewInternal.h >@@ -194,6 +194,4 @@ namespace WebCore { > - (void)_fullScreenRendererChanged:(WebCore::RenderBox*)renderer; > #endif > >-- (JSValueRef)_computedStyleIncludingVisitedInfo:(JSContextRef)context forElement:(JSValueRef)value; >- > @end >diff --git a/Source/WebKit/mac/WebView/WebViewPrivate.h b/Source/WebKit/mac/WebView/WebViewPrivate.h >index a4ea809b001dbc6a67234f172f020bc34cf7e84c..8c4af849ca67a1ea1fe6dae0b26bd0784b7ec5a2 100644 >--- a/Source/WebKit/mac/WebView/WebViewPrivate.h >+++ b/Source/WebKit/mac/WebView/WebViewPrivate.h >@@ -677,6 +677,10 @@ Could be worth adding to the API. > - (JSValueRef)_computedStyleIncludingVisitedInfo:(JSContextRef)context forElement:(JSValueRef)value; > @end > >+@interface WebView (WebViewPrivateSetValueForUser) >+- (void)_setValueForUser:(JSContextRef)context forElement:(JSValueRef)element withValue:(JSValueRef)value; >+@end >+ > @interface WebView (WebViewPrivateNodesFromRect) > - (JSValueRef)_nodesFromRect:(JSContextRef)context forDocument:(JSValueRef)value x:(int)x y:(int)y top:(unsigned)top right:(unsigned)right bottom:(unsigned)bottom left:(unsigned)left ignoreClipping:(BOOL)ignoreClipping; > @end >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index a2f1394296487857dd504d363172781f70484bd4..6eb6ba21e978d1c6892bab24538ecdd97016e2b9 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,26 @@ >+2011-03-02 Ilya Sherman <isherman@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ HTMLInputElement::setValue() should schedule change event when the element is focused >+ In service of https://code.google.com/p/chromium/issues/detail?id=42716 >+ https://bugs.webkit.org/show_bug.cgi?id=53160 >+ >+ * DumpRenderTree/LayoutTestController.cpp: >+ (setValueForUserCallback): >+ (LayoutTestController::staticFunctions): >+ * DumpRenderTree/LayoutTestController.h: >+ * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp: >+ (LayoutTestController::setValueForUser): Stubbed out; need real implementation. >+ * DumpRenderTree/mac/LayoutTestControllerMac.mm: >+ (LayoutTestController::setValueForUser): Expose HTMLInputElement::setValueForUser() to tests >+ * DumpRenderTree/qt/LayoutTestControllerQt.cpp: >+ (LayoutTestController::setValueForUser): Stubbed out; need real implementation. >+ * DumpRenderTree/win/LayoutTestControllerWin.cpp: >+ (LayoutTestController::setValueForUser): Stubbed out; need real implementation. >+ * DumpRenderTree/wx/LayoutTestControllerWx.cpp: >+ (LayoutTestController::setValueForUser): Stubbed out; need real implementation. >+ > 2011-03-01 Adam Roben <aroben@apple.com> > > Test that the WebKit2 responsiveness timer doesn't fire too early >diff --git a/Tools/DumpRenderTree/LayoutTestController.cpp b/Tools/DumpRenderTree/LayoutTestController.cpp >index 416b9fcb1085fe1cd483fdd92c66d4b5dba8686d..8d8ebc3636c9fbe5a25b166f4be33d05bf363a1b 100644 >--- a/Tools/DumpRenderTree/LayoutTestController.cpp >+++ b/Tools/DumpRenderTree/LayoutTestController.cpp >@@ -1432,6 +1432,18 @@ static JSValueRef setUserStyleSheetLocationCallback(JSContextRef context, JSObje > return JSValueMakeUndefined(context); > } > >+static JSValueRef setValueForUserCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) >+{ >+ // Has mac implementation >+ if (argumentCount != 2) >+ return JSValueMakeUndefined(context); >+ >+ LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); >+ controller->setValueForUser(context, arguments[0], arguments[1]); >+ >+ return JSValueMakeUndefined(context); >+} >+ > static JSValueRef setViewModeMediaFeatureCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) > { > // Has mac implementation >@@ -2129,6 +2141,7 @@ JSStaticFunction* LayoutTestController::staticFunctions() > { "setUseDashboardCompatibilityMode", setUseDashboardCompatibilityModeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > { "setUserStyleSheetEnabled", setUserStyleSheetEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, >+ { "setValueForUser", setValueForUserCallback, kJSPropertyAttributeDontDelete }, > { "setViewModeMediaFeature", setViewModeMediaFeatureCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > { "setWebViewEditable", setWebViewEditableCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > { "setWillSendRequestClearHeader", setWillSendRequestClearHeaderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, >diff --git a/Tools/DumpRenderTree/LayoutTestController.h b/Tools/DumpRenderTree/LayoutTestController.h >index 8a20500591e1a49c7bfa1b34bf7728bf51610b95..fa9cff28d4222532cf6b0d56bd16a87399ddba6c 100644 >--- a/Tools/DumpRenderTree/LayoutTestController.h >+++ b/Tools/DumpRenderTree/LayoutTestController.h >@@ -111,6 +111,7 @@ public: > void setUseDashboardCompatibilityMode(bool flag); > void setUserStyleSheetEnabled(bool flag); > void setUserStyleSheetLocation(JSStringRef path); >+ void setValueForUser(JSContextRef, JSValueRef element, JSValueRef userValue); > void setViewModeMediaFeature(JSStringRef mode); > void setXSSAuditorEnabled(bool flag); > void setFrameFlatteningEnabled(bool enable); >diff --git a/Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp >index 0bbab867efb005343edae9998962c4b498dfff6a..e9b84fa5e287eee7800ee353b516394697fcb583 100644 >--- a/Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp >+++ b/Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp >@@ -333,6 +333,11 @@ void LayoutTestController::setUserStyleSheetLocation(JSStringRef path) > setUserStyleSheetEnabled(true); > } > >+void LayoutTestController::setValueForUser(JSContextRef context, JSValueRef element, JSValueRef value) >+{ >+ // FIXME: implement >+} >+ > void LayoutTestController::setViewModeMediaFeature(JSStringRef mode) > { > WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); >diff --git a/Tools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/Tools/DumpRenderTree/mac/LayoutTestControllerMac.mm >index bc9dbb7c8289c2c331fea8d1f1f5a60e061ad13c..a12579bf772cb83308057fc00d41829edbeb8cff 100644 >--- a/Tools/DumpRenderTree/mac/LayoutTestControllerMac.mm >+++ b/Tools/DumpRenderTree/mac/LayoutTestControllerMac.mm >@@ -479,6 +479,11 @@ void LayoutTestController::setUserStyleSheetLocation(JSStringRef path) > [[WebPreferences standardPreferences] setUserStyleSheetLocation:url]; > } > >+void LayoutTestController::setValueForUser(JSContextRef context, JSValueRef element, JSValueRef value) >+{ >+ [[mainFrame webView] _setValueForUser:context forElement:element withValue:value]; >+} >+ > void LayoutTestController::setViewModeMediaFeature(JSStringRef mode) > { > // FIXME: implement >diff --git a/Tools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/Tools/DumpRenderTree/win/LayoutTestControllerWin.cpp >index 80862eb21b6b7b1f5c96f5a9973d080b430cf3be..6da62d7b1ef9f88b20be9b59fb40446c75999f7e 100644 >--- a/Tools/DumpRenderTree/win/LayoutTestControllerWin.cpp >+++ b/Tools/DumpRenderTree/win/LayoutTestControllerWin.cpp >@@ -755,6 +755,11 @@ void LayoutTestController::setUserStyleSheetLocation(JSStringRef jsURL) > SysFreeString(resultPathBSTR); > } > >+void LayoutTestController::setValueForUser(JSContextRef context, JSValueRef element, JSValueRef value) >+{ >+ // FIXME: implement >+} >+ > void LayoutTestController::setViewModeMediaFeature(JSStringRef mode) > { > // FIXME: implement >diff --git a/Tools/DumpRenderTree/wx/LayoutTestControllerWx.cpp b/Tools/DumpRenderTree/wx/LayoutTestControllerWx.cpp >index 10e1107116bd4c6301e641cedc7a3f13a6f4c6fa..7066fdc05d4c72a03f35ef3bb8b1df61a882119a 100644 >--- a/Tools/DumpRenderTree/wx/LayoutTestControllerWx.cpp >+++ b/Tools/DumpRenderTree/wx/LayoutTestControllerWx.cpp >@@ -135,6 +135,11 @@ void LayoutTestController::setUserStyleSheetLocation(JSStringRef path) > { > } > >+void LayoutTestController::setValueForUser(JSContextRef context, JSValueRef element, JSValueRef value) >+{ >+ // FIXME: implement >+} >+ > void LayoutTestController::setViewModeMediaFeature(JSStringRef mode) > { > // FIXME: implement
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 53160
:
80167
|
80168
|
80171
|
80173
|
83610
|
84131
|
84138
|
84142
|
84402
|
84531
|
84715
|
84824