| 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 // Ensure we don't go smaller than our minimum bounds. | 430 SetBoundsInternal(new_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 } | |
| 440 } | 431 } |
| 441 | 432 |
| 442 void Window::SetBoundsInScreen(const gfx::Rect& new_bounds_in_screen, | 433 void Window::SetBoundsInScreen(const gfx::Rect& new_bounds_in_screen, |
| 443 const gfx::Display& dst_display) { | 434 const gfx::Display& dst_display) { |
| 444 Window* root = GetRootWindow(); | 435 Window* root = GetRootWindow(); |
| 445 if (root) { | 436 if (root) { |
| 446 gfx::Point origin = new_bounds_in_screen.origin(); | 437 gfx::Point origin = new_bounds_in_screen.origin(); |
| 447 aura::client::ScreenPositionClient* screen_position_client = | 438 aura::client::ScreenPositionClient* screen_position_client = |
| 448 aura::client::GetScreenPositionClient(root); | 439 aura::client::GetScreenPositionClient(root); |
| 449 screen_position_client->SetBounds(this, new_bounds_in_screen, dst_display); | 440 screen_position_client->SetBounds(this, new_bounds_in_screen, dst_display); |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 SkRegion clip_region; | 858 SkRegion clip_region; |
| 868 clip_region.setRect(local_bounds.x(), local_bounds.y(), | 859 clip_region.setRect(local_bounds.x(), local_bounds.y(), |
| 869 local_bounds.width(), local_bounds.height()); | 860 local_bounds.width(), local_bounds.height()); |
| 870 SkRegion mask_region; | 861 SkRegion mask_region; |
| 871 return mask_region.setPath(mask, clip_region) && | 862 return mask_region.setPath(mask, clip_region) && |
| 872 mask_region.contains(local_point.x(), local_point.y()); | 863 mask_region.contains(local_point.x(), local_point.y()); |
| 873 } | 864 } |
| 874 | 865 |
| 875 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { | 866 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { |
| 876 gfx::Rect actual_new_bounds(new_bounds); | 867 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 |
| 877 gfx::Rect old_bounds = GetTargetBounds(); | 878 gfx::Rect old_bounds = GetTargetBounds(); |
| 878 | 879 |
| 879 // Always need to set the layer's bounds -- even if it is to the same thing. | 880 // Always need to set the layer's bounds -- even if it is to the same thing. |
| 880 // This may cause important side effects such as stopping animation. | 881 // This may cause important side effects such as stopping animation. |
| 881 if (!layer()) { | 882 if (!layer()) { |
| 882 const gfx::Vector2d origin_delta = new_bounds.OffsetFromOrigin() - | 883 const gfx::Vector2d origin_delta = new_bounds.OffsetFromOrigin() - |
| 883 bounds_.OffsetFromOrigin(); | 884 bounds_.OffsetFromOrigin(); |
| 884 bounds_ = new_bounds; | 885 bounds_ = new_bounds; |
| 885 OffsetLayerBounds(origin_delta); | 886 OffsetLayerBounds(origin_delta); |
| 886 } else { | 887 } else { |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 return window; | 1428 return window; |
| 1428 if (offset) | 1429 if (offset) |
| 1429 *offset += window->bounds().OffsetFromOrigin(); | 1430 *offset += window->bounds().OffsetFromOrigin(); |
| 1430 } | 1431 } |
| 1431 if (offset) | 1432 if (offset) |
| 1432 *offset = gfx::Vector2d(); | 1433 *offset = gfx::Vector2d(); |
| 1433 return NULL; | 1434 return NULL; |
| 1434 } | 1435 } |
| 1435 | 1436 |
| 1436 } // namespace aura | 1437 } // namespace aura |
| OLD | NEW |