Chromium Code Reviews| Index: ui/display/manager/display_layout.cc |
| diff --git a/ui/display/manager/display_layout.cc b/ui/display/manager/display_layout.cc |
| index 25660de1af10c97f7f99a28c95d5557570c6a1ab..d3a08fe6297de8bf37f1be2a1beed10bc1d4cd80 100644 |
| --- a/ui/display/manager/display_layout.cc |
| +++ b/ui/display/manager/display_layout.cc |
| @@ -214,15 +214,19 @@ bool DisplayLayout::Validate(const DisplayIdList& list, |
| if (layout.placement_list.size() == 0u) |
| return true; |
| - bool has_primary_as_parent = false; |
| - int64_t id = 0; |
|
oshima
2016/11/22 21:47:18
this should have been std::numeric_limits<int64_t>
|
| + // Placements are sorted by display_id. |
| + if (!std::is_sorted(layout.placement_list.begin(), |
| + layout.placement_list.end(), |
| + [](const display::DisplayPlacement& d1, |
| + const display::DisplayPlacement& d2) { |
| + return d1.display_id < d2.display_id; |
| + })) { |
| + LOG(ERROR) << "PlacementList must be sorted by display_id"; |
| + return false; |
| + } |
|
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.
|
| + bool has_primary_as_parent = false; |
| for (const auto& placement : layout.placement_list) { |
| - // Placements are sorted by display_id. |
| - if (id >= placement.display_id) { |
| - LOG(ERROR) << "PlacementList must be sorted by display_id"; |
| - return false; |
| - } |
| if (placement.display_id == kInvalidDisplayId) { |
| LOG(ERROR) << "display_id is not initialized"; |
| return false; |