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

Unified Diff: third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp

Issue 2246143004: Use EphemeralRange instead of Range* in DocumentMarkerController class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on master Created 4 years, 4 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/markers/DocumentMarkerController.cpp
diff --git a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
index 3fa6b03d460a134e1fb142e8ca44dee4b0fce701..a3cc9fec0814db7af6ffbd6ed3ef6ad5b9f4575e 100644
--- a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
+++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
@@ -104,14 +104,14 @@ void DocumentMarkerController::addMarker(const Position& start, const Position&
}
}
-void DocumentMarkerController::addTextMatchMarker(const Range* range, bool activeMatch)
+void DocumentMarkerController::addTextMatchMarker(const EphemeralRange& range, bool activeMatch)
{
// TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets needs to be audited.
// see http://crbug.com/590369 for more details.
- range->startPosition().document()->updateStyleAndLayoutIgnorePendingStylesheets();
+ range.startPosition().document()->updateStyleAndLayoutIgnorePendingStylesheets();
// Use a TextIterator to visit the potentially multiple nodes the range covers.
- for (TextIterator markedText(range->startPosition(), range->endPosition()); !markedText.atEnd(); markedText.advance())
+ for (TextIterator markedText(range.startPosition(), range.endPosition()); !markedText.atEnd(); markedText.advance())
addMarker(markedText.currentContainer(), DocumentMarker(markedText.startOffsetInCurrentContainer(), markedText.endOffsetInCurrentContainer(), activeMatch));
// Don't invalidate tickmarks here. TextFinder invalidates tickmarks using a throttling algorithm. crbug.com/6819.
}
@@ -713,19 +713,25 @@ void DocumentMarkerController::shiftMarkers(Node* node, unsigned startOffset, in
}
}
-bool DocumentMarkerController::setMarkersActive(Range* range, bool active)
+bool DocumentMarkerController::setMarkersActive(const EphemeralRange& range, bool active)
{
if (!possiblyHasMarkers(DocumentMarker::AllMarkers()))
return false;
DCHECK(!m_markers.isEmpty());
- Node* startContainer = range->startContainer();
- Node* endContainer = range->endContainer();
+ Node* const startContainer = range.startPosition().computeContainerNode();
+ DCHECK(startContainer);
+ Node* const endContainer = range.endPosition().computeContainerNode();
+ DCHECK(endContainer);
+
+ const unsigned containerStartOffset = range.startPosition().computeOffsetInContainerNode();
+ const unsigned containerEndOffset = range.endPosition().computeOffsetInContainerNode();
+
bool markerFound = false;
- for (Node& node : EphemeralRange(range).nodes()) {
- int startOffset = node == startContainer ? range->startOffset() : 0;
- int endOffset = node == endContainer ? range->endOffset() : INT_MAX;
+ for (Node& node : range.nodes()) {
+ int startOffset = node == startContainer ? containerStartOffset : 0;
+ int endOffset = node == endContainer ? containerEndOffset : INT_MAX;
markerFound |= setMarkersActive(&node, startOffset, endOffset, active);
}
return markerFound;

Powered by Google App Engine
This is Rietveld 408576698