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

Unified Diff: components/test_runner/web_widget_test_client.cc

Issue 2333813002: Introduce WebInputMethodController to blink (Closed)
Patch Set: Updated a comment Created 4 years, 3 months 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: components/test_runner/web_widget_test_client.cc
diff --git a/components/test_runner/web_widget_test_client.cc b/components/test_runner/web_widget_test_client.cc
index baaaece8274e55321744f9a0c54c827ef09fee2f..8705a5cb5a02bd3af08e4869181ade415bb6861c 100644
--- a/components/test_runner/web_widget_test_client.cc
+++ b/components/test_runner/web_widget_test_client.cc
@@ -16,7 +16,11 @@
#include "components/test_runner/web_view_test_proxy.h"
#include "components/test_runner/web_widget_test_proxy.h"
#include "third_party/WebKit/public/platform/WebScreenInfo.h"
+#include "third_party/WebKit/public/web/WebFrameWidget.h"
+#include "third_party/WebKit/public/web/WebInputMethodController.h"
+#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebPagePopup.h"
+#include "third_party/WebKit/public/web/WebView.h"
#include "third_party/WebKit/public/web/WebWidget.h"
namespace test_runner {
@@ -100,11 +104,23 @@ void WebWidgetTestClient::setToolTipText(const blink::WebString& text,
}
void WebWidgetTestClient::resetInputMethod() {
- // If a composition text exists, then we need to let the browser process
- // to cancel the input method's ongoing composition session.
- if (web_widget_test_proxy_base_)
- web_widget_test_proxy_base_->web_widget()->finishComposingText(
- blink::WebWidget::KeepSelection);
+ // We should finish any ongoing composition.
+ blink::WebFrameWidget* frame_widget = nullptr;
+ if (web_widget_test_proxy_base_ &&
+ web_widget_test_proxy_base_->web_widget()->isWebFrameWidget()) {
+ frame_widget = static_cast<blink::WebFrameWidget*>(
+ web_widget_test_proxy_base_->web_widget());
+ } else if (web_view_test_proxy_base_) {
+ blink::WebLocalFrame* main_frame =
+ web_view_test_proxy_base_->web_view()->mainFrame()->toWebLocalFrame();
+ DCHECK(main_frame);
+ frame_widget = main_frame->frameWidget();
+ }
+
+ if (frame_widget && frame_widget->getActiveWebInputMethodController()) {
+ frame_widget->getActiveWebInputMethodController()->finishComposingText(
+ blink::WebInputMethodController::DoNotKeepSelection);
+ }
}
} // namespace test_runner

Powered by Google App Engine
This is Rietveld 408576698