| Index: third_party/WebKit/Source/core/editing/markers/SpellingMarkerList.cpp
|
| diff --git a/third_party/WebKit/Source/core/editing/markers/SpellingMarkerList.cpp b/third_party/WebKit/Source/core/editing/markers/SpellingMarkerList.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..20744a880562b542e4888b9ae433f7d605c0c70b
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/editing/markers/SpellingMarkerList.cpp
|
| @@ -0,0 +1,37 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "core/editing/markers/SpellingMarkerList.h"
|
| +
|
| +#include <utility>
|
| +#include "core/dom/Text.h"
|
| +
|
| +namespace blink {
|
| +
|
| +SpellingMarkerList::SpellingMarkerList(
|
| + DocumentMarkerController* documentMarkerController)
|
| + : EditingMarkerListThatMergesTouchingMarkers(documentMarkerController) {}
|
| +
|
| +DocumentMarker::MarkerType SpellingMarkerList::allowedMarkerType() const {
|
| + return DocumentMarker::Spelling;
|
| +}
|
| +
|
| +void SpellingMarkerList::removeMarkersForWords(const Text& textNode,
|
| + const Vector<String>& words) {
|
| + // Build a second vector and swap with m_markers to avoid O(n^2) performance
|
| + HeapVector<Member<DocumentMarker>> newMarkerList;
|
| +
|
| + for (Member<DocumentMarker> marker : m_markers) {
|
| + unsigned start = marker->startOffset();
|
| + unsigned length = marker->endOffset() - marker->startOffset();
|
| +
|
| + String markerText = textNode.data().substring(start, length);
|
| + if (!words.contains(markerText))
|
| + newMarkerList.push_back(marker);
|
| + }
|
| +
|
| + std::swap(m_markers, newMarkerList);
|
| +}
|
| +
|
| +} // namespace blink
|
|
|