Chromium Code Reviews| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 MarkerTypeIndexesCount | 48 MarkerTypeIndexesCount |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 enum MarkerType { | 51 enum MarkerType { |
| 52 Spelling = 1 << SpellingMarkerIndex, | 52 Spelling = 1 << SpellingMarkerIndex, |
| 53 Grammar = 1 << GrammarMarkerIndex, | 53 Grammar = 1 << GrammarMarkerIndex, |
| 54 TextMatch = 1 << TextMatchMarkerIndex, | 54 TextMatch = 1 << TextMatchMarkerIndex, |
| 55 Composition = 1 << CompositionMarkerIndex, | 55 Composition = 1 << CompositionMarkerIndex, |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 class MarkerTypesIterator { | |
| 59 public: | |
| 60 explicit MarkerTypesIterator(int markerTypes) | |
|
Xiaocheng
2017/03/22 01:02:57
s/int/unsigned/
| |
| 61 : m_remainingTypes(markerTypes) {} | |
| 62 MarkerTypesIterator(const MarkerTypesIterator& other) = default; | |
| 63 | |
| 64 bool operator==(const MarkerTypesIterator& other) { | |
| 65 return m_remainingTypes == other.m_remainingTypes; | |
| 66 } | |
| 67 bool operator!=(const MarkerTypesIterator& other) { | |
| 68 return !(*this == other); | |
| 69 } | |
| 70 | |
| 71 MarkerTypesIterator& operator++() { | |
| 72 m_remainingTypes &= (m_remainingTypes - 1); | |
|
Xiaocheng
2017/03/22 01:02:57
add: DCHECK(m_remainingTypes);
| |
| 73 return *this; | |
| 74 } | |
| 75 | |
| 76 MarkerType operator*() const { | |
| 77 return static_cast<MarkerType>(m_remainingTypes & -m_remainingTypes); | |
|
Xiaocheng
2017/03/22 01:02:57
add: DCHECK(m_remainingTypes);
| |
| 78 } | |
| 79 | |
| 80 private: | |
| 81 int m_remainingTypes; | |
|
Xiaocheng
2017/03/22 01:02:57
s/int/unsigned/
| |
| 82 }; | |
| 83 | |
| 58 class MarkerTypes { | 84 class MarkerTypes { |
| 59 public: | 85 public: |
| 60 // The constructor is intentionally implicit to allow conversion from the | 86 // The constructor is intentionally implicit to allow conversion from the |
| 61 // bit-wise sum of above types | 87 // bit-wise sum of above types |
| 62 MarkerTypes(unsigned mask) : m_mask(mask) {} | 88 MarkerTypes(unsigned mask) : m_mask(mask) {} |
| 63 | 89 |
| 64 bool contains(MarkerType type) const { return m_mask & type; } | 90 bool contains(MarkerType type) const { return m_mask & type; } |
| 65 bool intersects(const MarkerTypes& types) const { | 91 bool intersects(const MarkerTypes& types) const { |
| 66 return (m_mask & types.m_mask); | 92 return (m_mask & types.m_mask); |
| 67 } | 93 } |
| 68 bool operator==(const MarkerTypes& other) const { | 94 bool operator==(const MarkerTypes& other) const { |
| 69 return m_mask == other.m_mask; | 95 return m_mask == other.m_mask; |
| 70 } | 96 } |
| 71 | 97 |
| 72 void add(const MarkerTypes& types) { m_mask |= types.m_mask; } | 98 void add(const MarkerTypes& types) { m_mask |= types.m_mask; } |
| 73 void remove(const MarkerTypes& types) { m_mask &= ~types.m_mask; } | 99 void remove(const MarkerTypes& types) { m_mask &= ~types.m_mask; } |
| 74 | 100 |
| 101 MarkerTypesIterator begin() const { return MarkerTypesIterator(m_mask); } | |
| 102 MarkerTypesIterator end() const { return MarkerTypesIterator(0); } | |
| 103 | |
| 75 private: | 104 private: |
| 76 unsigned m_mask; | 105 unsigned m_mask; |
| 77 }; | 106 }; |
| 78 | 107 |
| 79 class AllMarkers : public MarkerTypes { | 108 class AllMarkers : public MarkerTypes { |
| 80 public: | 109 public: |
| 81 AllMarkers() : MarkerTypes(Spelling | Grammar | TextMatch | Composition) {} | 110 AllMarkers() : MarkerTypes(Spelling | Grammar | TextMatch | Composition) {} |
| 82 }; | 111 }; |
| 83 | 112 |
| 84 class MisspellingMarkers : public MarkerTypes { | 113 class MisspellingMarkers : public MarkerTypes { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 virtual bool isDescription() const { return false; } | 183 virtual bool isDescription() const { return false; } |
| 155 virtual bool isTextMatch() const { return false; } | 184 virtual bool isTextMatch() const { return false; } |
| 156 virtual bool isComposition() const { return false; } | 185 virtual bool isComposition() const { return false; } |
| 157 | 186 |
| 158 DEFINE_INLINE_VIRTUAL_TRACE() {} | 187 DEFINE_INLINE_VIRTUAL_TRACE() {} |
| 159 }; | 188 }; |
| 160 | 189 |
| 161 } // namespace blink | 190 } // namespace blink |
| 162 | 191 |
| 163 #endif // DocumentMarker_h | 192 #endif // DocumentMarker_h |
| OLD | NEW |