| 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 12 matching lines...) Expand all Loading... |
| 23 * along with this library; see the file COPYING.LIB. If not, write to | 23 * along with this library; see the file COPYING.LIB. If not, write to |
| 24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 25 * Boston, MA 02110-1301, USA. | 25 * Boston, MA 02110-1301, USA. |
| 26 * | 26 * |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #ifndef DocumentMarkerController_h | 29 #ifndef DocumentMarkerController_h |
| 30 #define DocumentMarkerController_h | 30 #define DocumentMarkerController_h |
| 31 | 31 |
| 32 #include "core/CoreExport.h" | 32 #include "core/CoreExport.h" |
| 33 #include "core/editing/FrameSelection.h" |
| 34 #include "core/editing/VisiblePosition.h" |
| 33 #include "core/editing/iterators/TextIterator.h" | 35 #include "core/editing/iterators/TextIterator.h" |
| 34 #include "core/editing/markers/DocumentMarker.h" | 36 #include "core/editing/markers/DocumentMarker.h" |
| 35 #include "platform/geometry/IntRect.h" | 37 #include "platform/geometry/IntRect.h" |
| 36 #include "platform/heap/Handle.h" | 38 #include "platform/heap/Handle.h" |
| 37 #include "wtf/HashMap.h" | 39 #include "wtf/HashMap.h" |
| 38 #include "wtf/Vector.h" | 40 #include "wtf/Vector.h" |
| 39 | 41 |
| 40 namespace blink { | 42 namespace blink { |
| 41 | 43 |
| 42 class Node; | 44 class Node; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 63 void addMarker(const Position& start, | 65 void addMarker(const Position& start, |
| 64 const Position& end, | 66 const Position& end, |
| 65 DocumentMarker::MarkerType, | 67 DocumentMarker::MarkerType, |
| 66 const String& description = emptyString(), | 68 const String& description = emptyString(), |
| 67 uint32_t hash = 0); | 69 uint32_t hash = 0); |
| 68 void addTextMatchMarker(const EphemeralRange&, bool activeMatch); | 70 void addTextMatchMarker(const EphemeralRange&, bool activeMatch); |
| 69 void addCompositionMarker(const Position& start, | 71 void addCompositionMarker(const Position& start, |
| 70 const Position& end, | 72 const Position& end, |
| 71 Color underlineColor, | 73 Color underlineColor, |
| 72 bool thick, | 74 bool thick, |
| 73 Color backgroundColor); | 75 Color backgroundColor, |
| 76 const std::vector<std::string>& suggestions); |
| 77 void addSuggestionBackgroundHighlightMarker(const Position& start, |
| 78 const Position& end, |
| 79 Color underlineColor, |
| 80 bool thick, |
| 81 Color backgroundColor); |
| 74 | 82 |
| 75 void copyMarkers(Node* srcNode, | 83 void copyMarkers(Node* srcNode, |
| 76 unsigned startOffset, | 84 unsigned startOffset, |
| 77 int length, | 85 int length, |
| 78 Node* dstNode, | 86 Node* dstNode, |
| 79 int delta); | 87 int delta); |
| 80 | 88 |
| 81 void prepareForDestruction(); | 89 void prepareForDestruction(); |
| 82 // When a marker partially overlaps with range, if | 90 // When a marker partially overlaps with range, if |
| 83 // removePartiallyOverlappingMarkers is true, we completely remove the marker. | 91 // removePartiallyOverlappingMarkers is true, we completely remove the marker. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 97 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers(), | 105 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers(), |
| 98 RemovePartiallyOverlappingMarkerOrNot = | 106 RemovePartiallyOverlappingMarkerOrNot = |
| 99 DoNotRemovePartiallyOverlappingMarker); | 107 DoNotRemovePartiallyOverlappingMarker); |
| 100 | 108 |
| 101 void removeMarkers( | 109 void removeMarkers( |
| 102 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); | 110 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); |
| 103 void removeMarkers( | 111 void removeMarkers( |
| 104 Node*, | 112 Node*, |
| 105 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); | 113 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); |
| 106 void removeMarkers(const MarkerRemoverPredicate& shouldRemoveMarker); | 114 void removeMarkers(const MarkerRemoverPredicate& shouldRemoveMarker); |
| 115 void removeSuggestionMarkersByID(const Vector<int>& idsToRemove); |
| 116 void removeMarkersForWordsAffectedByEditing( |
| 117 DocumentMarker::MarkerTypes, |
| 118 bool doNotRemoveIfSelectionAtWordBoundary); |
| 107 void repaintMarkers( | 119 void repaintMarkers( |
| 108 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); | 120 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); |
| 109 void shiftMarkers(Node*, unsigned startOffset, int delta); | 121 void shiftMarkers(Node*, int startOffset, int prevLength, int delta); |
| 110 // Returns true if markers within a range are found. | 122 // Returns true if markers within a range are found. |
| 111 bool setMarkersActive(const EphemeralRange&, bool); | 123 bool setMarkersActive(const EphemeralRange&, bool); |
| 112 // Returns true if markers within a range defined by a node, |startOffset| and | 124 // Returns true if markers within a range defined by a node, |startOffset| and |
| 113 // |endOffset| are found. | 125 // |endOffset| are found. |
| 114 bool setMarkersActive(Node*, unsigned startOffset, unsigned endOffset, bool); | 126 bool setMarkersActive(Node*, unsigned startOffset, unsigned endOffset, bool); |
| 115 bool hasMarkers(Node* node) const { return m_markers.contains(node); } | 127 bool hasMarkers(Node* node) const { return m_markers.contains(node); } |
| 116 | 128 |
| 117 DocumentMarkerVector markersFor( | 129 DocumentMarkerVector markersFor( |
| 118 Node*, | 130 Node*, |
| 119 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); | 131 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); |
| 120 DocumentMarkerVector markersInRange(const EphemeralRange&, | 132 DocumentMarkerVector markersInRange(const EphemeralRange&, |
| 121 DocumentMarker::MarkerTypes); | 133 DocumentMarker::MarkerTypes); |
| 134 DocumentMarkerVector markersInRangeInclusive(const EphemeralRange&, |
| 135 DocumentMarker::MarkerTypes); |
| 122 DocumentMarkerVector markers(); | 136 DocumentMarkerVector markers(); |
| 123 Vector<IntRect> renderedRectsForMarkers(DocumentMarker::MarkerType); | 137 Vector<IntRect> renderedRectsForMarkers(DocumentMarker::MarkerType); |
| 124 void updateMarkerRenderedRectIfNeeded(const Node&, RenderedDocumentMarker&); | 138 void updateMarkerRenderedRectIfNeeded(const Node&, RenderedDocumentMarker&); |
| 125 void invalidateRectsForAllMarkers(); | 139 void invalidateRectsForAllMarkers(); |
| 126 void invalidateRectsForMarkersInNode(const Node&); | 140 void invalidateRectsForMarkersInNode(const Node&); |
| 127 | 141 |
| 128 DECLARE_TRACE(); | 142 DECLARE_TRACE(); |
| 129 | 143 |
| 130 #ifndef NDEBUG | 144 #ifndef NDEBUG |
| 131 void showMarkers() const; | 145 void showMarkers() const; |
| 132 #endif | 146 #endif |
| 133 | 147 |
| 134 private: | 148 private: |
| 135 void addMarker(Node*, const DocumentMarker&); | 149 void addMarker(Node*, const DocumentMarker&); |
| 136 | 150 |
| 137 using MarkerList = HeapVector<Member<RenderedDocumentMarker>>; | 151 using MarkerList = HeapVector<Member<RenderedDocumentMarker>>; |
| 138 using MarkerLists = | 152 using MarkerLists = |
| 139 HeapVector<Member<MarkerList>, DocumentMarker::MarkerTypeIndexesCount>; | 153 HeapVector<Member<MarkerList>, DocumentMarker::MarkerTypeIndexesCount>; |
| 140 using MarkerMap = HeapHashMap<WeakMember<const Node>, Member<MarkerLists>>; | 154 using MarkerMap = HeapHashMap<WeakMember<const Node>, Member<MarkerLists>>; |
| 155 DocumentMarkerVector markersInRangeInternal( |
| 156 const EphemeralRange&, |
| 157 DocumentMarker::MarkerTypes, |
| 158 bool includeSpansTouchingEndpoints); |
| 141 void mergeOverlapping(MarkerList*, RenderedDocumentMarker*); | 159 void mergeOverlapping(MarkerList*, RenderedDocumentMarker*); |
| 142 bool possiblyHasMarkers(DocumentMarker::MarkerTypes); | 160 bool possiblyHasMarkers(DocumentMarker::MarkerTypes); |
| 143 void removeMarkersFromList(MarkerMap::iterator, DocumentMarker::MarkerTypes); | 161 void removeMarkersFromList(MarkerMap::iterator, DocumentMarker::MarkerTypes); |
| 144 void removeMarkers(TextIterator&, | 162 void removeMarkers(TextIterator&, |
| 145 DocumentMarker::MarkerTypes, | 163 DocumentMarker::MarkerTypes, |
| 146 RemovePartiallyOverlappingMarkerOrNot); | 164 RemovePartiallyOverlappingMarkerOrNot); |
| 147 | 165 |
| 148 MarkerMap m_markers; | 166 MarkerMap m_markers; |
| 149 // Provide a quick way to determine whether a particular marker type is absent | 167 // Provide a quick way to determine whether a particular marker type is absent |
| 150 // without going through the map. | 168 // without going through the map. |
| 151 DocumentMarker::MarkerTypes m_possiblyExistingMarkerTypes; | 169 DocumentMarker::MarkerTypes m_possiblyExistingMarkerTypes; |
| 152 const Member<const Document> m_document; | 170 const Member<const Document> m_document; |
| 171 int m_nextSuggestionMarkerID; |
| 153 }; | 172 }; |
| 154 | 173 |
| 155 } // namespace blink | 174 } // namespace blink |
| 156 | 175 |
| 157 #ifndef NDEBUG | 176 #ifndef NDEBUG |
| 158 void showDocumentMarkers(const blink::DocumentMarkerController*); | 177 void showDocumentMarkers(const blink::DocumentMarkerController*); |
| 159 #endif | 178 #endif |
| 160 | 179 |
| 161 #endif // DocumentMarkerController_h | 180 #endif // DocumentMarkerController_h |
| OLD | NEW |