Diff
Modified: trunk/Source/WebKit2/ChangeLog (132593 => 132594)
--- trunk/Source/WebKit2/ChangeLog 2012-10-26 09:39:21 UTC (rev 132593)
+++ trunk/Source/WebKit2/ChangeLog 2012-10-26 09:40:21 UTC (rev 132594)
@@ -1,3 +1,41 @@
+2012-10-26 Christophe Dumez <[email protected]>
+
+ [EFL][WK2] Move input method code out of EwkViewImpl
+ https://bugs.webkit.org/show_bug.cgi?id=100468
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Move input method code out of EwkViewImpl and into
+ a new InputMethodContextEfl class to avoid cluttering
+ the view code.
+
+ * PlatformEfl.cmake:
+ * UIProcess/API/efl/EwkViewImpl.cpp:
+ (EwkViewImpl::EwkViewImpl):
+ (EwkViewImpl::inputMethodContext):
+ * UIProcess/API/efl/EwkViewImpl.h:
+ (WebKit):
+ (EwkViewImpl):
+ * UIProcess/API/efl/ewk_view.cpp:
+ (_ewk_view_smart_mouse_up):
+ (_ewk_view_smart_key_down):
+ * UIProcess/efl/InputMethodContextEfl.cpp: Added.
+ (WebKit):
+ (WebKit::InputMethodContextEfl::InputMethodContextEfl):
+ (WebKit::InputMethodContextEfl::~InputMethodContextEfl):
+ (WebKit::InputMethodContextEfl::onIMFInputSequenceComplete):
+ (WebKit::InputMethodContextEfl::onIMFPreeditSequenceChanged):
+ (WebKit::InputMethodContextEfl::createIMFContext):
+ (WebKit::InputMethodContextEfl::handleMouseUpEvent):
+ (WebKit::InputMethodContextEfl::handleKeyDownEvent):
+ (WebKit::InputMethodContextEfl::updateTextInputState):
+ * UIProcess/efl/InputMethodContextEfl.h: Added.
+ (WebKit):
+ (InputMethodContextEfl):
+ (WebKit::InputMethodContextEfl::create):
+ * UIProcess/efl/PageClientImpl.cpp:
+ (WebKit::PageClientImpl::updateTextInputState):
+
2012-10-26 Jaehun Lim <[email protected]>
Implement {get,set}FloatValueForKey
Modified: trunk/Source/WebKit2/PlatformEfl.cmake (132593 => 132594)
--- trunk/Source/WebKit2/PlatformEfl.cmake 2012-10-26 09:39:21 UTC (rev 132593)
+++ trunk/Source/WebKit2/PlatformEfl.cmake 2012-10-26 09:40:21 UTC (rev 132594)
@@ -72,6 +72,7 @@
UIProcess/efl/DownloadManagerEfl.cpp
UIProcess/efl/FindClientEfl.cpp
UIProcess/efl/FormClientEfl.cpp
+ UIProcess/efl/InputMethodContextEfl.cpp
UIProcess/efl/NetworkInfoProvider.cpp
UIProcess/efl/PageClientImpl.cpp
UIProcess/efl/PageLoadClientEfl.cpp
Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp (132593 => 132594)
--- trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp 2012-10-26 09:39:21 UTC (rev 132593)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp 2012-10-26 09:40:21 UTC (rev 132594)
@@ -24,6 +24,7 @@
#include "EflScreenUtilities.h"
#include "FindClientEfl.h"
#include "FormClientEfl.h"
+#include "InputMethodContextEfl.h"
#include "PageClientImpl.h"
#include "PageLoadClientEfl.h"
#include "PagePolicyClientEfl.h"
@@ -45,8 +46,6 @@
#include "ewk_view.h"
#include "ewk_view_private.h"
#include <Ecore_Evas.h>
-#include <Ecore_IMF.h>
-#include <Ecore_IMF_Evas.h>
#include <Edje.h>
#include <WebCore/Cursor.h>
@@ -80,56 +79,6 @@
return pageViewMap.get(page);
}
-void EwkViewImpl::onIMFInputSequenceComplete(void* data, Ecore_IMF_Context*, void* eventInfo)
-{
- Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
- EWK_VIEW_IMPL_GET_OR_RETURN(smartData, viewImpl);
- if (!eventInfo || !viewImpl->m_inputMethodContextFocused)
- return;
-
- viewImpl->pageProxy->confirmComposition(String::fromUTF8(static_cast<char*>(eventInfo)));
-}
-
-void EwkViewImpl::onIMFPreeditSequenceChanged(void* data, Ecore_IMF_Context* context, void*)
-{
- Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
- EWK_VIEW_IMPL_GET_OR_RETURN(smartData, viewImpl);
-
- if (!viewImpl->pageProxy->focusedFrame() || !viewImpl->m_inputMethodContextFocused)
- return;
-
- char* buffer = 0;
- ecore_imf_context_preedit_string_get(context, &buffer, 0);
- if (!buffer)
- return;
-
- String preeditString = String::fromUTF8(buffer);
- free(buffer);
- Vector<CompositionUnderline> underlines;
- underlines.append(CompositionUnderline(0, preeditString.length(), Color(0, 0, 0), false));
- viewImpl->pageProxy->setComposition(preeditString, underlines, 0);
-}
-
-PassOwnPtr<Ecore_IMF_Context> EwkViewImpl::createIMFContext(Ewk_View_Smart_Data* sd)
-{
- const char* defaultContextID = ecore_imf_context_default_id_get();
- if (!defaultContextID)
- return nullptr;
-
- OwnPtr<Ecore_IMF_Context> imfContext = adoptPtr(ecore_imf_context_add(defaultContextID));
- if (!imfContext)
- return nullptr;
-
- ecore_imf_context_event_callback_add(imfContext.get(), ECORE_IMF_CALLBACK_PREEDIT_CHANGED, onIMFPreeditSequenceChanged, sd);
- ecore_imf_context_event_callback_add(imfContext.get(), ECORE_IMF_CALLBACK_COMMIT, onIMFInputSequenceComplete, sd);
-
- Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(sd->base.evas);
- ecore_imf_context_client_window_set(imfContext.get(), reinterpret_cast<void*>(ecore_evas_window_get(ecoreEvas)));
- ecore_imf_context_client_canvas_set(imfContext.get(), sd->base.evas);
-
- return imfContext.release();
-}
-
EwkViewImpl::EwkViewImpl(Evas_Object* view)
#if USE(ACCELERATED_COMPOSITING)
: evasGl(0)
@@ -140,13 +89,12 @@
: m_view(view)
#endif
, m_settings(Ewk_Settings::create(this))
- , m_inputMethodContext(createIMFContext(smartData()))
- , m_inputMethodContextFocused(false)
, m_mouseEventsEnabled(false)
#if ENABLE(TOUCH_EVENTS)
, m_touchEventsEnabled(false)
#endif
, m_displayTimer(this, &EwkViewImpl::displayTimerFired)
+ , m_inputMethodContext(InputMethodContextEfl::create(this, smartData()->base.evas))
{
ASSERT(view);
@@ -593,7 +541,11 @@
return m_title;
}
-Ecore_IMF_Context* EwkViewImpl::inputMethodContext()
+/**
+ * @internal
+ * This function may return @c NULL.
+ */
+InputMethodContextEfl* EwkViewImpl::inputMethodContext()
{
return m_inputMethodContext.get();
}
@@ -969,37 +921,6 @@
/**
* @internal
- * The view was requested to update text input state
- */
-void EwkViewImpl::updateTextInputState()
-{
- if (!m_inputMethodContext)
- return;
-
- const EditorState& editor = pageProxy->editorState();
-
- if (editor.isContentEditable) {
- if (m_inputMethodContextFocused)
- return;
-
- ecore_imf_context_reset(m_inputMethodContext.get());
- ecore_imf_context_focus_in(m_inputMethodContext.get());
- m_inputMethodContextFocused = true;
- } else {
- if (!m_inputMethodContextFocused)
- return;
-
- if (editor.hasComposition)
- pageProxy->cancelComposition();
-
- m_inputMethodContextFocused = false;
- ecore_imf_context_reset(m_inputMethodContext.get());
- ecore_imf_context_focus_out(m_inputMethodContext.get());
- }
-}
-
-/**
- * @internal
* The url of view was changed by the frame loader.
*
* Emits signal: "url,changed" with pointer to new url string.
Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h (132593 => 132594)
--- trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h 2012-10-26 09:39:21 UTC (rev 132593)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h 2012-10-26 09:40:21 UTC (rev 132594)
@@ -24,8 +24,6 @@
#include "RefPtrEfl.h"
#include "WKEinaSharedString.h"
#include "WKRetainPtr.h"
-#include <Ecore_IMF.h>
-#include <Ecore_IMF_Evas.h>
#include <Evas.h>
#include <WebCore/TextDirection.h>
#include <WebCore/Timer.h>
@@ -63,6 +61,7 @@
namespace WebKit {
class FindClientEfl;
class FormClientEfl;
+class InputMethodContextEfl;
class PageClientImpl;
class PageLoadClientEfl;
class PagePolicyClientEfl;
@@ -118,7 +117,7 @@
const char* url() const { return m_url; }
const char* faviconURL() const { return m_faviconURL; }
const char* title() const;
- Ecore_IMF_Context* inputMethodContext();
+ WebKit::InputMethodContextEfl* inputMethodContext();
const char* themePath() const;
void setThemePath(const char* theme);
@@ -241,10 +240,6 @@
inline Ewk_View_Smart_Data* smartData();
void displayTimerFired(WebCore::Timer<EwkViewImpl>*);
- static PassOwnPtr<Ecore_IMF_Context> createIMFContext(Ewk_View_Smart_Data*);
- static void onIMFInputSequenceComplete(void* data, Ecore_IMF_Context*, void* eventInfo);
- static void onIMFPreeditSequenceChanged(void* data, Ecore_IMF_Context*, void* eventInfo);
-
static void onMouseDown(void* data, Evas*, Evas_Object*, void* eventInfo);
static void onMouseUp(void* data, Evas*, Evas_Object*, void* eventInfo);
static void onMouseMove(void* data, Evas*, Evas_Object*, void* eventInfo);
@@ -257,8 +252,6 @@
Evas_Object* m_view;
OwnPtr<Ewk_Settings> m_settings;
- OwnPtr<Ecore_IMF_Context> m_inputMethodContext;
- bool m_inputMethodContextFocused;
RefPtr<Evas_Object> m_cursorObject;
WKEinaSharedString m_cursorGroup;
WKEinaSharedString m_faviconURL;
@@ -274,6 +267,7 @@
WebCore::Timer<EwkViewImpl> m_displayTimer;
WTF::Vector <WebCore::IntRect> m_dirtyRects;
OwnPtr<Ewk_Popup_Menu> m_popupMenu;
+ OwnPtr<WebKit::InputMethodContextEfl> m_inputMethodContext;
typedef HashMap<WKPageRef, const Evas_Object*> PageViewMap;
static PageViewMap pageViewMap;
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp (132593 => 132594)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp 2012-10-26 09:39:21 UTC (rev 132593)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp 2012-10-26 09:40:21 UTC (rev 132594)
@@ -24,6 +24,7 @@
#include "EwkViewImpl.h"
#include "FindClientEfl.h"
#include "FormClientEfl.h"
+#include "InputMethodContextEfl.h"
#include "NativeWebKeyboardEvent.h"
#include "NativeWebMouseEvent.h"
#include "NativeWebWheelEvent.h"
@@ -213,9 +214,9 @@
impl->pageProxy->handleMouseEvent(NativeWebMouseEvent(upEvent, &position));
#endif
- Ecore_IMF_Context* inputMethodContext = impl->inputMethodContext();
+ InputMethodContextEfl* inputMethodContext = impl->inputMethodContext();
if (inputMethodContext)
- ecore_imf_context_reset(inputMethodContext);
+ inputMethodContext->handleMouseUpEvent(upEvent);
return true;
}
@@ -240,14 +241,10 @@
EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
bool isFiltered = false;
- Ecore_IMF_Context* inputMethodContext = impl->inputMethodContext();
- if (inputMethodContext) {
- Ecore_IMF_Event inputMethodEvent;
- ecore_imf_evas_event_key_down_wrap(const_cast<Evas_Event_Key_Down*>(downEvent), &inputMethodEvent.key_down);
+ InputMethodContextEfl* inputMethodContext = impl->inputMethodContext();
+ if (inputMethodContext)
+ inputMethodContext->handleKeyDownEvent(downEvent, &isFiltered);
- isFiltered = ecore_imf_context_filter_event(inputMethodContext, ECORE_IMF_EVENT_KEY_DOWN, &inputMethodEvent);
- }
-
impl->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, isFiltered));
return true;
}
Added: trunk/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp (0 => 132594)
--- trunk/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp 2012-10-26 09:40:21 UTC (rev 132594)
@@ -0,0 +1,132 @@
+/*
+ Copyright (C) 2011 Samsung Electronics
+ Copyright (C) 2012 Intel Corporation. All rights reserved.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "InputMethodContextEfl.h"
+
+#include "EwkViewImpl.h"
+#include "WebPageProxy.h"
+#include <Ecore_Evas.h>
+#include <Ecore_IMF_Evas.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+InputMethodContextEfl::InputMethodContextEfl(EwkViewImpl* viewImpl, PassOwnPtr<Ecore_IMF_Context> context)
+ : m_viewImpl(viewImpl)
+ , m_context(context)
+ , m_focused(false)
+{
+ ASSERT(context);
+ ecore_imf_context_event_callback_add(m_context.get(), ECORE_IMF_CALLBACK_PREEDIT_CHANGED, onIMFPreeditSequenceChanged, this);
+ ecore_imf_context_event_callback_add(m_context.get(), ECORE_IMF_CALLBACK_COMMIT, onIMFInputSequenceComplete, this);
+}
+
+InputMethodContextEfl::~InputMethodContextEfl()
+{
+}
+
+void InputMethodContextEfl::onIMFInputSequenceComplete(void* data, Ecore_IMF_Context*, void* eventInfo)
+{
+ InputMethodContextEfl* inputMethodContext = static_cast<InputMethodContextEfl*>(data);
+ if (!eventInfo || !inputMethodContext->m_focused)
+ return;
+
+ inputMethodContext->m_viewImpl->page()->confirmComposition(String::fromUTF8(static_cast<char*>(eventInfo)));
+}
+
+void InputMethodContextEfl::onIMFPreeditSequenceChanged(void* data, Ecore_IMF_Context* context, void*)
+{
+ InputMethodContextEfl* inputMethodContext = static_cast<InputMethodContextEfl*>(data);
+
+ if (!inputMethodContext->m_viewImpl->page()->focusedFrame() || !inputMethodContext->m_focused)
+ return;
+
+ char* buffer = 0;
+ ecore_imf_context_preedit_string_get(context, &buffer, 0);
+ if (!buffer)
+ return;
+
+ String preeditString = String::fromUTF8(buffer);
+ free(buffer);
+ Vector<CompositionUnderline> underlines;
+ underlines.append(CompositionUnderline(0, preeditString.length(), Color(0, 0, 0), false));
+ inputMethodContext->m_viewImpl->page()->setComposition(preeditString, underlines, 0);
+}
+
+PassOwnPtr<Ecore_IMF_Context> InputMethodContextEfl::createIMFContext(Evas* canvas)
+{
+ const char* defaultContextID = ecore_imf_context_default_id_get();
+ if (!defaultContextID)
+ return nullptr;
+
+ OwnPtr<Ecore_IMF_Context> imfContext = adoptPtr(ecore_imf_context_add(defaultContextID));
+ if (!imfContext)
+ return nullptr;
+
+ Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(canvas);
+ ecore_imf_context_client_window_set(imfContext.get(), reinterpret_cast<void*>(ecore_evas_window_get(ecoreEvas)));
+ ecore_imf_context_client_canvas_set(imfContext.get(), canvas);
+
+ return imfContext.release();
+}
+
+void InputMethodContextEfl::handleMouseUpEvent(const Evas_Event_Mouse_Up*)
+{
+ ecore_imf_context_reset(m_context.get());
+}
+
+void InputMethodContextEfl::handleKeyDownEvent(const Evas_Event_Key_Down* downEvent, bool* isFiltered)
+{
+ Ecore_IMF_Event inputMethodEvent;
+ ecore_imf_evas_event_key_down_wrap(const_cast<Evas_Event_Key_Down*>(downEvent), &inputMethodEvent.key_down);
+
+ *isFiltered = ecore_imf_context_filter_event(m_context.get(), ECORE_IMF_EVENT_KEY_DOWN, &inputMethodEvent);
+}
+
+void InputMethodContextEfl::updateTextInputState()
+{
+ if (!m_context)
+ return;
+
+ const EditorState& editor = m_viewImpl->page()->editorState();
+
+ if (editor.isContentEditable) {
+ if (m_focused)
+ return;
+
+ ecore_imf_context_reset(m_context.get());
+ ecore_imf_context_focus_in(m_context.get());
+ m_focused = true;
+ } else {
+ if (!m_focused)
+ return;
+
+ if (editor.hasComposition)
+ m_viewImpl->page()->cancelComposition();
+
+ m_focused = false;
+ ecore_imf_context_reset(m_context.get());
+ ecore_imf_context_focus_out(m_context.get());
+ }
+}
+
+}
Added: trunk/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h (0 => 132594)
--- trunk/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h 2012-10-26 09:40:21 UTC (rev 132594)
@@ -0,0 +1,65 @@
+/*
+ Copyright (C) 2011 Samsung Electronics
+ Copyright (C) 2012 Intel Corporation. All rights reserved.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef InputMethodContextEfl_h
+#define InputMethodContextEfl_h
+
+#include <Ecore_IMF.h>
+#include <Evas.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+class EwkViewImpl;
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class InputMethodContextEfl {
+public:
+ static PassOwnPtr<InputMethodContextEfl> create(EwkViewImpl* viewImpl, Evas* canvas)
+ {
+ OwnPtr<Ecore_IMF_Context> context = createIMFContext(canvas);
+ if (!context)
+ return nullptr;
+
+ return adoptPtr(new InputMethodContextEfl(viewImpl, context.release()));
+ }
+ ~InputMethodContextEfl();
+
+ void handleMouseUpEvent(const Evas_Event_Mouse_Up* upEvent);
+ void handleKeyDownEvent(const Evas_Event_Key_Down* downEvent, bool* isFiltered);
+ void updateTextInputState();
+
+private:
+ InputMethodContextEfl(EwkViewImpl*, PassOwnPtr<Ecore_IMF_Context>);
+
+ static PassOwnPtr<Ecore_IMF_Context> createIMFContext(Evas* canvas);
+ static void onIMFInputSequenceComplete(void* data, Ecore_IMF_Context*, void* eventInfo);
+ static void onIMFPreeditSequenceChanged(void* data, Ecore_IMF_Context*, void* eventInfo);
+
+ EwkViewImpl* m_viewImpl;
+ OwnPtr<Ecore_IMF_Context> m_context;
+ bool m_focused;
+};
+
+} // namespace WebKit
+
+#endif // InputMethodContextEfl_h
Modified: trunk/Source/WebKit2/UIProcess/efl/PageClientImpl.cpp (132593 => 132594)
--- trunk/Source/WebKit2/UIProcess/efl/PageClientImpl.cpp 2012-10-26 09:39:21 UTC (rev 132593)
+++ trunk/Source/WebKit2/UIProcess/efl/PageClientImpl.cpp 2012-10-26 09:40:21 UTC (rev 132594)
@@ -28,6 +28,7 @@
#include "DrawingAreaProxyImpl.h"
#include "EwkViewImpl.h"
+#include "InputMethodContextEfl.h"
#include "NativeWebKeyboardEvent.h"
#include "NotImplemented.h"
#include "WebContext.h"
@@ -298,7 +299,9 @@
void PageClientImpl::updateTextInputState()
{
- m_viewImpl->updateTextInputState();
+ InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
+ if (inputMethodContext)
+ inputMethodContext->updateTextInputState();
}
void PageClientImpl::handleDownloadRequest(DownloadProxy* download)