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

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

Issue 2764743004: Add DocumentMarker::createGrammarMarker() and createSpellingMarker() (Closed)
Patch Set: Move test case changes into createTextMatchMarker() CL Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
7 * reserved. 7 * reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 for (DocumentMarker::MarkerType type : DocumentMarker::AllMarkers()) { 57 for (DocumentMarker::MarkerType type : DocumentMarker::AllMarkers()) {
58 MarkerMap& markerMap = markerMapForType(type); 58 MarkerMap& markerMap = markerMapForType(type);
59 markerMap.clear(); 59 markerMap.clear();
60 } 60 }
61 } 61 }
62 62
63 void DocumentMarkerController::addMarker(const Position& start, 63 void DocumentMarkerController::addMarker(const Position& start,
64 const Position& end, 64 const Position& end,
65 DocumentMarker::MarkerType type, 65 DocumentMarker::MarkerType type,
66 const String& description) { 66 const String& description) {
67 DCHECK(type == DocumentMarker::Grammar || type == DocumentMarker::Spelling);
67 // Use a TextIterator to visit the potentially multiple nodes the range 68 // Use a TextIterator to visit the potentially multiple nodes the range
68 // covers. 69 // covers.
69 for (TextIterator markedText(start, end); !markedText.atEnd(); 70 for (TextIterator markedText(start, end); !markedText.atEnd();
70 markedText.advance()) { 71 markedText.advance()) {
71 addMarker(markedText.currentContainer(), 72 DocumentMarker* marker;
72 new DocumentMarker( 73 if (type == DocumentMarker::Grammar) {
yosin_UTC9 2017/03/23 04:01:27 Could you add TODO for introducing add{Grammaer,Sp
73 type, markedText.startOffsetInCurrentContainer(), 74 marker = DocumentMarker::createGrammarMarker(
74 markedText.endOffsetInCurrentContainer(), description)); 75 markedText.startOffsetInCurrentContainer(),
76 markedText.endOffsetInCurrentContainer(), description);
77 } else {
78 marker = DocumentMarker::createSpellingMarker(
79 markedText.startOffsetInCurrentContainer(),
80 markedText.endOffsetInCurrentContainer(), description);
81 }
82 addMarker(markedText.currentContainer(), marker);
75 } 83 }
76 } 84 }
77 85
78 void DocumentMarkerController::addTextMatchMarker(const EphemeralRange& range, 86 void DocumentMarkerController::addTextMatchMarker(const EphemeralRange& range,
79 bool activeMatch) { 87 bool activeMatch) {
80 DCHECK(!m_document->needsLayoutTreeUpdate()); 88 DCHECK(!m_document->needsLayoutTreeUpdate());
81 89
82 // Use a TextIterator to visit the potentially multiple nodes the range 90 // Use a TextIterator to visit the potentially multiple nodes the range
83 // covers. 91 // covers.
84 for (TextIterator markedText(range.startPosition(), range.endPosition()); 92 for (TextIterator markedText(range.startPosition(), range.endPosition());
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 } 574 }
567 575
568 } // namespace blink 576 } // namespace blink
569 577
570 #ifndef NDEBUG 578 #ifndef NDEBUG
571 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { 579 void showDocumentMarkers(const blink::DocumentMarkerController* controller) {
572 if (controller) 580 if (controller)
573 controller->showMarkers(); 581 controller->showMarkers();
574 } 582 }
575 #endif 583 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698