Index: third_party/WebKit/Source/core/editing/markers/DocumentMarker.h |
diff --git a/third_party/WebKit/Source/core/editing/markers/DocumentMarker.h b/third_party/WebKit/Source/core/editing/markers/DocumentMarker.h |
index 7db49d1a45320fa4724c6a664cb6a6d88e08a618..0a85bda6d137fab0cc6f5d5de15a277b3fd16de7 100644 |
--- a/third_party/WebKit/Source/core/editing/markers/DocumentMarker.h |
+++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarker.h |
@@ -55,6 +55,32 @@ class CORE_EXPORT DocumentMarker : public GarbageCollected<DocumentMarker> { |
Composition = 1 << CompositionMarkerIndex, |
}; |
+ class MarkerTypesIterator { |
+ public: |
+ explicit MarkerTypesIterator(int markerTypes) |
Xiaocheng
2017/03/22 01:02:57
s/int/unsigned/
|
+ : m_remainingTypes(markerTypes) {} |
+ MarkerTypesIterator(const MarkerTypesIterator& other) = default; |
+ |
+ bool operator==(const MarkerTypesIterator& other) { |
+ return m_remainingTypes == other.m_remainingTypes; |
+ } |
+ bool operator!=(const MarkerTypesIterator& other) { |
+ return !(*this == other); |
+ } |
+ |
+ MarkerTypesIterator& operator++() { |
+ m_remainingTypes &= (m_remainingTypes - 1); |
Xiaocheng
2017/03/22 01:02:57
add: DCHECK(m_remainingTypes);
|
+ return *this; |
+ } |
+ |
+ MarkerType operator*() const { |
+ return static_cast<MarkerType>(m_remainingTypes & -m_remainingTypes); |
Xiaocheng
2017/03/22 01:02:57
add: DCHECK(m_remainingTypes);
|
+ } |
+ |
+ private: |
+ int m_remainingTypes; |
Xiaocheng
2017/03/22 01:02:57
s/int/unsigned/
|
+ }; |
+ |
class MarkerTypes { |
public: |
// The constructor is intentionally implicit to allow conversion from the |
@@ -72,6 +98,9 @@ class CORE_EXPORT DocumentMarker : public GarbageCollected<DocumentMarker> { |
void add(const MarkerTypes& types) { m_mask |= types.m_mask; } |
void remove(const MarkerTypes& types) { m_mask &= ~types.m_mask; } |
+ MarkerTypesIterator begin() const { return MarkerTypesIterator(m_mask); } |
+ MarkerTypesIterator end() const { return MarkerTypesIterator(0); } |
+ |
private: |
unsigned m_mask; |
}; |