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 16 matching lines...) Expand all Loading... |
27 */ | 27 */ |
28 | 28 |
29 #include "core/editing/markers/DocumentMarkerController.h" | 29 #include "core/editing/markers/DocumentMarkerController.h" |
30 | 30 |
31 #include <algorithm> | 31 #include <algorithm> |
32 #include "core/dom/Node.h" | 32 #include "core/dom/Node.h" |
33 #include "core/dom/NodeTraversal.h" | 33 #include "core/dom/NodeTraversal.h" |
34 #include "core/dom/Text.h" | 34 #include "core/dom/Text.h" |
35 #include "core/editing/VisibleUnits.h" | 35 #include "core/editing/VisibleUnits.h" |
36 #include "core/editing/iterators/TextIterator.h" | 36 #include "core/editing/iterators/TextIterator.h" |
| 37 #include "core/editing/markers/ActiveSuggestionMarker.h" |
| 38 #include "core/editing/markers/ActiveSuggestionMarkerListImpl.h" |
37 #include "core/editing/markers/CompositionMarker.h" | 39 #include "core/editing/markers/CompositionMarker.h" |
38 #include "core/editing/markers/CompositionMarkerListImpl.h" | 40 #include "core/editing/markers/CompositionMarkerListImpl.h" |
39 #include "core/editing/markers/DocumentMarkerListEditor.h" | 41 #include "core/editing/markers/DocumentMarkerListEditor.h" |
40 #include "core/editing/markers/GrammarMarker.h" | 42 #include "core/editing/markers/GrammarMarker.h" |
41 #include "core/editing/markers/GrammarMarkerListImpl.h" | 43 #include "core/editing/markers/GrammarMarkerListImpl.h" |
42 #include "core/editing/markers/SpellingMarker.h" | 44 #include "core/editing/markers/SpellingMarker.h" |
43 #include "core/editing/markers/SpellingMarkerListImpl.h" | 45 #include "core/editing/markers/SpellingMarkerListImpl.h" |
44 #include "core/editing/markers/TextMatchMarker.h" | 46 #include "core/editing/markers/TextMatchMarker.h" |
45 #include "core/editing/markers/TextMatchMarkerListImpl.h" | 47 #include "core/editing/markers/TextMatchMarkerListImpl.h" |
46 #include "core/frame/LocalFrameView.h" | 48 #include "core/frame/LocalFrameView.h" |
(...skipping 11 matching lines...) Expand all Loading... |
58 DocumentMarker::MarkerType type) { | 60 DocumentMarker::MarkerType type) { |
59 switch (type) { | 61 switch (type) { |
60 case DocumentMarker::kSpelling: | 62 case DocumentMarker::kSpelling: |
61 return DocumentMarker::kSpellingMarkerIndex; | 63 return DocumentMarker::kSpellingMarkerIndex; |
62 case DocumentMarker::kGrammar: | 64 case DocumentMarker::kGrammar: |
63 return DocumentMarker::kGrammarMarkerIndex; | 65 return DocumentMarker::kGrammarMarkerIndex; |
64 case DocumentMarker::kTextMatch: | 66 case DocumentMarker::kTextMatch: |
65 return DocumentMarker::kTextMatchMarkerIndex; | 67 return DocumentMarker::kTextMatchMarkerIndex; |
66 case DocumentMarker::kComposition: | 68 case DocumentMarker::kComposition: |
67 return DocumentMarker::kCompositionMarkerIndex; | 69 return DocumentMarker::kCompositionMarkerIndex; |
| 70 case DocumentMarker::kActiveSuggestion: |
| 71 return DocumentMarker::kActiveSuggestionMarkerIndex; |
68 } | 72 } |
69 | 73 |
70 NOTREACHED(); | 74 NOTREACHED(); |
71 return DocumentMarker::kSpellingMarkerIndex; | 75 return DocumentMarker::kSpellingMarkerIndex; |
72 } | 76 } |
73 | 77 |
74 DocumentMarkerList* CreateListForType(DocumentMarker::MarkerType type) { | 78 DocumentMarkerList* CreateListForType(DocumentMarker::MarkerType type) { |
75 switch (type) { | 79 switch (type) { |
| 80 case DocumentMarker::kActiveSuggestion: |
| 81 return new ActiveSuggestionMarkerListImpl(); |
76 case DocumentMarker::kComposition: | 82 case DocumentMarker::kComposition: |
77 return new CompositionMarkerListImpl(); | 83 return new CompositionMarkerListImpl(); |
78 case DocumentMarker::kSpelling: | 84 case DocumentMarker::kSpelling: |
79 return new SpellingMarkerListImpl(); | 85 return new SpellingMarkerListImpl(); |
80 case DocumentMarker::kGrammar: | 86 case DocumentMarker::kGrammar: |
81 return new GrammarMarkerListImpl(); | 87 return new GrammarMarkerListImpl(); |
82 case DocumentMarker::kTextMatch: | 88 case DocumentMarker::kTextMatch: |
83 return new TextMatchMarkerListImpl(); | 89 return new TextMatchMarkerListImpl(); |
84 } | 90 } |
85 | 91 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 StyleableMarker::Thickness thickness, | 162 StyleableMarker::Thickness thickness, |
157 Color background_color) { | 163 Color background_color) { |
158 DCHECK(!document_->NeedsLayoutTreeUpdate()); | 164 DCHECK(!document_->NeedsLayoutTreeUpdate()); |
159 AddMarkerInternal(range, [underline_color, thickness, background_color]( | 165 AddMarkerInternal(range, [underline_color, thickness, background_color]( |
160 int start_offset, int end_offset) { | 166 int start_offset, int end_offset) { |
161 return new CompositionMarker(start_offset, end_offset, underline_color, | 167 return new CompositionMarker(start_offset, end_offset, underline_color, |
162 thickness, background_color); | 168 thickness, background_color); |
163 }); | 169 }); |
164 } | 170 } |
165 | 171 |
| 172 void DocumentMarkerController::AddActiveSuggestionMarker( |
| 173 const EphemeralRange& range, |
| 174 Color underline_color, |
| 175 StyleableMarker::Thickness thickness, |
| 176 Color background_color) { |
| 177 DCHECK(!document_->NeedsLayoutTreeUpdate()); |
| 178 AddMarkerInternal(range, [underline_color, thickness, background_color]( |
| 179 int start_offset, int end_offset) { |
| 180 return new ActiveSuggestionMarker(start_offset, end_offset, underline_color, |
| 181 thickness, background_color); |
| 182 }); |
| 183 } |
| 184 |
166 void DocumentMarkerController::PrepareForDestruction() { | 185 void DocumentMarkerController::PrepareForDestruction() { |
167 Clear(); | 186 Clear(); |
168 } | 187 } |
169 | 188 |
170 void DocumentMarkerController::RemoveMarkers( | 189 void DocumentMarkerController::RemoveMarkers( |
171 TextIterator& marked_text, | 190 TextIterator& marked_text, |
172 DocumentMarker::MarkerTypes marker_types) { | 191 DocumentMarker::MarkerTypes marker_types) { |
173 for (; !marked_text.AtEnd(); marked_text.Advance()) { | 192 for (; !marked_text.AtEnd(); marked_text.Advance()) { |
174 if (!PossiblyHasMarkers(marker_types)) | 193 if (!PossiblyHasMarkers(marker_types)) |
175 return; | 194 return; |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 } | 733 } |
715 | 734 |
716 } // namespace blink | 735 } // namespace blink |
717 | 736 |
718 #ifndef NDEBUG | 737 #ifndef NDEBUG |
719 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { | 738 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { |
720 if (controller) | 739 if (controller) |
721 controller->ShowMarkers(); | 740 controller->ShowMarkers(); |
722 } | 741 } |
723 #endif | 742 #endif |
OLD | NEW |