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

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

Issue 399343003: Make WebContents get the correct screen coordinates when initially added. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: set kHostViewKey earlier Created 6 years, 5 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
« no previous file with comments | « no previous file | ui/views/controls/native/native_view_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_aura.h" 5 #include "ui/views/controls/native/native_view_host_aura.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/aura/client/aura_constants.h" 8 #include "ui/aura/client/aura_constants.h"
9 #include "ui/aura/client/focus_client.h" 9 #include "ui/aura/client/focus_client.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // static 140 // static
141 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( 141 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper(
142 NativeViewHost* host) { 142 NativeViewHost* host) {
143 return new NativeViewHostAura(host); 143 return new NativeViewHostAura(host);
144 } 144 }
145 145
146 void NativeViewHostAura::AddClippingWindow() { 146 void NativeViewHostAura::AddClippingWindow() {
147 RemoveClippingWindow(); 147 RemoveClippingWindow();
148 148
149 gfx::Rect bounds = host_->native_view()->bounds(); 149 gfx::Rect bounds = host_->native_view()->bounds();
150 host_->native_view()->SetProperty(aura::client::kHostWindowKey,
151 host_->GetWidget()->GetNativeView());
152 Widget::ReparentNativeView(host_->native_view(),
153 &clipping_window_);
150 if (host_->GetWidget()->GetNativeView()) { 154 if (host_->GetWidget()->GetNativeView()) {
151 Widget::ReparentNativeView(&clipping_window_, 155 Widget::ReparentNativeView(&clipping_window_,
152 host_->GetWidget()->GetNativeView()); 156 host_->GetWidget()->GetNativeView());
153 } 157 }
154 host_->native_view()->SetProperty(aura::client::kHostWindowKey,
155 host_->GetWidget()->GetNativeView());
156 Widget::ReparentNativeView(host_->native_view(),
157 &clipping_window_);
158 clipping_window_.SetBounds(bounds); 158 clipping_window_.SetBounds(bounds);
159 bounds.set_origin(gfx::Point(0, 0)); 159 bounds.set_origin(gfx::Point(0, 0));
160 host_->native_view()->SetBounds(bounds); 160 host_->native_view()->SetBounds(bounds);
161 clipping_window_.Show(); 161 clipping_window_.Show();
162 } 162 }
163 163
164 void NativeViewHostAura::RemoveClippingWindow() { 164 void NativeViewHostAura::RemoveClippingWindow() {
165 clipping_window_.Hide(); 165 clipping_window_.Hide();
166 if (host_->native_view()) 166 if (host_->native_view())
167 host_->native_view()->ClearProperty(aura::client::kHostWindowKey); 167 host_->native_view()->ClearProperty(aura::client::kHostWindowKey);
168 168
169 if (host_->native_view()->parent() == &clipping_window_) { 169 if (host_->native_view()->parent() == &clipping_window_) {
170 if (host_->GetWidget() && host_->GetWidget()->GetNativeView()) { 170 if (host_->GetWidget() && host_->GetWidget()->GetNativeView()) {
171 Widget::ReparentNativeView(host_->native_view(), 171 Widget::ReparentNativeView(host_->native_view(),
172 host_->GetWidget()->GetNativeView()); 172 host_->GetWidget()->GetNativeView());
173 } else { 173 } else {
174 clipping_window_.RemoveChild(host_->native_view()); 174 clipping_window_.RemoveChild(host_->native_view());
175 } 175 }
176 host_->native_view()->SetBounds(clipping_window_.bounds()); 176 host_->native_view()->SetBounds(clipping_window_.bounds());
177 } 177 }
178 if (clipping_window_.parent()) 178 if (clipping_window_.parent())
179 clipping_window_.parent()->RemoveChild(&clipping_window_); 179 clipping_window_.parent()->RemoveChild(&clipping_window_);
180 } 180 }
181 181
182 } // namespace views 182 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/native/native_view_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698