Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/DOMSelection.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/DOMSelection.cpp b/third_party/WebKit/Source/core/editing/DOMSelection.cpp |
| index bb6e173919ba4199fe6b7bb9a67fccceaed84d45..f72745a78166e6ab4172f6506e67d49d1d1e2dda 100644 |
| --- a/third_party/WebKit/Source/core/editing/DOMSelection.cpp |
| +++ b/third_party/WebKit/Source/core/editing/DOMSelection.cpp |
| @@ -600,7 +600,7 @@ void DOMSelection::addRange(Range* newRange) { |
| // no longer performs synchronous layout by itself. |
| frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| - if (selection.isNone()) { |
| + if (rangeCount() == 0) { |
| selection.setSelectedRange(EphemeralRange(newRange), VP_DEFAULT_AFFINITY); |
| cacheRangeIfSelectionOfDocument(newRange); |
| return; |
| @@ -608,17 +608,8 @@ void DOMSelection::addRange(Range* newRange) { |
| Range* originalRange = selection.firstRange(); |
| - if (originalRange->startContainer()->document() != |
| - newRange->startContainer()->document()) { |
| - addConsoleError( |
| - "The given range does not belong to the current selection's document."); |
| - return; |
| - } |
| if (originalRange->startContainer()->treeScope() != |
| newRange->startContainer()->treeScope()) { |
|
yoichio
2017/02/20 07:42:19
Why do you leave these two early returns though yo
tkent
2017/02/20 07:53:25
The removed one was dead code. We check Document i
|
| - addConsoleError( |
| - "The given range and the current selection belong to two different " |
| - "document fragments."); |
| return; |
| } |
| @@ -626,32 +617,14 @@ void DOMSelection::addRange(Range* newRange) { |
| ASSERT_NO_EXCEPTION) < 0 || |
| newRange->compareBoundaryPoints(Range::kStartToEnd, originalRange, |
| ASSERT_NO_EXCEPTION) < 0) { |
| - addConsoleError("Discontiguous selection is not supported."); |
| return; |
| } |
| - // FIXME: "Merge the ranges if they intersect" is Blink-specific behavior; |
| - // other browsers supporting discontiguous selection (obviously) keep each |
| - // Range added and return it in getRangeAt(). But it's unclear if we can |
| - // really do the same, since we don't support discontiguous selection. Further |
| - // discussions at |
| + // TODO(tkent): "Merge the ranges if they intersect" was removed. We show a |
| + // warning message for a while, and continue to collect the usage data. |
| // <https://code.google.com/p/chromium/issues/detail?id=353069>. |
| Deprecation::countDeprecation(frame(), |
| UseCounter::SelectionAddRangeIntersect); |
| - |
| - Range* start = originalRange->compareBoundaryPoints( |
| - Range::kStartToStart, newRange, ASSERT_NO_EXCEPTION) < 0 |
| - ? originalRange |
| - : newRange; |
| - Range* end = originalRange->compareBoundaryPoints(Range::kEndToEnd, newRange, |
| - ASSERT_NO_EXCEPTION) < 0 |
| - ? newRange |
| - : originalRange; |
| - const EphemeralRange merged = |
| - EphemeralRange(start->startPosition(), end->endPosition()); |
| - TextAffinity affinity = selection.selection().affinity(); |
| - selection.setSelectedRange(merged, affinity); |
| - cacheRangeIfSelectionOfDocument(createRange(merged)); |
| } |
| void DOMSelection::deleteFromDocument() { |