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

Unified Diff: ui/views/view.cc

Issue 2500623002: Add ViewObserver to View for view updates (Closed)
Patch Set: sadruls comments Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/view.cc
diff --git a/ui/views/view.cc b/ui/views/view.cc
index b6cd9d0e97f9345128f754a62f0b80e15fa2430f..697e1be2a35ed3aea5d4355d3a4999a04435b8b9 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -48,6 +48,7 @@
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/context_menu_controller.h"
+#include "ui/views/devtools_observer.h"
#include "ui/views/drag_controller.h"
#include "ui/views/focus/view_storage.h"
#include "ui/views/layout/layout_manager.h"
@@ -118,7 +119,8 @@ View::View()
focus_behavior_(FocusBehavior::NEVER),
context_menu_controller_(NULL),
drag_controller_(NULL),
- native_view_accessibility_(NULL) {
+ native_view_accessibility_(NULL),
+ devtools_observer_(nullptr) {
SetTargetHandler(this);
}
@@ -220,6 +222,9 @@ void View::AddChildViewAt(View* view, int index) {
if (layout_manager_.get())
layout_manager_->ViewAdded(this, view);
+
+ if (devtools_observer_)
+ devtools_observer_->OnViewHierarchyChanged(view, nullptr, this);
}
void View::ReorderChildView(View* view, int index) {
@@ -243,6 +248,9 @@ void View::ReorderChildView(View* view, int index) {
if (next_focusable)
next_focusable->previous_focusable_view_ = prev_focusable;
+ if (devtools_observer_)
+ devtools_observer_->OnChildViewReordered(view, index);
+
// Add it in the specified index now.
InitFocusSiblings(view, index);
children_.insert(children_.begin() + index, view);
@@ -295,6 +303,9 @@ void View::SetBoundsRect(const gfx::Rect& bounds) {
SCHEDULE_PAINT_SIZE_CHANGED);
}
+ if (devtools_observer_)
+ devtools_observer_->OnViewBoundsChanged(this, bounds);
+
gfx::Rect prev = bounds_;
bounds_ = bounds;
BoundsChanged(prev);
@@ -436,6 +447,8 @@ void View::SetEnabled(bool enabled) {
if (enabled != enabled_) {
enabled_ = enabled;
AdvanceFocusIfNecessary();
+ if (devtools_observer_)
+ devtools_observer_->OnViewEnabledChanged(this, enabled);
OnEnabledChanged();
}
}
@@ -1839,6 +1852,11 @@ void View::DoRemoveChildView(View* view,
if (layout_manager_)
layout_manager_->ViewRemoved(this, view);
+
+ // We don't care about the new_parent here because if there is one,
+ // devtools will be notified in the AddChildViewAt method.
+ if (devtools_observer_)
+ devtools_observer_->OnViewHierarchyChanged(view, this, nullptr);
}
void View::PropagateRemoveNotifications(View* old_parent, View* new_parent) {
@@ -1897,6 +1915,8 @@ void View::PropagateVisibilityNotifications(View* start, bool is_visible) {
}
void View::VisibilityChangedImpl(View* starting_from, bool is_visible) {
+ if (devtools_observer_)
+ devtools_observer_->OnViewVisibilityChanged(starting_from, is_visible);
VisibilityChanged(starting_from, is_visible);
}
« ui/views/devtools_observer.h ('K') | « ui/views/view.h ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698