OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef COMPONENTS_MUS_COMMON_TRANSIENT_WINDOW_UTILS_H_ | 5 #ifndef COMPONENTS_MUS_COMMON_TRANSIENT_WINDOW_UTILS_H_ |
6 #define COMPONENTS_MUS_COMMON_TRANSIENT_WINDOW_UTILS_H_ | 6 #define COMPONENTS_MUS_COMMON_TRANSIENT_WINDOW_UTILS_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 T* stacking_target) { | 71 T* stacking_target) { |
72 if (stacking_target == *target) | 72 if (stacking_target == *target) |
73 return true; | 73 return true; |
74 | 74 |
75 // For windows that have transient children stack the transient ancestors that | 75 // For windows that have transient children stack the transient ancestors that |
76 // are siblings. This prevents one transient group from being inserted in the | 76 // are siblings. This prevents one transient group from being inserted in the |
77 // middle of another. | 77 // middle of another. |
78 FindCommonTransientAncestor(child, target); | 78 FindCommonTransientAncestor(child, target); |
79 | 79 |
80 // When stacking above skip to the topmost transient descendant of the target. | 80 // When stacking above skip to the topmost transient descendant of the target. |
81 if (*direction == mojom::ORDER_DIRECTION_ABOVE && | 81 if (*direction == mojom::OrderDirection::ABOVE && |
82 !HasTransientAncestor(*child, *target)) { | 82 !HasTransientAncestor(*child, *target)) { |
83 const std::vector<T*>& siblings((*child)->parent()->children()); | 83 const std::vector<T*>& siblings((*child)->parent()->children()); |
84 size_t target_i = | 84 size_t target_i = |
85 std::find(siblings.begin(), siblings.end(), *target) - siblings.begin(); | 85 std::find(siblings.begin(), siblings.end(), *target) - siblings.begin(); |
86 while (target_i + 1 < siblings.size() && | 86 while (target_i + 1 < siblings.size() && |
87 HasTransientAncestor(siblings[target_i + 1], *target)) { | 87 HasTransientAncestor(siblings[target_i + 1], *target)) { |
88 ++target_i; | 88 ++target_i; |
89 } | 89 } |
90 *target = siblings[target_i]; | 90 *target = siblings[target_i]; |
91 } | 91 } |
(...skipping 17 matching lines...) Expand all Loading... |
109 return; | 109 return; |
110 | 110 |
111 // stack any transient children that share the same parent to be in front of | 111 // stack any transient children that share the same parent to be in front of |
112 // |window_|. the existing stacking order is preserved by iterating backwards | 112 // |window_|. the existing stacking order is preserved by iterating backwards |
113 // and always stacking on top. | 113 // and always stacking on top. |
114 std::vector<T*> children(parent->children()); | 114 std::vector<T*> children(parent->children()); |
115 for (auto it = children.rbegin(); it != children.rend(); ++it) { | 115 for (auto it = children.rbegin(); it != children.rend(); ++it) { |
116 if ((*it) != window && HasTransientAncestor(*it, window)) { | 116 if ((*it) != window && HasTransientAncestor(*it, window)) { |
117 T* old_stacking_target = *GetStackingTarget(*it); | 117 T* old_stacking_target = *GetStackingTarget(*it); |
118 *GetStackingTarget(*it) = window; | 118 *GetStackingTarget(*it) = window; |
119 Reorder(*it, window, mojom::ORDER_DIRECTION_ABOVE); | 119 Reorder(*it, window, mojom::OrderDirection::ABOVE); |
120 *GetStackingTarget(*it) = old_stacking_target; | 120 *GetStackingTarget(*it) = old_stacking_target; |
121 } | 121 } |
122 } | 122 } |
123 } | 123 } |
124 } // namespace mus | 124 } // namespace mus |
125 | 125 |
126 #endif // COMPONENTS_MUS_COMMON_TRANSIENT_WINDOW_UTILS_H_ | 126 #endif // COMPONENTS_MUS_COMMON_TRANSIENT_WINDOW_UTILS_H_ |
OLD | NEW |