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
reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * reserved. |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) |
8 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
9 * | 11 * |
10 * This library is free software; you can redistribute it and/or | 12 * This library is free software; you can redistribute it and/or |
11 * modify it under the terms of the GNU Library General Public | 13 * modify it under the terms of the GNU Library General Public |
12 * License as published by the Free Software Foundation; either | 14 * License as published by the Free Software Foundation; either |
13 * version 2 of the License, or (at your option) any later version. | 15 * version 2 of the License, or (at your option) any later version. |
14 * | 16 * |
15 * This library is distributed in the hope that it will be useful, | 17 * This library is distributed in the hope that it will be useful, |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 void DocumentMarkerController::clear() { | 90 void DocumentMarkerController::clear() { |
89 m_markers.clear(); | 91 m_markers.clear(); |
90 m_possiblyExistingMarkerTypes = 0; | 92 m_possiblyExistingMarkerTypes = 0; |
91 } | 93 } |
92 | 94 |
93 void DocumentMarkerController::addMarker(const Position& start, | 95 void DocumentMarkerController::addMarker(const Position& start, |
94 const Position& end, | 96 const Position& end, |
95 DocumentMarker::MarkerType type, | 97 DocumentMarker::MarkerType type, |
96 const String& description, | 98 const String& description, |
97 uint32_t hash) { | 99 uint32_t hash) { |
98 // Use a TextIterator to visit the potentially multiple nodes the range covers
. | 100 // Use a TextIterator to visit the potentially multiple nodes the range |
| 101 // covers. |
99 for (TextIterator markedText(start, end); !markedText.atEnd(); | 102 for (TextIterator markedText(start, end); !markedText.atEnd(); |
100 markedText.advance()) { | 103 markedText.advance()) { |
101 addMarker(markedText.currentContainer(), | 104 addMarker(markedText.currentContainer(), |
102 DocumentMarker(type, markedText.startOffsetInCurrentContainer(), | 105 DocumentMarker(type, markedText.startOffsetInCurrentContainer(), |
103 markedText.endOffsetInCurrentContainer(), | 106 markedText.endOffsetInCurrentContainer(), |
104 description, hash)); | 107 description, hash)); |
105 } | 108 } |
106 } | 109 } |
107 | 110 |
108 void DocumentMarkerController::addTextMatchMarker(const EphemeralRange& range, | 111 void DocumentMarkerController::addTextMatchMarker(const EphemeralRange& range, |
109 bool activeMatch) { | 112 bool activeMatch) { |
110 DCHECK(!m_document->needsLayoutTreeUpdate()); | 113 DCHECK(!m_document->needsLayoutTreeUpdate()); |
111 | 114 |
112 // Use a TextIterator to visit the potentially multiple nodes the range covers
. | 115 // Use a TextIterator to visit the potentially multiple nodes the range |
| 116 // covers. |
113 for (TextIterator markedText(range.startPosition(), range.endPosition()); | 117 for (TextIterator markedText(range.startPosition(), range.endPosition()); |
114 !markedText.atEnd(); markedText.advance()) | 118 !markedText.atEnd(); markedText.advance()) |
115 addMarker( | 119 addMarker( |
116 markedText.currentContainer(), | 120 markedText.currentContainer(), |
117 DocumentMarker(markedText.startOffsetInCurrentContainer(), | 121 DocumentMarker(markedText.startOffsetInCurrentContainer(), |
118 markedText.endOffsetInCurrentContainer(), activeMatch)); | 122 markedText.endOffsetInCurrentContainer(), activeMatch)); |
119 // Don't invalidate tickmarks here. TextFinder invalidates tickmarks using a t
hrottling algorithm. crbug.com/6819. | 123 // Don't invalidate tickmarks here. TextFinder invalidates tickmarks using a |
| 124 // throttling algorithm. crbug.com/6819. |
120 } | 125 } |
121 | 126 |
122 void DocumentMarkerController::addCompositionMarker(const Position& start, | 127 void DocumentMarkerController::addCompositionMarker(const Position& start, |
123 const Position& end, | 128 const Position& end, |
124 Color underlineColor, | 129 Color underlineColor, |
125 bool thick, | 130 bool thick, |
126 Color backgroundColor) { | 131 Color backgroundColor) { |
127 DCHECK(!m_document->needsLayoutTreeUpdate()); | 132 DCHECK(!m_document->needsLayoutTreeUpdate()); |
128 | 133 |
129 for (TextIterator markedText(start, end); !markedText.atEnd(); | 134 for (TextIterator markedText(start, end); !markedText.atEnd(); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 for (MarkerList::iterator i = firstOverlapping; | 281 for (MarkerList::iterator i = firstOverlapping; |
277 i != list->end() && (*i)->startOffset() <= (*inserted)->endOffset();) { | 282 i != list->end() && (*i)->startOffset() <= (*inserted)->endOffset();) { |
278 (*inserted)->setStartOffset( | 283 (*inserted)->setStartOffset( |
279 std::min((*inserted)->startOffset(), (*i)->startOffset())); | 284 std::min((*inserted)->startOffset(), (*i)->startOffset())); |
280 (*inserted)->setEndOffset( | 285 (*inserted)->setEndOffset( |
281 std::max((*inserted)->endOffset(), (*i)->endOffset())); | 286 std::max((*inserted)->endOffset(), (*i)->endOffset())); |
282 list->remove(i - list->begin()); | 287 list->remove(i - list->begin()); |
283 } | 288 } |
284 } | 289 } |
285 | 290 |
286 // copies markers from srcNode to dstNode, applying the specified shift delta to
the copies. The shift is | 291 // copies markers from srcNode to dstNode, applying the specified shift delta to |
287 // useful if, e.g., the caller has created the dstNode from a non-prefix substri
ng of the srcNode. | 292 // the copies. The shift is useful if, e.g., the caller has created the dstNode |
| 293 // from a non-prefix substring of the srcNode. |
288 void DocumentMarkerController::copyMarkers(Node* srcNode, | 294 void DocumentMarkerController::copyMarkers(Node* srcNode, |
289 unsigned startOffset, | 295 unsigned startOffset, |
290 int length, | 296 int length, |
291 Node* dstNode, | 297 Node* dstNode, |
292 int delta) { | 298 int delta) { |
293 if (length <= 0) | 299 if (length <= 0) |
294 return; | 300 return; |
295 | 301 |
296 if (!possiblyHasMarkers(DocumentMarker::AllMarkers())) | 302 if (!possiblyHasMarkers(DocumentMarker::AllMarkers())) |
297 return; | 303 return; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 continue; | 373 continue; |
368 } | 374 } |
369 if (!markerTypes.contains((*list->begin())->type())) | 375 if (!markerTypes.contains((*list->begin())->type())) |
370 continue; | 376 continue; |
371 unsigned endOffset = startOffset + length; | 377 unsigned endOffset = startOffset + length; |
372 MarkerList::iterator startPos = | 378 MarkerList::iterator startPos = |
373 std::upper_bound(list->begin(), list->end(), startOffset, endsBefore); | 379 std::upper_bound(list->begin(), list->end(), startOffset, endsBefore); |
374 for (MarkerList::iterator i = startPos; i != list->end();) { | 380 for (MarkerList::iterator i = startPos; i != list->end();) { |
375 DocumentMarker marker(*i->get()); | 381 DocumentMarker marker(*i->get()); |
376 | 382 |
377 // markers are returned in order, so stop if we are now past the specified
range | 383 // markers are returned in order, so stop if we are now past the specified |
| 384 // range |
378 if (marker.startOffset() >= endOffset) | 385 if (marker.startOffset() >= endOffset) |
379 break; | 386 break; |
380 | 387 |
381 // at this point we know that marker and target intersect in some way | 388 // at this point we know that marker and target intersect in some way |
382 docDirty = true; | 389 docDirty = true; |
383 | 390 |
384 // pitch the old marker | 391 // pitch the old marker |
385 list->remove(i - list->begin()); | 392 list->remove(i - list->begin()); |
386 | 393 |
387 if (shouldRemovePartiallyOverlappingMarker) { | 394 if (shouldRemovePartiallyOverlappingMarker) { |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 | 802 |
796 bool docDirty = false; | 803 bool docDirty = false; |
797 Member<MarkerList>& list = | 804 Member<MarkerList>& list = |
798 (*markers)[MarkerTypeToMarkerIndex(DocumentMarker::TextMatch)]; | 805 (*markers)[MarkerTypeToMarkerIndex(DocumentMarker::TextMatch)]; |
799 if (!list) | 806 if (!list) |
800 return false; | 807 return false; |
801 MarkerList::iterator startPos = | 808 MarkerList::iterator startPos = |
802 std::upper_bound(list->begin(), list->end(), startOffset, endsBefore); | 809 std::upper_bound(list->begin(), list->end(), startOffset, endsBefore); |
803 for (MarkerList::iterator marker = startPos; marker != list->end(); | 810 for (MarkerList::iterator marker = startPos; marker != list->end(); |
804 ++marker) { | 811 ++marker) { |
805 // Markers are returned in order, so stop if we are now past the specified r
ange. | 812 // Markers are returned in order, so stop if we are now past the specified |
| 813 // range. |
806 if ((*marker)->startOffset() >= endOffset) | 814 if ((*marker)->startOffset() >= endOffset) |
807 break; | 815 break; |
808 | 816 |
809 (*marker)->setActiveMatch(active); | 817 (*marker)->setActiveMatch(active); |
810 docDirty = true; | 818 docDirty = true; |
811 } | 819 } |
812 | 820 |
813 // repaint the affected node | 821 // repaint the affected node |
814 if (docDirty && node->layoutObject()) | 822 if (docDirty && node->layoutObject()) |
815 node->layoutObject()->setShouldDoFullPaintInvalidation(); | 823 node->layoutObject()->setShouldDoFullPaintInvalidation(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 #endif | 859 #endif |
852 | 860 |
853 } // namespace blink | 861 } // namespace blink |
854 | 862 |
855 #ifndef NDEBUG | 863 #ifndef NDEBUG |
856 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { | 864 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { |
857 if (controller) | 865 if (controller) |
858 controller->showMarkers(); | 866 controller->showMarkers(); |
859 } | 867 } |
860 #endif | 868 #endif |
OLD | NEW |