Changeset 245174 in webkit


Ignore:
Timestamp:
May 10, 2019 9:05:34 AM (5 years ago)
Author:
Michael Catanzaro
Message:

[WPE][GTK] Add WebKitWebPage::did-associate-form-controls-for-frame and deprecate original did-associate-form-controls
https://bugs.webkit.org/show_bug.cgi?id=197271

Reviewed by Youenn Fablet.

Source/WebCore:

  • dom/Document.cpp:

(WebCore::Document::didAssociateFormControlsTimerFired):

  • loader/EmptyClients.h:
  • page/ChromeClient.h:

Source/WebKit:

  • WebProcess/InjectedBundle/API/c/WKBundlePageFormClient.h:
  • WebProcess/InjectedBundle/API/glib/WebKitWebPage.cpp:

(webkit_web_page_class_init):

  • WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:

(-[WKWebProcessPlugInBrowserContextController _setFormDelegate:]):

  • WebProcess/InjectedBundle/APIInjectedBundleFormClient.h:

(API::InjectedBundle::FormClient::didAssociateFormControls):

  • WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp:

(WebKit::InjectedBundlePageFormClient::didAssociateFormControls):

  • WebProcess/InjectedBundle/InjectedBundlePageFormClient.h:
  • WebProcess/WebCoreSupport/WebChromeClient.cpp:

(WebKit::WebChromeClient::didAssociateFormControls):

  • WebProcess/WebCoreSupport/WebChromeClient.h:

Tools:

  • TestWebKitAPI/Tests/WebKitGLib/WebExtensionTest.cpp:

(formControlsAssociatedForFrameCallback):
(pageCreatedCallback):
(formControlsAssociatedCallback): Deleted.

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r245170 r245174  
     12019-05-10  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        [WPE][GTK] Add WebKitWebPage::did-associate-form-controls-for-frame and deprecate original did-associate-form-controls
     4        https://bugs.webkit.org/show_bug.cgi?id=197271
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * dom/Document.cpp:
     9        (WebCore::Document::didAssociateFormControlsTimerFired):
     10        * loader/EmptyClients.h:
     11        * page/ChromeClient.h:
     12
    1132019-05-09  Simon Fraser  <simon.fraser@apple.com>
    214
  • trunk/Source/WebCore/dom/Document.cpp

    r245142 r245174  
    69606960    auto vector = copyToVector(m_associatedFormControls);
    69616961    m_associatedFormControls.clear();
    6962     if (auto* page = this->page())
    6963         page->chrome().client().didAssociateFormControls(vector);
     6962    if (auto* page = this->page()) {
     6963        ASSERT(m_frame);
     6964        page->chrome().client().didAssociateFormControls(vector, *m_frame);
     6965    }
    69646966}
    69656967
  • trunk/Source/WebCore/loader/EmptyClients.h

    r244633 r245174  
    195195    bool isEmptyChromeClient() const final { return true; }
    196196
    197     void didAssociateFormControls(const Vector<RefPtr<Element>>&) final { }
     197    void didAssociateFormControls(const Vector<RefPtr<Element>>&, Frame&) final { }
    198198    bool shouldNotifyOnFormChanges() final { return false; }
    199199
  • trunk/Source/WebCore/page/ChromeClient.h

    r245025 r245174  
    429429    virtual String plugInExtraScript() const { return String(); }
    430430
    431     virtual void didAssociateFormControls(const Vector<RefPtr<Element>>&) { };
     431    virtual void didAssociateFormControls(const Vector<RefPtr<Element>>&, Frame&) { };
    432432    virtual bool shouldNotifyOnFormChanges() { return false; };
    433433
  • trunk/Source/WebKit/ChangeLog

    r245171 r245174  
     12019-05-10  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        [WPE][GTK] Add WebKitWebPage::did-associate-form-controls-for-frame and deprecate original did-associate-form-controls
     4        https://bugs.webkit.org/show_bug.cgi?id=197271
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * WebProcess/InjectedBundle/API/c/WKBundlePageFormClient.h:
     9        * WebProcess/InjectedBundle/API/glib/WebKitWebPage.cpp:
     10        (webkit_web_page_class_init):
     11        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
     12        (-[WKWebProcessPlugInBrowserContextController _setFormDelegate:]):
     13        * WebProcess/InjectedBundle/APIInjectedBundleFormClient.h:
     14        (API::InjectedBundle::FormClient::didAssociateFormControls):
     15        * WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp:
     16        (WebKit::InjectedBundlePageFormClient::didAssociateFormControls):
     17        * WebProcess/InjectedBundle/InjectedBundlePageFormClient.h:
     18        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     19        (WebKit::WebChromeClient::didAssociateFormControls):
     20        * WebProcess/WebCoreSupport/WebChromeClient.h:
     21
    1222019-05-09  Rob Buis  <rbuis@igalia.com>
    223
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePageFormClient.h

    r188279 r245174  
    4040typedef bool (*WKBundlePageShouldNotifyOnFormChangesCallback)(WKBundlePageRef page, const void* clientInfo);
    4141typedef void (*WKBundlePageDidAssociateFormControlsCallback)(WKBundlePageRef page, WKArrayRef elementHandles, const void* clientInfo);
     42typedef void (*WKBundlePageDidAssociateFormControlsForFrameCallback)(WKBundlePageRef page, WKArrayRef elementHandles, WKBundleFrameRef frame, const void* clientInfo);
    4243
    4344typedef struct WKBundlePageFormClientBase {
     
    9394} WKBundlePageFormClientV2;
    9495
     96typedef struct WKBundlePageFormClientV3 {
     97    WKBundlePageFormClientBase                                          base;
     98
     99    // Version 0.
     100    WKBundlePageTextFieldDidBeginEditingCallback                        textFieldDidBeginEditing;
     101    WKBundlePageTextFieldDidEndEditingCallback                          textFieldDidEndEditing;
     102    WKBundlePageTextDidChangeInTextFieldCallback                        textDidChangeInTextField;
     103    WKBundlePageTextDidChangeInTextAreaCallback                         textDidChangeInTextArea;
     104    WKBundlePageShouldPerformActionInTextFieldCallback                  shouldPerformActionInTextField;
     105    WKBundlePageWillSubmitFormCallback                                  willSubmitForm;
     106
     107    // Version 1.
     108    WKBundlePageWillSendSubmitEventCallback                             willSendSubmitEvent;
     109
     110    // version 2.
     111    WKBundlePageDidFocusTextFieldCallback                               didFocusTextField;
     112    WKBundlePageShouldNotifyOnFormChangesCallback                       shouldNotifyOnFormChanges;
     113    WKBundlePageDidAssociateFormControlsCallback                        didAssociateFormControls;
     114
     115    // version 3.
     116    WKBundlePageDidAssociateFormControlsForFrameCallback                didAssociateFormControlsForFrame;
     117} WKBundlePageFormClientV3;
     118
    95119#endif // WKBundlePageFormClient_h
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitWebPage.cpp

    r240808 r245174  
    6969    CONSOLE_MESSAGE_SENT,
    7070    FORM_CONTROLS_ASSOCIATED,
     71    FORM_CONTROLS_ASSOCIATED_FOR_FRAME,
    7172    WILL_SUBMIT_FORM,
    7273
     
    381382    }
    382383
    383     void didAssociateFormControls(WebPage*, const Vector<RefPtr<Element>>& elements) override
     384    void didAssociateFormControls(WebPage*, const Vector<RefPtr<Element>>& elements, WebFrame* frame) override
    384385    {
    385386        GRefPtr<GPtrArray> formElements = adoptGRef(g_ptr_array_sized_new(elements.size()));
     
    388389
    389390        g_signal_emit(m_webPage, signals[FORM_CONTROLS_ASSOCIATED], 0, formElements.get());
     391        g_signal_emit(m_webPage, signals[FORM_CONTROLS_ASSOCIATED_FOR_FRAME], 0, formElements.get(), webkitFrameGetOrCreate(frame));
    390392    }
    391393
     
    566568     *
    567569     * Since: 2.16
     570     *
     571     * Deprecated: 2.26, use #WebKitWebPage::form-controls-associated-for-frame instead.
    568572     */
    569573    signals[FORM_CONTROLS_ASSOCIATED] = g_signal_new(
    570574        "form-controls-associated",
    571575        G_TYPE_FROM_CLASS(klass),
    572         G_SIGNAL_RUN_LAST,
     576        static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_DEPRECATED),
    573577        0, 0, nullptr,
    574578        g_cclosure_marshal_VOID__BOXED,
    575579        G_TYPE_NONE, 1,
    576580        G_TYPE_PTR_ARRAY);
     581
     582    /**
     583     * WebKitWebPage::form-controls-associated-for-frame:
     584     * @web_page: the #WebKitWebPage on which the signal is emitted
     585     * @elements: (element-type WebKitDOMElement) (transfer none): a #GPtrArray of
     586     *     #WebKitDOMElement with the list of forms in the page
     587     * @frame: the #WebKitFrame
     588     *
     589     * Emitted after form elements (or form associated elements) are associated to a particular web
     590     * page. This is useful to implement form auto filling for web pages where form fields are added
     591     * dynamically. This signal might be emitted multiple times for the same web page.
     592     *
     593     * Note that this signal could be also emitted when form controls are moved between forms. In
     594     * that case, the @elements array carries the list of those elements which have moved.
     595     *
     596     * Clients should take a reference to the members of the @elements array if it is desired to
     597     * keep them alive after the signal handler returns.
     598     *
     599     * Since: 2.26
     600     */
     601    signals[FORM_CONTROLS_ASSOCIATED_FOR_FRAME] = g_signal_new(
     602        "form-controls-associated-for-frame",
     603        G_TYPE_FROM_CLASS(klass),
     604        G_SIGNAL_RUN_LAST,
     605        0, 0, nullptr,
     606        g_cclosure_marshal_generic,
     607        G_TYPE_NONE, 2,
     608        G_TYPE_PTR_ARRAY,
     609        WEBKIT_TYPE_FRAME);
    577610
    578611    /**
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm

    r244139 r245174  
    527527        }
    528528
    529         void didAssociateFormControls(WebKit::WebPage*, const Vector<RefPtr<WebCore::Element>>& elements) override
     529        void didAssociateFormControls(WebKit::WebPage*, const Vector<RefPtr<WebCore::Element>>& elements, WebKit::WebFrame*) override
    530530        {
    531531            auto formDelegate = m_controller->_formDelegate.get();
  • trunk/Source/WebKit/WebProcess/InjectedBundle/APIInjectedBundleFormClient.h

    r241183 r245174  
    7171    virtual void willSubmitForm(WebKit::WebPage*, WebCore::HTMLFormElement*, WebKit::WebFrame*, WebKit::WebFrame*, const Vector<std::pair<WTF::String, WTF::String>>&, RefPtr<API::Object>& userData) { UNUSED_PARAM(userData); }
    7272    virtual void willSendSubmitEvent(WebKit::WebPage*, WebCore::HTMLFormElement*, WebKit::WebFrame*, WebKit::WebFrame*, const Vector<std::pair<WTF::String, WTF::String>>&) { }
    73     virtual void didAssociateFormControls(WebKit::WebPage*, const Vector<RefPtr<WebCore::Element>>&) { }
     73    virtual void didAssociateFormControls(WebKit::WebPage*, const Vector<RefPtr<WebCore::Element>>&, WebKit::WebFrame*) { }
    7474    virtual bool shouldNotifyOnFormChanges(WebKit::WebPage*) { return false; }
    7575    virtual void willBeginInputSession(WebKit::WebPage*, WebCore::Element*, WebKit::WebFrame*, bool userIsInteracting, RefPtr<API::Object>& userData) { UNUSED_PARAM(userData); }
  • trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp

    r235205 r245174  
    158158}
    159159
    160 void InjectedBundlePageFormClient::didAssociateFormControls(WebPage* page, const Vector<RefPtr<WebCore::Element>>& elements)
     160void InjectedBundlePageFormClient::didAssociateFormControls(WebPage* page, const Vector<RefPtr<WebCore::Element>>& elements, WebFrame* frame)
    161161{
    162     if (!m_client.didAssociateFormControls)
     162    if (!m_client.didAssociateFormControls && !m_client.didAssociateFormControlsForFrame)
    163163        return;
    164164
     
    169169        elementHandles.uncheckedAppend(InjectedBundleNodeHandle::getOrCreate(element.get()));
    170170
    171     m_client.didAssociateFormControls(toAPI(page), toAPI(API::Array::create(WTFMove(elementHandles)).ptr()), m_client.base.clientInfo);
     171    if (!m_client.didAssociateFormControlsForFrame) {
     172        m_client.didAssociateFormControls(toAPI(page), toAPI(API::Array::create(WTFMove(elementHandles)).ptr()), m_client.base.clientInfo);
     173        return;
     174    }
     175
     176    m_client.didAssociateFormControlsForFrame(toAPI(page), toAPI(API::Array::create(WTFMove(elementHandles)).ptr()), toAPI(frame), m_client.base.clientInfo);
    172177}
    173178
  • trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageFormClient.h

    r197563 r245174  
    3434
    3535template<> struct ClientTraits<WKBundlePageFormClientBase> {
    36     typedef std::tuple<WKBundlePageFormClientV0, WKBundlePageFormClientV1, WKBundlePageFormClientV2> Versions;
     36    typedef std::tuple<WKBundlePageFormClientV0, WKBundlePageFormClientV1, WKBundlePageFormClientV2, WKBundlePageFormClientV3> Versions;
    3737};
    3838}
     
    5252    void willSubmitForm(WebPage*, WebCore::HTMLFormElement*, WebFrame*, WebFrame* sourceFrame, const Vector<std::pair<String, String>>&, RefPtr<API::Object>& userData) override;
    5353    void willSendSubmitEvent(WebPage*, WebCore::HTMLFormElement*, WebFrame*, WebFrame* sourceFrame, const Vector<std::pair<String, String>>&) override;
    54     void didAssociateFormControls(WebPage*, const Vector<RefPtr<WebCore::Element>>&) override;
     54    void didAssociateFormControls(WebPage*, const Vector<RefPtr<WebCore::Element>>&, WebFrame*) override;
    5555    bool shouldNotifyOnFormChanges(WebPage*) override;
    5656};
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r245025 r245174  
    848848#endif
    849849
    850 void WebChromeClient::didAssociateFormControls(const Vector<RefPtr<Element>>& elements)
    851 {
    852     return m_page.injectedBundleFormClient().didAssociateFormControls(&m_page, elements);
     850void WebChromeClient::didAssociateFormControls(const Vector<RefPtr<Element>>& elements, WebCore::Frame& frame)
     851{
     852    WebFrame* webFrame = WebFrame::fromCoreFrame(frame);
     853    ASSERT(webFrame);
     854    return m_page.injectedBundleFormClient().didAssociateFormControls(&m_page, elements, webFrame);
    853855}
    854856
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h

    r245025 r245174  
    207207#endif
    208208
    209     void didAssociateFormControls(const Vector<RefPtr<WebCore::Element>>&) final;
     209    void didAssociateFormControls(const Vector<RefPtr<WebCore::Element>>&, WebCore::Frame&) final;
    210210    bool shouldNotifyOnFormChanges() final;
    211211
  • trunk/Tools/ChangeLog

    r245172 r245174  
     12019-05-10  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        [WPE][GTK] Add WebKitWebPage::did-associate-form-controls-for-frame and deprecate original did-associate-form-controls
     4        https://bugs.webkit.org/show_bug.cgi?id=197271
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * TestWebKitAPI/Tests/WebKitGLib/WebExtensionTest.cpp:
     9        (formControlsAssociatedForFrameCallback):
     10        (pageCreatedCallback):
     11        (formControlsAssociatedCallback): Deleted.
     12
    1132019-05-10  Adrian Perez de Castro  <aperez@igalia.com>
    214
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/WebExtensionTest.cpp

    r243534 r245174  
    317317}
    318318
    319 static void formControlsAssociatedCallback(WebKitWebPage* webPage, GPtrArray* formElements, WebKitWebExtension* extension)
    320 {
    321     auto* frame = webkit_web_page_get_main_frame(webPage);
     319static void formControlsAssociatedForFrameCallback(WebKitWebPage* webPage, GPtrArray* formElements, WebKitFrame* frame, WebKitWebExtension* extension)
     320{
    322321    GString* formIdsBuilder = g_string_new(nullptr);
    323322    for (guint i = 0; i < formElements->len; ++i) {
     
    414413    g_signal_connect(webPage, "console-message-sent", G_CALLBACK(consoleMessageSentCallback), nullptr);
    415414    g_signal_connect(webPage, "context-menu", G_CALLBACK(contextMenuCallback), nullptr);
    416     g_signal_connect(webPage, "form-controls-associated", G_CALLBACK(formControlsAssociatedCallback), extension);
     415    g_signal_connect(webPage, "form-controls-associated-for-frame", G_CALLBACK(formControlsAssociatedForFrameCallback), extension);
    417416    g_signal_connect(webPage, "will-submit-form", G_CALLBACK(willSubmitFormCallback), extension);
    418417}
Note: See TracChangeset for help on using the changeset viewer.