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

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

Issue 1878473002: ASSERT -> DCHECK in core/editing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Output info for some DCHECKs, add TODOs. Created 4 years, 8 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"
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 ENABLE(ASSERT) 18 #if ENABLE(ASSERT)
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 ASSERT(m_endPosition.isNull()); 23 DCHECK(m_endPosition.isNull());
24 return; 24 return;
25 } 25 }
26 ASSERT(m_endPosition.isNotNull()); 26 DCHECK(m_endPosition.isNotNull());
27 ASSERT(m_startPosition.document() == m_endPosition.document()); 27 DCHECK_EQ(m_startPosition.document(), m_endPosition.document());
28 ASSERT(m_startPosition.inShadowIncludingDocument()); 28 DCHECK(m_startPosition.inShadowIncludingDocument());
29 ASSERT(m_endPosition.inShadowIncludingDocument()); 29 DCHECK(m_endPosition.inShadowIncludingDocument());
30 } 30 }
31 31
32 template <typename Strategy> 32 template <typename Strategy>
33 EphemeralRangeTemplate<Strategy>::EphemeralRangeTemplate(const EphemeralRangeTem plate<Strategy>& other) 33 EphemeralRangeTemplate<Strategy>::EphemeralRangeTemplate(const EphemeralRangeTem plate<Strategy>& other)
34 : EphemeralRangeTemplate(other.m_startPosition, other.m_endPosition) 34 : EphemeralRangeTemplate(other.m_startPosition, other.m_endPosition)
35 { 35 {
36 ASSERT(other.isValid()); 36 DCHECK(other.isValid());
37 } 37 }
38 38
39 template <typename Strategy> 39 template <typename Strategy>
40 EphemeralRangeTemplate<Strategy>::EphemeralRangeTemplate(const PositionTemplate< Strategy>& position) 40 EphemeralRangeTemplate<Strategy>::EphemeralRangeTemplate(const PositionTemplate< Strategy>& position)
41 : EphemeralRangeTemplate(position, position) 41 : EphemeralRangeTemplate(position, position)
42 { 42 {
43 } 43 }
44 44
45 template <typename Strategy> 45 template <typename Strategy>
46 EphemeralRangeTemplate<Strategy>::EphemeralRangeTemplate(const Range* range) 46 EphemeralRangeTemplate<Strategy>::EphemeralRangeTemplate(const Range* range)
47 { 47 {
48 if (!range) 48 if (!range)
49 return; 49 return;
50 ASSERT(range->inShadowIncludingDocument()); 50 DCHECK(range->inShadowIncludingDocument());
51 m_startPosition = fromPositionInDOMTree<Strategy>(range->startPosition()); 51 m_startPosition = fromPositionInDOMTree<Strategy>(range->startPosition());
52 m_endPosition = fromPositionInDOMTree<Strategy>(range->endPosition()); 52 m_endPosition = fromPositionInDOMTree<Strategy>(range->endPosition());
53 #if ENABLE(ASSERT) 53 #if ENABLE(ASSERT)
54 m_domTreeVersion = range->ownerDocument().domTreeVersion(); 54 m_domTreeVersion = range->ownerDocument().domTreeVersion();
55 #endif 55 #endif
56 } 56 }
57 57
58 template <typename Strategy> 58 template <typename Strategy>
59 EphemeralRangeTemplate<Strategy>::EphemeralRangeTemplate() 59 EphemeralRangeTemplate<Strategy>::EphemeralRangeTemplate()
60 { 60 {
61 } 61 }
62 62
63 template <typename Strategy> 63 template <typename Strategy>
64 EphemeralRangeTemplate<Strategy>::~EphemeralRangeTemplate() 64 EphemeralRangeTemplate<Strategy>::~EphemeralRangeTemplate()
65 { 65 {
66 } 66 }
67 67
68 template <typename Strategy> 68 template <typename Strategy>
69 EphemeralRangeTemplate<Strategy>& EphemeralRangeTemplate<Strategy>::operator=(co nst EphemeralRangeTemplate<Strategy>& other) 69 EphemeralRangeTemplate<Strategy>& EphemeralRangeTemplate<Strategy>::operator=(co nst EphemeralRangeTemplate<Strategy>& other)
70 { 70 {
71 ASSERT(other.isValid()); 71 DCHECK(other.isValid());
72 m_startPosition = other.m_startPosition; 72 m_startPosition = other.m_startPosition;
73 m_endPosition = other.m_endPosition; 73 m_endPosition = other.m_endPosition;
74 #if ENABLE(ASSERT) 74 #if ENABLE(ASSERT)
75 m_domTreeVersion = other.m_domTreeVersion; 75 m_domTreeVersion = other.m_domTreeVersion;
76 #endif 76 #endif
77 return *this; 77 return *this;
78 } 78 }
79 79
80 template <typename Strategy> 80 template <typename Strategy>
81 bool EphemeralRangeTemplate<Strategy>::operator==(const EphemeralRangeTemplate<S trategy>& other) const 81 bool EphemeralRangeTemplate<Strategy>::operator==(const EphemeralRangeTemplate<S trategy>& other) const
82 { 82 {
83 return startPosition() == other.startPosition() && endPosition() == other.en dPosition(); 83 return startPosition() == other.startPosition() && endPosition() == other.en dPosition();
84 } 84 }
85 85
86 template <typename Strategy> 86 template <typename Strategy>
87 bool EphemeralRangeTemplate<Strategy>::operator!=(const EphemeralRangeTemplate<S trategy>& other) const 87 bool EphemeralRangeTemplate<Strategy>::operator!=(const EphemeralRangeTemplate<S trategy>& other) const
88 { 88 {
89 return !operator==(other); 89 return !operator==(other);
90 } 90 }
91 91
92 template <typename Strategy> 92 template <typename Strategy>
93 Document& EphemeralRangeTemplate<Strategy>::document() const 93 Document& EphemeralRangeTemplate<Strategy>::document() const
94 { 94 {
95 ASSERT(isNotNull()); 95 DCHECK(isNotNull());
96 return *m_startPosition.document(); 96 return *m_startPosition.document();
97 } 97 }
98 98
99 template <typename Strategy> 99 template <typename Strategy>
100 PositionTemplate<Strategy> EphemeralRangeTemplate<Strategy>::startPosition() con st 100 PositionTemplate<Strategy> EphemeralRangeTemplate<Strategy>::startPosition() con st
101 { 101 {
102 ASSERT(isValid()); 102 DCHECK(isValid());
103 return m_startPosition; 103 return m_startPosition;
104 } 104 }
105 105
106 template <typename Strategy> 106 template <typename Strategy>
107 PositionTemplate<Strategy> EphemeralRangeTemplate<Strategy>::endPosition() const 107 PositionTemplate<Strategy> EphemeralRangeTemplate<Strategy>::endPosition() const
108 { 108 {
109 ASSERT(isValid()); 109 DCHECK(isValid());
110 return m_endPosition; 110 return m_endPosition;
111 } 111 }
112 112
113 template <typename Strategy> 113 template <typename Strategy>
114 bool EphemeralRangeTemplate<Strategy>::isCollapsed() const 114 bool EphemeralRangeTemplate<Strategy>::isCollapsed() const
115 { 115 {
116 ASSERT(isValid()); 116 DCHECK(isValid());
117 return m_startPosition == m_endPosition; 117 return m_startPosition == m_endPosition;
118 } 118 }
119 119
120 template <typename Strategy> 120 template <typename Strategy>
121 EphemeralRangeTemplate<Strategy> EphemeralRangeTemplate<Strategy>::rangeOfConten ts(const Node& node) 121 EphemeralRangeTemplate<Strategy> EphemeralRangeTemplate<Strategy>::rangeOfConten ts(const Node& node)
122 { 122 {
123 return EphemeralRangeTemplate<Strategy>(PositionTemplate<Strategy>::firstPos itionInNode(&const_cast<Node&>(node)), PositionTemplate<Strategy>::lastPositionI nNode(&const_cast<Node&>(node))); 123 return EphemeralRangeTemplate<Strategy>(PositionTemplate<Strategy>::firstPos itionInNode(&const_cast<Node&>(node)), PositionTemplate<Strategy>::lastPositionI nNode(&const_cast<Node&>(node)));
124 } 124 }
125 125
126 #if ENABLE(ASSERT) 126 #if ENABLE(ASSERT)
(...skipping 14 matching lines...) Expand all
141 { 141 {
142 if (range.isNull()) 142 if (range.isNull())
143 return nullptr; 143 return nullptr;
144 return Range::create(range.document(), range.startPosition(), range.endPosit ion()); 144 return Range::create(range.document(), range.startPosition(), range.endPosit ion());
145 } 145 }
146 146
147 template class CORE_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingStrategy>; 147 template class CORE_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingStrategy>;
148 template class CORE_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingInFlatTreeStra tegy>; 148 template class CORE_TEMPLATE_EXPORT EphemeralRangeTemplate<EditingInFlatTreeStra tegy>;
149 149
150 } // namespace blink 150 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698