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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 setContext(&document); | 53 setContext(&document); |
54 } | 54 } |
55 | 55 |
56 void DocumentMarkerController::clear() { | 56 void DocumentMarkerController::clear() { |
57 m_spelling.clear(); | 57 m_spelling.clear(); |
58 m_grammar.clear(); | 58 m_grammar.clear(); |
59 m_textMatches.clear(); | 59 m_textMatches.clear(); |
60 m_compositions.clear(); | 60 m_compositions.clear(); |
61 } | 61 } |
62 | 62 |
63 void DocumentMarkerController::addMarker(const Position& start, | 63 void DocumentMarkerController::addCompositionMarker(const Position& start, |
yosin_UTC9
2017/03/22 05:23:46
Please move addCompositionMarker() changes to anot
rlanday
2017/03/22 17:21:51
I was just re-ordering the methods to put them in
| |
64 const Position& end, | 64 const Position& end, |
65 DocumentMarker::MarkerType type, | 65 Color underlineColor, |
66 const String& description) { | 66 bool thick, |
67 Color backgroundColor) { | |
68 DCHECK(!m_document->needsLayoutTreeUpdate()); | |
69 | |
70 for (TextIterator markedText(start, end); !markedText.atEnd(); | |
71 markedText.advance()) { | |
72 addMarker(markedText.currentContainer(), | |
73 DocumentMarker::createCompositionMarker( | |
74 markedText.startOffsetInCurrentContainer(), | |
75 markedText.endOffsetInCurrentContainer(), underlineColor, | |
76 thick, backgroundColor)); | |
77 } | |
78 } | |
79 | |
80 void DocumentMarkerController::addGrammarOrSpellingMarker( | |
81 const Position& start, | |
82 const Position& end, | |
83 DocumentMarker::MarkerType type, | |
84 const String& description) { | |
85 DCHECK(!m_document->needsLayoutTreeUpdate()); | |
67 DCHECK(type == DocumentMarker::Grammar || type == DocumentMarker::Spelling); | 86 DCHECK(type == DocumentMarker::Grammar || type == DocumentMarker::Spelling); |
68 // Use a TextIterator to visit the potentially multiple nodes the range | 87 // Use a TextIterator to visit the potentially multiple nodes the range |
69 // covers. | 88 // covers. |
70 for (TextIterator markedText(start, end); !markedText.atEnd(); | 89 for (TextIterator markedText(start, end); !markedText.atEnd(); |
71 markedText.advance()) { | 90 markedText.advance()) { |
72 DocumentMarker* marker; | 91 DocumentMarker* marker; |
73 if (type == DocumentMarker::Grammar) { | 92 if (type == DocumentMarker::Grammar) { |
74 marker = DocumentMarker::createGrammarMarker( | 93 marker = DocumentMarker::createGrammarMarker( |
75 markedText.startOffsetInCurrentContainer(), | 94 markedText.startOffsetInCurrentContainer(), |
76 markedText.endOffsetInCurrentContainer(), description); | 95 markedText.endOffsetInCurrentContainer(), description); |
77 } else { | 96 } else { |
78 marker = DocumentMarker::createSpellingMarker( | 97 marker = DocumentMarker::createSpellingMarker( |
79 markedText.startOffsetInCurrentContainer(), | 98 markedText.startOffsetInCurrentContainer(), |
80 markedText.endOffsetInCurrentContainer(), description); | 99 markedText.endOffsetInCurrentContainer(), description); |
81 } | 100 } |
82 addMarker(markedText.currentContainer(), marker); | 101 addMarker(markedText.currentContainer(), marker); |
83 } | 102 } |
84 } | 103 } |
85 | 104 |
105 void DocumentMarkerController::addGrammarMarker(const Position& start, | |
106 const Position& end, | |
107 const String& description) { | |
108 addGrammarOrSpellingMarker(start, end, DocumentMarker::Grammar, description); | |
109 } | |
110 | |
111 void DocumentMarkerController::addSpellingMarker(const Position& start, | |
112 const Position& end, | |
113 const String& description) { | |
114 addGrammarOrSpellingMarker(start, end, DocumentMarker::Spelling, description); | |
115 } | |
116 | |
86 void DocumentMarkerController::addTextMatchMarker(const EphemeralRange& range, | 117 void DocumentMarkerController::addTextMatchMarker(const EphemeralRange& range, |
87 bool activeMatch) { | 118 bool activeMatch) { |
88 DCHECK(!m_document->needsLayoutTreeUpdate()); | 119 DCHECK(!m_document->needsLayoutTreeUpdate()); |
89 | 120 |
90 // Use a TextIterator to visit the potentially multiple nodes the range | 121 // Use a TextIterator to visit the potentially multiple nodes the range |
91 // covers. | 122 // covers. |
92 for (TextIterator markedText(range.startPosition(), range.endPosition()); | 123 for (TextIterator markedText(range.startPosition(), range.endPosition()); |
93 !markedText.atEnd(); markedText.advance()) { | 124 !markedText.atEnd(); markedText.advance()) { |
94 addMarker(markedText.currentContainer(), | 125 addMarker(markedText.currentContainer(), |
95 DocumentMarker::createTextMatchMarker( | 126 DocumentMarker::createTextMatchMarker( |
96 markedText.startOffsetInCurrentContainer(), | 127 markedText.startOffsetInCurrentContainer(), |
97 markedText.endOffsetInCurrentContainer(), activeMatch)); | 128 markedText.endOffsetInCurrentContainer(), activeMatch)); |
98 } | 129 } |
99 // Don't invalidate tickmarks here. TextFinder invalidates tickmarks using a | 130 // Don't invalidate tickmarks here. TextFinder invalidates tickmarks using a |
100 // throttling algorithm. crbug.com/6819. | 131 // throttling algorithm. crbug.com/6819. |
101 } | 132 } |
102 | 133 |
103 void DocumentMarkerController::addCompositionMarker(const Position& start, | |
Xiaocheng
2017/03/22 02:00:29
nit: Shouldn't move this function.
| |
104 const Position& end, | |
105 Color underlineColor, | |
106 bool thick, | |
107 Color backgroundColor) { | |
108 DCHECK(!m_document->needsLayoutTreeUpdate()); | |
109 | |
110 for (TextIterator markedText(start, end); !markedText.atEnd(); | |
111 markedText.advance()) { | |
112 addMarker(markedText.currentContainer(), | |
113 DocumentMarker::createCompositionMarker( | |
114 markedText.startOffsetInCurrentContainer(), | |
115 markedText.endOffsetInCurrentContainer(), underlineColor, | |
116 thick, backgroundColor)); | |
117 } | |
118 } | |
119 | |
120 void DocumentMarkerController::prepareForDestruction() { | 134 void DocumentMarkerController::prepareForDestruction() { |
121 clear(); | 135 clear(); |
122 } | 136 } |
123 | 137 |
124 void DocumentMarkerController::removeMarkers( | 138 void DocumentMarkerController::removeMarkers( |
125 const EphemeralRange& range, | 139 const EphemeralRange& range, |
126 DocumentMarker::MarkerTypes markerTypes, | 140 DocumentMarker::MarkerTypes markerTypes, |
127 RemovePartiallyOverlappingMarkerOrNot | 141 RemovePartiallyOverlappingMarkerOrNot |
128 shouldRemovePartiallyOverlappingMarker) { | 142 shouldRemovePartiallyOverlappingMarker) { |
129 DCHECK(!m_document->needsLayoutTreeUpdate()); | 143 DCHECK(!m_document->needsLayoutTreeUpdate()); |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
649 } | 663 } |
650 | 664 |
651 } // namespace blink | 665 } // namespace blink |
652 | 666 |
653 #ifndef NDEBUG | 667 #ifndef NDEBUG |
654 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { | 668 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { |
655 if (controller) | 669 if (controller) |
656 controller->showMarkers(); | 670 controller->showMarkers(); |
657 } | 671 } |
658 #endif | 672 #endif |
OLD | NEW |