| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 } | 422 } |
| 423 | 423 |
| 424 Desktop* Window::GetDesktop() { | 424 Desktop* Window::GetDesktop() { |
| 425 return parent_ ? parent_->GetDesktop() : NULL; | 425 return parent_ ? parent_->GetDesktop() : NULL; |
| 426 } | 426 } |
| 427 | 427 |
| 428 void Window::WindowDetachedFromDesktop(aura::Window* window) { | 428 void Window::WindowDetachedFromDesktop(aura::Window* window) { |
| 429 } | 429 } |
| 430 | 430 |
| 431 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { | 431 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { |
| 432 gfx::Rect actual_new_bounds(new_bounds); |
| 433 |
| 434 // Gives delegate a change to examine and change the new bounds. |
| 435 if (delegate_) |
| 436 delegate_->OnBoundsChanging(&actual_new_bounds); |
| 437 |
| 432 const gfx::Rect old_bounds = layer_->GetTargetBounds(); | 438 const gfx::Rect old_bounds = layer_->GetTargetBounds(); |
| 433 | 439 |
| 434 // Always need to set the layer's bounds -- even if it is to the same thing. | 440 // Always need to set the layer's bounds -- even if it is to the same thing. |
| 435 // This may cause important side effects such as stopping animation. | 441 // This may cause important side effects such as stopping animation. |
| 436 layer_->SetBounds(new_bounds); | 442 layer_->SetBounds(actual_new_bounds); |
| 437 | 443 |
| 438 // If we're not changing the effective bounds, then we can bail early and skip | 444 // If we're not changing the effective bounds, then we can bail early and skip |
| 439 // notifying our listeners. | 445 // notifying our listeners. |
| 440 if (old_bounds == new_bounds) | 446 if (old_bounds == actual_new_bounds) |
| 441 return; | 447 return; |
| 442 | 448 |
| 443 if (layout_manager_.get()) | 449 if (layout_manager_.get()) |
| 444 layout_manager_->OnWindowResized(); | 450 layout_manager_->OnWindowResized(); |
| 445 if (delegate_) | 451 if (delegate_) |
| 446 delegate_->OnBoundsChanged(old_bounds, new_bounds); | 452 delegate_->OnBoundsChanged(old_bounds, actual_new_bounds); |
| 447 } | 453 } |
| 448 | 454 |
| 449 void Window::SetVisible(bool visible) { | 455 void Window::SetVisible(bool visible) { |
| 450 if (visible == layer_->visible()) | 456 if (visible == layer_->visible()) |
| 451 return; // No change. | 457 return; // No change. |
| 452 | 458 |
| 453 bool was_visible = IsVisible(); | 459 bool was_visible = IsVisible(); |
| 454 layer_->SetVisible(visible); | 460 layer_->SetVisible(visible); |
| 455 bool is_visible = IsVisible(); | 461 bool is_visible = IsVisible(); |
| 456 if (was_visible != is_visible) { | 462 if (was_visible != is_visible) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 511 |
| 506 return delegate_ ? this : NULL; | 512 return delegate_ ? this : NULL; |
| 507 } | 513 } |
| 508 | 514 |
| 509 void Window::OnPaintLayer(gfx::Canvas* canvas) { | 515 void Window::OnPaintLayer(gfx::Canvas* canvas) { |
| 510 if (delegate_) | 516 if (delegate_) |
| 511 delegate_->OnPaint(canvas); | 517 delegate_->OnPaint(canvas); |
| 512 } | 518 } |
| 513 | 519 |
| 514 } // namespace aura | 520 } // namespace aura |
| OLD | NEW |