OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 static const int invalidOffset = -1; | 60 static const int invalidOffset = -1; |
61 | 61 |
62 RefPtr<Node> m_containerNode; | 62 RefPtr<Node> m_containerNode; |
63 mutable int m_offsetInContainer; | 63 mutable int m_offsetInContainer; |
64 RefPtr<Node> m_childBeforeBoundary; | 64 RefPtr<Node> m_childBeforeBoundary; |
65 }; | 65 }; |
66 | 66 |
67 inline RangeBoundaryPoint::RangeBoundaryPoint(PassRefPtr<Node> container) | 67 inline RangeBoundaryPoint::RangeBoundaryPoint(PassRefPtr<Node> container) |
68 : m_containerNode(container) | 68 : m_containerNode(container) |
69 , m_offsetInContainer(0) | 69 , m_offsetInContainer(0) |
70 , m_childBeforeBoundary(0) | 70 , m_childBeforeBoundary(nullptr) |
71 { | 71 { |
72 ASSERT(m_containerNode); | 72 ASSERT(m_containerNode); |
73 } | 73 } |
74 | 74 |
75 inline RangeBoundaryPoint::RangeBoundaryPoint(const RangeBoundaryPoint& other) | 75 inline RangeBoundaryPoint::RangeBoundaryPoint(const RangeBoundaryPoint& other) |
76 : m_containerNode(other.container()) | 76 : m_containerNode(other.container()) |
77 , m_offsetInContainer(other.offset()) | 77 , m_offsetInContainer(other.offset()) |
78 , m_childBeforeBoundary(other.childBefore()) | 78 , m_childBeforeBoundary(other.childBefore()) |
79 { | 79 { |
80 } | 80 } |
(...skipping 26 matching lines...) Expand all Loading... |
107 inline int RangeBoundaryPoint::offset() const | 107 inline int RangeBoundaryPoint::offset() const |
108 { | 108 { |
109 ensureOffsetIsValid(); | 109 ensureOffsetIsValid(); |
110 return m_offsetInContainer; | 110 return m_offsetInContainer; |
111 } | 111 } |
112 | 112 |
113 inline void RangeBoundaryPoint::clear() | 113 inline void RangeBoundaryPoint::clear() |
114 { | 114 { |
115 m_containerNode.clear(); | 115 m_containerNode.clear(); |
116 m_offsetInContainer = 0; | 116 m_offsetInContainer = 0; |
117 m_childBeforeBoundary = 0; | 117 m_childBeforeBoundary = nullptr; |
118 } | 118 } |
119 | 119 |
120 inline void RangeBoundaryPoint::set(PassRefPtr<Node> container, int offset, Node
* childBefore) | 120 inline void RangeBoundaryPoint::set(PassRefPtr<Node> container, int offset, Node
* childBefore) |
121 { | 121 { |
122 ASSERT(container); | 122 ASSERT(container); |
123 ASSERT(offset >= 0); | 123 ASSERT(offset >= 0); |
124 ASSERT(childBefore == (offset ? container->childNode(offset - 1) : 0)); | 124 ASSERT(childBefore == (offset ? container->childNode(offset - 1) : 0)); |
125 m_containerNode = container; | 125 m_containerNode = container; |
126 m_offsetInContainer = offset; | 126 m_offsetInContainer = offset; |
127 m_childBeforeBoundary = childBefore; | 127 m_childBeforeBoundary = childBefore; |
(...skipping 14 matching lines...) Expand all Loading... |
142 m_childBeforeBoundary = child.previousSibling(); | 142 m_childBeforeBoundary = child.previousSibling(); |
143 m_containerNode = child.parentNode(); | 143 m_containerNode = child.parentNode(); |
144 m_offsetInContainer = m_childBeforeBoundary ? invalidOffset : 0; | 144 m_offsetInContainer = m_childBeforeBoundary ? invalidOffset : 0; |
145 } | 145 } |
146 | 146 |
147 inline void RangeBoundaryPoint::setToStartOfNode(PassRefPtr<Node> container) | 147 inline void RangeBoundaryPoint::setToStartOfNode(PassRefPtr<Node> container) |
148 { | 148 { |
149 ASSERT(container); | 149 ASSERT(container); |
150 m_containerNode = container; | 150 m_containerNode = container; |
151 m_offsetInContainer = 0; | 151 m_offsetInContainer = 0; |
152 m_childBeforeBoundary = 0; | 152 m_childBeforeBoundary = nullptr; |
153 } | 153 } |
154 | 154 |
155 inline void RangeBoundaryPoint::setToEndOfNode(PassRefPtr<Node> container) | 155 inline void RangeBoundaryPoint::setToEndOfNode(PassRefPtr<Node> container) |
156 { | 156 { |
157 ASSERT(container); | 157 ASSERT(container); |
158 m_containerNode = container; | 158 m_containerNode = container; |
159 if (m_containerNode->offsetInCharacters()) { | 159 if (m_containerNode->offsetInCharacters()) { |
160 m_offsetInContainer = m_containerNode->maxCharacterOffset(); | 160 m_offsetInContainer = m_containerNode->maxCharacterOffset(); |
161 m_childBeforeBoundary = 0; | 161 m_childBeforeBoundary = nullptr; |
162 } else { | 162 } else { |
163 m_childBeforeBoundary = m_containerNode->lastChild(); | 163 m_childBeforeBoundary = m_containerNode->lastChild(); |
164 m_offsetInContainer = m_childBeforeBoundary ? invalidOffset : 0; | 164 m_offsetInContainer = m_childBeforeBoundary ? invalidOffset : 0; |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
168 inline void RangeBoundaryPoint::childBeforeWillBeRemoved() | 168 inline void RangeBoundaryPoint::childBeforeWillBeRemoved() |
169 { | 169 { |
170 ASSERT(m_offsetInContainer); | 170 ASSERT(m_offsetInContainer); |
171 m_childBeforeBoundary = m_childBeforeBoundary->previousSibling(); | 171 m_childBeforeBoundary = m_childBeforeBoundary->previousSibling(); |
(...skipping 18 matching lines...) Expand all Loading... |
190 } else { | 190 } else { |
191 if (a.offset() != b.offset()) | 191 if (a.offset() != b.offset()) |
192 return false; | 192 return false; |
193 } | 193 } |
194 return true; | 194 return true; |
195 } | 195 } |
196 | 196 |
197 } | 197 } |
198 | 198 |
199 #endif | 199 #endif |
OLD | NEW |