diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/editing/PlainTextRange.cpp')
-rw-r--r-- | chromium/third_party/WebKit/Source/core/editing/PlainTextRange.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/chromium/third_party/WebKit/Source/core/editing/PlainTextRange.cpp b/chromium/third_party/WebKit/Source/core/editing/PlainTextRange.cpp index 82f321566d7..ff63a5ef92d 100644 --- a/chromium/third_party/WebKit/Source/core/editing/PlainTextRange.cpp +++ b/chromium/third_party/WebKit/Source/core/editing/PlainTextRange.cpp @@ -57,28 +57,31 @@ PlainTextRange::PlainTextRange(int start, int end) ASSERT(start <= end); } -PassRefPtr<Range> PlainTextRange::createRange(const ContainerNode& scope) const +PassRefPtrWillBeRawPtr<Range> PlainTextRange::createRange(const ContainerNode& scope) const { return createRangeFor(scope, ForGeneric); } -PassRefPtr<Range> PlainTextRange::createRangeForSelection(const ContainerNode& scope) const +PassRefPtrWillBeRawPtr<Range> PlainTextRange::createRangeForSelection(const ContainerNode& scope) const { return createRangeFor(scope, ForSelection); } -PassRefPtr<Range> PlainTextRange::createRangeFor(const ContainerNode& scope, GetRangeFor getRangeFor) const +PassRefPtrWillBeRawPtr<Range> PlainTextRange::createRangeFor(const ContainerNode& scope, GetRangeFor getRangeFor) const { ASSERT(isNotNull()); - RefPtr<Range> resultRange = scope.document().createRange(); + RefPtrWillBeRawPtr<Range> resultRange = scope.document().createRange(); size_t docTextPosition = 0; bool startRangeFound = false; - RefPtr<Range> textRunRange; + RefPtrWillBeRawPtr<Range> textRunRange = nullptr; - TextIterator it(rangeOfContents(const_cast<ContainerNode*>(&scope)).get(), getRangeFor == ForSelection ? TextIteratorEmitsCharactersBetweenAllVisiblePositions : TextIteratorDefaultBehavior); + TextIteratorBehaviorFlags behaviorFlags = TextIteratorEmitsObjectReplacementCharacter; + if (getRangeFor == ForSelection) + behaviorFlags |= TextIteratorEmitsCharactersBetweenAllVisiblePositions; + TextIterator it(rangeOfContents(const_cast<ContainerNode*>(&scope)).get(), behaviorFlags); // FIXME: the atEnd() check shouldn't be necessary, workaround for <http://bugs.webkit.org/show_bug.cgi?id=6289>. if (!start() && !length() && it.atEnd()) { @@ -106,7 +109,7 @@ PassRefPtr<Range> PlainTextRange::createRangeFor(const ContainerNode& scope, Get scope.document().updateLayoutIgnorePendingStylesheets(); it.advance(); if (!it.atEnd()) { - RefPtr<Range> range = it.range(); + RefPtrWillBeRawPtr<Range> range = it.range(); textRunRange->setEnd(range->startContainer(), range->startOffset(), ASSERT_NO_EXCEPTION); } else { Position runStart = textRunRange->startPosition(); @@ -147,7 +150,7 @@ PassRefPtr<Range> PlainTextRange::createRangeFor(const ContainerNode& scope, Get } if (!startRangeFound) - return 0; + return nullptr; if (length() && end() > docTextPosition) { // end() is out of bounds resultRange->setEnd(textRunRange->endContainer(), textRunRange->endOffset(), IGNORE_EXCEPTION); @@ -171,7 +174,7 @@ PlainTextRange PlainTextRange::create(const Node& scope, const Range& range) if (range.endContainer() != scope && !range.endContainer()->isDescendantOf(&scope)) return PlainTextRange(); - RefPtr<Range> testRange = Range::create(scope.document(), const_cast<Node*>(&scope), 0, range.startContainer(), range.startOffset()); + RefPtrWillBeRawPtr<Range> testRange = Range::create(scope.document(), const_cast<Node*>(&scope), 0, range.startContainer(), range.startOffset()); ASSERT(testRange->startContainer() == &scope); size_t start = TextIterator::rangeLength(testRange.get()); |