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

Unified Diff: ui/display/display_layout.cc

Issue 2814843007: Fix expected PlacementList sort order. (Closed)
Patch Set: Don't register invalid layouts Created 3 years, 8 months 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
Index: ui/display/display_layout.cc
diff --git a/ui/display/display_layout.cc b/ui/display/display_layout.cc
index 70784947b1c328a8203299dcc1557476a9d8820e..89b97194c26e76a840bf0db50457b5b0fb5dbdfc 100644
--- a/ui/display/display_layout.cc
+++ b/ui/display/display_layout.cc
@@ -39,7 +39,7 @@ bool IsIdInList(int64_t id, const DisplayIdList& list) {
}
bool ComparePlacements(const DisplayPlacement& d1, const DisplayPlacement& d2) {
- return d1.display_id < d2.display_id;
+ return CompareDisplayIds(d1.display_id, d2.display_id);
}
// Extracts the displays IDs list from the displays list.
@@ -535,14 +535,16 @@ bool DisplayLayout::Validate(const DisplayIdList& list,
return true;
bool has_primary_as_parent = false;
- int64_t prev_id = std::numeric_limits<int64_t>::min();
+ // The placement list must be sorted by the first 8 bits of the display IDs.
+ int64_t prev_id = std::numeric_limits<int8_t>::min();
for (const auto& placement : layout.placement_list) {
// Placements are sorted by display_id.
- if (prev_id >= placement.display_id) {
- LOG(ERROR) << "PlacementList must be sorted by display_id";
+ if (prev_id >= (placement.display_id & 0xFF)) {
+ LOG(ERROR) << "PlacementList must be sorted by first 8 bits of"
+ << " display_id ";
return false;
}
- prev_id = placement.display_id;
+ prev_id = (placement.display_id & 0xFF);
if (placement.display_id == kInvalidDisplayId) {
LOG(ERROR) << "display_id is not initialized";
return false;

Powered by Google App Engine
This is Rietveld 408576698