summaryrefslogtreecommitdiffstats
path: root/views/view.cc
diff options
context:
space:
mode:
authordavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-09 16:52:00 +0000
committerdavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-09 16:52:00 +0000
commit8eb52a9ae0407aa717113d48b540b1abdb0616e8 (patch)
tree358644668ef2e16d94c86d04b56bb7c1e8673c4e /views/view.cc
parent470ed45abe7452e9f72122e0273cc0506114860a (diff)
downloadchromium_src-8eb52a9ae0407aa717113d48b540b1abdb0616e8.zip
chromium_src-8eb52a9ae0407aa717113d48b540b1abdb0616e8.tar.gz
chromium_src-8eb52a9ae0407aa717113d48b540b1abdb0616e8.tar.bz2
This will help minimize the area we paint various views, including BrowserView in cros. Before the default when a child's preferred view size changed was to propagate it up and
paint everything from the rootview down. This will limit the area to the parts that actually changed size. I expect we may find things that aren't being painted because they were assuming the behavior of Layout(). We should fix this as necessary. Also, a subsequent change will minimize our calls to SchedulePaint(). We frequently do it when we don't need to. BUG=None TEST=ViewTest.SetBoundsPaint Review URL: http://codereview.chromium.org/6531032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77481 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/view.cc')
-rw-r--r--views/view.cc37
1 files changed, 22 insertions, 15 deletions
diff --git a/views/view.cc b/views/view.cc
index ac5911d..aede253 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -214,17 +214,14 @@ void View::SetBoundsRect(const gfx::Rect& bounds) {
if (needs_layout_) {
needs_layout_ = false;
Layout();
+ SchedulePaint();
}
return;
}
gfx::Rect prev = bounds_;
bounds_ = bounds;
- bool size_changed = prev.size() != bounds_.size();
- bool position_changed = prev.origin() != bounds_.origin();
-
- if (size_changed || position_changed)
- BoundsChanged();
+ BoundsChanged(prev);
}
void View::SetSize(const gfx::Size& size) {
@@ -243,11 +240,6 @@ void View::SetY(int y) {
SetBounds(x(), y, width(), height());
}
-void View::OnBoundsChanged() {
- needs_layout_ = false;
- Layout();
-}
-
gfx::Rect View::GetContentsBounds() const {
gfx::Rect contents_bounds(GetLocalBounds());
if (border_.get()) {
@@ -468,10 +460,8 @@ void View::Layout() {
needs_layout_ = false;
// If we have a layout manager, let it handle the layout for us.
- if (layout_manager_.get()) {
+ if (layout_manager_.get())
layout_manager_->Layout(this);
- SchedulePaint();
- }
// Make sure to propagate the Layout() call to any children that haven't
// received it yet through the layout manager and need to be laid out. This
@@ -1085,6 +1075,9 @@ int View::GetLineScrollIncrement(ScrollView* scroll_view,
// Size and disposition --------------------------------------------------------
+void View::OnBoundsChanged(const gfx::Rect& previous_bounds) {
+}
+
void View::PreferredSizeChanged() {
InvalidateLayout();
if (parent_)
@@ -1361,8 +1354,22 @@ void View::VisibilityChangedImpl(View* starting_from, bool is_visible) {
VisibilityChanged(starting_from, is_visible);
}
-void View::BoundsChanged() {
- OnBoundsChanged();
+void View::BoundsChanged(const gfx::Rect& previous_bounds) {
+ if (parent_) {
+ parent_->SchedulePaintInRect(previous_bounds);
+ parent_->SchedulePaintInRect(bounds_);
+ } else {
+ // Previous bounds has no meaning to an orphan. This should only happen
+ // when the View is a RootView.
+ SchedulePaintInRect(gfx::Rect(0, 0, bounds_.width(), bounds_.height()));
+ }
+
+ OnBoundsChanged(previous_bounds);
+
+ if (previous_bounds.size() != size()) {
+ needs_layout_ = false;
+ Layout();
+ }
// Notify interested Views that visible bounds within the root view may have
// changed.