| 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 { |
| 11 | 11 |
| 12 template <typename Strategy> | 12 template <typename Strategy> |
| 13 SelectionTemplate<Strategy>::SelectionTemplate(const SelectionTemplate& other) | 13 SelectionTemplate<Strategy>::SelectionTemplate(const SelectionTemplate& other) |
| 14 : m_base(other.m_base), | 14 : m_base(other.m_base), |
| 15 m_extent(other.m_extent), | 15 m_extent(other.m_extent), |
| 16 m_affinity(other.m_affinity), | 16 m_affinity(other.m_affinity), |
| 17 m_granularity(other.m_granularity), | 17 m_granularity(other.m_granularity), |
| 18 m_hasTrailingWhitespace(other.m_hasTrailingWhitespace), | 18 m_hasTrailingWhitespace(other.m_hasTrailingWhitespace), |
| 19 m_isDirectional(other.m_isDirectional) | 19 m_isDirectional(other.m_isDirectional), |
| 20 m_isHandleVisible(other.m_isHandleVisible) |
| 20 #if DCHECK_IS_ON() | 21 #if DCHECK_IS_ON() |
| 21 , | 22 , |
| 22 m_domTreeVersion(other.m_domTreeVersion) | 23 m_domTreeVersion(other.m_domTreeVersion) |
| 23 #endif | 24 #endif |
| 24 { | 25 { |
| 25 DCHECK(other.assertValid()); | 26 DCHECK(other.assertValid()); |
| 26 if (!m_hasTrailingWhitespace) | 27 if (!m_hasTrailingWhitespace) |
| 27 return; | 28 return; |
| 28 DCHECK_EQ(m_granularity, WordGranularity) << *this; | 29 DCHECK_EQ(m_granularity, WordGranularity) << *this; |
| 29 } | 30 } |
| 30 | 31 |
| 31 template <typename Strategy> | 32 template <typename Strategy> |
| 32 SelectionTemplate<Strategy>::SelectionTemplate() = default; | 33 SelectionTemplate<Strategy>::SelectionTemplate() = default; |
| 33 | 34 |
| 34 template <typename Strategy> | 35 template <typename Strategy> |
| 35 bool SelectionTemplate<Strategy>::operator==( | 36 bool SelectionTemplate<Strategy>::operator==( |
| 36 const SelectionTemplate& other) const { | 37 const SelectionTemplate& other) const { |
| 37 DCHECK(assertValid()); | 38 DCHECK(assertValid()); |
| 38 DCHECK(other.assertValid()); | 39 DCHECK(other.assertValid()); |
| 39 if (isNone()) | 40 if (isNone()) |
| 40 return other.isNone(); | 41 return other.isNone(); |
| 41 if (other.isNone()) | 42 if (other.isNone()) |
| 42 return false; | 43 return false; |
| 43 DCHECK_EQ(m_base.document(), other.document()) << *this << ' ' << other; | 44 DCHECK_EQ(m_base.document(), other.document()) << *this << ' ' << other; |
| 44 return m_base == other.m_base && m_extent == other.m_extent && | 45 return m_base == other.m_base && m_extent == other.m_extent && |
| 45 m_affinity == other.m_affinity && | 46 m_affinity == other.m_affinity && |
| 46 m_granularity == other.m_granularity && | 47 m_granularity == other.m_granularity && |
| 47 m_hasTrailingWhitespace == other.m_hasTrailingWhitespace && | 48 m_hasTrailingWhitespace == other.m_hasTrailingWhitespace && |
| 48 m_isDirectional == other.m_isDirectional; | 49 m_isDirectional == other.m_isDirectional && |
| 50 m_isHandleVisible == other.m_isHandleVisible; |
| 49 } | 51 } |
| 50 | 52 |
| 51 template <typename Strategy> | 53 template <typename Strategy> |
| 52 bool SelectionTemplate<Strategy>::operator!=( | 54 bool SelectionTemplate<Strategy>::operator!=( |
| 53 const SelectionTemplate& other) const { | 55 const SelectionTemplate& other) const { |
| 54 return !operator==(other); | 56 return !operator==(other); |
| 55 } | 57 } |
| 56 | 58 |
| 57 template <typename Strategy> | 59 template <typename Strategy> |
| 58 const PositionTemplate<Strategy>& SelectionTemplate<Strategy>::base() const { | 60 const PositionTemplate<Strategy>& SelectionTemplate<Strategy>::base() const { |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 SelectionTemplate<Strategy>::Builder::setIsHandleVisible(bool isHandleVisible) { | 292 SelectionTemplate<Strategy>::Builder::setIsHandleVisible(bool isHandleVisible) { |
| 291 m_selection.m_isHandleVisible = isHandleVisible; | 293 m_selection.m_isHandleVisible = isHandleVisible; |
| 292 return *this; | 294 return *this; |
| 293 } | 295 } |
| 294 | 296 |
| 295 template class CORE_TEMPLATE_EXPORT SelectionTemplate<EditingStrategy>; | 297 template class CORE_TEMPLATE_EXPORT SelectionTemplate<EditingStrategy>; |
| 296 template class CORE_TEMPLATE_EXPORT | 298 template class CORE_TEMPLATE_EXPORT |
| 297 SelectionTemplate<EditingInFlatTreeStrategy>; | 299 SelectionTemplate<EditingInFlatTreeStrategy>; |
| 298 | 300 |
| 299 } // namespace blink | 301 } // namespace blink |
| OLD | NEW |