Changeset 150398 in webkit


Ignore:
Timestamp:
May 20, 2013 7:07:48 PM (11 years ago)
Author:
jberlin@webkit.org
Message:

Expose a way to know when forms are added to a page or when form controls are added to a form
in the injected bundle
https://bugs.webkit.org/show_bug.cgi?id=116334

Reviewed by Alexey Proskuryakov.

Source/WebKit2:

Add shouldNotifyOnFormChanges and didAssociateFormControls to the WKBundlePageFormClient.

  • WebProcess/InjectedBundle/API/c/WKBundlePage.h:

Add the new callbacks as part of version 2 of the WKBundlePageFormClient.

  • WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp:

(WebKit::InjectedBundlePageFormClient::didAssociateFormControls):
Pass the message along to the client if the client has a handler.
(WebKit::InjectedBundlePageFormClient::shouldNotifyOnFormChanges):
Ditto.

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

(WebKit::WebChromeClient::didAssociateFormControls):
Tell the injected bundle form client for the page.
(WebKit::WebChromeClient::shouldNotifyOnFormChanges):
Ditto.

  • WebProcess/WebCoreSupport/WebChromeClient.h:

Tools:

Add tests for the new callbacks.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:

Add DidAssociateFormControls/_Bundle.cpp and associate-form-controls.html

  • TestWebKitAPI/Tests/WebKit2/DidAssociateFormControls.cpp: Added.

(TestWebKitAPI::nullJavaScriptCallback):
A "null" callback to handle the fact that WKPageRunJavaScriptInMainFrame cannot handle null
being passed in for the callback.
(TestWebKitAPI::didReceiveMessageFromInjectedBundle):
After receiving the message that didAssociateFormControls callback was invoked from adding
the form in the onload handler, tell the page to add a password field to the form, which
should also invoke didAssociateFormControls callback.
(TestWebKitAPI::setInjectedBundleClient):
Register to receive messages.
(TestWebKitAPI::TEST):
Load associate-form-controls.html and wait until the didAssociateFormControls callback has
been invoked for both adding the form and for adding a password field to the form.

  • TestWebKitAPI/Tests/WebKit2/DidAssociateFormControls_Bundle.cpp: Added.

(TestWebKitAPI::shouldNotifyOnFormChanges):
Return true so the didAssociateFormControls callback is invoked.
(TestWebKitAPI::didAssociateFormControls):
Tell the UI process.
(TestWebKitAPI::DidAssociateFormControlsTest::DidAssociateFormControlsTest):
(TestWebKitAPI::DidAssociateFormControlsTest::didCreatePage):
Register for the shouldNotifyOnFormChanges and didAssociateFormControls callbacks.

  • TestWebKitAPI/Tests/WebKit2/associate-form-controls.html: Added.

Add a form in response to the onload event. Add a button that will add the password field
for manual testing.

Location:
trunk
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r150388 r150398  
     12013-05-20  Jessie Berlin  <jberlin@apple.com>
     2
     3        Expose a way to know when forms are added to a page or when form controls are added to a form
     4        in the injected bundle
     5        https://bugs.webkit.org/show_bug.cgi?id=116334
     6
     7        Reviewed by Alexey Proskuryakov.
     8
     9        Add shouldNotifyOnFormChanges and didAssociateFormControls to the WKBundlePageFormClient.
     10
     11        * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
     12        Add the new callbacks as part of version 2 of the WKBundlePageFormClient.
     13
     14        * WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp:
     15        (WebKit::InjectedBundlePageFormClient::didAssociateFormControls):
     16        Pass the message along to the client if the client has a handler.
     17        (WebKit::InjectedBundlePageFormClient::shouldNotifyOnFormChanges):
     18        Ditto.
     19        * WebProcess/InjectedBundle/InjectedBundlePageFormClient.h:
     20
     21        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     22        (WebKit::WebChromeClient::didAssociateFormControls):
     23        Tell the injected bundle form client for the page.
     24        (WebKit::WebChromeClient::shouldNotifyOnFormChanges):
     25        Ditto.
     26        * WebProcess/WebCoreSupport/WebChromeClient.h:
     27
    1282013-05-20  Tim Horton  <timothy_horton@apple.com>
    229
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h

    r150369 r150398  
    339339typedef void (*WKBundlePageWillSendSubmitEventCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlFormElementHandle, WKBundleFrameRef frame, WKBundleFrameRef sourceFrame, WKDictionaryRef values, const void* clientInfo);
    340340typedef void (*WKBundlePageDidFocusTextFieldCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo);
     341typedef bool (*WKBundlePageShouldNotifyOnFormChangesCallback)(WKBundlePageRef page, const void* clientInfo);
     342typedef void (*WKBundlePageDidAssociateFormControlsCallback)(WKBundlePageRef page, WKArrayRef elementHandles, const void* clientInfo);
    341343
    342344struct WKBundlePageFormClient {
     
    357359    // version 2.
    358360    WKBundlePageDidFocusTextFieldCallback                               didFocusTextField;
     361    WKBundlePageShouldNotifyOnFormChangesCallback                       shouldNotifyOnFormChanges;
     362    WKBundlePageDidAssociateFormControlsCallback                        didAssociateFormControls;
    359363};
    360364typedef struct WKBundlePageFormClient WKBundlePageFormClient;
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp

    r149848 r150398  
    2727#include "InjectedBundlePageFormClient.h"
    2828
     29#include "ImmutableArray.h"
    2930#include "ImmutableDictionary.h"
    3031#include "InjectedBundleNodeHandle.h"
     
    125126}
    126127
     128void InjectedBundlePageFormClient::didAssociateFormControls(WebPage* page, const Vector<RefPtr<WebCore::Element>>& elements)
     129{
     130    if (!m_client.didAssociateFormControls)
     131        return;
     132
     133    size_t size = elements.size();
     134
     135    Vector<RefPtr<APIObject>> elementHandles;
     136    elementHandles.reserveCapacity(size);
     137
     138    for (size_t i = 0; i < size; ++i)
     139        elementHandles.uncheckedAppend(InjectedBundleNodeHandle::getOrCreate(elements[i].get()).get());
     140
     141    m_client.didAssociateFormControls(toAPI(page), toAPI(ImmutableArray::adopt(elementHandles).get()), m_client.clientInfo);
     142}
     143
     144bool InjectedBundlePageFormClient::shouldNotifyOnFormChanges(WebPage* page)
     145{
     146    if (!m_client.shouldNotifyOnFormChanges)
     147        return false;
     148
     149    return m_client.shouldNotifyOnFormChanges(toAPI(page), m_client.clientInfo);
     150}
     151
    127152} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.h

    r149848 r150398  
    3434
    3535namespace WebCore {
    36     class HTMLFormElement;
    37     class HTMLInputElement;
    38     class HTMLTextAreaElement;
     36class Element;
     37class HTMLFormElement;
     38class HTMLInputElement;
     39class HTMLTextAreaElement;
    3940}
    4041
     
    5657    void willSubmitForm(WebPage*, WebCore::HTMLFormElement*, WebFrame*, WebFrame* sourceFrame, const Vector<std::pair<String, String>>&, RefPtr<APIObject>& userData);
    5758    void willSendSubmitEvent(WebPage*, WebCore::HTMLFormElement*, WebFrame*, WebFrame* sourceFrame, const Vector<std::pair<String, String>>&);
     59    void didAssociateFormControls(WebPage*, const Vector<RefPtr<WebCore::Element>>&);
     60    bool shouldNotifyOnFormChanges(WebPage*);
    5861};
    5962
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r150307 r150398  
    717717}
    718718
     719void WebChromeClient::didAssociateFormControls(const Vector<RefPtr<WebCore::Element>>& elements)
     720{
     721    return m_page->injectedBundleFormClient().didAssociateFormControls(m_page, elements);
     722}
     723
     724bool WebChromeClient::shouldNotifyOnFormChanges()
     725{
     726    return m_page->injectedBundleFormClient().shouldNotifyOnFormChanges(m_page);
     727}
     728
    719729bool WebChromeClient::selectItemWritingDirectionIsNatural()
    720730{
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h

    r150307 r150398  
    171171    virtual void formStateDidChange(const WebCore::Node*) OVERRIDE;
    172172
     173    virtual void didAssociateFormControls(const Vector<RefPtr<WebCore::Element>>&) OVERRIDE;
     174    virtual bool shouldNotifyOnFormChanges() OVERRIDE;
     175
    173176    virtual bool selectItemWritingDirectionIsNatural() OVERRIDE;
    174177    virtual bool selectItemAlignmentFollowsMenuWritingDirection() OVERRIDE;
  • trunk/Tools/ChangeLog

    r150391 r150398  
     12013-05-20  Jessie Berlin  <jberlin@apple.com>
     2
     3        Expose a way to know when forms are added to a page or when form controls are added to a form
     4        in the injected bundle
     5        https://bugs.webkit.org/show_bug.cgi?id=116334
     6
     7        Reviewed by Alexey Proskuryakov.
     8
     9        Add tests for the new callbacks.
     10
     11        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     12        Add DidAssociateFormControls/_Bundle.cpp and associate-form-controls.html
     13
     14        * TestWebKitAPI/Tests/WebKit2/DidAssociateFormControls.cpp: Added.
     15        (TestWebKitAPI::nullJavaScriptCallback):
     16        A "null" callback to handle the fact that WKPageRunJavaScriptInMainFrame cannot handle null
     17        being passed in for the callback.
     18        (TestWebKitAPI::didReceiveMessageFromInjectedBundle):
     19        After receiving the message that didAssociateFormControls callback was invoked from adding
     20        the form in the onload handler, tell the page to add a password field to the form, which
     21        should also invoke didAssociateFormControls callback.
     22        (TestWebKitAPI::setInjectedBundleClient):
     23        Register to receive messages.
     24        (TestWebKitAPI::TEST):
     25        Load associate-form-controls.html and wait until the didAssociateFormControls callback has
     26        been invoked for both adding the form and for adding a password field to the form.
     27
     28        * TestWebKitAPI/Tests/WebKit2/DidAssociateFormControls_Bundle.cpp: Added.
     29        (TestWebKitAPI::shouldNotifyOnFormChanges):
     30        Return true so the didAssociateFormControls callback is invoked.
     31        (TestWebKitAPI::didAssociateFormControls):
     32        Tell the UI process.
     33        (TestWebKitAPI::DidAssociateFormControlsTest::DidAssociateFormControlsTest):
     34        (TestWebKitAPI::DidAssociateFormControlsTest::didCreatePage):
     35        Register for the shouldNotifyOnFormChanges and didAssociateFormControls callbacks.
     36
     37        * TestWebKitAPI/Tests/WebKit2/associate-form-controls.html: Added.
     38        Add a form in response to the onload event. Add a button that will add the password field
     39        for manual testing.
     40
    1412013-05-20  Christophe Dumez  <ch.dumez@sisa.samsung.com>
    242
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r150242 r150398  
    210210                F660AA1315A619C9003A1243 /* InjectedBundleInitializationUserDataCallbackWins.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F660AA1215A619C8003A1243 /* InjectedBundleInitializationUserDataCallbackWins.cpp */; };
    211211                F660AA1515A61ABF003A1243 /* InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F660AA1415A61ABF003A1243 /* InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp */; };
     212                F6B7BE9417469209008A3445 /* DidAssociateFormControls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6B7BE93174691EF008A3445 /* DidAssociateFormControls.cpp */; };
     213                F6B7BE9517469212008A3445 /* DidAssociateFormControls_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6B7BE92174691EF008A3445 /* DidAssociateFormControls_Bundle.cpp */; };
     214                F6B7BE9717469B96008A3445 /* associate-form-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F6B7BE9617469B7E008A3445 /* associate-form-controls.html */; };
    212215                F6F3F29113342FEB00A6BF19 /* CookieManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */; };
    213216                F6F49C6915545C8E0007F39D /* DOMWindowExtensionNoCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6F49C6715545C8D0007F39D /* DOMWindowExtensionNoCache.cpp */; };
     
    249252                                C2CF975A16CEC7140054E99D /* JSContextBackForwardCache2.html in Copy Resources */,
    250253                                1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */,
     254                                F6B7BE9717469B96008A3445 /* associate-form-controls.html in Copy Resources */,
    251255                                379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */,
    252256                                B55F11BE15191A0600915916 /* Ahem.ttf in Copy Resources */,
     
    512516                F660AA1215A619C8003A1243 /* InjectedBundleInitializationUserDataCallbackWins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleInitializationUserDataCallbackWins.cpp; sourceTree = "<group>"; };
    513517                F660AA1415A61ABF003A1243 /* InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp; sourceTree = "<group>"; };
     518                F6B7BE92174691EF008A3445 /* DidAssociateFormControls_Bundle.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DidAssociateFormControls_Bundle.cpp; sourceTree = "<group>"; };
     519                F6B7BE93174691EF008A3445 /* DidAssociateFormControls.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DidAssociateFormControls.cpp; sourceTree = "<group>"; };
     520                F6B7BE9617469B7E008A3445 /* associate-form-controls.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "associate-form-controls.html"; sourceTree = "<group>"; };
    514521                F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CookieManager.cpp; sourceTree = "<group>"; };
    515522                F6F49C6615545C8D0007F39D /* DOMWindowExtensionNoCache_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowExtensionNoCache_Bundle.cpp; sourceTree = "<group>"; };
     
    667674                                BC246D97132F1FE100B56D7C /* CanHandleRequest_Bundle.cpp */,
    668675                                F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */,
     676                                F6B7BE93174691EF008A3445 /* DidAssociateFormControls.cpp */,
     677                                F6B7BE92174691EF008A3445 /* DidAssociateFormControls_Bundle.cpp */,
    669678                                BCB6803F126FBFE100642A61 /* DocumentStartUserScriptAlertCrash.cpp */,
    670679                                BCB68041126FBFF100642A61 /* DocumentStartUserScriptAlertCrash_Bundle.cpp */,
     
    777786                        children = (
    778787                                C045F9461385C2F800C0F3CD /* 18-characters.html */,
     788                                F6B7BE9617469B7E008A3445 /* associate-form-controls.html */,
    779789                                76E182DE15475A8300F1FADD /* auto-submitting-form.html */,
    780790                                290F4274172A1FDE00939FF0 /* custom-protocol-sync-xhr.html */,
     
    11541164                                76E182DA1547550100F1FADD /* WillSendSubmitEvent.cpp in Sources */,
    11551165                                A5E2027315B2181900C13E14 /* WindowlessWebViewWithMedia.mm in Sources */,
     1166                                F6B7BE9417469209008A3445 /* DidAssociateFormControls.cpp in Sources */,
    11561167                                BC3C4C7F14587AA60025FB62 /* WKBrowsingContextGroupTest.mm in Sources */,
    11571168                                BC3C4C7214575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm in Sources */,
     
    11961207                                BC575BD9126F58E2006F0F12 /* PlatformUtilities.cpp in Sources */,
    11971208                                BC575BE0126F590D006F0F12 /* PlatformUtilitiesMac.mm in Sources */,
     1209                                F6B7BE9517469212008A3445 /* DidAssociateFormControls_Bundle.cpp in Sources */,
    11981210                                C0BD669F131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp in Sources */,
    11991211                                51FCF7A11534B2A000104491 /* ShouldGoToBackForwardListItem_Bundle.cpp in Sources */,
Note: See TracChangeset for help on using the changeset viewer.