OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/editing/markers/DocumentMarkerListEditor.h" | 5 #include "core/editing/markers/DocumentMarkerListEditor.h" |
6 | 6 |
7 #include "core/editing/markers/RenderedDocumentMarker.h" | 7 #include "core/editing/markers/RenderedDocumentMarker.h" |
| 8 #include "core/editing/markers/SpellCheckMarkerListImpl.h" |
8 | 9 |
9 namespace blink { | 10 namespace blink { |
10 | 11 |
11 void DocumentMarkerListEditor::AddMarkerWithoutMergingOverlapping( | 12 void DocumentMarkerListEditor::AddMarkerWithoutMergingOverlapping( |
12 MarkerList* list, | 13 MarkerList* list, |
13 const DocumentMarker* marker) { | 14 const DocumentMarker* marker) { |
14 RenderedDocumentMarker* rendered_marker = | 15 RenderedDocumentMarker* rendered_marker = |
15 RenderedDocumentMarker::Create(*marker); | 16 RenderedDocumentMarker::Create(*marker); |
16 if (list->IsEmpty() || list->back()->EndOffset() <= marker->StartOffset()) { | 17 if (list->IsEmpty() || list->back()->EndOffset() <= marker->StartOffset()) { |
17 list->push_back(rendered_marker); | 18 list->push_back(rendered_marker); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 if (marker.StartOffset() >= end_offset) | 76 if (marker.StartOffset() >= end_offset) |
76 break; | 77 break; |
77 | 78 |
78 list->erase(i - list->begin()); | 79 list->erase(i - list->begin()); |
79 doc_dirty = true; | 80 doc_dirty = true; |
80 } | 81 } |
81 | 82 |
82 return doc_dirty; | 83 return doc_dirty; |
83 } | 84 } |
84 | 85 |
85 bool DocumentMarkerListEditor::RemoveMarkersUnderWords( | 86 // TODO(rlanday): move to SpellCheckMarkerListImpl.cpp |
86 MarkerList* list, | 87 bool SpellCheckMarkerListImpl::RemoveMarkersUnderWords( |
87 const String& node_text, | 88 const String& node_text, |
88 const Vector<String>& words) { | 89 const Vector<String>& words) { |
89 bool removed_markers = false; | 90 bool removed_markers = false; |
90 for (size_t j = list->size(); j > 0; --j) { | 91 for (size_t j = markers_.size(); j > 0; --j) { |
91 const DocumentMarker& marker = *(*list)[j - 1]; | 92 const DocumentMarker& marker = *markers_[j - 1]; |
92 const unsigned start = marker.StartOffset(); | 93 const unsigned start = marker.StartOffset(); |
93 const unsigned length = marker.EndOffset() - marker.StartOffset(); | 94 const unsigned length = marker.EndOffset() - marker.StartOffset(); |
94 const String& marker_text = node_text.Substring(start, length); | 95 const String& marker_text = node_text.Substring(start, length); |
95 if (words.Contains(marker_text)) { | 96 if (words.Contains(marker_text)) { |
96 list->erase(j - 1); | 97 markers_.erase(j - 1); |
97 removed_markers = true; | 98 removed_markers = true; |
98 } | 99 } |
99 } | 100 } |
100 | 101 |
101 return removed_markers; | 102 return removed_markers; |
102 } | 103 } |
103 | 104 |
104 bool DocumentMarkerListEditor::ShiftMarkers(MarkerList* list, | 105 bool DocumentMarkerListEditor::ShiftMarkers(MarkerList* list, |
105 unsigned offset, | 106 unsigned offset, |
106 unsigned old_length, | 107 unsigned old_length, |
(...skipping 15 matching lines...) Expand all Loading... |
122 did_shift_marker = true; | 123 did_shift_marker = true; |
123 marker.SetStartOffset(result.value().start_offset); | 124 marker.SetStartOffset(result.value().start_offset); |
124 marker.SetEndOffset(result.value().end_offset); | 125 marker.SetEndOffset(result.value().end_offset); |
125 } | 126 } |
126 } | 127 } |
127 | 128 |
128 return did_shift_marker; | 129 return did_shift_marker; |
129 } | 130 } |
130 | 131 |
131 } // namespace blink | 132 } // namespace blink |
OLD | NEW |