Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 setContext(&document); | 55 setContext(&document); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void DocumentMarkerController::clear() { | 58 void DocumentMarkerController::clear() { |
| 59 for (DocumentMarker::MarkerType type : DocumentMarker::AllMarkers()) { | 59 for (DocumentMarker::MarkerType type : DocumentMarker::AllMarkers()) { |
| 60 MarkerMap& markerMap = markerMapForType(type); | 60 MarkerMap& markerMap = markerMapForType(type); |
| 61 markerMap.clear(); | 61 markerMap.clear(); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 void DocumentMarkerController::addMarker(const Position& start, | 65 void DocumentMarkerController::addGrammarOrSpellingMarker( |
| 66 const Position& end, | 66 const Position& start, |
| 67 DocumentMarker::MarkerType type, | 67 const Position& end, |
| 68 const String& description) { | 68 DocumentMarker::MarkerType type, |
| 69 const String& description) { | |
| 70 DCHECK(!m_document->needsLayoutTreeUpdate()); | |
| 71 DCHECK(type == DocumentMarker::Grammar || type == DocumentMarker::Spelling); | |
|
yosin_UTC9
2017/03/30 01:48:57
nit: Could you add |<< type| for ease of debugging
| |
| 69 // Use a TextIterator to visit the potentially multiple nodes the range | 72 // Use a TextIterator to visit the potentially multiple nodes the range |
| 70 // covers. | 73 // covers. |
| 71 for (TextIterator markedText(start, end); !markedText.atEnd(); | 74 for (TextIterator markedText(start, end); !markedText.atEnd(); |
| 72 markedText.advance()) { | 75 markedText.advance()) { |
| 73 addMarker(markedText.currentContainer(), | 76 addMarker(markedText.currentContainer(), |
| 74 new SpellCheckMarker( | 77 new SpellCheckMarker( |
| 75 type, markedText.startOffsetInCurrentContainer(), | 78 type, markedText.startOffsetInCurrentContainer(), |
| 76 markedText.endOffsetInCurrentContainer(), description)); | 79 markedText.endOffsetInCurrentContainer(), description)); |
| 77 } | 80 } |
| 78 } | 81 } |
| 79 | 82 |
| 83 void DocumentMarkerController::addSpellingMarker(const Position& start, | |
| 84 const Position& end, | |
| 85 const String& description) { | |
| 86 addGrammarOrSpellingMarker(start, end, DocumentMarker::Spelling, description); | |
| 87 } | |
| 88 | |
| 89 void DocumentMarkerController::addGrammarMarker(const Position& start, | |
| 90 const Position& end, | |
| 91 const String& description) { | |
| 92 addGrammarOrSpellingMarker(start, end, DocumentMarker::Grammar, description); | |
| 93 } | |
| 94 | |
| 80 void DocumentMarkerController::addTextMatchMarker(const EphemeralRange& range, | 95 void DocumentMarkerController::addTextMatchMarker(const EphemeralRange& range, |
| 81 bool activeMatch) { | 96 bool activeMatch) { |
| 82 DCHECK(!m_document->needsLayoutTreeUpdate()); | 97 DCHECK(!m_document->needsLayoutTreeUpdate()); |
| 83 | 98 |
| 84 // Use a TextIterator to visit the potentially multiple nodes the range | 99 // Use a TextIterator to visit the potentially multiple nodes the range |
| 85 // covers. | 100 // covers. |
| 86 for (TextIterator markedText(range.startPosition(), range.endPosition()); | 101 for (TextIterator markedText(range.startPosition(), range.endPosition()); |
| 87 !markedText.atEnd(); markedText.advance()) { | 102 !markedText.atEnd(); markedText.advance()) { |
| 88 addMarker(markedText.currentContainer(), | 103 addMarker(markedText.currentContainer(), |
| 89 new TextMatchMarker(markedText.startOffsetInCurrentContainer(), | 104 new TextMatchMarker(markedText.startOffsetInCurrentContainer(), |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 586 } | 601 } |
| 587 | 602 |
| 588 } // namespace blink | 603 } // namespace blink |
| 589 | 604 |
| 590 #ifndef NDEBUG | 605 #ifndef NDEBUG |
| 591 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { | 606 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { |
| 592 if (controller) | 607 if (controller) |
| 593 controller->showMarkers(); | 608 controller->showMarkers(); |
| 594 } | 609 } |
| 595 #endif | 610 #endif |
| OLD | NEW |