diff options
author | Shu Chen <shuchen@google.com> | 2016-01-22 08:40:15 +0800 |
---|---|---|
committer | Shu Chen <shuchen@google.com> | 2016-01-22 00:43:23 +0000 |
commit | a8e034d7e113cd2c245cd4e148ae4a7f82310074 (patch) | |
tree | 9af949371a62fa348e95b7349cce4a9751a2c3a2 /ui | |
parent | 7ea1943fbc1257675d7ff7db3a6522814a24cab8 (diff) | |
download | chromium_src-a8e034d7e113cd2c245cd4e148ae4a7f82310074.zip chromium_src-a8e034d7e113cd2c245cd4e148ae4a7f82310074.tar.gz chromium_src-a8e034d7e113cd2c245cd4e148ae4a7f82310074.tar.bz2 |
Revert "Makes sure the keyboard typing isn't blocked when InputMethod::OnFocus() is not correctly called."
This reverts commit 9c6a42893d80bb623934781221b364e27077cd2b.
Reason: Very high crash rate.
BUG=579910
Review URL: https://codereview.chromium.org/1617833003 .
Cr-Commit-Position: refs/branch-heads/2623@{#62}
Cr-Branched-From: 92d77538a86529ca35f9220bd3cd512cbea1f086-refs/heads/master@{#369907}
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/ime/BUILD.gn | 2 | ||||
-rw-r--r-- | ui/base/ime/input_method.h | 3 | ||||
-rw-r--r-- | ui/base/ime/input_method_auralinux.cc | 13 | ||||
-rw-r--r-- | ui/base/ime/input_method_base.cc | 14 | ||||
-rw-r--r-- | ui/base/ime/input_method_base.h | 4 | ||||
-rw-r--r-- | ui/base/ime/input_method_log_collector.cc | 56 | ||||
-rw-r--r-- | ui/base/ime/input_method_log_collector.h | 36 | ||||
-rw-r--r-- | ui/base/ime/input_method_win.cc | 17 | ||||
-rw-r--r-- | ui/base/ime/mock_input_method.cc | 5 | ||||
-rw-r--r-- | ui/base/ime/mock_input_method.h | 2 | ||||
-rw-r--r-- | ui/base/ime/remote_input_method_win.cc | 9 | ||||
-rw-r--r-- | ui/base/ime/ui_base_ime.gyp | 2 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_native_widget_aura.cc | 8 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc | 8 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_window_tree_host_win.h | 2 | ||||
-rw-r--r-- | ui/views/win/hwnd_message_handler.cc | 17 | ||||
-rw-r--r-- | ui/views/win/hwnd_message_handler_delegate.h | 3 |
17 files changed, 8 insertions, 193 deletions
diff --git a/ui/base/ime/BUILD.gn b/ui/base/ime/BUILD.gn index ea0a8ad..b915757 100644 --- a/ui/base/ime/BUILD.gn +++ b/ui/base/ime/BUILD.gn @@ -69,8 +69,6 @@ component("ime") { "input_method_factory.h", "input_method_initializer.cc", "input_method_initializer.h", - "input_method_log_collector.cc", - "input_method_log_collector.h", "input_method_mac.h", "input_method_mac.mm", "input_method_minimal.cc", diff --git a/ui/base/ime/input_method.h b/ui/base/ime/input_method.h index 77f5317..598fd4f 100644 --- a/ui/base/ime/input_method.h +++ b/ui/base/ime/input_method.h @@ -11,7 +11,6 @@ #include "base/event_types.h" #include "build/build_config.h" -#include "ui/base/ime/input_method_log_collector.h" #include "ui/base/ime/text_input_mode.h" #include "ui/base/ime/text_input_type.h" @@ -153,8 +152,6 @@ class InputMethod { // Management of the observer list. virtual void AddObserver(InputMethodObserver* observer) = 0; virtual void RemoveObserver(InputMethodObserver* observer) = 0; - - virtual InputMethodLogCollector* GetLogCollector() = 0; }; } // namespace ui diff --git a/ui/base/ime/input_method_auralinux.cc b/ui/base/ime/input_method_auralinux.cc index d6ceeaa..ca9931f 100644 --- a/ui/base/ime/input_method_auralinux.cc +++ b/ui/base/ime/input_method_auralinux.cc @@ -46,19 +46,6 @@ bool InputMethodAuraLinux::OnUntranslatedIMEMessage( void InputMethodAuraLinux::DispatchKeyEvent(ui::KeyEvent* event) { DCHECK(event->type() == ET_KEY_PRESSED || event->type() == ET_KEY_RELEASED); DCHECK(system_toplevel_window_focused()); - if (!system_toplevel_window_focused()) { - GetLogCollector()->AddString( - "Unexpected DispatchKeyEvent: InputMethod is not active."); - GetLogCollector()->DumpLogs(); - // There are random issues that the keyboard typing doesn't work. - // The root cause might be the InputMethod::OnFocus() is not correctly - // called when the top-level window is activated - // (in DNWA::HandleActivationChanged). - // Calls OnFocus here to unblock the keyboard typing. - OnFocus(); - } else { - GetLogCollector()->ClearLogs(); - } // If no text input client, do nothing. if (!GetTextInputClient()) { diff --git a/ui/base/ime/input_method_base.cc b/ui/base/ime/input_method_base.cc index 9702454..3441f928 100644 --- a/ui/base/ime/input_method_base.cc +++ b/ui/base/ime/input_method_base.cc @@ -15,10 +15,10 @@ namespace ui { InputMethodBase::InputMethodBase() - : delegate_(NULL), - text_input_client_(NULL), - system_toplevel_window_focused_(false), - log_collector_(new InputMethodLogCollector()) {} + : delegate_(NULL), + text_input_client_(NULL), + system_toplevel_window_focused_(false) { +} InputMethodBase::~InputMethodBase() { FOR_EACH_OBSERVER(InputMethodObserver, @@ -36,8 +36,6 @@ void InputMethodBase::OnFocus() { void InputMethodBase::OnBlur() { system_toplevel_window_focused_ = false; - log_collector_->ClearLogs(); - log_collector_->AddString("Input method is blurred."); } void InputMethodBase::SetFocusedTextInputClient(TextInputClient* client) { @@ -92,10 +90,6 @@ void InputMethodBase::RemoveObserver(InputMethodObserver* observer) { observer_list_.RemoveObserver(observer); } -InputMethodLogCollector* InputMethodBase::GetLogCollector() { - return log_collector_.get(); -} - bool InputMethodBase::IsTextInputClientFocused(const TextInputClient* client) { return client && (client == GetTextInputClient()); } diff --git a/ui/base/ime/input_method_base.h b/ui/base/ime/input_method_base.h index dfa0b20..e9efb3a 100644 --- a/ui/base/ime/input_method_base.h +++ b/ui/base/ime/input_method_base.h @@ -56,8 +56,6 @@ class UI_BASE_IME_EXPORT InputMethodBase void AddObserver(InputMethodObserver* observer) override; void RemoveObserver(InputMethodObserver* observer) override; - InputMethodLogCollector* GetLogCollector() override; - protected: virtual void OnWillChangeFocusedClient(TextInputClient* focused_before, TextInputClient* focused) {} @@ -103,8 +101,6 @@ class UI_BASE_IME_EXPORT InputMethodBase bool system_toplevel_window_focused_; - scoped_ptr<InputMethodLogCollector> log_collector_; - DISALLOW_COPY_AND_ASSIGN(InputMethodBase); }; diff --git a/ui/base/ime/input_method_log_collector.cc b/ui/base/ime/input_method_log_collector.cc deleted file mode 100644 index daa3396..0000000 --- a/ui/base/ime/input_method_log_collector.cc +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2016 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 "ui/base/ime/input_method_log_collector.h" - -#include <string.h> - -#include "base/debug/alias.h" -#include "base/debug/dump_without_crashing.h" -#include "base/macros.h" - -namespace { - -const size_t kMaxLogCount = 50; - -} - -namespace ui { - -InputMethodLogCollector::InputMethodLogCollector() {} - -InputMethodLogCollector::~InputMethodLogCollector() {} - -void InputMethodLogCollector::AddString(const char* str_val) { - if (logs_.size() >= kMaxLogCount) - logs_.erase(logs_.begin()); - logs_.push_back(str_val); -} - -void InputMethodLogCollector::AddBoolean(bool bool_val) { - AddString(bool_val ? "true" : "false"); -} - -void InputMethodLogCollector::DumpLogs() { - static int dump_times = 0; - if (dump_times > 5) { - ClearLogs(); - return; - } - const char* logs_copy[kMaxLogCount]; - size_t log_count = logs_.size(); - for (size_t i = 0; i < log_count && i < arraysize(logs_copy); ++i) - logs_copy[i] = logs_[i]; - base::debug::Alias(&log_count); - base::debug::Alias(&logs_copy); - base::debug::DumpWithoutCrashing(); - dump_times++; - ClearLogs(); -} - -void InputMethodLogCollector::ClearLogs() { - logs_.clear(); -} - -} // namespace ui diff --git a/ui/base/ime/input_method_log_collector.h b/ui/base/ime/input_method_log_collector.h deleted file mode 100644 index bdc8b4d..0000000 --- a/ui/base/ime/input_method_log_collector.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2016 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. - -#ifndef UI_BASE_IME_INPUT_METHOD_LOG_COLLECTOR_H_ -#define UI_BASE_IME_INPUT_METHOD_LOG_COLLECTOR_H_ - -#include <string> -#include <vector> - -#include "base/macros.h" -#include "ui/base/ime/ui_base_ime_export.h" - -namespace ui { - -// The class to gather some logs and dump it through -// base::debug::DumpWithoutCrashing when InputMethod processing a key event. -// This is for tracing the issue that hardly repros: crbug.com/569339. -class UI_BASE_IME_EXPORT InputMethodLogCollector { - public: - InputMethodLogCollector(); - ~InputMethodLogCollector(); - void AddString(const char* str_val); - void AddBoolean(bool bool_val); - void DumpLogs(); - void ClearLogs(); - - private: - std::vector<const char*> logs_; - - DISALLOW_COPY_AND_ASSIGN(InputMethodLogCollector); -}; - -} // namespace ui - -#endif // UI_BASE_IME_INPUT_METHOD_LOG_COLLECTOR_H_ diff --git a/ui/base/ime/input_method_win.cc b/ui/base/ime/input_method_win.cc index a50d877..56bbac1 100644 --- a/ui/base/ime/input_method_win.cc +++ b/ui/base/ime/input_method_win.cc @@ -262,22 +262,6 @@ LRESULT InputMethodWin::OnChar(HWND window_handle, BOOL* handled) { *handled = TRUE; - if (!system_toplevel_window_focused()) { - GetLogCollector()->AddString( - "Unexpected OnChar: InputMethod is not active. Window focused: "); - GetLogCollector()->AddBoolean( - ::GetActiveWindow() == toplevel_window_handle_); - GetLogCollector()->DumpLogs(); - // There are random issues that the keyboard typing doesn't work. - // The root cause might be the InputMethod::OnFocus() is not correctly - // called when the top-level window is activated - // (in DNWA::HandleActivationChanged). - // Calls OnFocus here to unblock the keyboard typing. - OnFocus(); - } else { - GetLogCollector()->ClearLogs(); - } - // We need to send character events to the focused text input client event if // its text input type is ui::TEXT_INPUT_TYPE_NONE. if (GetTextInputClient()) { @@ -311,7 +295,6 @@ LRESULT InputMethodWin::OnImeSetContext(HWND window_handle, WPARAM wparam, LPARAM lparam, BOOL* handled) { - GetLogCollector()->AddString("WM_IME_SETCONTEXT"); if (!!wparam) { imm32_manager_.CreateImeWindow(window_handle); if (system_toplevel_window_focused()) { diff --git a/ui/base/ime/mock_input_method.cc b/ui/base/ime/mock_input_method.cc index e09e2a8..f2cf8eb 100644 --- a/ui/base/ime/mock_input_method.cc +++ b/ui/base/ime/mock_input_method.cc @@ -5,7 +5,6 @@ #include "ui/base/ime/mock_input_method.h" #include "ui/base/ime/input_method_delegate.h" -#include "ui/base/ime/input_method_log_collector.h" #include "ui/events/event.h" namespace ui { @@ -117,8 +116,4 @@ void MockInputMethod::RemoveObserver(InputMethodObserver* observer) { observer_list_.RemoveObserver(observer); } -InputMethodLogCollector* MockInputMethod::GetLogCollector() { - return nullptr; -} - } // namespace ui diff --git a/ui/base/ime/mock_input_method.h b/ui/base/ime/mock_input_method.h index a6a68b4..96d2c47 100644 --- a/ui/base/ime/mock_input_method.h +++ b/ui/base/ime/mock_input_method.h @@ -16,7 +16,6 @@ namespace ui { -class InputMethodLogCollector; class KeyEvent; class TextInputClient; @@ -53,7 +52,6 @@ class UI_BASE_IME_EXPORT MockInputMethod void ShowImeIfNeeded() override; void AddObserver(InputMethodObserver* observer) override; void RemoveObserver(InputMethodObserver* observer) override; - InputMethodLogCollector* GetLogCollector() override; private: TextInputClient* text_input_client_; diff --git a/ui/base/ime/remote_input_method_win.cc b/ui/base/ime/remote_input_method_win.cc index 70c065f..27d242a 100644 --- a/ui/base/ime/remote_input_method_win.cc +++ b/ui/base/ime/remote_input_method_win.cc @@ -14,7 +14,6 @@ #include "base/win/scoped_handle.h" #include "ui/base/ime/input_method.h" #include "ui/base/ime/input_method_delegate.h" -#include "ui/base/ime/input_method_log_collector.h" #include "ui/base/ime/input_method_observer.h" #include "ui/base/ime/remote_input_method_delegate_win.h" #include "ui/base/ime/text_input_client.h" @@ -121,8 +120,7 @@ class RemoteInputMethodWin : public InputMethod, text_input_client_(NULL), is_candidate_popup_open_(false), is_ime_(false), - langid_(kFallbackLangID), - log_collector_(new InputMethodLogCollector()) { + langid_(kFallbackLangID) { RegisterInstance(this, this); } @@ -331,10 +329,6 @@ class RemoteInputMethodWin : public InputMethod, text_input_client_->InsertText(text); } - InputMethodLogCollector* GetLogCollector() override { - return log_collector_.get(); - } - bool CanSendRemoteNotification( const TextInputClient* text_input_client) const { return text_input_client_ && @@ -353,7 +347,6 @@ class RemoteInputMethodWin : public InputMethod, bool is_candidate_popup_open_; bool is_ime_; LANGID langid_; - scoped_ptr<InputMethodLogCollector> log_collector_; DISALLOW_COPY_AND_ASSIGN(RemoteInputMethodWin); }; diff --git a/ui/base/ime/ui_base_ime.gyp b/ui/base/ime/ui_base_ime.gyp index 47ffda9..22c3e72 100644 --- a/ui/base/ime/ui_base_ime.gyp +++ b/ui/base/ime/ui_base_ime.gyp @@ -91,8 +91,6 @@ 'input_method_factory.h', 'input_method_initializer.cc', 'input_method_initializer.h', - 'input_method_log_collector.cc', - 'input_method_log_collector.h', 'input_method_mac.h', 'input_method_mac.mm', 'input_method_minimal.cc', diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc index 1e4f71f..618d774 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc @@ -369,11 +369,8 @@ void DesktopNativeWidgetAura::HandleActivationChanged(bool active) { native_widget_delegate_->OnNativeWidgetActivationChanged(active); aura::client::ActivationClient* activation_client = aura::client::GetActivationClient(host_->window()); - if (!activation_client) { - GetInputMethod()->GetLogCollector()->AddString( - "Missing OnFocus call when activating due to no activation client."); + if (!activation_client) return; - } if (active) { if (GetWidget()->HasFocusManager()) { // This function can be called before the focus manager has had a @@ -390,9 +387,6 @@ void DesktopNativeWidgetAura::HandleActivationChanged(bool active) { // Refreshes the focus info to IMF in case that IMF cached the old info // about focused text input client when it was "inactive". GetInputMethod()->OnFocus(); - } else { - GetInputMethod()->GetLogCollector()->AddString( - "Missing OnFocus call when activating due to no focus manager."); } } else { // If we're not active we need to deactivate the corresponding diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc index 77fbb26d..c354154 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc @@ -916,14 +916,6 @@ void DesktopWindowTreeHostWin::HandleWindowSizeChanged() { compositor()->size()); } -void DesktopWindowTreeHostWin::AddStringLog(const char* log_string) { - GetInputMethod()->GetLogCollector()->AddString(log_string); -} - -void DesktopWindowTreeHostWin::AddBooleanLog(bool bool_val) { - GetInputMethod()->GetLogCollector()->AddBoolean(bool_val); -} - //////////////////////////////////////////////////////////////////////////////// // DesktopWindowTreeHostWin, private: diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h index cab1428..ad82485 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h @@ -193,8 +193,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin bool HandleScrollEvent(const ui::ScrollEvent& event) override; void HandleWindowSizeChanging() override; void HandleWindowSizeChanged() override; - void AddStringLog(const char* log_string) override; - void AddBooleanLog(bool bool_val) override; Widget* GetWidget(); const Widget* GetWidget() const; diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc index d5e972a..0cacffe 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc @@ -928,12 +928,8 @@ LRESULT HWNDMessageHandler::OnWndProc(UINT message, delegate_->HandleDestroyed(); } - if (message == WM_ACTIVATE) { - if (IsTopLevelWindow(window)) - PostProcessActivateMessage(LOWORD(w_param), !!HIWORD(w_param)); - else - delegate_->AddStringLog("WM_ACTIVATE on non-top-level window."); - } + if (message == WM_ACTIVATE && IsTopLevelWindow(window)) + PostProcessActivateMessage(LOWORD(w_param), !!HIWORD(w_param)); return result; } @@ -1037,8 +1033,6 @@ void HWNDMessageHandler::PostProcessActivateMessage(int activation_state, const bool active = activation_state != WA_INACTIVE && !minimized; if (delegate_->CanActivate()) delegate_->HandleActivationChanged(active); - else - delegate_->AddStringLog("Missing call to HandleActivationChanged."); } void HWNDMessageHandler::RestoreEnabledIfNecessary() { @@ -1237,8 +1231,6 @@ void HWNDMessageHandler::ForceRedrawWindow(int attempts) { // Message handlers ------------------------------------------------------------ void HWNDMessageHandler::OnActivateApp(BOOL active, DWORD thread_id) { - delegate_->AddStringLog("WM_ACTIVATEAPP: "); - delegate_->AddBooleanLog(active ? true : false); if (delegate_->IsWidgetWindow() && !active && thread_id != GetCurrentThreadId()) { delegate_->HandleAppDeactivated(); @@ -1494,8 +1486,6 @@ void HWNDMessageHandler::OnInputLangChange(DWORD character_set, LRESULT HWNDMessageHandler::OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param) { - if (message == WM_KEYDOWN || message == WM_SYSKEYDOWN) - delegate_->AddStringLog("WM_KEYDOWN || WM_SYSKEYDOWN"); MSG msg = { hwnd(), message, w_param, l_param, static_cast<DWORD>(GetMessageTime())}; ui::KeyEvent key(msg); @@ -1513,7 +1503,6 @@ void HWNDMessageHandler::OnKillFocus(HWND focused_window) { LRESULT HWNDMessageHandler::OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param) { - delegate_->AddStringLog("WM_MOUSEACTIVATE"); // Please refer to the comments in the header for the touch_down_contexts_ // member for the if statement below. if (touch_down_contexts_) @@ -1578,8 +1567,6 @@ void HWNDMessageHandler::OnMoving(UINT param, const RECT* new_bounds) { LRESULT HWNDMessageHandler::OnNCActivate(UINT message, WPARAM w_param, LPARAM l_param) { - delegate_->AddStringLog("WM_NCACTIVATE: "); - delegate_->AddBooleanLog(w_param ? true : false); // Per MSDN, w_param is either TRUE or FALSE. However, MSDN also hints that: // "If the window is minimized when this message is received, the application // should pass the message to the DefWindowProc function." diff --git a/ui/views/win/hwnd_message_handler_delegate.h b/ui/views/win/hwnd_message_handler_delegate.h index 174a7ca..55ac440 100644 --- a/ui/views/win/hwnd_message_handler_delegate.h +++ b/ui/views/win/hwnd_message_handler_delegate.h @@ -228,9 +228,6 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate { // Called when the window size has finished changing. virtual void HandleWindowSizeChanged() = 0; - virtual void AddStringLog(const char* log_string) = 0; - virtual void AddBooleanLog(bool bool_val) = 0; - protected: virtual ~HWNDMessageHandlerDelegate() {} }; |