| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of the DOM implementation for WebCore. | 2 * This file is part of the DOM implementation for WebCore. |
| 3 * | 3 * |
| 4 * Copyright (C) 2006 Apple Computer, Inc. | 4 * Copyright (C) 2006 Apple Computer, Inc. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #include "core/CoreExport.h" | 26 #include "core/CoreExport.h" |
| 27 #include "platform/graphics/Color.h" | 27 #include "platform/graphics/Color.h" |
| 28 #include "platform/heap/Handle.h" | 28 #include "platform/heap/Handle.h" |
| 29 #include "platform/wtf/Optional.h" | 29 #include "platform/wtf/Optional.h" |
| 30 #include "platform/wtf/VectorTraits.h" | 30 #include "platform/wtf/VectorTraits.h" |
| 31 #include "platform/wtf/text/WTFString.h" | 31 #include "platform/wtf/text/WTFString.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 class DocumentMarkerDetails; | |
| 36 | |
| 37 // A range of a node within a document that is "marked", such as the range of a | 35 // A range of a node within a document that is "marked", such as the range of a |
| 38 // misspelled word. It optionally includes a description that could be displayed | 36 // misspelled word. It optionally includes a description that could be displayed |
| 39 // in the user interface. | 37 // in the user interface. |
| 40 class CORE_EXPORT DocumentMarker : public GarbageCollected<DocumentMarker> { | 38 class CORE_EXPORT DocumentMarker |
| 39 : public GarbageCollectedFinalized<DocumentMarker> { |
| 41 public: | 40 public: |
| 42 enum MarkerTypeIndex { | 41 enum MarkerTypeIndex { |
| 43 kSpellingMarkerIndex = 0, | 42 kSpellingMarkerIndex = 0, |
| 44 kGrammarMarkerIndex, | 43 kGrammarMarkerIndex, |
| 45 kTextMatchMarkerIndex, | 44 kTextMatchMarkerIndex, |
| 46 kCompositionMarkerIndex, | 45 kCompositionMarkerIndex, |
| 47 kMarkerTypeIndexesCount | 46 kMarkerTypeIndexesCount |
| 48 }; | 47 }; |
| 49 | 48 |
| 50 enum MarkerType { | 49 enum MarkerType { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 class AllMarkers : public MarkerTypes { | 120 class AllMarkers : public MarkerTypes { |
| 122 public: | 121 public: |
| 123 AllMarkers() : MarkerTypes((1 << kMarkerTypeIndexesCount) - 1) {} | 122 AllMarkers() : MarkerTypes((1 << kMarkerTypeIndexesCount) - 1) {} |
| 124 }; | 123 }; |
| 125 | 124 |
| 126 class MisspellingMarkers : public MarkerTypes { | 125 class MisspellingMarkers : public MarkerTypes { |
| 127 public: | 126 public: |
| 128 MisspellingMarkers() : MarkerTypes(kSpelling | kGrammar) {} | 127 MisspellingMarkers() : MarkerTypes(kSpelling | kGrammar) {} |
| 129 }; | 128 }; |
| 130 | 129 |
| 131 DocumentMarker(MarkerType, | 130 virtual ~DocumentMarker(); |
| 132 unsigned start_offset, | |
| 133 unsigned end_offset, | |
| 134 const String& description); | |
| 135 | 131 |
| 136 MarkerType GetType() const { return type_; } | 132 MarkerType GetType() const { return type_; } |
| 137 unsigned StartOffset() const { return start_offset_; } | 133 unsigned StartOffset() const { return start_offset_; } |
| 138 unsigned EndOffset() const { return end_offset_; } | 134 unsigned EndOffset() const { return end_offset_; } |
| 139 | 135 |
| 140 const String& Description() const; | |
| 141 DocumentMarkerDetails* Details() const; | |
| 142 | |
| 143 void ClearDetails() { details_.Clear(); } | |
| 144 | |
| 145 struct MarkerOffsets { | 136 struct MarkerOffsets { |
| 146 unsigned start_offset; | 137 unsigned start_offset; |
| 147 unsigned end_offset; | 138 unsigned end_offset; |
| 148 }; | 139 }; |
| 149 | 140 |
| 150 Optional<MarkerOffsets> ComputeOffsetsAfterShift(unsigned offset, | 141 Optional<MarkerOffsets> ComputeOffsetsAfterShift(unsigned offset, |
| 151 unsigned old_length, | 142 unsigned old_length, |
| 152 unsigned new_length) const; | 143 unsigned new_length) const; |
| 153 | 144 |
| 154 // Offset modifications are done by DocumentMarkerController. | 145 // Offset modifications are done by DocumentMarkerController. |
| 155 // Other classes should not call following setters. | 146 // Other classes should not call following setters. |
| 156 void SetStartOffset(unsigned offset) { start_offset_ = offset; } | 147 void SetStartOffset(unsigned offset) { start_offset_ = offset; } |
| 157 void SetEndOffset(unsigned offset) { end_offset_ = offset; } | 148 void SetEndOffset(unsigned offset) { end_offset_ = offset; } |
| 158 void ShiftOffsets(int delta); | 149 void ShiftOffsets(int delta); |
| 159 | 150 |
| 160 DECLARE_TRACE(); | 151 DEFINE_INLINE_VIRTUAL_TRACE() {} |
| 161 | 152 |
| 162 protected: | 153 protected: |
| 163 DocumentMarker(MarkerType, unsigned start_offset, unsigned end_offset); | 154 DocumentMarker(MarkerType, unsigned start_offset, unsigned end_offset); |
| 164 | 155 |
| 165 private: | 156 private: |
| 166 const MarkerType type_; | 157 const MarkerType type_; |
| 167 unsigned start_offset_; | 158 unsigned start_offset_; |
| 168 unsigned end_offset_; | 159 unsigned end_offset_; |
| 169 Member<DocumentMarkerDetails> details_; | |
| 170 | 160 |
| 171 DISALLOW_COPY_AND_ASSIGN(DocumentMarker); | 161 DISALLOW_COPY_AND_ASSIGN(DocumentMarker); |
| 172 }; | 162 }; |
| 173 | 163 |
| 174 using DocumentMarkerVector = HeapVector<Member<DocumentMarker>>; | 164 using DocumentMarkerVector = HeapVector<Member<DocumentMarker>>; |
| 175 | 165 |
| 176 inline DocumentMarkerDetails* DocumentMarker::Details() const { | |
| 177 return details_.Get(); | |
| 178 } | |
| 179 | |
| 180 class DocumentMarkerDetails | |
| 181 : public GarbageCollectedFinalized<DocumentMarkerDetails> { | |
| 182 public: | |
| 183 DocumentMarkerDetails() {} | |
| 184 virtual ~DocumentMarkerDetails(); | |
| 185 virtual bool IsDescription() const { return false; } | |
| 186 | |
| 187 DEFINE_INLINE_VIRTUAL_TRACE() {} | |
| 188 }; | |
| 189 | |
| 190 } // namespace blink | 166 } // namespace blink |
| 191 | 167 |
| 192 #endif // DocumentMarker_h | 168 #endif // DocumentMarker_h |
| OLD | NEW |