Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/controls/native/native_view_host.h" | 5 #include "ui/views/controls/native/native_view_host.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/gfx/canvas.h" | 8 #include "ui/gfx/canvas.h" |
| 9 #include "ui/views/controls/native/native_view_host_wrapper.h" | 9 #include "ui/views/controls/native/native_view_host_wrapper.h" |
| 10 #include "ui/views/widget/widget.h" | 10 #include "ui/views/widget/widget.h" |
| 11 | 11 |
| 12 #if defined (OS_WIN) | |
| 13 #include "ui/base/win/dpi.h" | |
| 14 #endif | |
| 15 | |
| 12 namespace views { | 16 namespace views { |
| 13 | 17 |
| 14 // static | 18 // static |
| 15 const char NativeViewHost::kViewClassName[] = "NativeViewHost"; | 19 const char NativeViewHost::kViewClassName[] = "NativeViewHost"; |
| 16 | 20 |
| 17 #if defined(USE_AURA) | 21 #if defined(USE_AURA) |
| 18 // Views implmenetatxion draws the focus. | 22 // Views implementation draws the focus. |
| 19 // TODO(oshima): Eliminate this flag and consolidate | 23 // TODO(oshima): Eliminate this flag and consolidate |
| 20 // the focus border code. | 24 // the focus border code. |
| 21 const bool NativeViewHost::kRenderNativeControlFocus = false; | 25 const bool NativeViewHost::kRenderNativeControlFocus = false; |
| 22 #else | 26 #else |
| 23 // static | 27 // static |
| 24 const bool NativeViewHost::kRenderNativeControlFocus = true; | 28 const bool NativeViewHost::kRenderNativeControlFocus = true; |
| 25 #endif | 29 #endif |
| 26 | 30 |
| 27 //////////////////////////////////////////////////////////////////////////////// | 31 //////////////////////////////////////////////////////////////////////////////// |
| 28 // NativeViewHost, public: | 32 // NativeViewHost, public: |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 } | 97 } |
| 94 } | 98 } |
| 95 | 99 |
| 96 if (visible) { | 100 if (visible) { |
| 97 // Since widgets know nothing about the View hierarchy (they are direct | 101 // Since widgets know nothing about the View hierarchy (they are direct |
| 98 // children of the Widget that hosts our View hierarchy) they need to be | 102 // children of the Widget that hosts our View hierarchy) they need to be |
| 99 // positioned in the coordinate system of the Widget, not the current | 103 // positioned in the coordinate system of the Widget, not the current |
| 100 // view. Also, they should be positioned respecting the border insets | 104 // view. Also, they should be positioned respecting the border insets |
| 101 // of the native view. | 105 // of the native view. |
| 102 gfx::Rect local_bounds = ConvertRectToWidget(GetContentsBounds()); | 106 gfx::Rect local_bounds = ConvertRectToWidget(GetContentsBounds()); |
| 107 #if defined(OS_WIN) && !defined(USE_AURA) | |
|
Ben Goodger (Google)
2013/06/11 16:10:43
this file doesn't really have platform stuff in it
girard
2013/06/11 19:12:13
Done. Thanks.
| |
| 108 gfx::Rect mapped_bounds = ui::win::DIPToScreenRect(local_bounds); | |
| 109 native_wrapper_->ShowWidget(mapped_bounds.x(), mapped_bounds.y(), | |
| 110 mapped_bounds.width(), | |
| 111 mapped_bounds.height()); | |
| 112 #else | |
| 103 native_wrapper_->ShowWidget(local_bounds.x(), local_bounds.y(), | 113 native_wrapper_->ShowWidget(local_bounds.x(), local_bounds.y(), |
| 104 local_bounds.width(), | 114 local_bounds.width(), |
| 105 local_bounds.height()); | 115 local_bounds.height()); |
| 116 #endif | |
| 106 } else { | 117 } else { |
| 107 native_wrapper_->HideWidget(); | 118 native_wrapper_->HideWidget(); |
| 108 } | 119 } |
| 109 fast_resize_at_last_layout_ = visible && fast_resize_; | 120 fast_resize_at_last_layout_ = visible && fast_resize_; |
| 110 } | 121 } |
| 111 | 122 |
| 112 void NativeViewHost::OnPaint(gfx::Canvas* canvas) { | 123 void NativeViewHost::OnPaint(gfx::Canvas* canvas) { |
| 113 // Paint background if there is one. NativeViewHost needs to paint | 124 // Paint background if there is one. NativeViewHost needs to paint |
| 114 // a background when it is hosted in a TabbedPane. For Gtk implementation, | 125 // a background when it is hosted in a TabbedPane. For Gtk implementation, |
| 115 // NativeTabbedPaneGtk uses a NativeWidgetGtk as page container and because | 126 // NativeTabbedPaneGtk uses a NativeWidgetGtk as page container and because |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 Widget::GetAllChildWidgets(native_view(), &widgets); | 222 Widget::GetAllChildWidgets(native_view(), &widgets); |
| 212 for (Widget::Widgets::iterator i = widgets.begin(); i != widgets.end(); ++i) { | 223 for (Widget::Widgets::iterator i = widgets.begin(); i != widgets.end(); ++i) { |
| 213 focus_manager->ViewRemoved((*i)->GetRootView()); | 224 focus_manager->ViewRemoved((*i)->GetRootView()); |
| 214 if (!focus_manager->GetFocusedView()) | 225 if (!focus_manager->GetFocusedView()) |
| 215 return; | 226 return; |
| 216 } | 227 } |
| 217 } | 228 } |
| 218 | 229 |
| 219 | 230 |
| 220 } // namespace views | 231 } // namespace views |
| OLD | NEW |