Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1369)

Unified Diff: Source/web/WebViewImpl.cpp

Issue 102963005: Add supportsInputMethod() interface for WebPlugin. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: setComposition/confirmComposition Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/web/WebViewImpl.cpp
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
index b9914471a160362749da4e8daa39cfddf0c3d4f1..648b6e11af64ba55014c8c0b25f37c4add70c528 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -88,6 +88,7 @@
#include "core/events/WheelEvent.h"
#include "core/html/HTMLInputElement.h"
#include "core/html/HTMLMediaElement.h"
+#include "core/html/HTMLPlugInElement.h"
#include "core/html/HTMLTextAreaElement.h"
#include "core/html/HTMLVideoElement.h"
#include "core/html/ime/InputMethodContext.h"
@@ -2063,6 +2064,10 @@ bool WebViewImpl::setComposition(
if (!focused || !m_imeAcceptEvents)
return false;
+ WebPlugin* plugin = getFocusedPluginIfInputMethodSupported();
tkent 2013/12/10 07:22:57 nit: We can simplify the code like: if (WebPlugin
kochi 2013/12/10 08:20:56 Done.
+ if (plugin)
+ return plugin->setComposition(text, underlines, selectionStart, selectionEnd);
+
// The input focus has been moved to another WebWidget object.
// We should use this |editor| object only to complete the ongoing
// composition.
@@ -2125,6 +2130,11 @@ bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe
Frame* focused = focusedWebCoreFrame();
if (!focused || !m_imeAcceptEvents)
return false;
+
+ WebPlugin* plugin = getFocusedPluginIfInputMethodSupported();
+ if (plugin)
+ return plugin->confirmComposition(text, selectionBehavior);
+
return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : InputMethodController::DoNotKeepSelection);
}
@@ -2333,6 +2343,17 @@ InputMethodContext* WebViewImpl::inputMethodContext()
return 0;
}
+WebPlugin* WebViewImpl::getFocusedPluginIfInputMethodSupported()
tkent 2013/12/10 07:22:57 We usually prepend no 'get' to such function. Thi
kochi 2013/12/10 08:20:56 Removed 'get' prefix. I think I need to support P
+{
+ Element* element = focusedElement();
+ if (element && element->isPluginElement()) {
+ WebPluginContainerImpl* container = toPluginContainerImpl(toHTMLPlugInElement(element)->pluginWidget());
+ if (container && container->supportsInputMethod())
+ return container->plugin();
+ }
+ return 0;
+}
+
void WebViewImpl::didShowCandidateWindow()
{
if (InputMethodContext* context = inputMethodContext())

Powered by Google App Engine
This is Rietveld 408576698