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

Side by Side Diff: ui/views/controls/native/native_view_host.cc

Issue 2654413002: Stretching NativeViewHost, and misc tab capture fixes.
Patch Set: Gettin' it all working on ui/cocoa and MacViews too. Created 3 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 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/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/base/cursor/cursor.h" 8 #include "ui/base/cursor/cursor.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/views/accessibility/native_view_accessibility.h" 10 #include "ui/views/accessibility/native_view_accessibility.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 void NativeViewHost::Detach() { 45 void NativeViewHost::Detach() {
46 Detach(false); 46 Detach(false);
47 } 47 }
48 48
49 void NativeViewHost::SetPreferredSize(const gfx::Size& size) { 49 void NativeViewHost::SetPreferredSize(const gfx::Size& size) {
50 preferred_size_ = size; 50 preferred_size_ = size;
51 PreferredSizeChanged(); 51 PreferredSizeChanged();
52 } 52 }
53 53
54 void NativeViewHost::SetRenderingSize(const gfx::Size& size) {
55 rendering_size_ = size;
56 InvalidateLayout();
57 }
58
54 void NativeViewHost::NativeViewDestroyed() { 59 void NativeViewHost::NativeViewDestroyed() {
55 // Detach so we can clear our state and notify the native_wrapper_ to release 60 // Detach so we can clear our state and notify the native_wrapper_ to release
56 // ref on the native view. 61 // ref on the native view.
57 Detach(true); 62 Detach(true);
58 } 63 }
59 64
60 //////////////////////////////////////////////////////////////////////////////// 65 ////////////////////////////////////////////////////////////////////////////////
61 // NativeViewHost, View overrides: 66 // NativeViewHost, View overrides:
62 67
63 gfx::Size NativeViewHost::GetPreferredSize() const { 68 gfx::Size NativeViewHost::GetPreferredSize() const {
(...skipping 21 matching lines...) Expand all
85 } 90 }
86 } 91 }
87 92
88 if (visible) { 93 if (visible) {
89 // Since widgets know nothing about the View hierarchy (they are direct 94 // Since widgets know nothing about the View hierarchy (they are direct
90 // children of the Widget that hosts our View hierarchy) they need to be 95 // children of the Widget that hosts our View hierarchy) they need to be
91 // positioned in the coordinate system of the Widget, not the current 96 // positioned in the coordinate system of the Widget, not the current
92 // view. Also, they should be positioned respecting the border insets 97 // view. Also, they should be positioned respecting the border insets
93 // of the native view. 98 // of the native view.
94 gfx::Rect local_bounds = ConvertRectToWidget(GetContentsBounds()); 99 gfx::Rect local_bounds = ConvertRectToWidget(GetContentsBounds());
95 native_wrapper_->ShowWidget(local_bounds.x(), local_bounds.y(), 100 gfx::Size rendering_size =
96 local_bounds.width(), 101 rendering_size_.IsEmpty() ? local_bounds.size() : rendering_size_;
97 local_bounds.height()); 102 native_wrapper_->ShowWidget(
103 local_bounds.x(), local_bounds.y(), local_bounds.width(),
104 local_bounds.height(), rendering_size.width(), rendering_size.height());
98 } else { 105 } else {
99 native_wrapper_->HideWidget(); 106 native_wrapper_->HideWidget();
100 } 107 }
101 fast_resize_at_last_layout_ = visible && fast_resize_; 108 fast_resize_at_last_layout_ = visible && fast_resize_;
102 } 109 }
103 110
104 void NativeViewHost::OnPaint(gfx::Canvas* canvas) { 111 void NativeViewHost::OnPaint(gfx::Canvas* canvas) {
105 // Paint background if there is one. NativeViewHost needs to paint 112 // Paint background if there is one. NativeViewHost needs to paint
106 // a background when it is hosted in a TabbedPane. For Gtk implementation, 113 // a background when it is hosted in a TabbedPane. For Gtk implementation,
107 // NativeTabbedPaneGtk uses a NativeWidgetGtk as page container and because 114 // NativeTabbedPaneGtk uses a NativeWidgetGtk as page container and because
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 Widget::Widgets widgets; 217 Widget::Widgets widgets;
211 Widget::GetAllChildWidgets(native_view(), &widgets); 218 Widget::GetAllChildWidgets(native_view(), &widgets);
212 for (Widget::Widgets::iterator i = widgets.begin(); i != widgets.end(); ++i) { 219 for (Widget::Widgets::iterator i = widgets.begin(); i != widgets.end(); ++i) {
213 focus_manager->ViewRemoved((*i)->GetRootView()); 220 focus_manager->ViewRemoved((*i)->GetRootView());
214 if (!focus_manager->GetFocusedView()) 221 if (!focus_manager->GetFocusedView())
215 return; 222 return;
216 } 223 }
217 } 224 }
218 225
219 } // namespace views 226 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/native/native_view_host.h ('k') | ui/views/controls/native/native_view_host_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698