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

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

Issue 1375453002: Use EphemeralRange in makeSearchRange in VisibleSelection.cpp instead of Range object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2015-09-28T15:19:43 Created 5 years, 3 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/VisibleSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/VisibleSelection.cpp b/third_party/WebKit/Source/core/editing/VisibleSelection.cpp
index 584a80da3362654d18f60cfb9905a63afc5c6cc2..adf30f825d315216d4ccb801fe61ec9cef3c814e 100644
--- a/third_party/WebKit/Source/core/editing/VisibleSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleSelection.cpp
@@ -295,39 +295,29 @@ bool VisibleSelection::expandUsingGranularityInComposedTree(TextGranularity gran
return expandUsingGranularity(granularity);
}
-static PassRefPtrWillBeRawPtr<Range> makeSearchRange(const Position& pos)
+template <typename Strategy>
+static EphemeralRangeTemplate<Strategy> makeSearchRange(const PositionAlgorithm<Strategy>& pos)
{
Node* node = pos.anchorNode();
if (!node)
- return nullptr;
+ return EphemeralRangeTemplate<Strategy>();
Document& document = node->document();
if (!document.documentElement())
- return nullptr;
+ return EphemeralRangeTemplate<Strategy>();
Element* boundary = enclosingBlockFlowElement(*node);
if (!boundary)
- return nullptr;
-
- RefPtrWillBeRawPtr<Range> searchRange(Range::create(document));
- TrackExceptionState exceptionState;
-
- Position start(pos.parentAnchoredEquivalent());
- searchRange->selectNodeContents(boundary, exceptionState);
- searchRange->setStart(start.computeContainerNode(), start.offsetInContainerNode(), exceptionState);
-
- ASSERT(!exceptionState.hadException());
- if (exceptionState.hadException())
- return nullptr;
+ return EphemeralRangeTemplate<Strategy>();
- return searchRange.release();
+ return EphemeralRangeTemplate<Strategy>(pos, PositionAlgorithm<Strategy>::lastPositionInNode(boundary));
}
void VisibleSelection::appendTrailingWhitespace()
{
- RefPtrWillBeRawPtr<Range> searchRange = makeSearchRange(m_end);
- if (!searchRange)
+ const EphemeralRange searchRange = makeSearchRange(m_end);
+ if (searchRange.isNull())
return;
- CharacterIterator charIt(searchRange->startPosition(), searchRange->endPosition(), TextIteratorEmitsCharactersBetweenAllVisiblePositions);
+ CharacterIterator charIt(searchRange.startPosition(), searchRange.endPosition(), TextIteratorEmitsCharactersBetweenAllVisiblePositions);
bool changed = false;
for (; charIt.length(); charIt.advance(1)) {
« 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