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

Unified Diff: Source/core/dom/DocumentMarkerController.h

Issue 419563003: Adding a word to dictionary should remove spelling markers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed comment Created 6 years, 5 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: Source/core/dom/DocumentMarkerController.h
diff --git a/Source/core/dom/DocumentMarkerController.h b/Source/core/dom/DocumentMarkerController.h
index c7f0e456b21235def99ddf076e5002f96baea5f6..d63b137bba0f7f900b2970077c8ea8173d9887e7 100644
--- a/Source/core/dom/DocumentMarkerController.h
+++ b/Source/core/dom/DocumentMarkerController.h
@@ -28,6 +28,7 @@
#define DocumentMarkerController_h
#include "core/dom/DocumentMarker.h"
+#include "core/dom/Range.h"
#include "platform/geometry/IntRect.h"
#include "platform/heap/Handle.h"
#include "wtf/HashMap.h"
@@ -35,10 +36,32 @@
namespace blink {
+class MarkerRemoverPredicate {
+public:
+ MarkerRemoverPredicate(Document* document, const Vector<String>& words)
dcheng 2014/08/05 20:30:38 This can't ever be passed a non-null document righ
Klemen Forstnerič 2014/08/07 17:47:28 Done.
+ : m_document(document), m_words(words)
+ {
+ }
+
+ bool operator()(const DocumentMarker& documentMarker,
+ const Node* node) const {
+
+ auto markerRange = Range::create(*m_document,
dcheng 2014/08/05 20:30:38 auto is not allowed in cross-platform code.
Klemen Forstnerič 2014/08/07 17:47:28 Done.
+ const_cast<Node *>(node), documentMarker.startOffset(),
dcheng 2014/08/05 20:30:38 Convention is to have the * and & by the typename,
Klemen Forstnerič 2014/08/07 17:47:28 Done.
+ const_cast<Node *>(node), documentMarker.endOffset());
+
+ return m_words.contains(markerRange->text())
+ ? true : false;
+ }
+
+private:
+ Document* m_document;
+ Vector<String> m_words;
+};
+
class LayoutPoint;
class LayoutRect;
class Node;
-class Range;
class RenderedDocumentMarker;
class DocumentMarkerController FINAL : public NoBaseWillBeGarbageCollected<DocumentMarkerController> {
@@ -67,6 +90,7 @@ public:
void removeMarkers(DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
void removeMarkers(Node*, DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
+ void removeMarkers(const MarkerRemoverPredicate& shouldRemoveMarker);
void repaintMarkers(DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
void invalidateRenderedRectsForMarkersInRect(const LayoutRect&);
void shiftMarkers(Node*, unsigned startOffset, int delta);
@@ -91,6 +115,7 @@ private:
typedef WillBeHeapVector<OwnPtrWillBeMember<RenderedDocumentMarker> > MarkerList;
typedef WillBeHeapVector<OwnPtrWillBeMember<MarkerList>, DocumentMarker::MarkerTypeIndexesCount> MarkerLists;
typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<const Node>, OwnPtrWillBeMember<MarkerLists> > MarkerMap;
+
void mergeOverlapping(MarkerList*, DocumentMarker&);
bool possiblyHasMarkers(DocumentMarker::MarkerTypes);
void removeMarkersFromList(MarkerMap::iterator, DocumentMarker::MarkerTypes);
« no previous file with comments | « no previous file | Source/core/dom/DocumentMarkerController.cpp » ('j') | Source/core/dom/DocumentMarkerController.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698