diff options
author | robliao <robliao@chromium.org> | 2016-03-22 17:42:34 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-23 00:43:35 +0000 |
commit | df372032b408542d782c18cfc057ed729e46665a (patch) | |
tree | c79f8438f9f5e833ba245aa7e26f1e4341df7016 /ash | |
parent | d6541e3442ef1da8fe2490f0ac315047d5d8d336 (diff) | |
download | chromium_src-df372032b408542d782c18cfc057ed729e46665a.zip chromium_src-df372032b408542d782c18cfc057ed729e46665a.tar.gz chromium_src-df372032b408542d782c18cfc057ed729e46665a.tar.bz2 |
Convert ScopedVector<DisplayPlacement> to std::vector<DisplayPlacement>
Now that JSONValueConverter isn't used any more, we can use std::vector.
BUG=595498
Review URL: https://codereview.chromium.org/1819533002
Cr-Commit-Position: refs/heads/master@{#382748}
Diffstat (limited to 'ash')
-rw-r--r-- | ash/display/display_layout.cc | 55 | ||||
-rw-r--r-- | ash/display/display_layout.h | 11 | ||||
-rw-r--r-- | ash/display/display_layout_builder.cc | 18 | ||||
-rw-r--r-- | ash/display/display_layout_builder_unittest.cc | 36 | ||||
-rw-r--r-- | ash/display/display_layout_store.cc | 20 | ||||
-rw-r--r-- | ash/display/display_manager.cc | 10 | ||||
-rw-r--r-- | ash/display/display_manager_unittest.cc | 7 | ||||
-rw-r--r-- | ash/display/extended_mouse_warp_controller.cc | 8 | ||||
-rw-r--r-- | ash/display/extended_mouse_warp_controller_unittest.cc | 14 | ||||
-rw-r--r-- | ash/display/json_converter.cc | 27 | ||||
-rw-r--r-- | ash/display/json_converter_unittest.cc | 22 | ||||
-rw-r--r-- | ash/display/mouse_cursor_event_filter_unittest.cc | 6 | ||||
-rw-r--r-- | ash/display/screen_position_controller_unittest.cc | 2 | ||||
-rw-r--r-- | ash/display/window_tree_host_manager.cc | 2 | ||||
-rw-r--r-- | ash/display/window_tree_host_manager_unittest.cc | 4 | ||||
-rw-r--r-- | ash/extended_desktop_unittest.cc | 2 |
16 files changed, 120 insertions, 124 deletions
diff --git a/ash/display/display_layout.cc b/ash/display/display_layout.cc index 1897d76..1cc7b7f 100644 --- a/ash/display/display_layout.cc +++ b/ash/display/display_layout.cc @@ -48,12 +48,6 @@ DisplayPlacement::DisplayPlacement() position(DisplayPlacement::RIGHT), offset(0) {} -DisplayPlacement::DisplayPlacement(const DisplayPlacement& placement) - : display_id(placement.display_id), - parent_display_id(placement.parent_display_id), - position(placement.position), - offset(placement.offset) {} - DisplayPlacement::DisplayPlacement(Position pos, int offset) : display_id(gfx::Display::kInvalidDisplayID), parent_display_id(gfx::Display::kInvalidDisplayID), @@ -69,6 +63,12 @@ DisplayPlacement::DisplayPlacement(Position pos, int offset) DCHECK_GE(kMaxValidOffset, abs(offset)); } +DisplayPlacement::DisplayPlacement(const DisplayPlacement& placement) + : display_id(placement.display_id), + parent_display_id(placement.parent_display_id), + position(placement.position), + offset(placement.offset) {} + DisplayPlacement& DisplayPlacement::Swap() { switch (position) { case TOP: @@ -167,36 +167,35 @@ bool DisplayLayout::Validate(const DisplayIdList& list, bool has_primary_as_parent = false; int64_t id = 0; - for (const auto* placement : layout.placement_list) { + for (const auto& placement : layout.placement_list) { // Placements are sorted by display_id. - if (id >= placement->display_id) { + if (id >= placement.display_id) { LOG(ERROR) << "PlacementList must be sorted by display_id"; return false; } - if (placement->display_id == gfx::Display::kInvalidDisplayID) { + if (placement.display_id == gfx::Display::kInvalidDisplayID) { LOG(ERROR) << "display_id is not initialized"; return false; } - if (placement->parent_display_id == gfx::Display::kInvalidDisplayID) { + if (placement.parent_display_id == gfx::Display::kInvalidDisplayID) { LOG(ERROR) << "display_parent_id is not initialized"; return false; } - if (placement->display_id == placement->parent_display_id) { + if (placement.display_id == placement.parent_display_id) { LOG(ERROR) << "display_id must not be same as parent_display_id"; return false; } - if (!IsIdInList(placement->display_id, list)) { - LOG(ERROR) << "display_id is not in the id list:" - << placement->ToString(); + if (!IsIdInList(placement.display_id, list)) { + LOG(ERROR) << "display_id is not in the id list:" << placement.ToString(); return false; } - if (!IsIdInList(placement->parent_display_id, list)) { + if (!IsIdInList(placement.parent_display_id, list)) { LOG(ERROR) << "parent_display_id is not in the id list:" - << placement->ToString(); + << placement.ToString(); return false; } - has_primary_as_parent |= layout.primary_id == placement->parent_display_id; + has_primary_as_parent |= layout.primary_id == placement.parent_display_id; } if (!has_primary_as_parent) LOG(ERROR) << "At least, one placement must have the primary as a parent."; @@ -205,8 +204,8 @@ bool DisplayLayout::Validate(const DisplayIdList& list, scoped_ptr<DisplayLayout> DisplayLayout::Copy() const { scoped_ptr<DisplayLayout> copy(new DisplayLayout); - for (auto placement : placement_list) - copy->placement_list.push_back(new DisplayPlacement(*placement)); + for (const auto& placement : placement_list) + copy->placement_list.push_back(placement); copy->mirrored = mirrored; copy->default_unified = default_unified; copy->primary_id = primary_id; @@ -217,8 +216,8 @@ bool DisplayLayout::HasSamePlacementList(const DisplayLayout& layout) const { if (placement_list.size() != layout.placement_list.size()) return false; for (size_t index = 0; index < placement_list.size(); index++) { - const DisplayPlacement& placement1 = *placement_list[index]; - const DisplayPlacement& placement2 = *layout.placement_list[index]; + const DisplayPlacement& placement1 = placement_list[index]; + const DisplayPlacement& placement2 = layout.placement_list[index]; if (placement1.position != placement2.position || placement1.offset != placement2.offset || placement1.display_id != placement2.display_id || @@ -237,9 +236,9 @@ std::string DisplayLayout::ToString() const { if (default_unified) s << ", default_unified"; bool added = false; - for (const auto* placement : placement_list) { + for (const auto& placement : placement_list) { s << (added ? "),(" : " [("); - s << placement->ToString(); + s << placement.ToString(); added = true; } if (added) @@ -247,14 +246,14 @@ std::string DisplayLayout::ToString() const { return s.str(); } -const DisplayPlacement* DisplayLayout::FindPlacementById( - int64_t display_id) const { +DisplayPlacement DisplayLayout::FindPlacementById(int64_t display_id) const { const auto iter = std::find_if(placement_list.begin(), placement_list.end(), - [display_id](const DisplayPlacement* placement) { - return placement->display_id == display_id; + [display_id](const DisplayPlacement& placement) { + return placement.display_id == display_id; }); - return (iter == placement_list.end()) ? nullptr : *iter; + return (iter == placement_list.end()) ? DisplayPlacement() + : DisplayPlacement(*iter); } } // namespace ash diff --git a/ash/display/display_layout.h b/ash/display/display_layout.h index 136360b..fd05613 100644 --- a/ash/display/display_layout.h +++ b/ash/display/display_layout.h @@ -13,7 +13,6 @@ #include "ash/ash_export.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" -#include "base/memory/scoped_vector.h" #include "base/strings/string_piece.h" namespace base { @@ -61,9 +60,9 @@ struct ASH_EXPORT DisplayPlacement { // based on the top/left edge of the primary display. int offset; - explicit DisplayPlacement(const DisplayPlacement& placement); DisplayPlacement(Position position, int offset); DisplayPlacement(); + DisplayPlacement(const DisplayPlacement& placement); DisplayPlacement& Swap(); @@ -82,7 +81,7 @@ class ASH_EXPORT DisplayLayout final { // Validates the layout object. static bool Validate(const DisplayIdList& list, const DisplayLayout& layout); - ScopedVector<DisplayPlacement> placement_list; + std::vector<DisplayPlacement> placement_list; // True if displays are mirrored. bool mirrored; @@ -102,9 +101,9 @@ class ASH_EXPORT DisplayLayout final { // Returns string representation of the layout for debugging/testing. std::string ToString() const; - // Returns the DisplayPlacement entry in |placement_list| matching - // |display_id| if it exists, otherwise returns nullptr. - const DisplayPlacement* FindPlacementById(int64_t display_id) const; + // Returns the DisplayPlacement entry matching |display_id| if it exists, + // otherwise returns a DisplayPlacement with an invalid display id. + DisplayPlacement FindPlacementById(int64_t display_id) const; private: DISALLOW_COPY_AND_ASSIGN(DisplayLayout); diff --git a/ash/display/display_layout_builder.cc b/ash/display/display_layout_builder.cc index 6a1919d..579337f 100644 --- a/ash/display/display_layout_builder.cc +++ b/ash/display/display_layout_builder.cc @@ -4,6 +4,8 @@ #include "ash/display/display_layout_builder.h" +#include <algorithm> + namespace ash { DisplayLayoutBuilder::DisplayLayoutBuilder(const DisplayLayout& layout) @@ -37,12 +39,12 @@ DisplayLayoutBuilder& DisplayLayoutBuilder::AddDisplayPlacement( int64_t parent_display_id, DisplayPlacement::Position position, int offset) { - scoped_ptr<DisplayPlacement> placement(new DisplayPlacement); - placement->position = position; - placement->offset = offset; - placement->display_id = display_id; - placement->parent_display_id = parent_display_id; - layout_->placement_list.push_back(std::move(placement)); + DisplayPlacement placement; + placement.position = position; + placement.offset = offset; + placement.display_id = display_id; + placement.parent_display_id = parent_display_id; + layout_->placement_list.push_back(placement); return *this; } @@ -57,8 +59,8 @@ DisplayLayoutBuilder& DisplayLayoutBuilder::SetSecondaryPlacement( scoped_ptr<DisplayLayout> DisplayLayoutBuilder::Build() { std::sort(layout_->placement_list.begin(), layout_->placement_list.end(), - [](const DisplayPlacement* a, const DisplayPlacement* b) { - return a->display_id < b->display_id; + [](const DisplayPlacement& a, const DisplayPlacement& b) { + return a.display_id < b.display_id; }); return std::move(layout_); } diff --git a/ash/display/display_layout_builder_unittest.cc b/ash/display/display_layout_builder_unittest.cc index 91232052..159790c 100644 --- a/ash/display/display_layout_builder_unittest.cc +++ b/ash/display/display_layout_builder_unittest.cc @@ -16,10 +16,10 @@ TEST_F(DisplayLayoutBuilderTest, SecondaryPlacement) { scoped_ptr<DisplayLayout> layout(builder.Build()); ASSERT_EQ(1u, layout->placement_list.size()); - EXPECT_EQ(2, layout->placement_list[0]->display_id); - EXPECT_EQ(1, layout->placement_list[0]->parent_display_id); - EXPECT_EQ(30, layout->placement_list[0]->offset); - EXPECT_EQ(DisplayPlacement::LEFT, layout->placement_list[0]->position); + EXPECT_EQ(2, layout->placement_list[0].display_id); + EXPECT_EQ(1, layout->placement_list[0].parent_display_id); + EXPECT_EQ(30, layout->placement_list[0].offset); + EXPECT_EQ(DisplayPlacement::LEFT, layout->placement_list[0].position); } TEST_F(DisplayLayoutBuilderTest, MultiplePlacement) { @@ -32,20 +32,20 @@ TEST_F(DisplayLayoutBuilderTest, MultiplePlacement) { ASSERT_EQ(3u, layout->placement_list.size()); // placmenets are sorted by display_id. - EXPECT_EQ(3, layout->placement_list[0]->display_id); - EXPECT_EQ(5, layout->placement_list[0]->parent_display_id); - EXPECT_EQ(20, layout->placement_list[0]->offset); - EXPECT_EQ(DisplayPlacement::LEFT, layout->placement_list[0]->position); - - EXPECT_EQ(4, layout->placement_list[1]->display_id); - EXPECT_EQ(5, layout->placement_list[1]->parent_display_id); - EXPECT_EQ(10, layout->placement_list[1]->offset); - EXPECT_EQ(DisplayPlacement::RIGHT, layout->placement_list[1]->position); - - EXPECT_EQ(5, layout->placement_list[2]->display_id); - EXPECT_EQ(1, layout->placement_list[2]->parent_display_id); - EXPECT_EQ(30, layout->placement_list[2]->offset); - EXPECT_EQ(DisplayPlacement::TOP, layout->placement_list[2]->position); + EXPECT_EQ(3, layout->placement_list[0].display_id); + EXPECT_EQ(5, layout->placement_list[0].parent_display_id); + EXPECT_EQ(20, layout->placement_list[0].offset); + EXPECT_EQ(DisplayPlacement::LEFT, layout->placement_list[0].position); + + EXPECT_EQ(4, layout->placement_list[1].display_id); + EXPECT_EQ(5, layout->placement_list[1].parent_display_id); + EXPECT_EQ(10, layout->placement_list[1].offset); + EXPECT_EQ(DisplayPlacement::RIGHT, layout->placement_list[1].position); + + EXPECT_EQ(5, layout->placement_list[2].display_id); + EXPECT_EQ(1, layout->placement_list[2].parent_display_id); + EXPECT_EQ(30, layout->placement_list[2].offset); + EXPECT_EQ(DisplayPlacement::TOP, layout->placement_list[2].position); } } // namespace ash diff --git a/ash/display/display_layout_store.cc b/ash/display/display_layout_store.cc index b78bf98..1deb3a4 100644 --- a/ash/display/display_layout_store.cc +++ b/ash/display/display_layout_store.cc @@ -58,14 +58,13 @@ void DisplayLayoutStore::RegisterLayoutForDisplayIdList( // Old data may not have the display_id/parent_display_id. // Guess these values based on the saved primary_id. if (layout->placement_list.size() >= 1 && - layout->placement_list[0]->display_id == - gfx::Display::kInvalidDisplayID) { + layout->placement_list[0].display_id == gfx::Display::kInvalidDisplayID) { if (layout->primary_id == list[1]) { - layout->placement_list[0]->display_id = list[0]; - layout->placement_list[0]->parent_display_id = list[1]; + layout->placement_list[0].display_id = list[0]; + layout->placement_list[0].parent_display_id = list[1]; } else { - layout->placement_list[0]->display_id = list[1]; - layout->placement_list[0]->parent_display_id = list[0]; + layout->placement_list[0].display_id = list[1]; + layout->placement_list[0].parent_display_id = list[0]; } } DCHECK(DisplayLayout::Validate(list, *layout.get())) << layout->ToString(); @@ -102,11 +101,10 @@ DisplayLayout* DisplayLayoutStore::CreateDefaultDisplayLayout( layout->primary_id = list[0]; layout->placement_list.clear(); for (size_t i = 0; i < list.size() - 1; i++) { - scoped_ptr<DisplayPlacement> placement( - new DisplayPlacement(default_display_placement_)); - placement->display_id = list[i + 1]; - placement->parent_display_id = list[i]; - layout->placement_list.push_back(std::move(placement)); + DisplayPlacement placement(default_display_placement_); + placement.display_id = list[i + 1]; + placement.parent_display_id = list[i]; + layout->placement_list.push_back(placement); } layouts_[list] = std::move(layout); auto iter = layouts_.find(list); diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc index 25dfc06..06f956c 100644 --- a/ash/display/display_manager.cc +++ b/ash/display/display_manager.cc @@ -1326,11 +1326,11 @@ void DisplayManager::ApplyDisplayLayout(const DisplayLayout& layout, while (parents.size()) { int64_t parent_id = *parents.begin(); parents.erase(parent_id); - for (const DisplayPlacement* placement : layout.placement_list) { - if (placement->parent_display_id == parent_id) { - if (ApplyDisplayPlacement(*placement, display_list) && updated_ids) - updated_ids->push_back(placement->display_id); - parents.insert(placement->display_id); + for (const DisplayPlacement& placement : layout.placement_list) { + if (placement.parent_display_id == parent_id) { + if (ApplyDisplayPlacement(placement, display_list) && updated_ids) + updated_ids->push_back(placement.display_id); + parents.insert(placement.display_id); } } } diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc index 3424058..9be39e9 100644 --- a/ash/display/display_manager_unittest.cc +++ b/ash/display/display_manager_unittest.cc @@ -2203,8 +2203,7 @@ TEST_F(DisplayManagerTest, GuessDisplayIdFieldsInDisplayLayout) { int64_t id2 = 10002; scoped_ptr<DisplayLayout> old_layout(new DisplayLayout); - old_layout->placement_list.push_back( - new DisplayPlacement(DisplayPlacement::BOTTOM, 0)); + old_layout->placement_list.emplace_back(DisplayPlacement::BOTTOM, 0); old_layout->primary_id = id1; DisplayLayoutStore* layout_store = display_manager()->layout_store(); @@ -2212,8 +2211,8 @@ TEST_F(DisplayManagerTest, GuessDisplayIdFieldsInDisplayLayout) { layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout)); const DisplayLayout& stored = layout_store->GetRegisteredDisplayLayout(list); - EXPECT_EQ(id1, stored.placement_list[0]->parent_display_id); - EXPECT_EQ(id2, stored.placement_list[0]->display_id); + EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); + EXPECT_EQ(id2, stored.placement_list[0].display_id); } #endif // OS_CHROMEOS diff --git a/ash/display/extended_mouse_warp_controller.cc b/ash/display/extended_mouse_warp_controller.cc index 9fe1254..879b04b 100644 --- a/ash/display/extended_mouse_warp_controller.cc +++ b/ash/display/extended_mouse_warp_controller.cc @@ -80,13 +80,13 @@ ExtendedMouseWarpController::ExtendedMouseWarpController( Shell::GetInstance()->display_manager(); // TODO(oshima): Use ComputeBondary instead and try all combinations. - for (const auto* placement : + for (const auto& placement : display_manager->GetCurrentDisplayLayout().placement_list) { - DisplayPlacement::Position position = placement->position; + DisplayPlacement::Position position = placement.position; const gfx::Display& a = - display_manager->GetDisplayForId(placement->parent_display_id); + display_manager->GetDisplayForId(placement.parent_display_id); const gfx::Display& b = - display_manager->GetDisplayForId(placement->display_id); + display_manager->GetDisplayForId(placement.display_id); if (position == DisplayPlacement::TOP || position == DisplayPlacement::BOTTOM) { diff --git a/ash/display/extended_mouse_warp_controller_unittest.cc b/ash/display/extended_mouse_warp_controller_unittest.cc index 8709620..13f5e02 100644 --- a/ash/display/extended_mouse_warp_controller_unittest.cc +++ b/ash/display/extended_mouse_warp_controller_unittest.cc @@ -61,7 +61,7 @@ TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnRight) { mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds()); // Move 2nd display downwards a bit. - layout->placement_list[0]->offset = 5; + layout->placement_list[0].offset = 5; display_manager->SetLayoutForCurrentDisplays(layout->Copy()); event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); // This is same as before because the 2nd display's y is above @@ -79,7 +79,7 @@ TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnRight) { // Move it down further so that the shared edge is shorter than // minimum hole size (160). - layout->placement_list[0]->offset = 200; + layout->placement_list[0].offset = 200; display_manager->SetLayoutForCurrentDisplays(layout->Copy()); event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size()); @@ -95,7 +95,7 @@ TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnRight) { mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds()); // Now move 2nd display upwards - layout->placement_list[0]->offset = -5; + layout->placement_list[0].offset = -5; display_manager->SetLayoutForCurrentDisplays(layout->Copy()); event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size()); @@ -139,7 +139,7 @@ TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnLeft) { EXPECT_EQ(gfx::Rect(0, 0, 1, 360), mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds()); - layout->placement_list[0]->offset = 250; + layout->placement_list[0].offset = 250; display_manager->SetLayoutForCurrentDisplays(layout->Copy()); event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size()); @@ -180,7 +180,7 @@ TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnTopBottom) { EXPECT_EQ(gfx::Rect(0, 0, 360, 1), mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds()); - layout->placement_list[0]->offset = 250; + layout->placement_list[0].offset = 250; display_manager->SetLayoutForCurrentDisplays(layout->Copy()); event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size()); @@ -195,8 +195,8 @@ TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnTopBottom) { EXPECT_EQ(gfx::Rect(250, 0, 110, 1), mouse_warp_controller()->warp_regions_[0]->b_indicator_bounds()); - layout->placement_list[0]->position = DisplayPlacement::BOTTOM; - layout->placement_list[0]->offset = 0; + layout->placement_list[0].position = DisplayPlacement::BOTTOM; + layout->placement_list[0].offset = 0; display_manager->SetLayoutForCurrentDisplays(layout->Copy()); event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); ASSERT_EQ(1U, mouse_warp_controller()->warp_regions_.size()); diff --git a/ash/display/json_converter.cc b/ash/display/json_converter.cc index 91017b6..63a7efe 100644 --- a/ash/display/json_converter.cc +++ b/ash/display/json_converter.cc @@ -9,7 +9,6 @@ #include "ash/display/display_layout.h" #include "ash/display/display_pref_util.h" #include "base/logging.h" -#include "base/memory/scoped_vector.h" #include "base/strings/string_number_conversions.h" #include "base/values.h" @@ -40,7 +39,7 @@ bool AddLegacyValuesFromValue(const base::Value& value, DisplayLayout* layout) { if (!dict_value->GetString(kPositionKey, &position_str)) return false; DisplayPlacement::StringToPosition(position_str, &position); - layout->placement_list.push_back(new DisplayPlacement(position, offset)); + layout->placement_list.emplace_back(position, offset); } return true; } @@ -112,7 +111,7 @@ bool UpdateFromDict(const base::DictionaryValue* dict_value, template <> bool UpdateFromDict(const base::DictionaryValue* dict_value, const std::string& field_name, - ScopedVector<DisplayPlacement>* output) { + std::vector<DisplayPlacement>* output) { bool (base::Value::*getter)(const base::ListValue**) const = &base::Value::GetAsList; const base::ListValue* list = nullptr; @@ -128,17 +127,17 @@ bool UpdateFromDict(const base::DictionaryValue* dict_value, if (!list_item->GetAsDictionary(&item_values)) return false; - scoped_ptr<DisplayPlacement> item(new DisplayPlacement); - if (!UpdateFromDict(item_values, kOffsetKey, &item->offset) || - !UpdateFromDict(item_values, kPositionKey, &item->position) || + DisplayPlacement item; + if (!UpdateFromDict(item_values, kOffsetKey, &item.offset) || + !UpdateFromDict(item_values, kPositionKey, &item.position) || !UpdateFromDict(item_values, kDisplayPlacementDisplayIdKey, - &item->display_id) || + &item.display_id) || !UpdateFromDict(item_values, kDisplayPlacementParentDisplayIdKey, - &item->parent_display_id)) { + &item.parent_display_id)) { return false; } - output->push_back(std::move(item)); + output->push_back(item); } return true; } @@ -177,17 +176,17 @@ bool DisplayLayoutToJson(const DisplayLayout& layout, base::Value* value) { dict_value->SetString(kPrimaryIdKey, base::Int64ToString(layout.primary_id)); scoped_ptr<base::ListValue> placement_list(new base::ListValue); - for (const auto* placement : layout.placement_list) { + for (const auto& placement : layout.placement_list) { scoped_ptr<base::DictionaryValue> placement_value( new base::DictionaryValue); placement_value->SetString( - kPositionKey, DisplayPlacement::PositionToString(placement->position)); - placement_value->SetInteger(kOffsetKey, placement->offset); + kPositionKey, DisplayPlacement::PositionToString(placement.position)); + placement_value->SetInteger(kOffsetKey, placement.offset); placement_value->SetString(kDisplayPlacementDisplayIdKey, - base::Int64ToString(placement->display_id)); + base::Int64ToString(placement.display_id)); placement_value->SetString( kDisplayPlacementParentDisplayIdKey, - base::Int64ToString(placement->parent_display_id)); + base::Int64ToString(placement.parent_display_id)); placement_list->Append(std::move(placement_value)); } dict_value->Set(kDisplayPlacementKey, std::move(placement_list)); diff --git a/ash/display/json_converter_unittest.cc b/ash/display/json_converter_unittest.cc index 3c964d0..0ac13d8 100644 --- a/ash/display/json_converter_unittest.cc +++ b/ash/display/json_converter_unittest.cc @@ -16,16 +16,16 @@ TEST(JsonConverterTest, JsonFromToDisplayLayout) { layout.primary_id = 1; layout.mirrored = true; layout.default_unified = false; - layout.placement_list.push_back(new DisplayPlacement); - layout.placement_list.push_back(new DisplayPlacement); - layout.placement_list[0]->display_id = 2; - layout.placement_list[0]->parent_display_id = 1; - layout.placement_list[0]->position = DisplayPlacement::BOTTOM; + layout.placement_list.push_back(DisplayPlacement()); + layout.placement_list.push_back(DisplayPlacement()); + layout.placement_list[0].display_id = 2; + layout.placement_list[0].parent_display_id = 1; + layout.placement_list[0].position = DisplayPlacement::BOTTOM; - layout.placement_list[1]->display_id = 3; - layout.placement_list[1]->parent_display_id = 2; - layout.placement_list[1]->position = DisplayPlacement::LEFT; - layout.placement_list[1]->offset = 30; + layout.placement_list[1].display_id = 3; + layout.placement_list[1].parent_display_id = 2; + layout.placement_list[1].position = DisplayPlacement::LEFT; + layout.placement_list[1].offset = 30; base::DictionaryValue value; DisplayLayoutToJson(layout, &value); @@ -85,8 +85,8 @@ TEST(JsonConverterTest, OldJsonToDisplayLayout) { EXPECT_EQ(1, read_layout.primary_id); EXPECT_EQ(false, read_layout.default_unified); ASSERT_EQ(1u, read_layout.placement_list.size()); - EXPECT_EQ(DisplayPlacement::BOTTOM, read_layout.placement_list[0]->position); - EXPECT_EQ(20, read_layout.placement_list[0]->offset); + EXPECT_EQ(DisplayPlacement::BOTTOM, read_layout.placement_list[0].position); + EXPECT_EQ(20, read_layout.placement_list[0].offset); } } // namespace ash diff --git a/ash/display/mouse_cursor_event_filter_unittest.cc b/ash/display/mouse_cursor_event_filter_unittest.cc index fb0e586..0842c69 100644 --- a/ash/display/mouse_cursor_event_filter_unittest.cc +++ b/ash/display/mouse_cursor_event_filter_unittest.cc @@ -46,7 +46,7 @@ TEST_F(MouseCursorEventFilterTest, WarpMouse) { ->display_manager() ->GetCurrentDisplayLayout() .placement_list[0] - ->position); + .position); EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(11, 11))); @@ -86,7 +86,7 @@ TEST_F(MouseCursorEventFilterTest, WarpMouseDifferentSizeDisplays) { ->display_manager() ->GetCurrentDisplayLayout() .placement_list[0] - ->position); + .position); // Touch the left edge of the secondary root window. Pointer should NOT warp // because 1px left of (0, 500) is outside the primary root window. @@ -114,7 +114,7 @@ TEST_F(MouseCursorEventFilterTest, WarpMouseDifferentScaleDisplaysInNative) { ->display_manager() ->GetCurrentDisplayLayout() .placement_list[0] - ->position); + .position); aura::Env::GetInstance()->set_last_mouse_location(gfx::Point(900, 123)); diff --git a/ash/display/screen_position_controller_unittest.cc b/ash/display/screen_position_controller_unittest.cc index 20120b5..333379c 100644 --- a/ash/display/screen_position_controller_unittest.cc +++ b/ash/display/screen_position_controller_unittest.cc @@ -46,7 +46,7 @@ void SetSecondaryDisplayLayout(DisplayPlacement::Position position) { ->display_manager() ->GetCurrentDisplayLayout() .Copy()); - layout->placement_list[0]->position = position; + layout->placement_list[0].position = position; Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( std::move(layout)); } diff --git a/ash/display/window_tree_host_manager.cc b/ash/display/window_tree_host_manager.cc index 13e143b..b24022e 100644 --- a/ash/display/window_tree_host_manager.cc +++ b/ash/display/window_tree_host_manager.cc @@ -445,7 +445,7 @@ void WindowTreeHostManager::SetPrimaryDisplayId(int64_t id) { // Only update the layout if it is requested to swap primary display. if (layout.primary_id != new_primary_display.id()) { scoped_ptr<DisplayLayout> swapped_layout(layout.Copy()); - swapped_layout->placement_list[0]->Swap(); + swapped_layout->placement_list[0].Swap(); swapped_layout->primary_id = new_primary_display.id(); DisplayIdList list = display_manager->GetCurrentDisplayIdList(); GetDisplayManager()->layout_store()->RegisterLayoutForDisplayIdList( diff --git a/ash/display/window_tree_host_manager_unittest.cc b/ash/display/window_tree_host_manager_unittest.cc index eb01743..0fdcb58 100644 --- a/ash/display/window_tree_host_manager_unittest.cc +++ b/ash/display/window_tree_host_manager_unittest.cc @@ -807,7 +807,7 @@ TEST_F(WindowTreeHostManagerTest, SwapPrimaryById) { EXPECT_EQ("200,0 300x253", secondary_display.work_area().ToString()); EXPECT_EQ( "id=2200000001, parent=2200000000, right, 50", - display_manager->GetCurrentDisplayLayout().placement_list[0]->ToString()); + display_manager->GetCurrentDisplayLayout().placement_list[0].ToString()); // Switch primary and secondary by display ID. TestObserver observer; @@ -828,7 +828,7 @@ TEST_F(WindowTreeHostManagerTest, SwapPrimaryById) { display_manager->GetCurrentDisplayLayout(); EXPECT_EQ("id=2200000000, parent=2200000001, left, -50", - inverted_layout.placement_list[0]->ToString()); + inverted_layout.placement_list[0].ToString()); // Test if the bounds are correctly swapped. gfx::Display swapped_primary = gfx::Screen::GetScreen()->GetPrimaryDisplay(); gfx::Display swapped_secondary = ScreenUtil::GetSecondaryDisplay(); diff --git a/ash/extended_desktop_unittest.cc b/ash/extended_desktop_unittest.cc index d4fc79b..035e925 100644 --- a/ash/extended_desktop_unittest.cc +++ b/ash/extended_desktop_unittest.cc @@ -36,7 +36,7 @@ namespace { void SetSecondaryDisplayLayout(DisplayPlacement::Position position) { scoped_ptr<DisplayLayout> layout = Shell::GetInstance()->display_manager()->GetCurrentDisplayLayout().Copy(); - layout->placement_list[0]->position = position; + layout->placement_list[0].position = position; Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( std::move(layout)); } |