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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 } | 102 } |
103 | 103 |
104 template <typename Strategy> | 104 template <typename Strategy> |
105 PositionTemplate<Strategy> EphemeralRangeTemplate<Strategy>::endPosition() | 105 PositionTemplate<Strategy> EphemeralRangeTemplate<Strategy>::endPosition() |
106 const { | 106 const { |
107 DCHECK(isValid()); | 107 DCHECK(isValid()); |
108 return m_endPosition; | 108 return m_endPosition; |
109 } | 109 } |
110 | 110 |
111 template <typename Strategy> | 111 template <typename Strategy> |
112 Node* EphemeralRangeTemplate<Strategy>::commonAncestorContainer() const | |
113 { | |
114 return commonAncestorContainer(m_startPosition.computeContainerNode(), m_end Position.computeContainerNode()); | |
115 } | |
116 | |
117 template <typename Strategy> | |
118 Node* EphemeralRangeTemplate<Strategy>::commonAncestorContainer(const Node* cont ainerA, const Node* containerB) | |
119 { | |
120 if (!containerA || !containerB) | |
121 return nullptr; | |
122 return containerA->commonAncestor(*containerB, NodeTraversal::parent); | |
Xiaocheng
2017/02/28 19:26:31
Should return |Strategy::commonAncestor(*container
tanvir
2017/03/02 14:59:14
Done.
| |
123 } | |
124 | |
125 template <typename Strategy> | |
112 bool EphemeralRangeTemplate<Strategy>::isCollapsed() const { | 126 bool EphemeralRangeTemplate<Strategy>::isCollapsed() const { |
113 DCHECK(isValid()); | 127 DCHECK(isValid()); |
114 return m_startPosition == m_endPosition; | 128 return m_startPosition == m_endPosition; |
115 } | 129 } |
116 | 130 |
117 template <typename Strategy> | 131 template <typename Strategy> |
118 typename EphemeralRangeTemplate<Strategy>::RangeTraversal | 132 typename EphemeralRangeTemplate<Strategy>::RangeTraversal |
119 EphemeralRangeTemplate<Strategy>::nodes() const { | 133 EphemeralRangeTemplate<Strategy>::nodes() const { |
120 return RangeTraversal(m_startPosition.nodeAsRangeFirstNode(), | 134 return RangeTraversal(m_startPosition.nodeAsRangeFirstNode(), |
121 m_endPosition.nodeAsRangePastLastNode()); | 135 m_endPosition.nodeAsRangePastLastNode()); |
(...skipping 25 matching lines...) Expand all Loading... | |
147 return nullptr; | 161 return nullptr; |
148 return Range::create(range.document(), range.startPosition(), | 162 return Range::create(range.document(), range.startPosition(), |
149 range.endPosition()); | 163 range.endPosition()); |
150 } | 164 } |
151 | 165 |
152 template class CORE_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingStrategy>; | 166 template class CORE_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingStrategy>; |
153 template class CORE_TEMPLATE_EXPORT | 167 template class CORE_TEMPLATE_EXPORT |
154 EphemeralRangeTemplate<EditingInFlatTreeStrategy>; | 168 EphemeralRangeTemplate<EditingInFlatTreeStrategy>; |
155 | 169 |
156 } // namespace blink | 170 } // namespace blink |
OLD | NEW |