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 #include "core/editing/SelectionTemplate.h" | 5 #include "core/editing/SelectionTemplate.h" |
6 | 6 |
7 #include "wtf/Assertions.h" | 7 #include "wtf/Assertions.h" |
8 #include <ostream> // NOLINT | 8 #include <ostream> // NOLINT |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 .utf8() | 126 .utf8() |
127 .data() | 127 .data() |
128 << "base: " << m_base.toAnchorTypeAndOffsetString().utf8().data() | 128 << "base: " << m_base.toAnchorTypeAndOffsetString().utf8().data() |
129 << "\n" | 129 << "\n" |
130 << "extent: " | 130 << "extent: " |
131 << m_extent.toAnchorTypeAndOffsetString().utf8().data(); | 131 << m_extent.toAnchorTypeAndOffsetString().utf8().data(); |
132 } | 132 } |
133 #endif | 133 #endif |
134 | 134 |
135 template <typename Strategy> | 135 template <typename Strategy> |
| 136 const PositionTemplate<Strategy>& |
| 137 SelectionTemplate<Strategy>::computeEndPosition() const { |
| 138 if (m_base == m_extent) |
| 139 return m_base; |
| 140 return m_base < m_extent ? m_extent : m_base; |
| 141 } |
| 142 |
| 143 template <typename Strategy> |
| 144 const PositionTemplate<Strategy>& |
| 145 SelectionTemplate<Strategy>::computeStartPosition() const { |
| 146 if (m_base == m_extent) |
| 147 return m_base; |
| 148 return m_base < m_extent ? m_base : m_extent; |
| 149 } |
| 150 |
| 151 template <typename Strategy> |
| 152 SelectionType SelectionTemplate<Strategy>::selectionTypeWithLegacyGranularity() |
| 153 const { |
| 154 if (m_base.isNull()) |
| 155 return NoSelection; |
| 156 if (m_base == m_extent && m_granularity == CharacterGranularity) |
| 157 return CaretSelection; |
| 158 return RangeSelection; |
| 159 } |
| 160 |
| 161 template <typename Strategy> |
136 void SelectionTemplate<Strategy>::printTo(std::ostream* ostream, | 162 void SelectionTemplate<Strategy>::printTo(std::ostream* ostream, |
137 const char* type) const { | 163 const char* type) const { |
138 if (isNone()) { | 164 if (isNone()) { |
139 *ostream << "()"; | 165 *ostream << "()"; |
140 return; | 166 return; |
141 } | 167 } |
142 *ostream << type << '('; | 168 *ostream << type << '('; |
143 #if DCHECK_IS_ON() | 169 #if DCHECK_IS_ON() |
144 if (m_domTreeVersion != m_base.document()->domTreeVersion()) { | 170 if (m_domTreeVersion != m_base.document()->domTreeVersion()) { |
145 *ostream << "Dirty: " << m_domTreeVersion; | 171 *ostream << "Dirty: " << m_domTreeVersion; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 SelectionTemplate<Strategy>::Builder::setIsHandleVisible(bool isHandleVisible) { | 324 SelectionTemplate<Strategy>::Builder::setIsHandleVisible(bool isHandleVisible) { |
299 m_selection.m_isHandleVisible = isHandleVisible; | 325 m_selection.m_isHandleVisible = isHandleVisible; |
300 return *this; | 326 return *this; |
301 } | 327 } |
302 | 328 |
303 template class CORE_TEMPLATE_EXPORT SelectionTemplate<EditingStrategy>; | 329 template class CORE_TEMPLATE_EXPORT SelectionTemplate<EditingStrategy>; |
304 template class CORE_TEMPLATE_EXPORT | 330 template class CORE_TEMPLATE_EXPORT |
305 SelectionTemplate<EditingInFlatTreeStrategy>; | 331 SelectionTemplate<EditingInFlatTreeStrategy>; |
306 | 332 |
307 } // namespace blink | 333 } // namespace blink |
OLD | NEW |