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

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

Issue 11110004: Make gfx::Rect class operations consistently mutate the class they are called on. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: cc/ fixes Created 8 years, 2 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 | « ui/views/widget/desktop_root_window_host_linux.cc ('k') | ui/views/widget/root_view.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/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/string_util.h" 8 #include "base/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/activation_change_observer.h" 10 #include "ui/aura/client/activation_change_observer.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 290
291 aura::client::ScreenPositionClient* screen_position_client = 291 aura::client::ScreenPositionClient* screen_position_client =
292 aura::client::GetScreenPositionClient(window_->GetRootWindow()); 292 aura::client::GetScreenPositionClient(window_->GetRootWindow());
293 if (screen_position_client) { 293 if (screen_position_client) {
294 gfx::Point origin = work_area.origin(); 294 gfx::Point origin = work_area.origin();
295 screen_position_client->ConvertPointFromScreen(window_->GetRootWindow(), 295 screen_position_client->ConvertPointFromScreen(window_->GetRootWindow(),
296 &origin); 296 &origin);
297 work_area.set_origin(origin); 297 work_area.set_origin(origin);
298 } 298 }
299 299
300 parent_bounds = parent_bounds.Intersect(work_area); 300 parent_bounds.Intersect(work_area);
301 301
302 // If |window_|'s transient parent's bounds are big enough to fit it, then we 302 // If |window_|'s transient parent's bounds are big enough to fit it, then we
303 // center it with respect to the transient parent. 303 // center it with respect to the transient parent.
304 if (window_->transient_parent()) { 304 if (window_->transient_parent()) {
305 gfx::Rect transient_parent_rect = window_->transient_parent()-> 305 gfx::Rect transient_parent_rect = window_->transient_parent()->
306 GetBoundsInRootWindow().Intersect(work_area); 306 GetBoundsInRootWindow();
307 transient_parent_rect.Intersect(work_area);
307 if (transient_parent_rect.height() >= size.height() && 308 if (transient_parent_rect.height() >= size.height() &&
308 transient_parent_rect.width() >= size.width()) 309 transient_parent_rect.width() >= size.width())
309 parent_bounds = transient_parent_rect; 310 parent_bounds = transient_parent_rect;
310 } 311 }
311 312
312 gfx::Rect window_bounds( 313 gfx::Rect window_bounds(
313 parent_bounds.x() + (parent_bounds.width() - size.width()) / 2, 314 parent_bounds.x() + (parent_bounds.width() - size.width()) / 2,
314 parent_bounds.y() + (parent_bounds.height() - size.height()) / 2, 315 parent_bounds.y() + (parent_bounds.height() - size.height()) / 2,
315 size.width(), 316 size.width(),
316 size.height()); 317 size.height());
317 // Don't size the window bigger than the parent, otherwise the user may not be 318 // Don't size the window bigger than the parent, otherwise the user may not be
318 // able to close or move it. 319 // able to close or move it.
319 window_bounds = window_bounds.AdjustToFit(parent_bounds); 320 window_bounds.AdjustToFit(parent_bounds);
320 321
321 // Convert the bounds back relative to the parent. 322 // Convert the bounds back relative to the parent.
322 gfx::Point origin = window_bounds.origin(); 323 gfx::Point origin = window_bounds.origin();
323 aura::Window::ConvertPointToTarget(window_->GetRootWindow(), 324 aura::Window::ConvertPointToTarget(window_->GetRootWindow(),
324 window_->parent(), &origin); 325 window_->parent(), &origin);
325 window_bounds.set_origin(origin); 326 window_bounds.set_origin(origin);
326 window_->SetBounds(window_bounds); 327 window_->SetBounds(window_bounds);
327 } 328 }
328 329
329 void NativeWidgetAura::GetWindowPlacement( 330 void NativeWidgetAura::GetWindowPlacement(
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 return aura::Env::GetInstance()->is_mouse_button_down(); 1006 return aura::Env::GetInstance()->is_mouse_button_down();
1006 } 1007 }
1007 1008
1008 // static 1009 // static
1009 bool NativeWidgetPrivate::IsTouchDown() { 1010 bool NativeWidgetPrivate::IsTouchDown() {
1010 return aura::Env::GetInstance()->is_touch_down(); 1011 return aura::Env::GetInstance()->is_touch_down();
1011 } 1012 }
1012 1013
1013 } // namespace internal 1014 } // namespace internal
1014 } // namespace views 1015 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_root_window_host_linux.cc ('k') | ui/views/widget/root_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698