- Revision
- 146672
- Author
- [email protected]
- Date
- 2013-03-22 16:11:59 -0700 (Fri, 22 Mar 2013)
Log Message
Add client callbacks to notify of changes of associated from controls
https://bugs.webkit.org/show_bug.cgi?id=110375
Patch by Dane Wallinga <[email protected]> on 2013-03-22
Reviewed by Ryosuke Niwa.
Source/WebCore:
Hook FormAssociatedElement, HTMLFormElement to notify EditorClient of form changes after a page has loaded.
Will be used to add autofill support for ajax-y webpages. e.g if while filling out a form, new fields
are dynamically created, autofill can know to re-query the autofill server and keep going.
https://bugs.webkit.org/show_bug.cgi?id=110375
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::didAssociateFormControl):
(WebCore):
(WebCore::Document::didAssociateFormControlsTimerFired):
* dom/Document.h:
(Document):
added method didAssociateFormControl, which batches form changes
and calls out to ChromeClient on a timer.
* html/FormAssociatedElement.cpp:
(WebCore::FormAssociatedElement::resetFormOwner):
(WebCore::FormAssociatedElement::formAttributeChanged):
(WebCore):
* html/FormAssociatedElement.h:
(FormAssociatedElement):
add calls to Document::didAssociateFormControl when form changes
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::insertedInto):
(WebCore):
* html/HTMLFormElement.h:
add call to Document::didAssociateFormControl
* loader/EmptyClients.h:
(EmptyChromeClient):
(WebCore::EmptyChromeClient::didAssociateFormControls):
(WebCore::EmptyChromeClient::shouldNotifyOnFormChanges):
* page/ChromeClient.h:
(ChromeClient):
add new method didAssociateFormControls
Source/WebKit/chromium:
Implement form association methods of ChromeClient
to inform autofill of form changes after a page has loaded
* public/WebAutofillClient.h:
(WebAutofillClient):
(WebKit::WebAutofillClient::didAssociateInput):
(WebKit::WebAutofillClient::didAddForm):
(WebKit::WebAutofillClient::didAssociateFormControls):
* src/ChromeClientImpl.cpp:
(WebKit::ChromeClientImpl::didAssociateFormControls):
(WebKit):
(WebKit::ChromeClientImpl::shouldNotifyOnFormChanges):
* src/ChromeClientImpl.h:
(ChromeClientImpl):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (146671 => 146672)
--- trunk/Source/WebCore/ChangeLog 2013-03-22 23:04:16 UTC (rev 146671)
+++ trunk/Source/WebCore/ChangeLog 2013-03-22 23:11:59 UTC (rev 146672)
@@ -1,3 +1,44 @@
+2013-03-22 Dane Wallinga <[email protected]>
+
+ Add client callbacks to notify of changes of associated from controls
+ https://bugs.webkit.org/show_bug.cgi?id=110375
+
+ Reviewed by Ryosuke Niwa.
+
+ Hook FormAssociatedElement, HTMLFormElement to notify EditorClient of form changes after a page has loaded.
+ Will be used to add autofill support for ajax-y webpages. e.g if while filling out a form, new fields
+ are dynamically created, autofill can know to re-query the autofill server and keep going.
+ https://bugs.webkit.org/show_bug.cgi?id=110375
+
+ * dom/Document.cpp:
+ (WebCore::Document::Document):
+ (WebCore::Document::didAssociateFormControl):
+ (WebCore):
+ (WebCore::Document::didAssociateFormControlsTimerFired):
+ * dom/Document.h:
+ (Document):
+ added method didAssociateFormControl, which batches form changes
+ and calls out to ChromeClient on a timer.
+ * html/FormAssociatedElement.cpp:
+ (WebCore::FormAssociatedElement::resetFormOwner):
+ (WebCore::FormAssociatedElement::formAttributeChanged):
+ (WebCore):
+ * html/FormAssociatedElement.h:
+ (FormAssociatedElement):
+ add calls to Document::didAssociateFormControl when form changes
+ * html/HTMLFormElement.cpp:
+ (WebCore::HTMLFormElement::insertedInto):
+ (WebCore):
+ * html/HTMLFormElement.h:
+ add call to Document::didAssociateFormControl
+ * loader/EmptyClients.h:
+ (EmptyChromeClient):
+ (WebCore::EmptyChromeClient::didAssociateFormControls):
+ (WebCore::EmptyChromeClient::shouldNotifyOnFormChanges):
+ * page/ChromeClient.h:
+ (ChromeClient):
+ add new method didAssociateFormControls
+
2013-03-22 Alexey Proskuryakov <[email protected]>
Split ResourceHandleMac into multiple files
Modified: trunk/Source/WebCore/dom/Document.cpp (146671 => 146672)
--- trunk/Source/WebCore/dom/Document.cpp 2013-03-22 23:04:16 UTC (rev 146671)
+++ trunk/Source/WebCore/dom/Document.cpp 2013-03-22 23:11:59 UTC (rev 146672)
@@ -496,6 +496,7 @@
#if ENABLE(FONT_LOAD_EVENTS)
, m_fontloader(0)
#endif
+ , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsTimerFired)
{
m_printing = false;
m_paginatedForScreen = false;
@@ -6160,4 +6161,26 @@
}
#endif
+void Document::didAssociateFormControl(Element* element)
+{
+ if (!frame() || !frame()->page() || !frame()->page()->chrome()->client()->shouldNotifyOnFormChanges())
+ return;
+ m_associatedFormControls.add(element);
+ if (!m_didAssociateFormControlsTimer.isActive())
+ m_didAssociateFormControlsTimer.startOneShot(0);
+}
+
+void Document::didAssociateFormControlsTimerFired(Timer<Document>* timer)
+{
+ ASSERT_UNUSED(timer, timer == &m_didAssociateFormControlsTimer);
+ if (!frame() || !frame()->page())
+ return;
+
+ Vector<Element*> associatedFormControls;
+ copyToVector(m_associatedFormControls, associatedFormControls);
+
+ frame()->page()->chrome()->client()->didAssociateFormControls(associatedFormControls);
+ m_associatedFormControls.clear();
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/Document.h (146671 => 146672)
--- trunk/Source/WebCore/dom/Document.h 2013-03-22 23:04:16 UTC (rev 146671)
+++ trunk/Source/WebCore/dom/Document.h 2013-03-22 23:11:59 UTC (rev 146672)
@@ -52,6 +52,7 @@
#include "ViewportArguments.h"
#include <wtf/Deque.h>
#include <wtf/FixedArray.h>
+#include <wtf/HashSet.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
@@ -1209,6 +1210,8 @@
Document* templateDocumentHost() { return m_templateDocumentHost; }
#endif
+ void didAssociateFormControl(Element*);
+
virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0);
virtual const SecurityOrigin* topOrigin() const OVERRIDE;
@@ -1297,6 +1300,8 @@
void addListenerType(ListenerType listenerType) { m_listenerTypes |= listenerType; }
void addMutationEventListenerTypeIfEnabled(ListenerType);
+ void didAssociateFormControlsTimerFired(Timer<Document>*);
+
void styleResolverThrowawayTimerFired(Timer<Document>*);
Timer<Document> m_styleResolverThrowawayTimer;
double m_lastStyleResolverAccessTime;
@@ -1592,6 +1597,10 @@
#if ENABLE(FONT_LOAD_EVENTS)
RefPtr<FontLoader> m_fontloader;
#endif
+
+ Timer<Document> m_didAssociateFormControlsTimer;
+ HashSet<Element*> m_associatedFormControls;
+
};
inline void Document::notifyRemovePendingSheetIfNeeded()
Modified: trunk/Source/WebCore/html/FormAssociatedElement.cpp (146671 => 146672)
--- trunk/Source/WebCore/html/FormAssociatedElement.cpp 2013-03-22 23:04:16 UTC (rev 146671)
+++ trunk/Source/WebCore/html/FormAssociatedElement.cpp 2013-03-22 23:11:59 UTC (rev 146672)
@@ -25,7 +25,9 @@
#include "config.h"
#include "FormAssociatedElement.h"
+#include "EditorClient.h"
#include "FormController.h"
+#include "Frame.h"
#include "HTMLFormControlElement.h"
#include "HTMLFormElement.h"
#include "HTMLNames.h"
@@ -157,7 +159,11 @@
void FormAssociatedElement::resetFormOwner()
{
+ HTMLFormElement* originalForm = m_form;
setForm(findAssociatedForm(toHTMLElement(this), m_form));
+ HTMLElement* element = toHTMLElement(this);
+ if (m_form && m_form != originalForm && m_form->inDocument())
+ element->document()->didAssociateFormControl(element);
}
void FormAssociatedElement::formAttributeChanged()
@@ -165,7 +171,11 @@
HTMLElement* element = toHTMLElement(this);
if (!element->fastHasAttribute(formAttr)) {
// The form attribute removed. We need to reset form owner here.
+ HTMLFormElement* originalForm = m_form;
setForm(element->findFormAncestor());
+ HTMLElement* element = toHTMLElement(this);
+ if (m_form && m_form != originalForm && m_form->inDocument())
+ element->document()->didAssociateFormControl(element);
m_formAttributeTargetObserver = nullptr;
} else {
resetFormOwner();
Modified: trunk/Source/WebCore/html/HTMLFormElement.cpp (146671 => 146672)
--- trunk/Source/WebCore/html/HTMLFormElement.cpp 2013-03-22 23:04:16 UTC (rev 146671)
+++ trunk/Source/WebCore/html/HTMLFormElement.cpp 2013-03-22 23:11:59 UTC (rev 146672)
@@ -139,6 +139,8 @@
Node::InsertionNotificationRequest HTMLFormElement::insertedInto(ContainerNode* insertionPoint)
{
HTMLElement::insertedInto(insertionPoint);
+ if (insertionPoint->inDocument())
+ this->document()->didAssociateFormControl(this);
return InsertionDone;
}
Modified: trunk/Source/WebCore/loader/EmptyClients.h (146671 => 146672)
--- trunk/Source/WebCore/loader/EmptyClients.h 2013-03-22 23:04:16 UTC (rev 146671)
+++ trunk/Source/WebCore/loader/EmptyClients.h 2013-03-22 23:11:59 UTC (rev 146672)
@@ -208,6 +208,9 @@
virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const { return false; }
virtual bool isEmptyChromeClient() const { return true; }
+
+ virtual void didAssociateFormControls(const Vector<Element*>&) { }
+ virtual bool shouldNotifyOnFormChanges() { return false; }
};
class EmptyFrameLoaderClient : public FrameLoaderClient {
Modified: trunk/Source/WebCore/page/ChromeClient.h (146671 => 146672)
--- trunk/Source/WebCore/page/ChromeClient.h 2013-03-22 23:04:16 UTC (rev 146671)
+++ trunk/Source/WebCore/page/ChromeClient.h 2013-03-22 23:11:59 UTC (rev 146672)
@@ -382,6 +382,9 @@
// FIXME: Port should return true using heuristic based on scrollable(RenderBox).
virtual bool shouldAutoscrollForDragAndDrop(RenderBox*) const { return false; }
+ virtual void didAssociateFormControls(const Vector<Element*>&) { };
+ virtual bool shouldNotifyOnFormChanges() { return false; };
+
protected:
virtual ~ChromeClient() { }
};
Modified: trunk/Source/WebKit/chromium/ChangeLog (146671 => 146672)
--- trunk/Source/WebKit/chromium/ChangeLog 2013-03-22 23:04:16 UTC (rev 146671)
+++ trunk/Source/WebKit/chromium/ChangeLog 2013-03-22 23:11:59 UTC (rev 146672)
@@ -1,3 +1,25 @@
+2013-03-22 Dane Wallinga <[email protected]>
+
+ Add client callbacks to notify of changes of associated from controls
+ https://bugs.webkit.org/show_bug.cgi?id=110375
+
+ Reviewed by Ryosuke Niwa.
+
+ Implement form association methods of ChromeClient
+ to inform autofill of form changes after a page has loaded
+
+ * public/WebAutofillClient.h:
+ (WebAutofillClient):
+ (WebKit::WebAutofillClient::didAssociateInput):
+ (WebKit::WebAutofillClient::didAddForm):
+ (WebKit::WebAutofillClient::didAssociateFormControls):
+ * src/ChromeClientImpl.cpp:
+ (WebKit::ChromeClientImpl::didAssociateFormControls):
+ (WebKit):
+ (WebKit::ChromeClientImpl::shouldNotifyOnFormChanges):
+ * src/ChromeClientImpl.h:
+ (ChromeClientImpl):
+
2013-03-22 Alec Flett <[email protected]>
[chromium] Support Quota API in Worker
Modified: trunk/Source/WebKit/chromium/public/WebAutofillClient.h (146671 => 146672)
--- trunk/Source/WebKit/chromium/public/WebAutofillClient.h 2013-03-22 23:04:16 UTC (rev 146671)
+++ trunk/Source/WebKit/chromium/public/WebAutofillClient.h 2013-03-22 23:11:59 UTC (rev 146672)
@@ -40,6 +40,8 @@
class WebNode;
class WebString;
+template <typename T> class WebVector;
+
class WebAutofillClient {
public:
enum {
@@ -93,6 +95,8 @@
// Informs the client whether or not any subsequent text changes should be ignored.
virtual void setIgnoreTextChanges(bool ignore) { }
+ virtual void didAssociateFormControls(const WebVector<WebNode>&) { }
+
protected:
virtual ~WebAutofillClient() { }
};
Modified: trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp (146671 => 146672)
--- trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp 2013-03-22 23:04:16 UTC (rev 146671)
+++ trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp 2013-03-22 23:11:59 UTC (rev 146672)
@@ -77,6 +77,7 @@
#include "Settings.h"
#include "TextFieldDecorationElement.h"
#include "WebAccessibilityObject.h"
+#include "WebAutofillClient.h"
#if ENABLE(INPUT_TYPE_COLOR)
#include "WebColorChooser.h"
#endif
@@ -1144,6 +1145,22 @@
}
#endif
+void ChromeClientImpl::didAssociateFormControls(const Vector<Element*>& elements)
+{
+ if (!m_webView->autofillClient())
+ return;
+ WebVector<WebNode> elementVector(static_cast<size_t>(elements.size()));
+ size_t elementsCount = elements.size();
+ for (size_t i = 0; i < elementsCount; ++i)
+ elementVector[i] = elements[i];
+ m_webView->autofillClient()->didAssociateFormControls(elementVector);
+}
+
+bool ChromeClientImpl::shouldNotifyOnFormChanges()
+{
+ return true;
+}
+
#if ENABLE(NAVIGATOR_CONTENT_UTILS)
PassOwnPtr<NavigatorContentUtilsClientImpl> NavigatorContentUtilsClientImpl::create(WebViewImpl* webView)
{
Modified: trunk/Source/WebKit/chromium/src/ChromeClientImpl.h (146671 => 146672)
--- trunk/Source/WebKit/chromium/src/ChromeClientImpl.h 2013-03-22 23:04:16 UTC (rev 146671)
+++ trunk/Source/WebKit/chromium/src/ChromeClientImpl.h 2013-03-22 23:11:59 UTC (rev 146672)
@@ -234,6 +234,9 @@
virtual bool isPointerLocked();
#endif
+ virtual void didAssociateFormControls(const Vector<WebCore::Element*>&) OVERRIDE;
+ virtual bool shouldNotifyOnFormChanges() OVERRIDE;
+
private:
WebNavigationPolicy getNavigationPolicy();
void getPopupMenuInfo(WebCore::PopupContainer*, WebPopupMenuInfo*);