[Title] Do not insert text if default action was prevented.
[Issue#] N_SE-42125
[Problem] Text was inserted, even though default action was prevent.
[Cause] Do not prevent when insert text by ime.
[Solution] Add prevent code for inserting text by ime.
Change-Id: I7347d005e02196f7d5935eeed6f1ac6d5f2ff1f0
#endif
#if ENABLE(TIZEN_ISF_PORT)
+ void prepareKeyDownEvent();
int getCursorOffset();
void getSurroundingTextAndCursorOffset(String&, int&);
WebCore::IntRect getSelectionRect(bool);
#if ENABLE(TIZEN_ISF_PORT)
if (!m_context)
return;
+
+ m_viewImpl->page()->prepareKeyDownEvent();
#endif
Ecore_IMF_Event inputMethodEvent;
#endif
#if ENABLE(TIZEN_ISF_PORT)
+void WebPageProxy::prepareKeyDownEvent()
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::PrepareKeyDownEvent(), m_pageID);
+}
+
int WebPageProxy::getCursorOffset()
{
if (!isValid())
namespace WebKit {
+#if ENABLE(TIZEN_ISF_PORT)
+static bool handleKeyPressCommands(WebPage* page, KeyboardEvent* event)
+{
+ const NativeWebKeyboardEvent* currentEvent = static_cast<const NativeWebKeyboardEvent*>(WebPage::currentEvent());
+ if (!currentEvent || !currentEvent->isFiltered())
+ return false;
+
+ Vector<OwnPtr<KeyPressCommand> > commands;
+ page->swapKeyPressCommands(commands);
+
+ size_t size = commands.size();
+ if (!size)
+ return true;
+
+ for (size_t i = 0; i < size; ++i) {
+ switch (commands[i]->type) {
+ case KeyPressCommandSetComposition: {
+ const SetCompositionKeyPressCommand* command = reinterpret_cast<const SetCompositionKeyPressCommand*>(commands[i].get());
+ page->setComposition(command->compositionString, command->underlines, command->cursorPosition);
+ break;
+ }
+ case KeyPressCommandConfirmComposition: {
+ const ConfirmCompositionKeyPressCommand* command = reinterpret_cast<const ConfirmCompositionKeyPressCommand*>(commands[i].get());
+ page->confirmComposition(command->compositionString);
+ break;
+ }
+ case KeyPressCommandDeleteText: {
+ const DeleteTextKeyPressCommand* command = reinterpret_cast<const DeleteTextKeyPressCommand*>(commands[i].get());
+ page->deleteSurroundingText(command->offset, command->count);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ event->setDefaultHandled();
+
+ return true;
+}
+#endif
+
void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
{
+#if ENABLE(TIZEN_ISF_PORT)
+ if (event->type() == eventNames().keypressEvent && handleKeyPressCommands(m_page, event))
+ return;
+#endif
+
if (m_page->handleEditingKeyboardEvent(event))
event->setDefaultHandled();
}
void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event)
{
+#if ENABLE(TIZEN_ISF_PORT)
+ return;
+#endif
+
Frame* frame = m_page->corePage()->focusController()->focusedOrMainFrame();
if (!frame || !frame->editor()->canEdit())
return;
// FIXME: sending sync message might make input lagging.
bool handled = false;
-#if ENABLE(TIZEN_ISF_PORT)
- const NativeWebKeyboardEvent* currentEvent = static_cast<const NativeWebKeyboardEvent*>(WebPage::currentEvent());
- ASSERT(currentEvent);
- handled = currentEvent->isFiltered();
-#else
m_page->sendSync(Messages::WebPageProxy::HandleInputMethodKeydown(), Messages::WebPageProxy::HandleInputMethodKeydown::Reply(handled));
-#endif
if (handled)
event->setDefaultHandled();
, m_suspendedAnimationController(false)
#endif
, m_inspectorClient(0)
+#if ENABLE(TIZEN_ISF_PORT)
+ , m_prepareKeyDownEvent(false)
+#endif
{
ASSERT(m_pageID);
// FIXME: This is a non-ideal location for this Setting and
{
CurrentEvent currentEvent(keyboardEvent);
+#if ENABLE(TIZEN_ISF_PORT)
+ m_prepareKeyDownEvent = false;
+#endif
+
bool handled = handleKeyEvent(keyboardEvent, m_page.get());
// FIXME: Platform default behaviors should be performed during normal DOM event dispatch (in most cases, in default keydown event handler).
if (!handled)
#if ENABLE(TIZEN_ISF_PORT)
class NativeWebKeyboardEvent;
+
+enum {
+ KeyPressCommandSetComposition,
+ KeyPressCommandConfirmComposition,
+ KeyPressCommandDeleteText
+};
+
+struct KeyPressCommand {
+ KeyPressCommand(int type) : type(type) { }
+
+ int type;
+};
+
+struct SetCompositionKeyPressCommand : public KeyPressCommand {
+ SetCompositionKeyPressCommand(const String& compositionString, const Vector<WebCore::CompositionUnderline>& underlines, uint64_t cursorPosition)
+ : KeyPressCommand(KeyPressCommandSetComposition), compositionString(compositionString), underlines(underlines), cursorPosition(cursorPosition) { }
+
+ String compositionString;
+ Vector<WebCore::CompositionUnderline> underlines;
+ uint64_t cursorPosition;
+};
+
+struct ConfirmCompositionKeyPressCommand : public KeyPressCommand {
+ ConfirmCompositionKeyPressCommand(const String& compositionString)
+ : KeyPressCommand(KeyPressCommandConfirmComposition), compositionString(compositionString) { }
+
+ String compositionString;
+};
+
+struct DeleteTextKeyPressCommand : public KeyPressCommand {
+ DeleteTextKeyPressCommand(int offset, int count)
+ : KeyPressCommand(KeyPressCommandDeleteText), offset(offset), count(count) { }
+
+ int offset;
+ int count;
+};
#endif
class WebPage : public APIObject, public CoreIPC::MessageSender<WebPage> {
#if ENABLE(TIZEN_ISF_PORT)
void didCancelComposition(WebCore::Node*);
+ void prepareKeyDownEvent();
+ void swapKeyPressCommands(Vector<OwnPtr<KeyPressCommand> >&);
+
void getCursorOffset(int&);
void getSurroundingTextAndCursorOffset(String&, int&);
void getSelectionRect(bool, WebCore::IntRect&);
#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
EditorState m_editorState;
#endif
+
+#if ENABLE(TIZEN_ISF_PORT)
+ bool m_prepareKeyDownEvent;
+ Vector<OwnPtr<KeyPressCommand> > m_keyPressCommands;
+#endif
};
#if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT)
GetCaretPosition() -> (WebCore::IntRect rect)
#endif
#if ENABLE(TIZEN_ISF_PORT)
+ PrepareKeyDownEvent()
GetCursorOffset() -> (int offset)
GetSurroundingTextAndCursorOffset() -> (String text, int offset)
GetSelectionRect(bool isOnlyEditable) -> (WebCore::IntRect rect)
if (!targetFrame)
return;
+ if (m_prepareKeyDownEvent) {
+ m_keyPressCommands.append(adoptPtr(new ConfirmCompositionKeyPressCommand(compositionString)));
+ return;
+ }
+
targetFrame->editor()->confirmComposition(compositionString);
#if ENABLE(TIZEN_ISF_PORT)
if (!targetFrame)
return;
+ if (m_prepareKeyDownEvent) {
+ m_keyPressCommands.append(adoptPtr(new SetCompositionKeyPressCommand(compositionString, underlines, cursorPosition)));
+ return;
+ }
+
#if ENABLE(TIZEN_ISF_PORT)
if (targetFrame->selection()->rootEditableElement()) {
HTMLTextFormControlElement* textFormControl = toTextFormControl(targetFrame->selection()->rootEditableElement()->shadowAncestorNode());
send(Messages::WebPageProxy::DidCancelComposition());
}
+void WebPage::prepareKeyDownEvent()
+{
+ m_prepareKeyDownEvent = true;
+ m_keyPressCommands.clear();
+}
+
+void WebPage::swapKeyPressCommands(Vector<OwnPtr<KeyPressCommand> >& commands)
+{
+ m_keyPressCommands.swap(commands);
+}
+
void WebPage::getCursorOffset(int& offset)
{
offset = 0;
if (!frame || !frame->editor()->canEdit())
return;
+ if (m_prepareKeyDownEvent) {
+ m_keyPressCommands.append(adoptPtr(new DeleteTextKeyPressCommand(offset, count)));
+ return;
+ }
+
Position base(frame->selection()->base());
offset += base.offsetInContainerNode();
base.moveToOffset(offset);