| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file./* | 3 // found in the LICENSE file./* |
| 4 | 4 |
| 5 #ifndef PositionWithAffinity_h | 5 #ifndef PositionWithAffinity_h |
| 6 #define PositionWithAffinity_h | 6 #define PositionWithAffinity_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/dom/Position.h" | 9 #include "core/dom/Position.h" |
| 10 #include "core/editing/TextAffinity.h" | 10 #include "core/editing/TextAffinity.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 template <typename Position> | 14 template <typename Position> |
| 15 class CORE_TEMPLATE_CLASS_EXPORT PositionWithAffinityTemplate { | 15 class CORE_TEMPLATE_CLASS_EXPORT PositionWithAffinityTemplate { |
| 16 DISALLOW_ALLOCATION(); | 16 DISALLOW_ALLOCATION(); |
| 17 public: | 17 public: |
| 18 typedef Position PositionType; | 18 typedef Position PositionType; |
| 19 | 19 |
| 20 PositionWithAffinityTemplate(const PositionType&, EAffinity = DOWNSTREAM); | 20 PositionWithAffinityTemplate(const PositionType&, EAffinity = DOWNSTREAM); |
| 21 PositionWithAffinityTemplate(); | 21 PositionWithAffinityTemplate(); |
| 22 ~PositionWithAffinityTemplate(); | 22 ~PositionWithAffinityTemplate(); |
| 23 | 23 |
| 24 EAffinity affinity() const { return m_affinity; } | 24 EAffinity affinity() const { return m_affinity; } |
| 25 const PositionType& position() const { return m_position; } | 25 const PositionType& position() const { return m_position; } |
| 26 | 26 |
| 27 // Returns true if both |this| and |other| is null or both |m_position| |
| 28 // and |m_affinity| equal. |
| 29 bool operator==(const PositionWithAffinityTemplate& other) const; |
| 30 bool operator!=(const PositionWithAffinityTemplate& other) const { return !o
perator==(other); } |
| 31 |
| 32 bool isNotNull() const { return m_position.isNotNull(); } |
| 33 bool isNull() const { return m_position.isNull(); } |
| 34 |
| 27 DEFINE_INLINE_TRACE() | 35 DEFINE_INLINE_TRACE() |
| 28 { | 36 { |
| 29 visitor->trace(m_position); | 37 visitor->trace(m_position); |
| 30 } | 38 } |
| 31 | 39 |
| 32 private: | 40 private: |
| 33 PositionType m_position; | 41 PositionType m_position; |
| 34 EAffinity m_affinity; | 42 EAffinity m_affinity; |
| 35 }; | 43 }; |
| 36 | 44 |
| 37 extern template class CORE_EXTERN_TEMPLATE_EXPORT PositionWithAffinityTemplate<P
osition>; | 45 extern template class CORE_EXTERN_TEMPLATE_EXPORT PositionWithAffinityTemplate<P
osition>; |
| 38 | 46 |
| 39 using PositionWithAffinity = PositionWithAffinityTemplate<Position>; | 47 using PositionWithAffinity = PositionWithAffinityTemplate<Position>; |
| 40 | 48 |
| 41 } // namespace blink | 49 } // namespace blink |
| 42 | 50 |
| 43 #endif // PositionWithAffinity_h | 51 #endif // PositionWithAffinity_h |
| OLD | NEW |