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

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

Issue 2437873008: Get rid of flat tree version of createVisibleSelection() taking two VisiblePosition (Closed)
Patch Set: 2016-10-24T13:35:49 Created 4 years, 2 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
Index: third_party/WebKit/Source/core/editing/EditingUtilities.cpp
diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
index 113b1f17c14fe76c9acb0cc4b85ce7cdfd37cfd0..7c250f89f2bdc925909e8aacc584568dc1cc4931 100644
--- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
+++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
@@ -1789,10 +1789,22 @@ VisibleSelection selectionForParagraphIteration(
// we'll want modify is the last one inside the table, not the table itself (a
// table is itself a paragraph).
if (Element* table = tableElementJustBefore(endOfSelection)) {
- if (startOfSelection.deepEquivalent().anchorNode()->isDescendantOf(table))
- newSelection = createVisibleSelection(
- startOfSelection,
- previousPositionOf(endOfSelection, CannotCrossEditingBoundary));
+ if (startOfSelection.deepEquivalent().anchorNode()->isDescendantOf(table)) {
+ const VisiblePosition& newEnd =
+ previousPositionOf(endOfSelection, CannotCrossEditingBoundary);
+ if (newEnd.isNotNull()) {
+ newSelection = createVisibleSelection(
+ SelectionInDOMTree::Builder()
+ .collapse(startOfSelection.toPositionWithAffinity())
+ .extend(newEnd.deepEquivalent())
+ .build());
+ } else {
+ newSelection = createVisibleSelection(
+ SelectionInDOMTree::Builder()
+ .collapse(startOfSelection.toPositionWithAffinity())
+ .build());
+ }
+ }
}
// If the start of the selection to modify is just before a table, and if the
@@ -1800,10 +1812,22 @@ VisibleSelection selectionForParagraphIteration(
// want to modify is the first one inside the table, not the paragraph
// containing the table itself.
if (Element* table = tableElementJustAfter(startOfSelection)) {
- if (endOfSelection.deepEquivalent().anchorNode()->isDescendantOf(table))
- newSelection = createVisibleSelection(
- nextPositionOf(startOfSelection, CannotCrossEditingBoundary),
- endOfSelection);
+ if (endOfSelection.deepEquivalent().anchorNode()->isDescendantOf(table)) {
+ const VisiblePosition newStart =
+ nextPositionOf(startOfSelection, CannotCrossEditingBoundary);
+ if (newStart.isNotNull()) {
+ newSelection = createVisibleSelection(
+ SelectionInDOMTree::Builder()
+ .collapse(newStart.toPositionWithAffinity())
+ .extend(endOfSelection.deepEquivalent())
+ .build());
+ } else {
+ newSelection = createVisibleSelection(
+ SelectionInDOMTree::Builder()
+ .collapse(endOfSelection.toPositionWithAffinity())
+ .build());
+ }
+ }
}
return newSelection;

Powered by Google App Engine
This is Rietveld 408576698