| 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/editing/Position.h" | 9 #include "core/editing/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 Strategy> | 14 template <typename Strategy> |
| 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 PositionWithAffinityTemplate(const PositionAlgorithm<Strategy>&, EAffinity =
DOWNSTREAM); | 18 // TODO(yosin) We should have single parameter constructor not to use |
| 19 // default parameter for avoiding include "TextAffinity.h" |
| 20 PositionWithAffinityTemplate(const PositionAlgorithm<Strategy>&, TextAffinit
y = TextAffinity::Downstream); |
| 19 PositionWithAffinityTemplate(); | 21 PositionWithAffinityTemplate(); |
| 20 ~PositionWithAffinityTemplate(); | 22 ~PositionWithAffinityTemplate(); |
| 21 | 23 |
| 22 EAffinity affinity() const { return m_affinity; } | 24 TextAffinity affinity() const { return m_affinity; } |
| 23 const PositionAlgorithm<Strategy>& position() const { return m_position; } | 25 const PositionAlgorithm<Strategy>& position() const { return m_position; } |
| 24 | 26 |
| 25 // Returns true if both |this| and |other| is null or both |m_position| | 27 // Returns true if both |this| and |other| is null or both |m_position| |
| 26 // and |m_affinity| equal. | 28 // and |m_affinity| equal. |
| 27 bool operator==(const PositionWithAffinityTemplate& other) const; | 29 bool operator==(const PositionWithAffinityTemplate& other) const; |
| 28 bool operator!=(const PositionWithAffinityTemplate& other) const { return !o
perator==(other); } | 30 bool operator!=(const PositionWithAffinityTemplate& other) const { return !o
perator==(other); } |
| 29 | 31 |
| 30 bool isNotNull() const { return m_position.isNotNull(); } | 32 bool isNotNull() const { return m_position.isNotNull(); } |
| 31 bool isNull() const { return m_position.isNull(); } | 33 bool isNull() const { return m_position.isNull(); } |
| 32 | 34 |
| 33 DEFINE_INLINE_TRACE() | 35 DEFINE_INLINE_TRACE() |
| 34 { | 36 { |
| 35 visitor->trace(m_position); | 37 visitor->trace(m_position); |
| 36 } | 38 } |
| 37 | 39 |
| 38 private: | 40 private: |
| 39 PositionAlgorithm<Strategy> m_position; | 41 PositionAlgorithm<Strategy> m_position; |
| 40 EAffinity m_affinity; | 42 TextAffinity m_affinity; |
| 41 }; | 43 }; |
| 42 | 44 |
| 43 extern template class CORE_EXTERN_TEMPLATE_EXPORT PositionWithAffinityTemplate<E
ditingStrategy>; | 45 extern template class CORE_EXTERN_TEMPLATE_EXPORT PositionWithAffinityTemplate<E
ditingStrategy>; |
| 44 extern template class CORE_EXTERN_TEMPLATE_EXPORT PositionWithAffinityTemplate<E
ditingInComposedTreeStrategy>; | 46 extern template class CORE_EXTERN_TEMPLATE_EXPORT PositionWithAffinityTemplate<E
ditingInComposedTreeStrategy>; |
| 45 | 47 |
| 46 using PositionWithAffinity = PositionWithAffinityTemplate<EditingStrategy>; | 48 using PositionWithAffinity = PositionWithAffinityTemplate<EditingStrategy>; |
| 47 using PositionInComposedTreeWithAffinity = PositionWithAffinityTemplate<EditingI
nComposedTreeStrategy>; | 49 using PositionInComposedTreeWithAffinity = PositionWithAffinityTemplate<EditingI
nComposedTreeStrategy>; |
| 48 | 50 |
| 49 } // namespace blink | 51 } // namespace blink |
| 50 | 52 |
| 51 #endif // PositionWithAffinity_h | 53 #endif // PositionWithAffinity_h |
| OLD | NEW |