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

Unified Diff: third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp

Issue 2947093003: [MarkersIntersectingRange #3] Optimize SpellChecker::GetSpellCheckMarkerUnderSelection() (Closed)
Patch Set: Use const reference for node_marker_pairs Created 3 years, 6 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/spellcheck/SpellChecker.cpp
diff --git a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
index 4dda54c77b692b36d6c73c3b3d308ebd3223f48b..d60f315c608f34ccd0cb83ea57d2725a967af5a5 100644
--- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
+++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
@@ -877,31 +877,16 @@ SpellChecker::GetSpellCheckMarkerTouchingSelection() {
const EphemeralRange& range_to_check =
ExpandSelectionRangeIfNecessary(selection);
rlanday 2017/06/22 04:05:13 I think I'm probably going to get rid of this and
- Node* const start_container =
- range_to_check.StartPosition().ComputeContainerNode();
- const unsigned start_offset =
- range_to_check.StartPosition().ComputeOffsetInContainerNode();
- Node* const end_container =
- range_to_check.EndPosition().ComputeContainerNode();
- const unsigned end_offset =
- range_to_check.EndPosition().ComputeOffsetInContainerNode();
-
- for (Node& node : range_to_check.Nodes()) {
- const DocumentMarkerVector& markers_in_node =
- GetFrame().GetDocument()->Markers().MarkersFor(
- &node, DocumentMarker::MisspellingMarkers());
- for (DocumentMarker* marker : markers_in_node) {
- if (node == start_container && marker->EndOffset() <= start_offset)
- continue;
- if (node == end_container && marker->StartOffset() >= end_offset)
- continue;
-
- return std::make_pair(&node, &ToSpellCheckMarker(*marker));
- }
- }
+ const Vector<std::pair<Node*, DocumentMarker*>>& node_marker_pairs =
+ GetFrame().GetDocument()->Markers().MarkersIntersectingRange(
+ range_to_check, DocumentMarker::MisspellingMarkers());
// No marker found
- return Optional<std::pair<Node*, SpellCheckMarker*>>();
+ if (node_marker_pairs.IsEmpty())
+ return Optional<std::pair<Node*, SpellCheckMarker*>>();
+
+ return std::make_pair(node_marker_pairs.front().first,
+ ToSpellCheckMarker(node_marker_pairs.front().second));
}
void SpellChecker::ReplaceMisspelledRange(const String& text) {
« 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