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

Unified Diff: views/ime/mock_input_method.cc

Issue 8581003: views: Move ime and test directories to ui/views. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linux Created 9 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 | « views/ime/mock_input_method.h ('k') | views/ime/text_input_type_tracker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/ime/mock_input_method.cc
diff --git a/views/ime/mock_input_method.cc b/views/ime/mock_input_method.cc
deleted file mode 100644
index 5a227b7deb32574e151439e88cb61439c130aafc..0000000000000000000000000000000000000000
--- a/views/ime/mock_input_method.cc
+++ /dev/null
@@ -1,173 +0,0 @@
-// Copyright (c) 2011 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 "views/ime/mock_input_method.h"
-
-#include "base/basictypes.h"
-#include "base/logging.h"
-#include "ui/base/ime/text_input_client.h"
-#include "ui/base/keycodes/keyboard_codes.h"
-#include "views/events/event.h"
-#include "views/widget/widget.h"
-
-namespace views {
-
-MockInputMethod::MockInputMethod()
- : composition_changed_(false),
- focus_changed_(false),
- text_input_type_changed_(false),
- caret_bounds_changed_(false),
- cancel_composition_called_(false),
- locale_("en-US"),
- direction_(base::i18n::LEFT_TO_RIGHT),
- active_(true) {
-}
-
-MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate)
- : composition_changed_(false),
- focus_changed_(false),
- text_input_type_changed_(false),
- caret_bounds_changed_(false),
- cancel_composition_called_(false),
- locale_("en-US"),
- direction_(base::i18n::LEFT_TO_RIGHT),
- active_(true) {
- set_delegate(delegate);
-}
-
-MockInputMethod::~MockInputMethod() {
-}
-
-void MockInputMethod::Init(Widget* widget) {
- InputMethodBase::Init(widget);
-}
-
-void MockInputMethod::DispatchKeyEvent(const KeyEvent& key) {
- bool handled = (composition_changed_ || result_text_.length()) &&
- !IsTextInputTypeNone();
-
- ClearStates();
- if (handled) {
- KeyEvent mock_key(ui::ET_KEY_PRESSED, ui::VKEY_PROCESSKEY, key.flags());
- DispatchKeyEventPostIME(mock_key);
- } else {
- DispatchKeyEventPostIME(key);
- }
-
- if (focus_changed_)
- return;
-
- ui::TextInputClient* client = GetTextInputClient();
- if (client) {
- if (handled) {
- if (result_text_.length())
- client->InsertText(result_text_);
- if (composition_changed_) {
- if (composition_.text.length())
- client->SetCompositionText(composition_);
- else
- client->ClearCompositionText();
- }
- } else if (key.type() == ui::ET_KEY_PRESSED) {
- char16 ch = key.GetCharacter();
- client->InsertChar(ch, key.flags());
- }
- }
-
- ClearResult();
-}
-
-void MockInputMethod::OnTextInputTypeChanged(View* view) {
- if (IsViewFocused(view))
- text_input_type_changed_ = true;
- InputMethodBase::OnTextInputTypeChanged(view);
-}
-
-void MockInputMethod::OnCaretBoundsChanged(View* view) {
- if (IsViewFocused(view))
- caret_bounds_changed_ = true;
-}
-
-void MockInputMethod::CancelComposition(View* view) {
- if (IsViewFocused(view)) {
- cancel_composition_called_ = true;
- ClearResult();
- }
-}
-
-std::string MockInputMethod::GetInputLocale() {
- return locale_;
-}
-
-base::i18n::TextDirection MockInputMethod::GetInputTextDirection() {
- return direction_;
-}
-
-bool MockInputMethod::IsActive() {
- return active_;
-}
-
-bool MockInputMethod::IsMock() const {
- return true;
-}
-
-void MockInputMethod::OnWillChangeFocus(View* focused_before, View* focused) {
- ui::TextInputClient* client = GetTextInputClient();
- if (client && client->HasCompositionText())
- client->ConfirmCompositionText();
- focus_changed_ = true;
- ClearResult();
-}
-
-void MockInputMethod::Clear() {
- ClearStates();
- ClearResult();
-}
-
-void MockInputMethod::SetCompositionTextForNextKey(
- const ui::CompositionText& composition) {
- composition_changed_ = true;
- composition_ = composition;
-}
-
-void MockInputMethod::SetResultTextForNextKey(const string16& result) {
- result_text_ = result;
-}
-
-void MockInputMethod::SetInputLocale(const std::string& locale) {
- if (locale_ != locale) {
- locale_ = locale;
- OnInputMethodChanged();
- }
-}
-
-void MockInputMethod::SetInputTextDirection(
- base::i18n::TextDirection direction) {
- if (direction_ != direction) {
- direction_ = direction;
- OnInputMethodChanged();
- }
-}
-
-void MockInputMethod::SetActive(bool active) {
- if (active_ != active) {
- active_ = active;
- OnInputMethodChanged();
- }
-}
-
-void MockInputMethod::ClearStates() {
- focus_changed_ = false;
- text_input_type_changed_ = false;
- caret_bounds_changed_ = false;
- cancel_composition_called_ = false;
-}
-
-void MockInputMethod::ClearResult() {
- composition_.Clear();
- composition_changed_ = false;
- result_text_.clear();
-}
-
-} // namespace views
« no previous file with comments | « views/ime/mock_input_method.h ('k') | views/ime/text_input_type_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698