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/aura/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 scoped_ptr<ui::EventTargeter> | 419 scoped_ptr<ui::EventTargeter> |
420 Window::SetEventTargeter(scoped_ptr<ui::EventTargeter> targeter) { | 420 Window::SetEventTargeter(scoped_ptr<ui::EventTargeter> targeter) { |
421 scoped_ptr<ui::EventTargeter> old_targeter = targeter_.Pass(); | 421 scoped_ptr<ui::EventTargeter> old_targeter = targeter_.Pass(); |
422 targeter_ = targeter.Pass(); | 422 targeter_ = targeter.Pass(); |
423 return old_targeter.Pass(); | 423 return old_targeter.Pass(); |
424 } | 424 } |
425 | 425 |
426 void Window::SetBounds(const gfx::Rect& new_bounds) { | 426 void Window::SetBounds(const gfx::Rect& new_bounds) { |
427 if (parent_ && parent_->layout_manager()) | 427 if (parent_ && parent_->layout_manager()) |
428 parent_->layout_manager()->SetChildBounds(this, new_bounds); | 428 parent_->layout_manager()->SetChildBounds(this, new_bounds); |
429 else | 429 else { |
430 SetBoundsInternal(new_bounds); | 430 // Ensure we don't go smaller than our minimum bounds. |
| 431 gfx::Rect final_bounds(new_bounds); |
| 432 if (delegate_) { |
| 433 const gfx::Size& min_size = delegate_->GetMinimumSize(); |
| 434 final_bounds.set_width(std::max(min_size.width(), final_bounds.width())); |
| 435 final_bounds.set_height(std::max(min_size.height(), |
| 436 final_bounds.height())); |
| 437 } |
| 438 SetBoundsInternal(final_bounds); |
| 439 } |
431 } | 440 } |
432 | 441 |
433 void Window::SetBoundsInScreen(const gfx::Rect& new_bounds_in_screen, | 442 void Window::SetBoundsInScreen(const gfx::Rect& new_bounds_in_screen, |
434 const gfx::Display& dst_display) { | 443 const gfx::Display& dst_display) { |
435 Window* root = GetRootWindow(); | 444 Window* root = GetRootWindow(); |
436 if (root) { | 445 if (root) { |
437 gfx::Point origin = new_bounds_in_screen.origin(); | 446 gfx::Point origin = new_bounds_in_screen.origin(); |
438 aura::client::ScreenPositionClient* screen_position_client = | 447 aura::client::ScreenPositionClient* screen_position_client = |
439 aura::client::GetScreenPositionClient(root); | 448 aura::client::GetScreenPositionClient(root); |
440 screen_position_client->SetBounds(this, new_bounds_in_screen, dst_display); | 449 screen_position_client->SetBounds(this, new_bounds_in_screen, dst_display); |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 SkRegion clip_region; | 867 SkRegion clip_region; |
859 clip_region.setRect(local_bounds.x(), local_bounds.y(), | 868 clip_region.setRect(local_bounds.x(), local_bounds.y(), |
860 local_bounds.width(), local_bounds.height()); | 869 local_bounds.width(), local_bounds.height()); |
861 SkRegion mask_region; | 870 SkRegion mask_region; |
862 return mask_region.setPath(mask, clip_region) && | 871 return mask_region.setPath(mask, clip_region) && |
863 mask_region.contains(local_point.x(), local_point.y()); | 872 mask_region.contains(local_point.x(), local_point.y()); |
864 } | 873 } |
865 | 874 |
866 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { | 875 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { |
867 gfx::Rect actual_new_bounds(new_bounds); | 876 gfx::Rect actual_new_bounds(new_bounds); |
868 | |
869 // Ensure we don't go smaller than our minimum bounds. | |
870 if (delegate_) { | |
871 const gfx::Size& min_size = delegate_->GetMinimumSize(); | |
872 actual_new_bounds.set_width( | |
873 std::max(min_size.width(), actual_new_bounds.width())); | |
874 actual_new_bounds.set_height( | |
875 std::max(min_size.height(), actual_new_bounds.height())); | |
876 } | |
877 | |
878 gfx::Rect old_bounds = GetTargetBounds(); | 877 gfx::Rect old_bounds = GetTargetBounds(); |
879 | 878 |
880 // Always need to set the layer's bounds -- even if it is to the same thing. | 879 // Always need to set the layer's bounds -- even if it is to the same thing. |
881 // This may cause important side effects such as stopping animation. | 880 // This may cause important side effects such as stopping animation. |
882 if (!layer()) { | 881 if (!layer()) { |
883 const gfx::Vector2d origin_delta = new_bounds.OffsetFromOrigin() - | 882 const gfx::Vector2d origin_delta = new_bounds.OffsetFromOrigin() - |
884 bounds_.OffsetFromOrigin(); | 883 bounds_.OffsetFromOrigin(); |
885 bounds_ = new_bounds; | 884 bounds_ = new_bounds; |
886 OffsetLayerBounds(origin_delta); | 885 OffsetLayerBounds(origin_delta); |
887 } else { | 886 } else { |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 return window; | 1427 return window; |
1429 if (offset) | 1428 if (offset) |
1430 *offset += window->bounds().OffsetFromOrigin(); | 1429 *offset += window->bounds().OffsetFromOrigin(); |
1431 } | 1430 } |
1432 if (offset) | 1431 if (offset) |
1433 *offset = gfx::Vector2d(); | 1432 *offset = gfx::Vector2d(); |
1434 return NULL; | 1433 return NULL; |
1435 } | 1434 } |
1436 | 1435 |
1437 } // namespace aura | 1436 } // namespace aura |
OLD | NEW |