Index: third_party/WebKit/Source/core/editing/LayoutSelection.cpp |
diff --git a/third_party/WebKit/Source/core/editing/LayoutSelection.cpp b/third_party/WebKit/Source/core/editing/LayoutSelection.cpp |
index e6c1a3a727b033743767bf4665fcca75e6cd65b0..8552c70e914e2794db512071d18f2b267169f654 100644 |
--- a/third_party/WebKit/Source/core/editing/LayoutSelection.cpp |
+++ b/third_party/WebKit/Source/core/editing/LayoutSelection.cpp |
@@ -186,13 +186,7 @@ struct SelectedMap { |
DISALLOW_COPY_AND_ASSIGN(SelectedMap); |
}; |
-enum class CollectSelectedMapOption { |
- kCollectBlock, |
- kNotCollectBlock, |
-}; |
- |
-static SelectedMap CollectSelectedMap(const SelectionPaintRange& range, |
- CollectSelectedMapOption option) { |
+static SelectedMap CollectSelectedMap(const SelectionPaintRange& range) { |
if (range.IsNull()) |
return SelectedMap(); |
@@ -205,15 +199,14 @@ static SelectedMap CollectSelectedMap(const SelectionPaintRange& range, |
// Blocks are responsible for painting line gaps and margin gaps. They |
// must be examined as well. |
selected_map.object_map.Set(runner, runner->GetSelectionState()); |
- if (option == CollectSelectedMapOption::kCollectBlock) { |
- LayoutBlock* containing_block = runner->ContainingBlock(); |
- while (containing_block && !containing_block->IsLayoutView()) { |
- SelectedBlockMap::AddResult result = selected_map.block_map.insert( |
- containing_block, containing_block->GetSelectionState()); |
- if (!result.is_new_entry) |
- break; |
- containing_block = containing_block->ContainingBlock(); |
- } |
+ |
+ for (LayoutBlock* containing_block = runner->ContainingBlock(); |
+ containing_block && !containing_block->IsLayoutView(); |
+ containing_block = containing_block->ContainingBlock()) { |
+ SelectedBlockMap::AddResult result = selected_map.block_map.insert( |
+ containing_block, containing_block->GetSelectionState()); |
+ if (!result.is_new_entry) |
+ break; |
} |
} |
return selected_map; |
@@ -244,8 +237,7 @@ static void SetSelectionState(const SelectionPaintRange& range) { |
// comparing them in |new_range| and |old_range|. |
static void UpdateLayoutObjectState(const SelectionPaintRange& new_range, |
const SelectionPaintRange& old_range) { |
- SelectedMap old_selected_map = |
- CollectSelectedMap(old_range, CollectSelectedMapOption::kCollectBlock); |
+ SelectedMap old_selected_map = CollectSelectedMap(old_range); |
yosin_UTC9
2017/06/14 04:01:15
nit: s/SelectedMap/const SelectedMap&/
|
// Now clear the selection. |
for (auto layout_object : old_selected_map.object_map.Keys()) |
@@ -258,8 +250,7 @@ static void UpdateLayoutObjectState(const SelectionPaintRange& new_range, |
// TODO(editing-dev): |new_selected_map| doesn't really need to store the |
// SelectionState, it's just more convenient to have it use the same data |
// structure as |old_selected_map|. |
- SelectedMap new_selected_map = |
- CollectSelectedMap(new_range, CollectSelectedMapOption::kCollectBlock); |
+ SelectedMap new_selected_map = CollectSelectedMap(new_range); |
yosin_UTC9
2017/06/14 04:01:15
nit: s/SelectedMap/const SelectedMap&/
|
// Have any of the old selected objects changed compared to the new selection? |
for (const auto& pair : old_selected_map.object_map) { |
@@ -315,11 +306,7 @@ void LayoutSelection::ClearSelection() { |
if (paint_range_.IsNull()) |
return; |
- const SelectedMap& old_selected_map = CollectSelectedMap( |
- paint_range_, CollectSelectedMapOption::kNotCollectBlock); |
- // Clear SelectionState and invalidation. |
- // TODO(yoichio): Iterate with *this directrly. |
- for (auto layout_object : old_selected_map.object_map.Keys()) { |
+ for (auto layout_object : paint_range_) { |
const SelectionState old_state = layout_object->GetSelectionState(); |
layout_object->SetSelectionStateIfNeeded(SelectionState::kNone); |
if (layout_object->GetSelectionState() == old_state) |