summaryrefslogtreecommitdiff
path: root/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp')
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp55
1 files changed, 44 insertions, 11 deletions
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp
index f93bb9631..d642dc0b6 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp
@@ -27,10 +27,12 @@
#include "InjectedBundlePageFormClient.h"
#include "APIArray.h"
-#include "ImmutableDictionary.h"
+#include "APIDictionary.h"
#include "InjectedBundleNodeHandle.h"
#include "WKAPICast.h"
#include "WKBundleAPICast.h"
+#include "WebFrame.h"
+#include "WebPage.h"
#include <WebCore/HTMLFormElement.h>
#include <WebCore/HTMLInputElement.h>
#include <WebCore/HTMLTextAreaElement.h>
@@ -39,6 +41,11 @@ using namespace WebCore;
namespace WebKit {
+InjectedBundlePageFormClient::InjectedBundlePageFormClient(const WKBundlePageFormClientBase* client)
+{
+ initialize(client);
+}
+
void InjectedBundlePageFormClient::didFocusTextField(WebPage* page, HTMLInputElement* inputElement, WebFrame* frame)
{
if (!m_client.didFocusTextField)
@@ -66,11 +73,14 @@ void InjectedBundlePageFormClient::textFieldDidEndEditing(WebPage* page, HTMLInp
m_client.textFieldDidEndEditing(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), m_client.base.clientInfo);
}
-void InjectedBundlePageFormClient::textDidChangeInTextField(WebPage* page, HTMLInputElement* inputElement, WebFrame* frame)
+void InjectedBundlePageFormClient::textDidChangeInTextField(WebPage* page, HTMLInputElement* inputElement, WebFrame* frame, bool initiatedByUserTyping)
{
if (!m_client.textDidChangeInTextField)
return;
+ if (!initiatedByUserTyping)
+ return;
+
RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(inputElement);
m_client.textDidChangeInTextField(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), m_client.base.clientInfo);
}
@@ -84,13 +94,36 @@ void InjectedBundlePageFormClient::textDidChangeInTextArea(WebPage* page, HTMLTe
m_client.textDidChangeInTextArea(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), m_client.base.clientInfo);
}
-bool InjectedBundlePageFormClient::shouldPerformActionInTextField(WebPage* page, HTMLInputElement* inputElement, WKInputFieldActionType actionType, WebFrame* frame)
+static WKInputFieldActionType toWKInputFieldActionType(API::InjectedBundle::FormClient::InputFieldAction action)
+{
+ switch (action) {
+ case API::InjectedBundle::FormClient::InputFieldAction::MoveUp:
+ return WKInputFieldActionTypeMoveUp;
+ case API::InjectedBundle::FormClient::InputFieldAction::MoveDown:
+ return WKInputFieldActionTypeMoveDown;
+ case API::InjectedBundle::FormClient::InputFieldAction::Cancel:
+ return WKInputFieldActionTypeCancel;
+ case API::InjectedBundle::FormClient::InputFieldAction::InsertTab:
+ return WKInputFieldActionTypeInsertTab;
+ case API::InjectedBundle::FormClient::InputFieldAction::InsertBacktab:
+ return WKInputFieldActionTypeInsertBacktab;
+ case API::InjectedBundle::FormClient::InputFieldAction::InsertNewline:
+ return WKInputFieldActionTypeInsertNewline;
+ case API::InjectedBundle::FormClient::InputFieldAction::InsertDelete:
+ return WKInputFieldActionTypeInsertDelete;
+ }
+
+ ASSERT_NOT_REACHED();
+ return WKInputFieldActionTypeCancel;
+}
+
+bool InjectedBundlePageFormClient::shouldPerformActionInTextField(WebPage* page, HTMLInputElement* inputElement, API::InjectedBundle::FormClient::InputFieldAction actionType, WebFrame* frame)
{
if (!m_client.shouldPerformActionInTextField)
return false;
RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(inputElement);
- return m_client.shouldPerformActionInTextField(toAPI(page), toAPI(nodeHandle.get()), actionType, toAPI(frame), m_client.base.clientInfo);
+ return m_client.shouldPerformActionInTextField(toAPI(page), toAPI(nodeHandle.get()), toWKInputFieldActionType(actionType), toAPI(frame), m_client.base.clientInfo);
}
void InjectedBundlePageFormClient::willSendSubmitEvent(WebPage* page, HTMLFormElement* formElement, WebFrame* frame, WebFrame* sourceFrame, const Vector<std::pair<String, String>>& values)
@@ -100,12 +133,12 @@ void InjectedBundlePageFormClient::willSendSubmitEvent(WebPage* page, HTMLFormEl
RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(formElement);
- ImmutableDictionary::MapType map;
+ API::Dictionary::MapType map;
for (size_t i = 0; i < values.size(); ++i)
map.set(values[i].first, API::String::create(values[i].second));
- auto textFieldsMap = ImmutableDictionary::create(std::move(map));
+ auto textFieldsMap = API::Dictionary::create(WTFMove(map));
- m_client.willSendSubmitEvent(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), toAPI(sourceFrame), toAPI(textFieldsMap.get()), m_client.base.clientInfo);
+ m_client.willSendSubmitEvent(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), toAPI(sourceFrame), toAPI(textFieldsMap.ptr()), m_client.base.clientInfo);
}
void InjectedBundlePageFormClient::willSubmitForm(WebPage* page, HTMLFormElement* formElement, WebFrame* frame, WebFrame* sourceFrame, const Vector<std::pair<String, String>>& values, RefPtr<API::Object>& userData)
@@ -115,13 +148,13 @@ void InjectedBundlePageFormClient::willSubmitForm(WebPage* page, HTMLFormElement
RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(formElement);
- ImmutableDictionary::MapType map;
+ API::Dictionary::MapType map;
for (size_t i = 0; i < values.size(); ++i)
map.set(values[i].first, API::String::create(values[i].second));
- auto textFieldsMap = ImmutableDictionary::create(std::move(map));
+ auto textFieldsMap = API::Dictionary::create(WTFMove(map));
WKTypeRef userDataToPass = 0;
- m_client.willSubmitForm(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), toAPI(sourceFrame), toAPI(textFieldsMap.get()), &userDataToPass, m_client.base.clientInfo);
+ m_client.willSubmitForm(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), toAPI(sourceFrame), toAPI(textFieldsMap.ptr()), &userDataToPass, m_client.base.clientInfo);
userData = adoptRef(toImpl(userDataToPass));
}
@@ -136,7 +169,7 @@ void InjectedBundlePageFormClient::didAssociateFormControls(WebPage* page, const
for (const auto& element : elements)
elementHandles.uncheckedAppend(InjectedBundleNodeHandle::getOrCreate(element.get()));
- m_client.didAssociateFormControls(toAPI(page), toAPI(API::Array::create(std::move(elementHandles)).get()), m_client.base.clientInfo);
+ m_client.didAssociateFormControls(toAPI(page), toAPI(API::Array::create(WTFMove(elementHandles)).ptr()), m_client.base.clientInfo);
}
bool InjectedBundlePageFormClient::shouldNotifyOnFormChanges(WebPage* page)