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

Unified Diff: components/html_viewer/ime_controller.cc

Issue 1677293002: Bye bye Mandoline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moar Created 4 years, 10 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
« no previous file with comments | « components/html_viewer/ime_controller.h ('k') | components/html_viewer/input_events_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/html_viewer/ime_controller.cc
diff --git a/components/html_viewer/ime_controller.cc b/components/html_viewer/ime_controller.cc
deleted file mode 100644
index d438284daa1c64f5354ff7c342b4ea9bc6e46798..0000000000000000000000000000000000000000
--- a/components/html_viewer/ime_controller.cc
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/html_viewer/ime_controller.h"
-
-#include <utility>
-
-#include "components/html_viewer/blink_text_input_type_converters.h"
-#include "components/mus/public/cpp/window.h"
-#include "mojo/converters/blink/blink_input_events_type_converters.h"
-#include "third_party/WebKit/public/web/WebInputEvent.h"
-#include "third_party/WebKit/public/web/WebWidget.h"
-
-namespace html_viewer {
-
-ImeController::ImeController(mus::Window* window, blink::WebWidget* widget)
- : window_(window), widget_(widget) {}
-
-ImeController::~ImeController() {}
-
-void ImeController::ResetInputMethod() {
- // TODO(penghuang): Reset IME.
-}
-
-void ImeController::DidHandleGestureEvent(const blink::WebGestureEvent& event,
- bool event_cancelled) {
- // Called when a gesture event is handled.
- if (event_cancelled)
- return;
-
- if (event.type == blink::WebInputEvent::GestureTap) {
- const bool show_ime = true;
- UpdateTextInputState(show_ime);
- } else if (event.type == blink::WebInputEvent::GestureLongPress) {
- // Only show IME if the textfield contains text.
- const bool show_ime = !widget_->textInputInfo().value.isEmpty();
- UpdateTextInputState(show_ime);
- }
-}
-
-void ImeController::DidUpdateTextOfFocusedElementByNonUserInput() {
- // Called when value of focused textfield gets dirty, e.g. value is
- // modified by script, not by user input.
- const bool show_ime = false;
- UpdateTextInputState(show_ime);
-}
-
-void ImeController::ShowImeIfNeeded() {
- // Request the browser to show the IME for current input type.
- const bool show_ime = true;
- UpdateTextInputState(show_ime);
-}
-
-void ImeController::UpdateTextInputState(bool show_ime) {
- blink::WebTextInputInfo new_info = widget_->textInputInfo();
- // Only show IME if the focused element is editable.
- show_ime = show_ime && new_info.type != blink::WebTextInputTypeNone;
- if (show_ime || text_input_info_ != new_info) {
- text_input_info_ = new_info;
- mojo::TextInputStatePtr state = mojo::TextInputState::New();
- state->type = mojo::ConvertTo<mojo::TextInputType>(new_info.type);
- state->flags = new_info.flags;
- state->text = mojo::String::From(new_info.value.utf8());
- state->selection_start = new_info.selectionStart;
- state->selection_end = new_info.selectionEnd;
- state->composition_start = new_info.compositionStart;
- state->composition_end = new_info.compositionEnd;
- if (show_ime)
- window_->SetImeVisibility(true, std::move(state));
- else
- window_->SetTextInputState(std::move(state));
- }
-}
-
-} // namespace html_viewer
« no previous file with comments | « components/html_viewer/ime_controller.h ('k') | components/html_viewer/input_events_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698