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

Side by Side Diff: ui/views/widget/native_widget_aura.cc

Issue 1155013005: Refactoring the ownership of ui::InputMethod. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased. Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/native_widget_aura.h" 5 #include "ui/views/widget/native_widget_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "third_party/skia/include/core/SkRegion.h" 9 #include "third_party/skia/include/core/SkRegion.h"
10 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
11 #include "ui/aura/client/cursor_client.h" 11 #include "ui/aura/client/cursor_client.h"
12 #include "ui/aura/client/focus_client.h" 12 #include "ui/aura/client/focus_client.h"
13 #include "ui/aura/client/screen_position_client.h" 13 #include "ui/aura/client/screen_position_client.h"
14 #include "ui/aura/client/window_tree_client.h" 14 #include "ui/aura/client/window_tree_client.h"
15 #include "ui/aura/env.h" 15 #include "ui/aura/env.h"
16 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
17 #include "ui/aura/window_event_dispatcher.h" 17 #include "ui/aura/window_event_dispatcher.h"
18 #include "ui/aura/window_observer.h" 18 #include "ui/aura/window_observer.h"
19 #include "ui/aura/window_tree_host.h"
19 #include "ui/base/dragdrop/os_exchange_data.h" 20 #include "ui/base/dragdrop/os_exchange_data.h"
20 #include "ui/base/ui_base_switches_util.h" 21 #include "ui/base/ui_base_switches_util.h"
21 #include "ui/base/ui_base_types.h" 22 #include "ui/base/ui_base_types.h"
22 #include "ui/compositor/layer.h" 23 #include "ui/compositor/layer.h"
23 #include "ui/events/event.h" 24 #include "ui/events/event.h"
24 #include "ui/gfx/canvas.h" 25 #include "ui/gfx/canvas.h"
25 #include "ui/gfx/font_list.h" 26 #include "ui/gfx/font_list.h"
26 #include "ui/gfx/screen.h" 27 #include "ui/gfx/screen.h"
27 #include "ui/native_theme/native_theme_aura.h" 28 #include "ui/native_theme/native_theme_aura.h"
28 #include "ui/views/drag_utils.h" 29 #include "ui/views/drag_utils.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 269 }
269 270
270 InputMethod* NativeWidgetAura::CreateInputMethod() { 271 InputMethod* NativeWidgetAura::CreateInputMethod() {
271 if (!window_) 272 if (!window_)
272 return NULL; 273 return NULL;
273 274
274 if (switches::IsTextInputFocusManagerEnabled()) 275 if (switches::IsTextInputFocusManagerEnabled())
275 return new NullInputMethod(); 276 return new NullInputMethod();
276 277
277 aura::Window* root_window = window_->GetRootWindow(); 278 aura::Window* root_window = window_->GetRootWindow();
278 ui::InputMethod* host = 279 ui::InputMethod* host = root_window->GetHost()->GetInputMethod();
James Su 2015/06/02 07:05:27 You can just call GetHostInputMethod() here.
Shu Chen 2015/06/02 07:20:21 Done.
279 root_window->GetProperty(aura::client::kRootWindowInputMethodKey);
280 return new InputMethodBridge(this, host, true); 280 return new InputMethodBridge(this, host, true);
281 } 281 }
282 282
283 internal::InputMethodDelegate* NativeWidgetAura::GetInputMethodDelegate() { 283 internal::InputMethodDelegate* NativeWidgetAura::GetInputMethodDelegate() {
284 return this; 284 return this;
285 } 285 }
286 286
287 ui::InputMethod* NativeWidgetAura::GetHostInputMethod() { 287 ui::InputMethod* NativeWidgetAura::GetHostInputMethod() {
288 aura::Window* root_window = window_->GetRootWindow(); 288 aura::Window* root_window = window_->GetRootWindow();
289 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey); 289 return root_window->GetHost()->GetInputMethod();
290 } 290 }
291 291
292 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { 292 void NativeWidgetAura::CenterWindow(const gfx::Size& size) {
293 if (!window_) 293 if (!window_)
294 return; 294 return;
295 295
296 gfx::Rect parent_bounds(window_->parent()->GetBoundsInRootWindow()); 296 gfx::Rect parent_bounds(window_->parent()->GetBoundsInRootWindow());
297 // When centering window, we take the intersection of the host and 297 // When centering window, we take the intersection of the host and
298 // the parent. We assume the root window represents the visible 298 // the parent. We assume the root window represents the visible
299 // rect of a single screen. 299 // rect of a single screen.
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); 1205 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont));
1206 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); 1206 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont)));
1207 return gfx::FontList(gfx::Font(caption_font)); 1207 return gfx::FontList(gfx::Font(caption_font));
1208 #else 1208 #else
1209 return gfx::FontList(); 1209 return gfx::FontList();
1210 #endif 1210 #endif
1211 } 1211 }
1212 1212
1213 } // namespace internal 1213 } // namespace internal
1214 } // namespace views 1214 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698