OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 SelectionTemplate_h | 5 #ifndef SelectionTemplate_h |
6 #define SelectionTemplate_h | 6 #define SelectionTemplate_h |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
10 #include "core/editing/EphemeralRange.h" | 10 #include "core/editing/EphemeralRange.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Note: This function should be used only in "core/editing/commands". | 59 // Note: This function should be used only in "core/editing/commands". |
60 // TODO(yosin): Once all we get rid of all call sites, we remove this. | 60 // TODO(yosin): Once all we get rid of all call sites, we remove this. |
61 Builder& setBaseAndExtentDeprecated( | 61 Builder& setBaseAndExtentDeprecated( |
62 const PositionTemplate<Strategy>& base, | 62 const PositionTemplate<Strategy>& base, |
63 const PositionTemplate<Strategy>& extent); | 63 const PositionTemplate<Strategy>& extent); |
64 | 64 |
65 Builder& setAffinity(TextAffinity); | 65 Builder& setAffinity(TextAffinity); |
66 Builder& setGranularity(TextGranularity); | 66 Builder& setGranularity(TextGranularity); |
67 Builder& setHasTrailingWhitespace(bool); | 67 Builder& setHasTrailingWhitespace(bool); |
68 Builder& setIsDirectional(bool); | 68 Builder& setIsDirectional(bool); |
| 69 Builder& setIsHandleVisible(bool); |
69 | 70 |
70 private: | 71 private: |
71 SelectionTemplate m_selection; | 72 SelectionTemplate m_selection; |
72 | 73 |
73 DISALLOW_COPY_AND_ASSIGN(Builder); | 74 DISALLOW_COPY_AND_ASSIGN(Builder); |
74 }; | 75 }; |
75 | 76 |
76 SelectionTemplate(const SelectionTemplate& other); | 77 SelectionTemplate(const SelectionTemplate& other); |
77 SelectionTemplate(); | 78 SelectionTemplate(); |
78 | 79 |
79 SelectionTemplate& operator=(const SelectionTemplate&) = default; | 80 SelectionTemplate& operator=(const SelectionTemplate&) = default; |
80 | 81 |
81 bool operator==(const SelectionTemplate&) const; | 82 bool operator==(const SelectionTemplate&) const; |
82 bool operator!=(const SelectionTemplate&) const; | 83 bool operator!=(const SelectionTemplate&) const; |
83 | 84 |
84 const PositionTemplate<Strategy>& base() const; | 85 const PositionTemplate<Strategy>& base() const; |
85 const PositionTemplate<Strategy>& extent() const; | 86 const PositionTemplate<Strategy>& extent() const; |
86 TextAffinity affinity() const { return m_affinity; } | 87 TextAffinity affinity() const { return m_affinity; } |
87 TextGranularity granularity() const { return m_granularity; } | 88 TextGranularity granularity() const { return m_granularity; } |
88 bool hasTrailingWhitespace() const { return m_hasTrailingWhitespace; } | 89 bool hasTrailingWhitespace() const { return m_hasTrailingWhitespace; } |
89 bool isDirectional() const { return m_isDirectional; } | 90 bool isDirectional() const { return m_isDirectional; } |
| 91 bool isHandleVisible() const { return m_isHandleVisible; } |
90 bool isNone() const { return m_base.isNull(); } | 92 bool isNone() const { return m_base.isNull(); } |
91 | 93 |
92 // Returns true if |this| selection holds valid values otherwise it causes | 94 // Returns true if |this| selection holds valid values otherwise it causes |
93 // assertion failure. | 95 // assertion failure. |
94 bool assertValid() const; | 96 bool assertValid() const; |
95 bool assertValidFor(const Document&) const; | 97 bool assertValidFor(const Document&) const; |
96 | 98 |
97 DEFINE_INLINE_TRACE() { | 99 DEFINE_INLINE_TRACE() { |
98 visitor->trace(m_base); | 100 visitor->trace(m_base); |
99 visitor->trace(m_extent); | 101 visitor->trace(m_extent); |
100 } | 102 } |
101 | 103 |
102 void printTo(std::ostream*, const char* type) const; | 104 void printTo(std::ostream*, const char* type) const; |
103 #ifndef NDEBUG | 105 #ifndef NDEBUG |
104 void showTreeForThis() const; | 106 void showTreeForThis() const; |
105 #endif | 107 #endif |
106 | 108 |
107 private: | 109 private: |
108 friend class SelectionEditor; | 110 friend class SelectionEditor; |
109 | 111 |
110 Document* document() const; | 112 Document* document() const; |
111 | 113 |
112 PositionTemplate<Strategy> m_base; | 114 PositionTemplate<Strategy> m_base; |
113 PositionTemplate<Strategy> m_extent; | 115 PositionTemplate<Strategy> m_extent; |
114 TextAffinity m_affinity = TextAffinity::Downstream; | 116 TextAffinity m_affinity = TextAffinity::Downstream; |
115 TextGranularity m_granularity = CharacterGranularity; | 117 TextGranularity m_granularity = CharacterGranularity; |
116 bool m_hasTrailingWhitespace = false; | 118 bool m_hasTrailingWhitespace = false; |
117 bool m_isDirectional = false; | 119 bool m_isDirectional = false; |
| 120 bool m_isHandleVisible = false; |
118 #if DCHECK_IS_ON() | 121 #if DCHECK_IS_ON() |
119 uint64_t m_domTreeVersion; | 122 uint64_t m_domTreeVersion; |
120 #endif | 123 #endif |
121 }; | 124 }; |
122 | 125 |
123 extern template class CORE_EXTERN_TEMPLATE_EXPORT | 126 extern template class CORE_EXTERN_TEMPLATE_EXPORT |
124 SelectionTemplate<EditingStrategy>; | 127 SelectionTemplate<EditingStrategy>; |
125 extern template class CORE_EXTERN_TEMPLATE_EXPORT | 128 extern template class CORE_EXTERN_TEMPLATE_EXPORT |
126 SelectionTemplate<EditingInFlatTreeStrategy>; | 129 SelectionTemplate<EditingInFlatTreeStrategy>; |
127 | 130 |
128 using SelectionInDOMTree = SelectionTemplate<EditingStrategy>; | 131 using SelectionInDOMTree = SelectionTemplate<EditingStrategy>; |
129 using SelectionInFlatTree = SelectionTemplate<EditingInFlatTreeStrategy>; | 132 using SelectionInFlatTree = SelectionTemplate<EditingInFlatTreeStrategy>; |
130 | 133 |
131 CORE_EXPORT std::ostream& operator<<(std::ostream&, const SelectionInDOMTree&); | 134 CORE_EXPORT std::ostream& operator<<(std::ostream&, const SelectionInDOMTree&); |
132 CORE_EXPORT std::ostream& operator<<(std::ostream&, const SelectionInFlatTree&); | 135 CORE_EXPORT std::ostream& operator<<(std::ostream&, const SelectionInFlatTree&); |
133 | 136 |
134 } // namespace blink | 137 } // namespace blink |
135 | 138 |
136 #endif // SelectionTemplate_h | 139 #endif // SelectionTemplate_h |
OLD | NEW |