Skip to content
Permalink
Browse files
Replace the uint64_t used to identify form submits with a strongly ty…
…ped identifier

https://bugs.webkit.org/show_bug.cgi?id=229513

Reviewed by Alex Christensen.

Introduce FormSubmitListenerIdentifier and use it in place of a uint64_t.

* Scripts/webkit/messages.py:
(types_that_cannot_be_forward_declared):
(headers_for_type):
* Shared/IdentifierTypes.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::willSubmitForm):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchWillSubmitForm):
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::setUpWillSubmitFormListener):
(WebKit::WebFrame::continueWillSubmitForm):
* WebProcess/WebPage/WebFrame.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::continueWillSubmitForm):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:


Canonical link: https://commits.webkit.org/240964@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281606 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
smfr committed Aug 26, 2021
1 parent 388f105 commit 0d5be8b114856dd18aff592635735a1749bd31b2
Showing 12 changed files with 47 additions and 13 deletions.
@@ -1,3 +1,31 @@
2021-08-25 Simon Fraser <simon.fraser@apple.com>

Replace the uint64_t used to identify form submits with a strongly typed identifier
https://bugs.webkit.org/show_bug.cgi?id=229513

Reviewed by Alex Christensen.

Introduce FormSubmitListenerIdentifier and use it in place of a uint64_t.

* Scripts/webkit/messages.py:
(types_that_cannot_be_forward_declared):
(headers_for_type):
* Shared/IdentifierTypes.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::willSubmitForm):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchWillSubmitForm):
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::setUpWillSubmitFormListener):
(WebKit::WebFrame::continueWillSubmitForm):
* WebProcess/WebPage/WebFrame.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::continueWillSubmitForm):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

2021-08-25 Wenson Hsieh <wenson_hsieh@apple.com>

[iOS] Visual Look Up animates from the wrong rect when the web view is scaled
@@ -314,6 +314,7 @@ def types_that_cannot_be_forward_declared():
'WebKit::ContentWorldIdentifier',
'WebKit::DisplayLinkObserverID',
'WebKit::DownloadID',
'WebKit::FormSubmitListenerIdentifier',
'WebKit::GeolocationIdentifier',
'WebKit::GraphicsContextGLIdentifier',
'WebKit::ImageBufferBackendHandle',
@@ -775,6 +776,7 @@ def headers_for_type(type):
'WebKit::ContentWorldIdentifier': ['"ContentWorldShared.h"'],
'WebKit::DocumentEditingContextRequest': ['"DocumentEditingContext.h"'],
'WebKit::FindOptions': ['"WebFindOptions.h"'],
'WebKit::FormSubmitListenerIdentifier': ['"IdentifierTypes.h"'],
'WebKit::GestureRecognizerState': ['"GestureTypes.h"'],
'WebKit::GestureType': ['"GestureTypes.h"'],
'WebKit::LastNavigationWasAppInitiated': ['"AppPrivacyReport.h"'],
@@ -29,6 +29,9 @@

namespace WebKit {

enum FormSubmitListenerIdentifierType { };
using FormSubmitListenerIdentifier = ObjectIdentifier<FormSubmitListenerIdentifierType>;

enum PageGroupIdentifierType { };
using PageGroupIdentifier = ObjectIdentifier<PageGroupIdentifierType>;

@@ -5686,7 +5686,7 @@ void WebPageProxy::unableToImplementPolicy(FrameIdentifier frameID, const Resour

// FormClient

void WebPageProxy::willSubmitForm(FrameIdentifier frameID, FrameIdentifier sourceFrameID, const Vector<std::pair<String, String>>& textFieldValues, uint64_t listenerID, const UserData& userData)
void WebPageProxy::willSubmitForm(FrameIdentifier frameID, FrameIdentifier sourceFrameID, const Vector<std::pair<String, String>>& textFieldValues, FormSubmitListenerIdentifier listenerID, const UserData& userData)
{
WebFrameProxy* frame = m_process->webFrame(frameID);
MESSAGE_CHECK(m_process, frame);
@@ -2066,7 +2066,7 @@ class WebPageProxy final : public API::ObjectImpl<API::Object::Type::Page>

WebContentMode effectiveContentModeAfterAdjustingPolicies(API::WebsitePolicies&, const WebCore::ResourceRequest&);

void willSubmitForm(WebCore::FrameIdentifier, WebCore::FrameIdentifier sourceFrameID, const Vector<std::pair<String, String>>& textFieldValues, uint64_t listenerID, const UserData&);
void willSubmitForm(WebCore::FrameIdentifier, WebCore::FrameIdentifier sourceFrameID, const Vector<std::pair<String, String>>& textFieldValues, FormSubmitListenerIdentifier, const UserData&);

void contentRuleListNotification(URL&&, WebCore::ContentRuleListResults&&);

@@ -161,7 +161,7 @@ messages -> WebPageProxy {
DidFinishLoadingDataForCustomContentProvider(String suggestedFilename, IPC::DataReference data)

# Forms messages
WillSubmitForm(WebCore::FrameIdentifier frameID, WebCore::FrameIdentifier sourceFrameID, Vector<std::pair<String, String>> textFieldValues, uint64_t listenerID, WebKit::UserData userData)
WillSubmitForm(WebCore::FrameIdentifier frameID, WebCore::FrameIdentifier sourceFrameID, Vector<std::pair<String, String>> textFieldValues, WebKit::FormSubmitListenerIdentifier listenerID, WebKit::UserData userData)

#if PLATFORM(IOS_FAMILY)
InterpretKeyEvent(struct WebKit::EditorState state, bool isCharEvent) -> (bool handled) Synchronous
@@ -1094,7 +1094,7 @@ void WebFrameLoaderClient::dispatchWillSubmitForm(FormState& formState, Completi
RefPtr<API::Object> userData;
webPage->injectedBundleFormClient().willSubmitForm(webPage, &form, m_frame.ptr(), sourceFrame, values, userData);

uint64_t listenerID = m_frame->setUpWillSubmitFormListener(WTFMove(completionHandler));
auto listenerID = m_frame->setUpWillSubmitFormListener(WTFMove(completionHandler));

webPage->send(Messages::WebPageProxy::WillSubmitForm(m_frame->frameID(), sourceFrame->frameID(), values, listenerID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
}
@@ -218,14 +218,14 @@ uint64_t WebFrame::setUpPolicyListener(WebCore::PolicyCheckIdentifier identifier
return policyListenerID;
}

uint64_t WebFrame::setUpWillSubmitFormListener(CompletionHandler<void()>&& completionHandler)
FormSubmitListenerIdentifier WebFrame::setUpWillSubmitFormListener(CompletionHandler<void()>&& completionHandler)
{
uint64_t identifier = generateListenerID();
auto identifier = FormSubmitListenerIdentifier::generate();
m_willSubmitFormCompletionHandlers.set(identifier, WTFMove(completionHandler));
return identifier;
}

void WebFrame::continueWillSubmitForm(uint64_t listenerID)
void WebFrame::continueWillSubmitForm(FormSubmitListenerIdentifier listenerID)
{
Ref<WebFrame> protectedThis(*this);
if (auto completionHandler = m_willSubmitFormCompletionHandlers.take(listenerID))
@@ -27,6 +27,7 @@

#include "APIObject.h"
#include "DownloadID.h"
#include "IdentifierTypes.h"
#include "PolicyDecision.h"
#include "ShareableBitmap.h"
#include "TransactionID.h"
@@ -89,8 +90,8 @@ class WebFrame : public API::ObjectImpl<API::Object::Type::BundleFrame>, public
void invalidatePolicyListeners();
void didReceivePolicyDecision(uint64_t listenerID, PolicyDecision&&);

uint64_t setUpWillSubmitFormListener(CompletionHandler<void()>&&);
void continueWillSubmitForm(uint64_t);
FormSubmitListenerIdentifier setUpWillSubmitFormListener(CompletionHandler<void()>&&);
void continueWillSubmitForm(FormSubmitListenerIdentifier);

void startDownload(const WebCore::ResourceRequest&, const String& suggestedName = { });
void convertMainResourceLoadToDownload(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
@@ -207,7 +208,7 @@ class WebFrame : public API::ObjectImpl<API::Object::Type::BundleFrame>, public
};
HashMap<uint64_t, PolicyCheck> m_pendingPolicyChecks;

HashMap<uint64_t, CompletionHandler<void()>> m_willSubmitFormCompletionHandlers;
HashMap<FormSubmitListenerIdentifier, CompletionHandler<void()>> m_willSubmitFormCompletionHandlers;
std::optional<DownloadID> m_policyDownloadID;

WeakPtr<LoadListener> m_loadListener;
@@ -3521,7 +3521,7 @@ void WebPage::didReceivePolicyDecision(FrameIdentifier frameID, uint64_t listene
frame->didReceivePolicyDecision(listenerID, WTFMove(policyDecision));
}

void WebPage::continueWillSubmitForm(FrameIdentifier frameID, uint64_t listenerID)
void WebPage::continueWillSubmitForm(FrameIdentifier frameID, FormSubmitListenerIdentifier listenerID)
{
WebFrame* frame = WebProcess::singleton().webFrame(frameID);
if (!frame)
@@ -1693,7 +1693,7 @@ class WebPage : public API::ObjectImpl<API::Object::Type::BundlePage>, public IP
#endif

void didReceivePolicyDecision(WebCore::FrameIdentifier, uint64_t listenerID, PolicyDecision&&, const Vector<SandboxExtension::Handle>&);
void continueWillSubmitForm(WebCore::FrameIdentifier, uint64_t listenerID);
void continueWillSubmitForm(WebCore::FrameIdentifier, FormSubmitListenerIdentifier);
void setUserAgent(const String&);
void setCustomTextEncodingName(const String&);
void suspendActiveDOMObjectsAndAnimations();
@@ -196,7 +196,7 @@ GenerateSyntheticEditingCommand(enum:uint8_t WebKit::SyntheticEditingCommandType
NotifyUserScripts()
DidReceivePolicyDecision(WebCore::FrameIdentifier frameID, uint64_t listenerID, struct WebKit::PolicyDecision policyDecision, Vector<WebKit::SandboxExtension::Handle> networkExtensionsSandboxExtensions)

ContinueWillSubmitForm(WebCore::FrameIdentifier frameID, uint64_t listenerID)
ContinueWillSubmitForm(WebCore::FrameIdentifier frameID, WebKit::FormSubmitListenerIdentifier listenerID)

ClearSelection()
RestoreSelectionInFocusedEditableElement()

0 comments on commit 0d5be8b

Please sign in to comment.