| 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 8112f8c98c307d38b375972dfef6f7b0a132e798..9b3eb4d05ad51c721f6c8d34133babd811180e73 100644
|
| --- a/third_party/WebKit/Source/core/editing/LayoutSelection.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/LayoutSelection.cpp
|
| @@ -186,6 +186,27 @@ static SelectedMap CollectSelectedMap(
|
| return selected_map;
|
| }
|
|
|
| +// Update the selection status of all LayoutObjects between |start| and |end|.
|
| +static void SetSelectionState(LayoutObject* start,
|
| + LayoutObject* end,
|
| + int end_pos) {
|
| + if (start && start == end) {
|
| + start->SetSelectionStateIfNeeded(SelectionBoth);
|
| + } else {
|
| + if (start)
|
| + start->SetSelectionStateIfNeeded(SelectionStart);
|
| + if (end)
|
| + end->SetSelectionStateIfNeeded(SelectionEnd);
|
| + }
|
| +
|
| + LayoutObject* const stop = LayoutObjectAfterPosition(end, end_pos);
|
| + for (LayoutObject* runner = start; runner && runner != stop;
|
| + runner = runner->NextInPreOrder()) {
|
| + if (runner != start && runner != end && runner->CanBeSelectionLeaf())
|
| + runner->SetSelectionStateIfNeeded(SelectionInside);
|
| + }
|
| +}
|
| +
|
| void LayoutSelection::SetSelection(
|
| LayoutObject* start,
|
| int start_pos,
|
| @@ -232,25 +253,7 @@ void LayoutSelection::SetSelection(
|
| selection_end_ = end;
|
| selection_end_pos_ = end_pos;
|
|
|
| - // Update the selection status of all objects between m_selectionStart and
|
| - // m_selectionEnd
|
| - if (start && start == end) {
|
| - start->SetSelectionStateIfNeeded(SelectionBoth);
|
| - } else {
|
| - if (start)
|
| - start->SetSelectionStateIfNeeded(SelectionStart);
|
| - if (end)
|
| - end->SetSelectionStateIfNeeded(SelectionEnd);
|
| - }
|
| -
|
| - LayoutObject* o = start;
|
| - LayoutObject* const stop = LayoutObjectAfterPosition(end, end_pos);
|
| -
|
| - while (o && o != stop) {
|
| - if (o != start && o != end && o->CanBeSelectionLeaf())
|
| - o->SetSelectionStateIfNeeded(SelectionInside);
|
| - o = o->NextInPreOrder();
|
| - }
|
| + SetSelectionState(start, end, end_pos);
|
|
|
| // Now that the selection state has been updated for the new objects, walk
|
| // them again and put them in the new objects list.
|
|
|