Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "ash/common/system/tray/tray_details_view.h" | 5 #include "ash/common/system/tray/tray_details_view.h" |
| 6 | 6 |
| 7 #include "ash/common/ash_view_ids.h" | 7 #include "ash/common/ash_view_ids.h" |
| 8 #include "ash/common/material_design/material_design_controller.h" | 8 #include "ash/common/material_design/material_design_controller.h" |
| 9 #include "ash/common/system/tray/fixed_sized_scroll_view.h" | 9 #include "ash/common/system/tray/fixed_sized_scroll_view.h" |
| 10 #include "ash/common/system/tray/system_menu_button.h" | 10 #include "ash/common/system/tray/system_menu_button.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 views::View::Layout(); | 93 views::View::Layout(); |
| 94 headers_.clear(); | 94 headers_.clear(); |
| 95 for (int i = 0; i < child_count(); ++i) { | 95 for (int i = 0; i < child_count(); ++i) { |
| 96 views::View* view = child_at(i); | 96 views::View* view = child_at(i); |
| 97 if (view->id() == VIEW_ID_STICKY_HEADER) | 97 if (view->id() == VIEW_ID_STICKY_HEADER) |
| 98 headers_.emplace_back(view); | 98 headers_.emplace_back(view); |
| 99 } | 99 } |
| 100 PositionHeaderRows(); | 100 PositionHeaderRows(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void ReorderChildLayers(ui::Layer* parent_layer) override { | |
| 104 views::View::ReorderChildLayers(parent_layer); | |
| 105 ui::Layer* topmost_layer = TopmostLayer(this, parent_layer); | |
| 106 if (!topmost_layer) | |
| 107 return; | |
| 108 | |
| 109 // Keep the sticky headers with layers above the rest of the children's | |
| 110 // layers. Make sure to avoid changing the stacking order of the layers that | |
| 111 // are children of |parent_layer| but do not belong to the same parent view. | |
| 112 for (int i = child_count() - 1; i >= 0; --i) { | |
| 113 View* child = child_at(i); | |
| 114 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.
| |
| 115 if (child->layer() != topmost_layer) | |
| 116 parent_layer->StackAbove(child->layer(), topmost_layer); | |
| 117 } | |
| 118 } | |
| 119 } | |
| 120 | |
| 103 void ViewHierarchyChanged( | 121 void ViewHierarchyChanged( |
| 104 const ViewHierarchyChangedDetails& details) override { | 122 const ViewHierarchyChangedDetails& details) override { |
| 105 if (!details.is_add && details.parent == this) { | 123 if (!details.is_add && details.parent == this) { |
| 106 headers_.erase(std::remove_if(headers_.begin(), headers_.end(), | 124 headers_.erase(std::remove_if(headers_.begin(), headers_.end(), |
| 107 [details](const Header& header) { | 125 [details](const Header& header) { |
| 108 return header.view == details.child; | 126 return header.view == details.child; |
| 109 }), | 127 }), |
| 110 headers_.end()); | 128 headers_.end()); |
| 111 } else if (details.is_add && details.parent == this && | 129 } else if (details.is_add && details.parent == this && |
| 112 details.child == child_at(0)) { | 130 details.child == child_at(0)) { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 SkPaint paint; | 245 SkPaint paint; |
| 228 gfx::ShadowValues shadow; | 246 gfx::ShadowValues shadow; |
| 229 shadow.emplace_back(gfx::Vector2d(0, kShadowOffsetY), kShadowBlur, | 247 shadow.emplace_back(gfx::Vector2d(0, kShadowOffsetY), kShadowBlur, |
| 230 kSeparatorColor); | 248 kSeparatorColor); |
| 231 paint.setLooper(gfx::CreateShadowDrawLooperCorrectBlur(shadow)); | 249 paint.setLooper(gfx::CreateShadowDrawLooperCorrectBlur(shadow)); |
| 232 paint.setAntiAlias(true); | 250 paint.setAntiAlias(true); |
| 233 canvas->ClipRect(shadowed_area, kDifference_SkClipOp); | 251 canvas->ClipRect(shadowed_area, kDifference_SkClipOp); |
| 234 canvas->DrawRect(shadowed_area, paint); | 252 canvas->DrawRect(shadowed_area, paint); |
| 235 } | 253 } |
| 236 | 254 |
| 255 // 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
| |
| 256 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.
| |
| 257 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
| |
| 258 DCHECK_EQ(parent_layer, view->layer()->parent()); | |
| 259 return view->layer(); | |
| 260 } | |
|
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
| |
| 261 // Iterate backwards through the children to find the topmost layer. | |
| 262 for (int i = view->child_count() - 1; i >= 0; --i) { | |
| 263 views::View* child = view->child_at(i); | |
| 264 ui::Layer* layer = TopmostLayer(child, parent_layer); | |
| 265 if (layer) | |
| 266 return layer; | |
| 267 } | |
| 268 return nullptr; | |
| 269 } | |
| 270 | |
| 237 views::BoxLayout* box_layout_; | 271 views::BoxLayout* box_layout_; |
| 238 | 272 |
| 239 // Header child views that stick to the top of visible viewport when scrolled. | 273 // Header child views that stick to the top of visible viewport when scrolled. |
| 240 std::vector<Header> headers_; | 274 std::vector<Header> headers_; |
| 241 | 275 |
| 242 DISALLOW_COPY_AND_ASSIGN(ScrollContentsView); | 276 DISALLOW_COPY_AND_ASSIGN(ScrollContentsView); |
| 243 }; | 277 }; |
| 244 | 278 |
| 245 // Constants for the title row in material design. | 279 // Constants for the title row in material design. |
| 246 const int kTitleRowVerticalPadding = 4; | 280 const int kTitleRowVerticalPadding = 4; |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 566 if (index < child_count() - 1 && child_at(index + 1) != title_row_) | 600 if (index < child_count() - 1 && child_at(index + 1) != title_row_) |
| 567 scroll_border_->set_visible(true); | 601 scroll_border_->set_visible(true); |
| 568 else | 602 else |
| 569 scroll_border_->set_visible(false); | 603 scroll_border_->set_visible(false); |
| 570 } | 604 } |
| 571 | 605 |
| 572 views::View::OnPaintBorder(canvas); | 606 views::View::OnPaintBorder(canvas); |
| 573 } | 607 } |
| 574 | 608 |
| 575 } // namespace ash | 609 } // namespace ash |
| OLD | NEW |