Changeset 146672 in webkit
- Timestamp:
- Mar 22, 2013 4:11:59 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r146667 r146672 1 2013-03-22 Dane Wallinga <dgwallinga@chromium.org> 2 3 Add client callbacks to notify of changes of associated from controls 4 https://bugs.webkit.org/show_bug.cgi?id=110375 5 6 Reviewed by Ryosuke Niwa. 7 8 Hook FormAssociatedElement, HTMLFormElement to notify EditorClient of form changes after a page has loaded. 9 Will be used to add autofill support for ajax-y webpages. e.g if while filling out a form, new fields 10 are dynamically created, autofill can know to re-query the autofill server and keep going. 11 https://bugs.webkit.org/show_bug.cgi?id=110375 12 13 * dom/Document.cpp: 14 (WebCore::Document::Document): 15 (WebCore::Document::didAssociateFormControl): 16 (WebCore): 17 (WebCore::Document::didAssociateFormControlsTimerFired): 18 * dom/Document.h: 19 (Document): 20 added method didAssociateFormControl, which batches form changes 21 and calls out to ChromeClient on a timer. 22 * html/FormAssociatedElement.cpp: 23 (WebCore::FormAssociatedElement::resetFormOwner): 24 (WebCore::FormAssociatedElement::formAttributeChanged): 25 (WebCore): 26 * html/FormAssociatedElement.h: 27 (FormAssociatedElement): 28 add calls to Document::didAssociateFormControl when form changes 29 * html/HTMLFormElement.cpp: 30 (WebCore::HTMLFormElement::insertedInto): 31 (WebCore): 32 * html/HTMLFormElement.h: 33 add call to Document::didAssociateFormControl 34 * loader/EmptyClients.h: 35 (EmptyChromeClient): 36 (WebCore::EmptyChromeClient::didAssociateFormControls): 37 (WebCore::EmptyChromeClient::shouldNotifyOnFormChanges): 38 * page/ChromeClient.h: 39 (ChromeClient): 40 add new method didAssociateFormControls 41 1 42 2013-03-22 Alexey Proskuryakov <ap@apple.com> 2 43 -
trunk/Source/WebCore/dom/Document.cpp
r146583 r146672 497 497 , m_fontloader(0) 498 498 #endif 499 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsTimerFired) 499 500 { 500 501 m_printing = false; … … 6161 6162 #endif 6162 6163 6164 void Document::didAssociateFormControl(Element* element) 6165 { 6166 if (!frame() || !frame()->page() || !frame()->page()->chrome()->client()->shouldNotifyOnFormChanges()) 6167 return; 6168 m_associatedFormControls.add(element); 6169 if (!m_didAssociateFormControlsTimer.isActive()) 6170 m_didAssociateFormControlsTimer.startOneShot(0); 6171 } 6172 6173 void Document::didAssociateFormControlsTimerFired(Timer<Document>* timer) 6174 { 6175 ASSERT_UNUSED(timer, timer == &m_didAssociateFormControlsTimer); 6176 if (!frame() || !frame()->page()) 6177 return; 6178 6179 Vector<Element*> associatedFormControls; 6180 copyToVector(m_associatedFormControls, associatedFormControls); 6181 6182 frame()->page()->chrome()->client()->didAssociateFormControls(associatedFormControls); 6183 m_associatedFormControls.clear(); 6184 } 6185 6163 6186 } // namespace WebCore -
trunk/Source/WebCore/dom/Document.h
r146583 r146672 53 53 #include <wtf/Deque.h> 54 54 #include <wtf/FixedArray.h> 55 #include <wtf/HashSet.h> 55 56 #include <wtf/OwnPtr.h> 56 57 #include <wtf/PassOwnPtr.h> … … 1210 1211 #endif 1211 1212 1213 void didAssociateFormControl(Element*); 1214 1212 1215 virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0); 1213 1216 … … 1297 1300 void addListenerType(ListenerType listenerType) { m_listenerTypes |= listenerType; } 1298 1301 void addMutationEventListenerTypeIfEnabled(ListenerType); 1302 1303 void didAssociateFormControlsTimerFired(Timer<Document>*); 1299 1304 1300 1305 void styleResolverThrowawayTimerFired(Timer<Document>*); … … 1593 1598 RefPtr<FontLoader> m_fontloader; 1594 1599 #endif 1600 1601 Timer<Document> m_didAssociateFormControlsTimer; 1602 HashSet<Element*> m_associatedFormControls; 1603 1595 1604 }; 1596 1605 -
trunk/Source/WebCore/html/FormAssociatedElement.cpp
r141002 r146672 26 26 #include "FormAssociatedElement.h" 27 27 28 #include "EditorClient.h" 28 29 #include "FormController.h" 30 #include "Frame.h" 29 31 #include "HTMLFormControlElement.h" 30 32 #include "HTMLFormElement.h" … … 158 160 void FormAssociatedElement::resetFormOwner() 159 161 { 162 HTMLFormElement* originalForm = m_form; 160 163 setForm(findAssociatedForm(toHTMLElement(this), m_form)); 164 HTMLElement* element = toHTMLElement(this); 165 if (m_form && m_form != originalForm && m_form->inDocument()) 166 element->document()->didAssociateFormControl(element); 161 167 } 162 168 … … 166 172 if (!element->fastHasAttribute(formAttr)) { 167 173 // The form attribute removed. We need to reset form owner here. 174 HTMLFormElement* originalForm = m_form; 168 175 setForm(element->findFormAncestor()); 176 HTMLElement* element = toHTMLElement(this); 177 if (m_form && m_form != originalForm && m_form->inDocument()) 178 element->document()->didAssociateFormControl(element); 169 179 m_formAttributeTargetObserver = nullptr; 170 180 } else { -
trunk/Source/WebCore/html/HTMLFormElement.cpp
r146055 r146672 140 140 { 141 141 HTMLElement::insertedInto(insertionPoint); 142 if (insertionPoint->inDocument()) 143 this->document()->didAssociateFormControl(this); 142 144 return InsertionDone; 143 145 } -
trunk/Source/WebCore/loader/EmptyClients.h
r145914 r146672 209 209 210 210 virtual bool isEmptyChromeClient() const { return true; } 211 212 virtual void didAssociateFormControls(const Vector<Element*>&) { } 213 virtual bool shouldNotifyOnFormChanges() { return false; } 211 214 }; 212 215 -
trunk/Source/WebCore/page/ChromeClient.h
r145393 r146672 383 383 virtual bool shouldAutoscrollForDragAndDrop(RenderBox*) const { return false; } 384 384 385 virtual void didAssociateFormControls(const Vector<Element*>&) { }; 386 virtual bool shouldNotifyOnFormChanges() { return false; }; 387 385 388 protected: 386 389 virtual ~ChromeClient() { } -
trunk/Source/WebKit/chromium/ChangeLog
r146633 r146672 1 2013-03-22 Dane Wallinga <dgwallinga@chromium.org> 2 3 Add client callbacks to notify of changes of associated from controls 4 https://bugs.webkit.org/show_bug.cgi?id=110375 5 6 Reviewed by Ryosuke Niwa. 7 8 Implement form association methods of ChromeClient 9 to inform autofill of form changes after a page has loaded 10 11 * public/WebAutofillClient.h: 12 (WebAutofillClient): 13 (WebKit::WebAutofillClient::didAssociateInput): 14 (WebKit::WebAutofillClient::didAddForm): 15 (WebKit::WebAutofillClient::didAssociateFormControls): 16 * src/ChromeClientImpl.cpp: 17 (WebKit::ChromeClientImpl::didAssociateFormControls): 18 (WebKit): 19 (WebKit::ChromeClientImpl::shouldNotifyOnFormChanges): 20 * src/ChromeClientImpl.h: 21 (ChromeClientImpl): 22 1 23 2013-03-22 Alec Flett <alecflett@chromium.org> 2 24 -
trunk/Source/WebKit/chromium/public/WebAutofillClient.h
r142927 r146672 40 40 class WebNode; 41 41 class WebString; 42 43 template <typename T> class WebVector; 42 44 43 45 class WebAutofillClient { … … 94 96 virtual void setIgnoreTextChanges(bool ignore) { } 95 97 98 virtual void didAssociateFormControls(const WebVector<WebNode>&) { } 99 96 100 protected: 97 101 virtual ~WebAutofillClient() { } -
trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp
r145562 r146672 78 78 #include "TextFieldDecorationElement.h" 79 79 #include "WebAccessibilityObject.h" 80 #include "WebAutofillClient.h" 80 81 #if ENABLE(INPUT_TYPE_COLOR) 81 82 #include "WebColorChooser.h" … … 1145 1146 #endif 1146 1147 1148 void ChromeClientImpl::didAssociateFormControls(const Vector<Element*>& elements) 1149 { 1150 if (!m_webView->autofillClient()) 1151 return; 1152 WebVector<WebNode> elementVector(static_cast<size_t>(elements.size())); 1153 size_t elementsCount = elements.size(); 1154 for (size_t i = 0; i < elementsCount; ++i) 1155 elementVector[i] = elements[i]; 1156 m_webView->autofillClient()->didAssociateFormControls(elementVector); 1157 } 1158 1159 bool ChromeClientImpl::shouldNotifyOnFormChanges() 1160 { 1161 return true; 1162 } 1163 1147 1164 #if ENABLE(NAVIGATOR_CONTENT_UTILS) 1148 1165 PassOwnPtr<NavigatorContentUtilsClientImpl> NavigatorContentUtilsClientImpl::create(WebViewImpl* webView) -
trunk/Source/WebKit/chromium/src/ChromeClientImpl.h
r143917 r146672 235 235 #endif 236 236 237 virtual void didAssociateFormControls(const Vector<WebCore::Element*>&) OVERRIDE; 238 virtual bool shouldNotifyOnFormChanges() OVERRIDE; 239 237 240 private: 238 241 WebNavigationPolicy getNavigationPolicy();
Note: See TracChangeset
for help on using the changeset viewer.