| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | |
| 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. | |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | |
| 8 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | |
| 9 * | |
| 10 * This library is free software; you can redistribute it and/or | |
| 11 * modify it under the terms of the GNU Library General Public | |
| 12 * License as published by the Free Software Foundation; either | |
| 13 * version 2 of the License, or (at your option) any later version. | |
| 14 * | |
| 15 * This library is distributed in the hope that it will be useful, | |
| 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 18 * Library General Public License for more details. | |
| 19 * | |
| 20 * You should have received a copy of the GNU Library General Public License | |
| 21 * along with this library; see the file COPYING.LIB. If not, write to | |
| 22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 23 * Boston, MA 02110-1301, USA. | |
| 24 * | |
| 25 */ | |
| 26 | |
| 27 #ifndef DocumentMarkerController_h | |
| 28 #define DocumentMarkerController_h | |
| 29 | |
| 30 #include "core/CoreExport.h" | |
| 31 #include "core/dom/DocumentMarker.h" | |
| 32 #include "core/editing/iterators/TextIterator.h" | |
| 33 #include "platform/geometry/IntRect.h" | |
| 34 #include "platform/heap/Handle.h" | |
| 35 #include "wtf/HashMap.h" | |
| 36 #include "wtf/Vector.h" | |
| 37 | |
| 38 namespace blink { | |
| 39 | |
| 40 class LayoutPoint; | |
| 41 class LayoutRect; | |
| 42 class Node; | |
| 43 class Range; | |
| 44 class RenderedDocumentMarker; | |
| 45 class Text; | |
| 46 | |
| 47 class MarkerRemoverPredicate final { | |
| 48 public: | |
| 49 explicit MarkerRemoverPredicate(const Vector<String>& words); | |
| 50 bool operator()(const DocumentMarker&, const Text&) const; | |
| 51 | |
| 52 private: | |
| 53 Vector<String> m_words; | |
| 54 }; | |
| 55 | |
| 56 class CORE_EXPORT DocumentMarkerController final : public NoBaseWillBeGarbageCol
lected<DocumentMarkerController> { | |
| 57 WTF_MAKE_NONCOPYABLE(DocumentMarkerController); WTF_MAKE_FAST_ALLOCATED_WILL
_BE_REMOVED(DocumentMarkerController); | |
| 58 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(DocumentMarkerController); | |
| 59 public: | |
| 60 | |
| 61 DocumentMarkerController(); | |
| 62 | |
| 63 void clear(); | |
| 64 void addMarker(const Position& start, const Position& end, DocumentMarker::M
arkerType, const String& description = emptyString(), uint32_t hash = 0); | |
| 65 void addTextMatchMarker(const Range*, bool activeMatch); | |
| 66 | |
| 67 void copyMarkers(Node* srcNode, unsigned startOffset, int length, Node* dstN
ode, int delta); | |
| 68 | |
| 69 void prepareForDestruction(); | |
| 70 // When a marker partially overlaps with range, if removePartiallyOverlappin
gMarkers is true, we completely | |
| 71 // remove the marker. If the argument is false, we will adjust the span of t
he marker so that it retains | |
| 72 // the portion that is outside of the range. | |
| 73 enum RemovePartiallyOverlappingMarkerOrNot { DoNotRemovePartiallyOverlapping
Marker, RemovePartiallyOverlappingMarker }; | |
| 74 void removeMarkers(const EphemeralRange&, DocumentMarker::MarkerTypes = Docu
mentMarker::AllMarkers(), RemovePartiallyOverlappingMarkerOrNot = DoNotRemovePar
tiallyOverlappingMarker); | |
| 75 void removeMarkers(Node*, unsigned startOffset, int length, DocumentMarker::
MarkerTypes = DocumentMarker::AllMarkers(), RemovePartiallyOverlappingMarkerOrN
ot = DoNotRemovePartiallyOverlappingMarker); | |
| 76 | |
| 77 void removeMarkers(DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers(
)); | |
| 78 void removeMarkers(Node*, DocumentMarker::MarkerTypes = DocumentMarker::AllM
arkers()); | |
| 79 void removeMarkers(const MarkerRemoverPredicate& shouldRemoveMarker); | |
| 80 void repaintMarkers(DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers
()); | |
| 81 void shiftMarkers(Node*, unsigned startOffset, int delta); | |
| 82 void setMarkersActive(Range*, bool); | |
| 83 void setMarkersActive(Node*, unsigned startOffset, unsigned endOffset, bool)
; | |
| 84 bool hasMarkers(Node* node) const { return m_markers.contains(node); } | |
| 85 | |
| 86 DocumentMarker* markerContainingPoint(const LayoutPoint&, DocumentMarker::Ma
rkerType); | |
| 87 DocumentMarkerVector markersFor(Node*, DocumentMarker::MarkerTypes = Documen
tMarker::AllMarkers()); | |
| 88 DocumentMarkerVector markersInRange(const EphemeralRange&, DocumentMarker::M
arkerTypes); | |
| 89 DocumentMarkerVector markers(); | |
| 90 Vector<IntRect> renderedRectsForMarkers(DocumentMarker::MarkerType); | |
| 91 void updateRenderedRectsForMarkers(); | |
| 92 | |
| 93 DECLARE_TRACE(); | |
| 94 | |
| 95 #ifndef NDEBUG | |
| 96 void showMarkers() const; | |
| 97 #endif | |
| 98 | |
| 99 private: | |
| 100 void addMarker(Node*, const DocumentMarker&); | |
| 101 | |
| 102 using MarkerList = WillBeHeapVector<OwnPtrWillBeMember<RenderedDocumentMarke
r>>; | |
| 103 using MarkerLists = WillBeHeapVector<OwnPtrWillBeMember<MarkerList>, Documen
tMarker::MarkerTypeIndexesCount>; | |
| 104 using MarkerMap = WillBeHeapHashMap<RawPtrWillBeWeakMember<const Node>, OwnP
trWillBeMember<MarkerLists>>; | |
| 105 void mergeOverlapping(MarkerList*, PassOwnPtrWillBeRawPtr<RenderedDocumentMa
rker>); | |
| 106 bool possiblyHasMarkers(DocumentMarker::MarkerTypes); | |
| 107 void removeMarkersFromList(MarkerMap::iterator, DocumentMarker::MarkerTypes)
; | |
| 108 void removeMarkers(TextIterator&, DocumentMarker::MarkerTypes, RemovePartial
lyOverlappingMarkerOrNot); | |
| 109 | |
| 110 MarkerMap m_markers; | |
| 111 // Provide a quick way to determine whether a particular marker type is abse
nt without going through the map. | |
| 112 DocumentMarker::MarkerTypes m_possiblyExistingMarkerTypes; | |
| 113 }; | |
| 114 | |
| 115 } // namespace blink | |
| 116 | |
| 117 #ifndef NDEBUG | |
| 118 void showDocumentMarkers(const blink::DocumentMarkerController*); | |
| 119 #endif | |
| 120 | |
| 121 #endif // DocumentMarkerController_h | |
| OLD | NEW |