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

Unified Diff: third_party/WebKit/Source/core/editing/LayoutSelection.cpp

Issue 2882963002: Introduce MarkSetSelectionState() in LayoutSelection::SetSelection() (Closed)
Patch Set: update Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698