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

Unified Diff: ui/views/view.cc

Issue 2813353002: Ensure that the focus ring in the bookmarks bar does not paint outside the parent view. (Closed)
Patch Set: \ Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/view.h ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view.cc
diff --git a/ui/views/view.cc b/ui/views/view.cc
index 6b231e9b15dc3498c65ef3322b7443069520cd7d..27eada4660d6798ae106657b69e53a3358dd1d72 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -537,39 +537,16 @@ void View::SetPaintToLayer(ui::LayerType layer_type) {
if (paint_to_layer_ && (layer()->type() == layer_type))
return;
- DestroyLayer();
+ DestroyLayerImpl(LayerChangeNotifyBehavior::DONT_NOTIFY);
CreateLayer(layer_type);
paint_to_layer_ = true;
+
+ // Notify the parent chain about the layer change.
+ NotifyParentsOfLayerChange();
}
void View::DestroyLayer() {
- if (!paint_to_layer_)
- return;
-
- paint_to_layer_ = false;
- if (!layer())
- return;
-
- ui::Layer* new_parent = layer()->parent();
- std::vector<ui::Layer*> children = layer()->children();
- for (size_t i = 0; i < children.size(); ++i) {
- layer()->Remove(children[i]);
- if (new_parent)
- new_parent->Add(children[i]);
- }
-
- LayerOwner::DestroyLayer();
-
- if (new_parent)
- ReorderLayers();
-
- UpdateChildLayerBounds(CalculateOffsetToAncestorWithLayer(NULL));
-
- SchedulePaint();
-
- Widget* widget = GetWidget();
- if (widget)
- widget->LayerTreeChanged();
+ DestroyLayerImpl(LayerChangeNotifyBehavior::NOTIFY);
}
std::unique_ptr<ui::Layer> View::RecreateLayer() {
@@ -1628,6 +1605,49 @@ void View::UpdateChildLayerVisibility(bool ancestor_visible) {
}
}
+void View::DestroyLayerImpl(LayerChangeNotifyBehavior notify_parents) {
+ if (!paint_to_layer_)
+ return;
+
+ paint_to_layer_ = false;
+ if (!layer())
+ return;
+
+ ui::Layer* new_parent = layer()->parent();
+ std::vector<ui::Layer*> children = layer()->children();
+ for (size_t i = 0; i < children.size(); ++i) {
+ layer()->Remove(children[i]);
+ if (new_parent)
+ new_parent->Add(children[i]);
+ }
+
+ LayerOwner::DestroyLayer();
+
+ if (new_parent)
+ ReorderLayers();
+
+ UpdateChildLayerBounds(CalculateOffsetToAncestorWithLayer(NULL));
+
+ SchedulePaint();
+
+ // Notify the parent chain about the layer change.
+ if (notify_parents == LayerChangeNotifyBehavior::NOTIFY)
+ NotifyParentsOfLayerChange();
+
+ Widget* widget = GetWidget();
+ if (widget)
+ widget->LayerTreeChanged();
+}
+
+void View::NotifyParentsOfLayerChange() {
+ // Notify the parent chain about the layer change.
+ View* view_parent = parent();
+ while (view_parent) {
+ view_parent->OnChildLayerChanged(this);
+ view_parent = view_parent->parent();
+ }
+}
+
void View::UpdateChildLayerBounds(const gfx::Vector2d& offset) {
if (layer()) {
SetLayerBounds(GetLocalBounds() + offset);
@@ -1696,6 +1716,8 @@ void View::ReorderChildLayers(ui::Layer* parent_layer) {
}
}
+void View::OnChildLayerChanged(View* child) {}
+
// Input -----------------------------------------------------------------------
View::DragInfo* View::GetDragInfo() {
« no previous file with comments | « 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