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

Side by Side Diff: ui/views/view.cc

Issue 566403002: Optimize View::UpdateRootBounds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove extra changes Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | 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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
6 6
7 #include "ui/views/view.h" 7 #include "ui/views/view.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 410
411 // Notify the parent. 411 // Notify the parent.
412 if (parent_) 412 if (parent_)
413 parent_->ChildVisibilityChanged(this); 413 parent_->ChildVisibilityChanged(this);
414 414
415 // This notifies all sub-views recursively. 415 // This notifies all sub-views recursively.
416 PropagateVisibilityNotifications(this, visible_); 416 PropagateVisibilityNotifications(this, visible_);
417 UpdateLayerVisibility(); 417 UpdateLayerVisibility();
418 418
419 // If we are newly visible, schedule paint. 419 // If we are newly visible, schedule paint.
420 if (visible_) 420 if (visible_) {
421 SchedulePaint(); 421 SchedulePaint();
422 } else {
423 // We're never painted when hidden, so no need to be in the BoundsTree.
424 BoundsTree* bounds_tree = GetBoundsTreeFromPaintRoot();
425 if (bounds_tree)
426 RemoveRootBounds(bounds_tree);
427 }
422 } 428 }
423 } 429 }
424 430
425 bool View::IsDrawn() const { 431 bool View::IsDrawn() const {
426 return visible_ && parent_ ? parent_->IsDrawn() : false; 432 return visible_ && parent_ ? parent_->IsDrawn() : false;
427 } 433 }
428 434
429 void View::SetEnabled(bool enabled) { 435 void View::SetEnabled(bool enabled) {
430 if (enabled != enabled_) { 436 if (enabled != enabled_) {
431 enabled_ = enabled; 437 enabled_ = enabled;
(...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 // coordinates in paint root space have changed since ours have changed. 2010 // coordinates in paint root space have changed since ours have changed.
2005 for (Views::const_iterator i(children_.begin()); i != children_.end(); 2011 for (Views::const_iterator i(children_.begin()); i != children_.end();
2006 ++i) { 2012 ++i) {
2007 if (!(*i)->IsPaintRoot()) 2013 if (!(*i)->IsPaintRoot())
2008 (*i)->SetRootBoundsDirty(origin_changed); 2014 (*i)->SetRootBoundsDirty(origin_changed);
2009 } 2015 }
2010 } 2016 }
2011 } 2017 }
2012 2018
2013 void View::UpdateRootBounds(BoundsTree* tree, const gfx::Vector2d& offset) { 2019 void View::UpdateRootBounds(BoundsTree* tree, const gfx::Vector2d& offset) {
2020 // If we're not visible no need to update BoundsTree. When we are made visible
2021 // the BoundsTree will be updated appropriately.
2022 if (!visible_)
2023 return;
2024
2025 if (!root_bounds_dirty_ && children_.empty())
2026 return;
2027
2014 // No need to recompute bounds if we haven't flagged ours as dirty. 2028 // No need to recompute bounds if we haven't flagged ours as dirty.
2015 TRACE_EVENT1("views", "View::UpdateRootBounds", "class", GetClassName()); 2029 TRACE_EVENT1("views", "View::UpdateRootBounds", "class", GetClassName());
2016 2030
2017 // Add our own offset to the provided offset, for our own bounds update and 2031 // Add our own offset to the provided offset, for our own bounds update and
2018 // for propagation to our children if needed. 2032 // for propagation to our children if needed.
2019 gfx::Vector2d view_offset = offset + GetMirroredBounds().OffsetFromOrigin(); 2033 gfx::Vector2d view_offset = offset + GetMirroredBounds().OffsetFromOrigin();
2020 2034
2021 // If our bounds have changed we must re-insert our new bounds to the tree. 2035 // If our bounds have changed we must re-insert our new bounds to the tree.
2022 if (root_bounds_dirty_) { 2036 if (root_bounds_dirty_) {
2023 root_bounds_dirty_ = false; 2037 root_bounds_dirty_ = false;
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
2442 // Message the RootView to do the drag and drop. That way if we're removed 2456 // Message the RootView to do the drag and drop. That way if we're removed
2443 // the RootView can detect it and avoid calling us back. 2457 // the RootView can detect it and avoid calling us back.
2444 gfx::Point widget_location(event.location()); 2458 gfx::Point widget_location(event.location());
2445 ConvertPointToWidget(this, &widget_location); 2459 ConvertPointToWidget(this, &widget_location);
2446 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2460 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2447 // WARNING: we may have been deleted. 2461 // WARNING: we may have been deleted.
2448 return true; 2462 return true;
2449 } 2463 }
2450 2464
2451 } // namespace views 2465 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698