| 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" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 template <typename Strategy> | 14 template <typename Strategy> |
| 15 EphemeralRangeTemplate<Strategy>::EphemeralRangeTemplate(const PositionTemplate<
Strategy>& start, const PositionTemplate<Strategy>& end) | 15 EphemeralRangeTemplate<Strategy>::EphemeralRangeTemplate(const PositionTemplate<
Strategy>& start, const PositionTemplate<Strategy>& end) |
| 16 : m_startPosition(start) | 16 : m_startPosition(start) |
| 17 , m_endPosition(end) | 17 , m_endPosition(end) |
| 18 #if DCHECK_IS_ON() | 18 #if DCHECK_IS_ON() |
| 19 , m_domTreeVersion(start.isNull() ? 0 : start.document()->domTreeVersion()) | 19 , m_domTreeVersion(start.isNull() ? 0 : start.document()->domTreeVersion()) |
| 20 #endif | 20 #endif |
| 21 { | 21 { |
| 22 if (m_startPosition.isNull()) { | 22 if (m_startPosition.isNull()) { |
| 23 DCHECK(m_endPosition.isNull()); | 23 DCHECK(m_endPosition.isNull()); |
| 24 return; | 24 return; |
| 25 } | 25 } |
| 26 DCHECK(m_endPosition.isNotNull()); | 26 DCHECK(m_endPosition.isNotNull()); |
| 27 DCHECK_EQ(m_startPosition.document(), m_endPosition.document()); | 27 DCHECK_EQ(m_startPosition.document(), m_endPosition.document()); |
| 28 DCHECK(m_startPosition.inShadowIncludingDocument()); | 28 DCHECK(m_startPosition.inShadowIncludingDocument()); |
| 29 DCHECK(m_endPosition.inShadowIncludingDocument()); | 29 DCHECK(m_endPosition.inShadowIncludingDocument()); |
| 30 DCHECK_LE(m_startPosition, m_endPosition); |
| 30 } | 31 } |
| 31 | 32 |
| 32 template <typename Strategy> | 33 template <typename Strategy> |
| 33 EphemeralRangeTemplate<Strategy>::EphemeralRangeTemplate(const EphemeralRangeTem
plate<Strategy>& other) | 34 EphemeralRangeTemplate<Strategy>::EphemeralRangeTemplate(const EphemeralRangeTem
plate<Strategy>& other) |
| 34 : EphemeralRangeTemplate(other.m_startPosition, other.m_endPosition) | 35 : EphemeralRangeTemplate(other.m_startPosition, other.m_endPosition) |
| 35 { | 36 { |
| 36 DCHECK(other.isValid()); | 37 DCHECK(other.isValid()); |
| 37 } | 38 } |
| 38 | 39 |
| 39 template <typename Strategy> | 40 template <typename Strategy> |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 { | 142 { |
| 142 if (range.isNull()) | 143 if (range.isNull()) |
| 143 return nullptr; | 144 return nullptr; |
| 144 return Range::create(range.document(), range.startPosition(), range.endPosit
ion()); | 145 return Range::create(range.document(), range.startPosition(), range.endPosit
ion()); |
| 145 } | 146 } |
| 146 | 147 |
| 147 template class CORE_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingStrategy>; | 148 template class CORE_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingStrategy>; |
| 148 template class CORE_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingInFlatTreeStra
tegy>; | 149 template class CORE_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingInFlatTreeStra
tegy>; |
| 149 | 150 |
| 150 } // namespace blink | 151 } // namespace blink |
| OLD | NEW |