Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/display/manager/display_layout.h" | 5 #include "ui/display/manager/display_layout.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 bool DisplayLayout::Validate(const DisplayIdList& list, | 207 bool DisplayLayout::Validate(const DisplayIdList& list, |
| 208 const DisplayLayout& layout) { | 208 const DisplayLayout& layout) { |
| 209 // The primary display should be in the list. | 209 // The primary display should be in the list. |
| 210 DCHECK(IsIdInList(layout.primary_id, list)); | 210 DCHECK(IsIdInList(layout.primary_id, list)); |
| 211 | 211 |
| 212 // Unified mode, or mirror mode switched from unified mode, | 212 // Unified mode, or mirror mode switched from unified mode, |
| 213 // may not have the placement yet. | 213 // may not have the placement yet. |
| 214 if (layout.placement_list.size() == 0u) | 214 if (layout.placement_list.size() == 0u) |
| 215 return true; | 215 return true; |
| 216 | 216 |
| 217 // Placements are sorted by display_id. | |
| 218 if (!std::is_sorted(layout.placement_list.begin(), | |
| 219 layout.placement_list.end(), | |
| 220 [](const display::DisplayPlacement& d1, | |
| 221 const display::DisplayPlacement& d2) { | |
| 222 return d1.display_id < d2.display_id; | |
| 223 })) { | |
| 224 LOG(ERROR) << "PlacementList must be sorted by display_id"; | |
| 225 return false; | |
| 226 } | |
|
oshima
2016/11/22 21:47:18
do you need this?
afakhry
2016/11/22 22:16:21
Reverted to the old way and fixed its bug.
| |
| 227 | |
| 217 bool has_primary_as_parent = false; | 228 bool has_primary_as_parent = false; |
| 218 int64_t id = 0; | |
|
oshima
2016/11/22 21:47:18
this should have been std::numeric_limits<int64_t>
| |
| 219 | |
| 220 for (const auto& placement : layout.placement_list) { | 229 for (const auto& placement : layout.placement_list) { |
| 221 // Placements are sorted by display_id. | |
| 222 if (id >= placement.display_id) { | |
| 223 LOG(ERROR) << "PlacementList must be sorted by display_id"; | |
| 224 return false; | |
| 225 } | |
| 226 if (placement.display_id == kInvalidDisplayId) { | 230 if (placement.display_id == kInvalidDisplayId) { |
| 227 LOG(ERROR) << "display_id is not initialized"; | 231 LOG(ERROR) << "display_id is not initialized"; |
| 228 return false; | 232 return false; |
| 229 } | 233 } |
| 230 if (placement.parent_display_id == kInvalidDisplayId) { | 234 if (placement.parent_display_id == kInvalidDisplayId) { |
| 231 LOG(ERROR) << "display_parent_id is not initialized"; | 235 LOG(ERROR) << "display_parent_id is not initialized"; |
| 232 return false; | 236 return false; |
| 233 } | 237 } |
| 234 if (placement.display_id == placement.parent_display_id) { | 238 if (placement.display_id == placement.parent_display_id) { |
| 235 LOG(ERROR) << "display_id must not be same as parent_display_id"; | 239 LOG(ERROR) << "display_id must not be same as parent_display_id"; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 | 365 |
| 362 gfx::Insets insets = target_display->GetWorkAreaInsets(); | 366 gfx::Insets insets = target_display->GetWorkAreaInsets(); |
| 363 target_display->set_bounds( | 367 target_display->set_bounds( |
| 364 gfx::Rect(new_target_origin, target_bounds.size())); | 368 gfx::Rect(new_target_origin, target_bounds.size())); |
| 365 target_display->UpdateWorkAreaFromInsets(insets); | 369 target_display->UpdateWorkAreaFromInsets(insets); |
| 366 | 370 |
| 367 return old_bounds != target_display->bounds(); | 371 return old_bounds != target_display->bounds(); |
| 368 } | 372 } |
| 369 | 373 |
| 370 } // namespace display | 374 } // namespace display |
| OLD | NEW |