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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 } | 408 } |
409 | 409 |
410 Desktop* Window::GetDesktop() { | 410 Desktop* Window::GetDesktop() { |
411 return parent_ ? parent_->GetDesktop() : NULL; | 411 return parent_ ? parent_->GetDesktop() : NULL; |
412 } | 412 } |
413 | 413 |
414 void Window::WindowDetachedFromDesktop(aura::Window* window) { | 414 void Window::WindowDetachedFromDesktop(aura::Window* window) { |
415 } | 415 } |
416 | 416 |
417 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { | 417 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { |
| 418 gfx::Rect actual_new_bounds(new_bounds); |
| 419 |
| 420 // Gives delegate a change to examine and change the new bounds. |
| 421 if (delegate_) |
| 422 delegate_->OnBoundsChanging(&actual_new_bounds); |
| 423 |
418 const gfx::Rect old_bounds = layer_->GetTargetBounds(); | 424 const gfx::Rect old_bounds = layer_->GetTargetBounds(); |
419 | 425 |
420 // Always need to set the layer's bounds -- even if it is to the same thing. | 426 // Always need to set the layer's bounds -- even if it is to the same thing. |
421 // This may cause important side effects such as stopping animation. | 427 // This may cause important side effects such as stopping animation. |
422 layer_->SetBounds(new_bounds); | 428 layer_->SetBounds(actual_new_bounds); |
423 | 429 |
424 // If we're not changing the effective bounds, then we can bail early and skip | 430 // If we're not changing the effective bounds, then we can bail early and skip |
425 // notifying our listeners. | 431 // notifying our listeners. |
426 if (old_bounds == new_bounds) | 432 if (old_bounds == actual_new_bounds) |
427 return; | 433 return; |
428 | 434 |
429 if (layout_manager_.get()) | 435 if (layout_manager_.get()) |
430 layout_manager_->OnWindowResized(); | 436 layout_manager_->OnWindowResized(); |
431 if (delegate_) | 437 if (delegate_) |
432 delegate_->OnBoundsChanged(old_bounds, new_bounds); | 438 delegate_->OnBoundsChanged(old_bounds, actual_new_bounds); |
433 } | 439 } |
434 | 440 |
435 void Window::SetVisible(bool visible) { | 441 void Window::SetVisible(bool visible) { |
436 if (visible == layer_->visible()) | 442 if (visible == layer_->visible()) |
437 return; // No change. | 443 return; // No change. |
438 | 444 |
439 bool was_visible = IsVisible(); | 445 bool was_visible = IsVisible(); |
440 layer_->SetVisible(visible); | 446 layer_->SetVisible(visible); |
441 bool is_visible = IsVisible(); | 447 bool is_visible = IsVisible(); |
442 if (was_visible != is_visible) { | 448 if (was_visible != is_visible) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 | 497 |
492 return delegate_ ? this : NULL; | 498 return delegate_ ? this : NULL; |
493 } | 499 } |
494 | 500 |
495 void Window::OnPaintLayer(gfx::Canvas* canvas) { | 501 void Window::OnPaintLayer(gfx::Canvas* canvas) { |
496 if (delegate_) | 502 if (delegate_) |
497 delegate_->OnPaint(canvas); | 503 delegate_->OnPaint(canvas); |
498 } | 504 } |
499 | 505 |
500 } // namespace aura | 506 } // namespace aura |
OLD | NEW |