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

Unified Diff: ash/common/system/tray/tray_details_view.cc

Issue 2557333003: [ash-md] Stacks child layers properly for sticky header rows (Closed)
Patch Set: Created 4 years 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 | « ash/common/system/chromeos/network/vpn_list_view.cc ('k') | ash/common/system/tray/tray_popup_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/tray/tray_details_view.cc
diff --git a/ash/common/system/tray/tray_details_view.cc b/ash/common/system/tray/tray_details_view.cc
index d48c0e3608800ba71fd7bb2ba4261fda9c035589..ae8ff6f34d3cf26988a38cfe987da5a8f19245c0 100644
--- a/ash/common/system/tray/tray_details_view.cc
+++ b/ash/common/system/tray/tray_details_view.cc
@@ -100,6 +100,24 @@ class ScrollContentsView : public views::View,
PositionHeaderRows();
}
+ void ReorderChildLayers(ui::Layer* parent_layer) override {
+ views::View::ReorderChildLayers(parent_layer);
+ ui::Layer* topmost_layer = TopmostLayer(this, parent_layer);
+ if (!topmost_layer)
+ return;
+
+ // Keep the sticky headers with layers above the rest of the children's
+ // layers. Make sure to avoid changing the stacking order of the layers that
+ // are children of |parent_layer| but do not belong to the same parent view.
+ for (int i = child_count() - 1; i >= 0; --i) {
+ View* child = child_at(i);
+ if (child->id() == VIEW_ID_STICKY_HEADER && child->layer()) {
sadrul 2016/12/09 00:55:47 if child->id() == VIEW_ID_STICKY_HEADER, will chil
varkha 2016/12/09 02:20:38 Done.
+ if (child->layer() != topmost_layer)
+ parent_layer->StackAbove(child->layer(), topmost_layer);
+ }
+ }
+ }
+
void ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) override {
if (!details.is_add && details.parent == this) {
@@ -234,6 +252,22 @@ class ScrollContentsView : public views::View,
canvas->DrawRect(shadowed_area, paint);
}
+ // Recursively iterates through children to return the topmost child layer.
sadrul 2016/12/09 00:55:47 Just to confirm: 'topmost' == topmost in stacking
varkha 2016/12/09 02:20:38 Yes, mentioned this in a comment above TopmostLaye
+ ui::Layer* TopmostLayer(views::View* view, ui::Layer* parent_layer) {
sadrul 2016/12/09 00:55:47 DCHECK() that parent_layer is not null?
varkha 2016/12/09 02:20:38 Done.
+ if (view->layer() && view->layer() != parent_layer) {
sadrul 2016/12/09 00:55:47 The first view->layer() check isn't necessary.
varkha 2016/12/09 02:20:38 Once we move this (see the next comment) I think w
+ DCHECK_EQ(parent_layer, view->layer()->parent());
+ return view->layer();
+ }
sadrul 2016/12/09 00:55:47 Shouldn't this go after iterating over the childre
varkha 2016/12/09 02:20:38 Done. Good catch, just not something that was exer
+ // Iterate backwards through the children to find the topmost layer.
+ for (int i = view->child_count() - 1; i >= 0; --i) {
+ views::View* child = view->child_at(i);
+ ui::Layer* layer = TopmostLayer(child, parent_layer);
+ if (layer)
+ return layer;
+ }
+ return nullptr;
+ }
+
views::BoxLayout* box_layout_;
// Header child views that stick to the top of visible viewport when scrolled.
« no previous file with comments | « ash/common/system/chromeos/network/vpn_list_view.cc ('k') | ash/common/system/tray/tray_popup_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698