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

Unified Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 2333813002: Introduce WebInputMethodController to blink (Closed)
Patch Set: Rebased Created 4 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/WebViewImpl.cpp
diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp
index cc73c649ca8ff43c1a961b24f0da4627e8df0707..c87d7c93c174b716261d2f1ea201d72275d43f3f 100644
--- a/third_party/WebKit/Source/web/WebViewImpl.cpp
+++ b/third_party/WebKit/Source/web/WebViewImpl.cpp
@@ -173,6 +173,7 @@
#include "web/ValidationMessageClientImpl.h"
#include "web/WebDevToolsAgentImpl.h"
#include "web/WebInputEventConversion.h"
+#include "web/WebInputMethodControllerImpl.h"
#include "web/WebLocalFrameImpl.h"
#include "web/WebPagePopupImpl.h"
#include "web/WebPluginContainerImpl.h"
@@ -2341,100 +2342,6 @@ void WebViewImpl::setFocus(bool enable) {
// TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as
// well. This code needs to be refactored (http://crbug.com/629721).
-bool WebViewImpl::setComposition(
- const WebString& text,
- const WebVector<WebCompositionUnderline>& underlines,
- int selectionStart,
- int selectionEnd) {
- LocalFrame* focused = focusedLocalFrameAvailableForIme();
- if (!focused)
- return false;
-
- if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused))
- 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.
- InputMethodController& inputMethodController =
- focused->inputMethodController();
- if (!focused->editor().canEdit() && !inputMethodController.hasComposition())
- return false;
-
- // We should verify the parent node of this IME composition node are
- // editable because JavaScript may delete a parent node of the composition
- // node. In this case, WebKit crashes while deleting texts from the parent
- // node, which doesn't exist any longer.
- const EphemeralRange range =
- inputMethodController.compositionEphemeralRange();
- if (range.isNotNull()) {
- Node* node = range.startPosition().computeContainerNode();
- focused->document()->updateStyleAndLayoutTree();
- if (!node || !hasEditableStyle(*node))
- return false;
- }
-
- // A keypress event is canceled. If an ongoing composition exists, then the
- // keydown event should have arisen from a handled key (e.g., backspace).
- // In this case we ignore the cancellation and continue; otherwise (no
- // ongoing composition) we exit and signal success only for attempts to
- // clear the composition.
- if (m_suppressNextKeypressEvent && !inputMethodController.hasComposition())
- return text.isEmpty();
-
- UserGestureIndicator gestureIndicator(DocumentUserGestureToken::create(
- focused->document(), UserGestureToken::NewGesture));
-
- // When the range of composition underlines overlap with the range between
- // selectionStart and selectionEnd, WebKit somehow won't paint the selection
- // at all (see InlineTextBox::paint() function in InlineTextBox.cpp).
- // But the selection range actually takes effect.
- inputMethodController.setComposition(
- String(text), CompositionUnderlineVectorBuilder(underlines),
- selectionStart, selectionEnd);
-
- return text.isEmpty() || inputMethodController.hasComposition();
-}
-
-// TODO(ekaramad):These methods are almost duplicated in WebFrameWidgetImpl as
-// well. This code needs to be refactored (http://crbug.com/629721).
-bool WebViewImpl::finishComposingText(
- ConfirmCompositionBehavior selectionBehavior) {
- LocalFrame* focused = focusedLocalFrameAvailableForIme();
- if (!focused)
- return false;
-
- if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused))
- return plugin->finishComposingText(selectionBehavior);
-
- return focused->inputMethodController().finishComposingText(
- selectionBehavior == KeepSelection
- ? InputMethodController::KeepSelection
- : InputMethodController::DoNotKeepSelection);
-}
-
-bool WebViewImpl::commitText(const WebString& text, int relativeCaretPosition) {
- LocalFrame* focused = focusedLocalFrameAvailableForIme();
- if (!focused)
- return false;
-
- UserGestureIndicator gestureIndicator(DocumentUserGestureToken::create(
- focused->document(), UserGestureToken::NewGesture));
-
- if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused))
- return plugin->commitText(text, relativeCaretPosition);
-
- // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
- // needs to be audited. See http://crbug.com/590369 for more details.
- focused->document()->updateStyleAndLayoutIgnorePendingStylesheets();
-
- return focused->inputMethodController().commitText(text,
- relativeCaretPosition);
-}
-
-// TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as
-// well. This code needs to be refactored (http://crbug.com/629721).
WebRange WebViewImpl::compositionRange() {
LocalFrame* focused = focusedLocalFrameAvailableForIme();
if (!focused)
@@ -3835,6 +3742,12 @@ bool WebViewImpl::isTransparent() const {
return m_isTransparent;
}
+WebInputMethodControllerImpl* WebViewImpl::getActiveWebInputMethodController()
+ const {
+ return WebInputMethodControllerImpl::fromFrame(
+ focusedLocalFrameAvailableForIme());
+}
+
void WebViewImpl::setBaseBackgroundColor(WebColor color) {
if (m_baseBackgroundColor == color)
return;
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698