| 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 * |
| 11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
| 15 * | 15 * |
| 16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
| 17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
| 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
| 20 * | 20 * |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #ifndef DocumentMarker_h | 23 #ifndef DocumentMarker_h |
| 24 #define DocumentMarker_h | 24 #define DocumentMarker_h |
| 25 | 25 |
| 26 #include "core/CoreExport.h" | 26 #include "core/CoreExport.h" |
| 27 #include "platform/graphics/Color.h" | |
| 28 #include "platform/heap/Handle.h" | 27 #include "platform/heap/Handle.h" |
| 29 #include "wtf/VectorTraits.h" | 28 #include "wtf/VectorTraits.h" |
| 30 #include "wtf/text/WTFString.h" | 29 #include "wtf/text/WTFString.h" |
| 31 | 30 |
| 32 namespace blink { | 31 namespace blink { |
| 33 | 32 |
| 34 class DocumentMarkerDetails; | 33 class DocumentMarkerDetails; |
| 35 | 34 |
| 36 // A range of a node within a document that is "marked", such as the range of a
misspelled word. | 35 // A range of a node within a document that is "marked", such as the range of a
misspelled word. |
| 37 // It optionally includes a description that could be displayed in the user inte
rface. | 36 // It optionally includes a description that could be displayed in the user inte
rface. |
| 38 // It also optionally includes a flag specifying whether the match is active, wh
ich is ignored | 37 // It also optionally includes a flag specifying whether the match is active, wh
ich is ignored |
| 39 // for all types other than type TextMatch. | 38 // for all types other than type TextMatch. |
| 40 class CORE_EXPORT DocumentMarker : public NoBaseWillBeGarbageCollected<DocumentM
arker> { | 39 class CORE_EXPORT DocumentMarker : public NoBaseWillBeGarbageCollected<DocumentM
arker> { |
| 41 public: | 40 public: |
| 42 enum MarkerTypeIndex { | 41 enum MarkerTypeIndex { |
| 43 SpellingMarkerIndex = 0, | 42 SpellingMarkerIndex = 0, |
| 44 GramarMarkerIndex, | 43 GramarMarkerIndex, |
| 45 TextMatchMarkerIndex, | 44 TextMatchMarkerIndex, |
| 46 InvisibleSpellcheckMarkerIndex, | 45 InvisibleSpellcheckMarkerIndex, |
| 47 CompositionMarkerIndex, | |
| 48 MarkerTypeIndexesCount | 46 MarkerTypeIndexesCount |
| 49 }; | 47 }; |
| 50 | 48 |
| 51 enum MarkerType { | 49 enum MarkerType { |
| 52 Spelling = 1 << SpellingMarkerIndex, | 50 Spelling = 1 << SpellingMarkerIndex, |
| 53 Grammar = 1 << GramarMarkerIndex, | 51 Grammar = 1 << GramarMarkerIndex, |
| 54 TextMatch = 1 << TextMatchMarkerIndex, | 52 TextMatch = 1 << TextMatchMarkerIndex, |
| 55 InvisibleSpellcheck = 1 << InvisibleSpellcheckMarkerIndex, | 53 InvisibleSpellcheck = 1 << InvisibleSpellcheckMarkerIndex |
| 56 Composition = 1 << CompositionMarkerIndex, | |
| 57 }; | 54 }; |
| 58 | 55 |
| 59 class MarkerTypes { | 56 class MarkerTypes { |
| 60 public: | 57 public: |
| 61 // The constructor is intentionally implicit to allow conversion from th
e bit-wise sum of above types | 58 // The constructor is intentionally implicit to allow conversion from th
e bit-wise sum of above types |
| 62 MarkerTypes(unsigned mask) : m_mask(mask) { } | 59 MarkerTypes(unsigned mask) : m_mask(mask) { } |
| 63 | 60 |
| 64 bool contains(MarkerType type) const { return m_mask & type; } | 61 bool contains(MarkerType type) const { return m_mask & type; } |
| 65 bool intersects(const MarkerTypes& types) const { return (m_mask & types
.m_mask); } | 62 bool intersects(const MarkerTypes& types) const { return (m_mask & types
.m_mask); } |
| 66 bool operator==(const MarkerTypes& other) const { return m_mask == other
.m_mask; } | 63 bool operator==(const MarkerTypes& other) const { return m_mask == other
.m_mask; } |
| 67 | 64 |
| 68 void add(const MarkerTypes& types) { m_mask |= types.m_mask; } | 65 void add(const MarkerTypes& types) { m_mask |= types.m_mask; } |
| 69 void remove(const MarkerTypes& types) { m_mask &= ~types.m_mask; } | 66 void remove(const MarkerTypes& types) { m_mask &= ~types.m_mask; } |
| 70 | 67 |
| 71 private: | 68 private: |
| 72 unsigned m_mask; | 69 unsigned m_mask; |
| 73 }; | 70 }; |
| 74 | 71 |
| 75 class AllMarkers : public MarkerTypes { | 72 class AllMarkers : public MarkerTypes { |
| 76 public: | 73 public: |
| 77 AllMarkers() | 74 AllMarkers() |
| 78 : MarkerTypes(Spelling | Grammar | TextMatch | InvisibleSpellcheck |
Composition) | 75 : MarkerTypes(Spelling | Grammar | TextMatch | InvisibleSpellcheck) |
| 79 { | 76 { |
| 80 } | 77 } |
| 81 }; | 78 }; |
| 82 | 79 |
| 83 class MisspellingMarkers : public MarkerTypes { | 80 class MisspellingMarkers : public MarkerTypes { |
| 84 public: | 81 public: |
| 85 MisspellingMarkers() | 82 MisspellingMarkers() |
| 86 : MarkerTypes(Spelling | Grammar) | 83 : MarkerTypes(Spelling | Grammar) |
| 87 { | 84 { |
| 88 } | 85 } |
| 89 }; | 86 }; |
| 90 | 87 |
| 91 class SpellCheckClientMarkers : public MarkerTypes { | 88 class SpellCheckClientMarkers : public MarkerTypes { |
| 92 public: | 89 public: |
| 93 SpellCheckClientMarkers() | 90 SpellCheckClientMarkers() |
| 94 : MarkerTypes(Spelling | Grammar | InvisibleSpellcheck) | 91 : MarkerTypes(Spelling | Grammar | InvisibleSpellcheck) |
| 95 { | 92 { |
| 96 } | 93 } |
| 97 }; | 94 }; |
| 98 | 95 |
| 99 DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, const S
tring& description, uint32_t hash); | 96 DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, const S
tring& description, uint32_t hash); |
| 100 DocumentMarker(unsigned startOffset, unsigned endOffset, bool activeMatch); | 97 DocumentMarker(unsigned startOffset, unsigned endOffset, bool activeMatch); |
| 101 DocumentMarker(unsigned startOffset, unsigned endOffset, Color underlineColo
r, bool thick, Color backgroundColor); | |
| 102 | |
| 103 DocumentMarker(const DocumentMarker&); | 98 DocumentMarker(const DocumentMarker&); |
| 104 | 99 |
| 105 MarkerType type() const { return m_type; } | 100 MarkerType type() const { return m_type; } |
| 106 unsigned startOffset() const { return m_startOffset; } | 101 unsigned startOffset() const { return m_startOffset; } |
| 107 unsigned endOffset() const { return m_endOffset; } | 102 unsigned endOffset() const { return m_endOffset; } |
| 108 uint32_t hash() const { return m_hash; } | 103 uint32_t hash() const { return m_hash; } |
| 109 | 104 |
| 110 const String& description() const; | 105 const String& description() const; |
| 111 bool activeMatch() const; | 106 bool activeMatch() const; |
| 112 Color underlineColor() const; | |
| 113 bool thick() const; | |
| 114 Color backgroundColor() const; | |
| 115 DocumentMarkerDetails* details() const; | 107 DocumentMarkerDetails* details() const; |
| 116 | 108 |
| 117 void setActiveMatch(bool); | 109 void setActiveMatch(bool); |
| 118 void clearDetails() { m_details.clear(); } | 110 void clearDetails() { m_details.clear(); } |
| 119 | 111 |
| 120 // Offset modifications are done by DocumentMarkerController. | 112 // Offset modifications are done by DocumentMarkerController. |
| 121 // Other classes should not call following setters. | 113 // Other classes should not call following setters. |
| 122 void setStartOffset(unsigned offset) { m_startOffset = offset; } | 114 void setStartOffset(unsigned offset) { m_startOffset = offset; } |
| 123 void setEndOffset(unsigned offset) { m_endOffset = offset; } | 115 void setEndOffset(unsigned offset) { m_endOffset = offset; } |
| 124 void shiftOffsets(int delta); | 116 void shiftOffsets(int delta); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 149 { | 141 { |
| 150 return m_details.get(); | 142 return m_details.get(); |
| 151 } | 143 } |
| 152 | 144 |
| 153 class DocumentMarkerDetails : public RefCountedWillBeGarbageCollectedFinalized<D
ocumentMarkerDetails> { | 145 class DocumentMarkerDetails : public RefCountedWillBeGarbageCollectedFinalized<D
ocumentMarkerDetails> { |
| 154 public: | 146 public: |
| 155 DocumentMarkerDetails() { } | 147 DocumentMarkerDetails() { } |
| 156 virtual ~DocumentMarkerDetails(); | 148 virtual ~DocumentMarkerDetails(); |
| 157 virtual bool isDescription() const { return false; } | 149 virtual bool isDescription() const { return false; } |
| 158 virtual bool isTextMatch() const { return false; } | 150 virtual bool isTextMatch() const { return false; } |
| 159 virtual bool isComposition() const { return false; } | |
| 160 | 151 |
| 161 DEFINE_INLINE_VIRTUAL_TRACE() { } | 152 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 162 }; | 153 }; |
| 163 | 154 |
| 164 } // namespace blink | 155 } // namespace blink |
| 165 | 156 |
| 166 #endif // DocumentMarker_h | 157 #endif // DocumentMarker_h |
| OLD | NEW |