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 <ostream> // NOLINT | 7 #include <ostream> // NOLINT |
8 #include "platform/wtf/Assertions.h" | 8 #include "platform/wtf/Assertions.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 | 76 |
77 template <typename Strategy> | 77 template <typename Strategy> |
78 const PositionTemplate<Strategy>& SelectionTemplate<Strategy>::Extent() const { | 78 const PositionTemplate<Strategy>& SelectionTemplate<Strategy>::Extent() const { |
79 DCHECK(AssertValid()); | 79 DCHECK(AssertValid()); |
80 DCHECK(!extent_.IsOrphan()) << extent_; | 80 DCHECK(!extent_.IsOrphan()) << extent_; |
81 return extent_; | 81 return extent_; |
82 } | 82 } |
83 | 83 |
84 template <typename Strategy> | 84 template <typename Strategy> |
| 85 bool SelectionTemplate<Strategy>::IsCaret() const { |
| 86 return base_.IsNotNull() && base_ == extent_ && |
| 87 granularity_ == kCharacterGranularity; |
| 88 } |
| 89 |
| 90 template <typename Strategy> |
| 91 bool SelectionTemplate<Strategy>::IsRange() const { |
| 92 return base_ != extent_ || |
| 93 (base_.IsNotNull() && granularity_ != kCharacterGranularity); |
| 94 } |
| 95 |
| 96 template <typename Strategy> |
85 bool SelectionTemplate<Strategy>::AssertValidFor( | 97 bool SelectionTemplate<Strategy>::AssertValidFor( |
86 const Document& document) const { | 98 const Document& document) const { |
87 if (!AssertValid()) | 99 if (!AssertValid()) |
88 return false; | 100 return false; |
89 if (base_.IsNull()) | 101 if (base_.IsNull()) |
90 return true; | 102 return true; |
91 DCHECK_EQ(base_.GetDocument(), document) << *this; | 103 DCHECK_EQ(base_.GetDocument(), document) << *this; |
92 return true; | 104 return true; |
93 } | 105 } |
94 | 106 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 bool is_handle_visible) { | 336 bool is_handle_visible) { |
325 selection_.is_handle_visible_ = is_handle_visible; | 337 selection_.is_handle_visible_ = is_handle_visible; |
326 return *this; | 338 return *this; |
327 } | 339 } |
328 | 340 |
329 template class CORE_TEMPLATE_EXPORT SelectionTemplate<EditingStrategy>; | 341 template class CORE_TEMPLATE_EXPORT SelectionTemplate<EditingStrategy>; |
330 template class CORE_TEMPLATE_EXPORT | 342 template class CORE_TEMPLATE_EXPORT |
331 SelectionTemplate<EditingInFlatTreeStrategy>; | 343 SelectionTemplate<EditingInFlatTreeStrategy>; |
332 | 344 |
333 } // namespace blink | 345 } // namespace blink |
OLD | NEW |