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

Side by Side Diff: ui/aura/window.cc

Issue 10545140: aura: Window should notify WindowDelegate of bounds changed if Layer cannot. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_unittest.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/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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 590
591 // Ensure we don't go smaller than our minimum bounds. 591 // Ensure we don't go smaller than our minimum bounds.
592 if (delegate_) { 592 if (delegate_) {
593 const gfx::Size& min_size = delegate_->GetMinimumSize(); 593 const gfx::Size& min_size = delegate_->GetMinimumSize();
594 actual_new_bounds.set_width( 594 actual_new_bounds.set_width(
595 std::max(min_size.width(), actual_new_bounds.width())); 595 std::max(min_size.width(), actual_new_bounds.width()));
596 actual_new_bounds.set_height( 596 actual_new_bounds.set_height(
597 std::max(min_size.height(), actual_new_bounds.height())); 597 std::max(min_size.height(), actual_new_bounds.height()));
598 } 598 }
599 599
600 gfx::Rect old_bounds = GetTargetBounds();
601
600 // Always need to set the layer's bounds -- even if it is to the same thing. 602 // Always need to set the layer's bounds -- even if it is to the same thing.
601 // This may cause important side effects such as stopping animation. 603 // This may cause important side effects such as stopping animation.
602 layer_->SetBounds(actual_new_bounds); 604 layer_->SetBounds(actual_new_bounds);
605
606 // If we are currently not the layer's delegate, we will not get bounds
607 // changed notification from the layer. We must notify ourselves.
sky 2012/06/12 21:19:39 Can you add: this typically happens after animatin
varunjain 2012/06/12 21:28:21 Done.
608 if (layer_->delegate() != this)
609 OnLayerBoundsChanged(old_bounds, ContainsMouse());
603 } 610 }
604 611
605 void Window::SetVisible(bool visible) { 612 void Window::SetVisible(bool visible) {
606 if (visible == layer_->GetTargetVisibility()) 613 if (visible == layer_->GetTargetVisibility())
607 return; // No change. 614 return; // No change.
608 615
609 RootWindow* root_window = GetRootWindow(); 616 RootWindow* root_window = GetRootWindow();
610 if (client::GetVisibilityClient(root_window)) { 617 if (client::GetVisibilityClient(root_window)) {
611 client::GetVisibilityClient(root_window)->UpdateLayerVisibility( 618 client::GetVisibilityClient(root_window)->UpdateLayerVisibility(
612 this, visible); 619 this, visible);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 if (root_window) 813 if (root_window)
807 root_window->OnWindowBoundsChanged(this, contained_mouse); 814 root_window->OnWindowBoundsChanged(this, contained_mouse);
808 } 815 }
809 816
810 void Window::OnPaintLayer(gfx::Canvas* canvas) { 817 void Window::OnPaintLayer(gfx::Canvas* canvas) {
811 if (delegate_) 818 if (delegate_)
812 delegate_->OnPaint(canvas); 819 delegate_->OnPaint(canvas);
813 } 820 }
814 821
815 base::Closure Window::PrepareForLayerBoundsChange() { 822 base::Closure Window::PrepareForLayerBoundsChange() {
816 bool contains_mouse = false;
817 if (IsVisible()) {
818 RootWindow* root_window = GetRootWindow();
819 contains_mouse =
820 root_window && ContainsPointInRoot(root_window->last_mouse_location());
821 }
822 return base::Bind(&Window::OnLayerBoundsChanged, base::Unretained(this), 823 return base::Bind(&Window::OnLayerBoundsChanged, base::Unretained(this),
823 bounds(), contains_mouse); 824 bounds(), ContainsMouse());
824 } 825 }
825 826
826 void Window::UpdateLayerName(const std::string& name) { 827 void Window::UpdateLayerName(const std::string& name) {
827 #if !defined(NDEBUG) 828 #if !defined(NDEBUG)
828 DCHECK(layer()); 829 DCHECK(layer());
829 830
830 std::string layer_name(name_); 831 std::string layer_name(name_);
831 if (layer_name.empty()) 832 if (layer_name.empty())
832 layer_name.append("Unnamed Window"); 833 layer_name.append("Unnamed Window");
833 834
834 if (id_ != -1) { 835 if (id_ != -1) {
835 char id_buf[10]; 836 char id_buf[10];
836 base::snprintf(id_buf, sizeof(id_buf), " %d", id_); 837 base::snprintf(id_buf, sizeof(id_buf), " %d", id_);
837 layer_name.append(id_buf); 838 layer_name.append(id_buf);
838 } 839 }
839 layer()->set_name(layer_name); 840 layer()->set_name(layer_name);
840 #endif 841 #endif
841 } 842 }
842 843
844 bool Window::ContainsMouse() {
845 bool contains_mouse = false;
846 if (IsVisible()) {
847 RootWindow* root_window = GetRootWindow();
848 contains_mouse =
849 root_window && ContainsPointInRoot(root_window->last_mouse_location());
850 }
851 return contains_mouse;
852 }
853
843 #ifndef NDEBUG 854 #ifndef NDEBUG
844 std::string Window::GetDebugInfo() const { 855 std::string Window::GetDebugInfo() const {
845 return StringPrintf( 856 return StringPrintf(
846 "%s<%d> bounds(%d, %d, %d, %d) %s", 857 "%s<%d> bounds(%d, %d, %d, %d) %s",
847 name().empty() ? "Unknown" : name().c_str(), id(), 858 name().empty() ? "Unknown" : name().c_str(), id(),
848 bounds().x(), bounds().y(), bounds().width(), bounds().height(), 859 bounds().x(), bounds().y(), bounds().width(), bounds().height(),
849 IsVisible() ? "Visible" : "Hidden"); 860 IsVisible() ? "Visible" : "Hidden");
850 } 861 }
851 862
852 void Window::PrintWindowHierarchy(int depth) const { 863 void Window::PrintWindowHierarchy(int depth) const {
853 printf("%*s%s\n", depth * 2, "", GetDebugInfo().c_str()); 864 printf("%*s%s\n", depth * 2, "", GetDebugInfo().c_str());
854 for (Windows::const_reverse_iterator it = children_.rbegin(), 865 for (Windows::const_reverse_iterator it = children_.rbegin(),
855 rend = children_.rend(); 866 rend = children_.rend();
856 it != rend; ++it) { 867 it != rend; ++it) {
857 Window* child = *it; 868 Window* child = *it;
858 child->PrintWindowHierarchy(depth + 1); 869 child->PrintWindowHierarchy(depth + 1);
859 } 870 }
860 } 871 }
861 #endif 872 #endif
862 873
863 } // namespace aura 874 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698