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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 case DocumentMarker::kComposition: | 70 case DocumentMarker::kComposition: |
71 return DocumentMarker::kCompositionMarkerIndex; | 71 return DocumentMarker::kCompositionMarkerIndex; |
72 } | 72 } |
73 | 73 |
74 NOTREACHED(); | 74 NOTREACHED(); |
75 return DocumentMarker::kSpellingMarkerIndex; | 75 return DocumentMarker::kSpellingMarkerIndex; |
76 } | 76 } |
77 | 77 |
78 } // namespace | 78 } // namespace |
79 | 79 |
| 80 Member<DocumentMarkerController::MarkerList>& |
| 81 DocumentMarkerController::ListForType(MarkerLists* marker_lists, |
| 82 DocumentMarker::MarkerType type) { |
| 83 const size_t marker_list_index = MarkerTypeToMarkerIndex(type); |
| 84 return (*marker_lists)[marker_list_index]; |
| 85 } |
| 86 |
80 inline bool DocumentMarkerController::PossiblyHasMarkers( | 87 inline bool DocumentMarkerController::PossiblyHasMarkers( |
81 DocumentMarker::MarkerTypes types) { | 88 DocumentMarker::MarkerTypes types) { |
82 return possibly_existing_marker_types_.Intersects(types); | 89 return possibly_existing_marker_types_.Intersects(types); |
83 } | 90 } |
84 | 91 |
85 DocumentMarkerController::DocumentMarkerController(Document& document) | 92 DocumentMarkerController::DocumentMarkerController(Document& document) |
86 : possibly_existing_marker_types_(0), document_(&document) { | 93 : possibly_existing_marker_types_(0), document_(&document) { |
87 SetContext(&document); | 94 SetContext(&document); |
88 } | 95 } |
89 | 96 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 227 |
221 possibly_existing_marker_types_.Add(new_marker.GetType()); | 228 possibly_existing_marker_types_.Add(new_marker.GetType()); |
222 | 229 |
223 Member<MarkerLists>& markers = | 230 Member<MarkerLists>& markers = |
224 markers_.insert(node, nullptr).stored_value->value; | 231 markers_.insert(node, nullptr).stored_value->value; |
225 if (!markers) { | 232 if (!markers) { |
226 markers = new MarkerLists; | 233 markers = new MarkerLists; |
227 markers->Grow(DocumentMarker::kMarkerTypeIndexesCount); | 234 markers->Grow(DocumentMarker::kMarkerTypeIndexesCount); |
228 } | 235 } |
229 | 236 |
230 DocumentMarker::MarkerTypeIndex marker_list_index = | 237 const DocumentMarker::MarkerType new_marker_type = new_marker.GetType(); |
231 MarkerTypeToMarkerIndex(new_marker.GetType()); | 238 if (!ListForType(markers, new_marker_type)) |
232 if (!markers->at(marker_list_index)) { | 239 ListForType(markers, new_marker_type) = new MarkerList; |
233 markers->at(marker_list_index) = new MarkerList; | |
234 } | |
235 | 240 |
236 Member<MarkerList>& list = markers->at(marker_list_index); | 241 Member<MarkerList>& list = ListForType(markers, new_marker_type); |
237 DocumentMarkerListEditor::AddMarker(list, &new_marker); | 242 DocumentMarkerListEditor::AddMarker(list, &new_marker); |
238 | 243 |
239 // repaint the affected node | 244 // repaint the affected node |
240 if (node->GetLayoutObject()) { | 245 if (node->GetLayoutObject()) { |
241 node->GetLayoutObject()->SetShouldDoFullPaintInvalidation( | 246 node->GetLayoutObject()->SetShouldDoFullPaintInvalidation( |
242 kPaintInvalidationDocumentMarkerChange); | 247 kPaintInvalidationDocumentMarkerChange); |
243 } | 248 } |
244 } | 249 } |
245 | 250 |
246 // TODO(rlanday): move DocumentMarkerListEditor into its own .h/.cpp files | 251 // TODO(rlanday): move DocumentMarkerListEditor into its own .h/.cpp files |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 | 759 |
755 bool DocumentMarkerController::SetMarkersActive(Node* node, | 760 bool DocumentMarkerController::SetMarkersActive(Node* node, |
756 unsigned start_offset, | 761 unsigned start_offset, |
757 unsigned end_offset, | 762 unsigned end_offset, |
758 bool active) { | 763 bool active) { |
759 MarkerLists* markers = markers_.at(node); | 764 MarkerLists* markers = markers_.at(node); |
760 if (!markers) | 765 if (!markers) |
761 return false; | 766 return false; |
762 | 767 |
763 bool doc_dirty = false; | 768 bool doc_dirty = false; |
764 Member<MarkerList>& list = | 769 Member<MarkerList>& list = ListForType(markers, DocumentMarker::kTextMatch); |
765 (*markers)[MarkerTypeToMarkerIndex(DocumentMarker::kTextMatch)]; | |
766 if (!list) | 770 if (!list) |
767 return false; | 771 return false; |
768 MarkerList::iterator start_pos = | 772 MarkerList::iterator start_pos = |
769 std::upper_bound(list->begin(), list->end(), start_offset, EndsBefore); | 773 std::upper_bound(list->begin(), list->end(), start_offset, EndsBefore); |
770 for (MarkerList::iterator marker = start_pos; marker != list->end(); | 774 for (MarkerList::iterator marker = start_pos; marker != list->end(); |
771 ++marker) { | 775 ++marker) { |
772 // Markers are returned in order, so stop if we are now past the specified | 776 // Markers are returned in order, so stop if we are now past the specified |
773 // range. | 777 // range. |
774 if ((*marker)->StartOffset() >= end_offset) | 778 if ((*marker)->StartOffset() >= end_offset) |
775 break; | 779 break; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 } | 885 } |
882 | 886 |
883 } // namespace blink | 887 } // namespace blink |
884 | 888 |
885 #ifndef NDEBUG | 889 #ifndef NDEBUG |
886 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { | 890 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { |
887 if (controller) | 891 if (controller) |
888 controller->ShowMarkers(); | 892 controller->ShowMarkers(); |
889 } | 893 } |
890 #endif | 894 #endif |
OLD | NEW |