Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: third_party/WebKit/Source/core/editing/EphemeralRange.cpp

Issue 2251703002: Introduce EphemeralRange::nodes() helper to traverse over a range. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move default template to right place Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 113
114 template <typename Strategy> 114 template <typename Strategy>
115 bool EphemeralRangeTemplate<Strategy>::isCollapsed() const 115 bool EphemeralRangeTemplate<Strategy>::isCollapsed() const
116 { 116 {
117 DCHECK(isValid()); 117 DCHECK(isValid());
118 return m_startPosition == m_endPosition; 118 return m_startPosition == m_endPosition;
119 } 119 }
120 120
121 template <typename Strategy> 121 template <typename Strategy>
122 typename EphemeralRangeTemplate<Strategy>::RangeTraversal
123 EphemeralRangeTemplate<Strategy>::nodes() const
124 {
125 return RangeTraversal(m_startPosition.nodeAsRangeFirstNode(), m_endPosition. nodeAsRangePastLastNode());
126 }
127
128 template <typename Strategy>
122 EphemeralRangeTemplate<Strategy> EphemeralRangeTemplate<Strategy>::rangeOfConten ts(const Node& node) 129 EphemeralRangeTemplate<Strategy> EphemeralRangeTemplate<Strategy>::rangeOfConten ts(const Node& node)
123 { 130 {
124 return EphemeralRangeTemplate<Strategy>(PositionTemplate<Strategy>::firstPos itionInNode(&const_cast<Node&>(node)), PositionTemplate<Strategy>::lastPositionI nNode(&const_cast<Node&>(node))); 131 return EphemeralRangeTemplate<Strategy>(PositionTemplate<Strategy>::firstPos itionInNode(&const_cast<Node&>(node)), PositionTemplate<Strategy>::lastPositionI nNode(&const_cast<Node&>(node)));
125 } 132 }
126 133
127 #if DCHECK_IS_ON() 134 #if DCHECK_IS_ON()
128 template <typename Strategy> 135 template <typename Strategy>
129 bool EphemeralRangeTemplate<Strategy>::isValid() const 136 bool EphemeralRangeTemplate<Strategy>::isValid() const
130 { 137 {
131 return m_startPosition.isNull() || m_domTreeVersion == m_startPosition.docum ent()->domTreeVersion(); 138 return m_startPosition.isNull() || m_domTreeVersion == m_startPosition.docum ent()->domTreeVersion();
(...skipping 10 matching lines...) Expand all
142 { 149 {
143 if (range.isNull()) 150 if (range.isNull())
144 return nullptr; 151 return nullptr;
145 return Range::create(range.document(), range.startPosition(), range.endPosit ion()); 152 return Range::create(range.document(), range.startPosition(), range.endPosit ion());
146 } 153 }
147 154
148 template class CORE_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingStrategy>; 155 template class CORE_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingStrategy>;
149 template class CORE_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingInFlatTreeStra tegy>; 156 template class CORE_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingInFlatTreeStra tegy>;
150 157
151 } // namespace blink 158 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/EphemeralRange.h ('k') | third_party/WebKit/Source/core/editing/EphemeralRangeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698