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

Side by Side Diff: ui/display/manager/display_layout_store.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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 if (layout->placement_list.size() >= 1 && 65 if (layout->placement_list.size() >= 1 &&
66 layout->placement_list[0].display_id == kInvalidDisplayId) { 66 layout->placement_list[0].display_id == kInvalidDisplayId) {
67 if (layout->primary_id == list[1]) { 67 if (layout->primary_id == list[1]) {
68 layout->placement_list[0].display_id = list[0]; 68 layout->placement_list[0].display_id = list[0];
69 layout->placement_list[0].parent_display_id = list[1]; 69 layout->placement_list[0].parent_display_id = list[1];
70 } else { 70 } else {
71 layout->placement_list[0].display_id = list[1]; 71 layout->placement_list[0].display_id = list[1];
72 layout->placement_list[0].parent_display_id = list[0]; 72 layout->placement_list[0].parent_display_id = list[0];
73 } 73 }
74 } 74 }
75 DCHECK(DisplayLayout::Validate(list, *layout.get())) 75
76 << "ids=" << DisplayIdListToString(list) 76 if (!DisplayLayout::Validate(list, *layout.get())) {
77 << ", layout=" << layout->ToString(); 77 NOTREACHED() << "Attempting to register an invalid layout: ids="
78 << DisplayIdListToString(list)
79 << ", layout=" << layout->ToString();
80 // We never allow to register an invalid layout, instead, we revert back to
81 // a default layout.
82 CreateDefaultDisplayLayout(list);
83 return;
84 }
85
78 layouts_[list] = std::move(layout); 86 layouts_[list] = std::move(layout);
79 } 87 }
80 88
81 const DisplayLayout& DisplayLayoutStore::GetRegisteredDisplayLayout( 89 const DisplayLayout& DisplayLayoutStore::GetRegisteredDisplayLayout(
82 const DisplayIdList& list) { 90 const DisplayIdList& list) {
83 DCHECK_NE(1u, list.size()); 91 DCHECK_NE(1u, list.size());
84 const auto iter = layouts_.find(list); 92 const auto iter = layouts_.find(list);
85 const DisplayLayout* layout = iter != layouts_.end() 93 const DisplayLayout* layout = iter != layouts_.end()
86 ? iter->second.get() 94 ? iter->second.get()
87 : CreateDefaultDisplayLayout(list); 95 : CreateDefaultDisplayLayout(list);
(...skipping 24 matching lines...) Expand all
112 placement.display_id = list[i + 1]; 120 placement.display_id = list[i + 1];
113 placement.parent_display_id = list[i]; 121 placement.parent_display_id = list[i];
114 layout->placement_list.push_back(placement); 122 layout->placement_list.push_back(placement);
115 } 123 }
116 layouts_[list] = std::move(layout); 124 layouts_[list] = std::move(layout);
117 auto iter = layouts_.find(list); 125 auto iter = layouts_.find(list);
118 return iter->second.get(); 126 return iter->second.get();
119 } 127 }
120 128
121 } // namespace display 129 } // namespace display
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698