OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/EphemeralRange.h" | 5 #include "core/editing/EphemeralRange.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/dom/Element.h" | 8 #include "core/dom/Element.h" |
9 #include "core/dom/Range.h" | 9 #include "core/dom/Range.h" |
10 #include "core/dom/Text.h" | 10 #include "core/dom/Text.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 EphemeralRangeTemplate<Strategy>::Nodes() const { | 137 EphemeralRangeTemplate<Strategy>::Nodes() const { |
138 return RangeTraversal(start_position_.NodeAsRangeFirstNode(), | 138 return RangeTraversal(start_position_.NodeAsRangeFirstNode(), |
139 end_position_.NodeAsRangePastLastNode()); | 139 end_position_.NodeAsRangePastLastNode()); |
140 } | 140 } |
141 | 141 |
142 template <typename Strategy> | 142 template <typename Strategy> |
143 EphemeralRangeTemplate<Strategy> | 143 EphemeralRangeTemplate<Strategy> |
144 EphemeralRangeTemplate<Strategy>::RangeOfContents(const Node& node) { | 144 EphemeralRangeTemplate<Strategy>::RangeOfContents(const Node& node) { |
145 return EphemeralRangeTemplate<Strategy>( | 145 return EphemeralRangeTemplate<Strategy>( |
146 PositionTemplate<Strategy>::FirstPositionInNode(node), | 146 PositionTemplate<Strategy>::FirstPositionInNode(node), |
147 PositionTemplate<Strategy>::LastPositionInNode(&const_cast<Node&>(node))); | 147 PositionTemplate<Strategy>::LastPositionInNode(node)); |
148 } | 148 } |
149 | 149 |
150 #if DCHECK_IS_ON() | 150 #if DCHECK_IS_ON() |
151 template <typename Strategy> | 151 template <typename Strategy> |
152 bool EphemeralRangeTemplate<Strategy>::IsValid() const { | 152 bool EphemeralRangeTemplate<Strategy>::IsValid() const { |
153 return start_position_.IsNull() || | 153 return start_position_.IsNull() || |
154 dom_tree_version_ == start_position_.GetDocument()->DomTreeVersion(); | 154 dom_tree_version_ == start_position_.GetDocument()->DomTreeVersion(); |
155 } | 155 } |
156 #else | 156 #else |
157 template <typename Strategy> | 157 template <typename Strategy> |
158 bool EphemeralRangeTemplate<Strategy>::IsValid() const { | 158 bool EphemeralRangeTemplate<Strategy>::IsValid() const { |
159 return true; | 159 return true; |
160 } | 160 } |
161 #endif | 161 #endif |
162 | 162 |
163 Range* CreateRange(const EphemeralRange& range) { | 163 Range* CreateRange(const EphemeralRange& range) { |
164 if (range.IsNull()) | 164 if (range.IsNull()) |
165 return nullptr; | 165 return nullptr; |
166 return Range::Create(range.GetDocument(), range.StartPosition(), | 166 return Range::Create(range.GetDocument(), range.StartPosition(), |
167 range.EndPosition()); | 167 range.EndPosition()); |
168 } | 168 } |
169 | 169 |
170 template class CORE_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingStrategy>; | 170 template class CORE_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingStrategy>; |
171 template class CORE_TEMPLATE_EXPORT | 171 template class CORE_TEMPLATE_EXPORT |
172 EphemeralRangeTemplate<EditingInFlatTreeStrategy>; | 172 EphemeralRangeTemplate<EditingInFlatTreeStrategy>; |
173 | 173 |
174 } // namespace blink | 174 } // namespace blink |
OLD | NEW |