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 30 matching lines...) Expand all Loading... |
41 | 41 |
42 Node* container() const; | 42 Node* container() const; |
43 int offset() const; | 43 int offset() const; |
44 Node* childBefore() const; | 44 Node* childBefore() const; |
45 | 45 |
46 void clear(); | 46 void clear(); |
47 | 47 |
48 void set(PassRefPtr<Node> container, int offset, Node* childBefore); | 48 void set(PassRefPtr<Node> container, int offset, Node* childBefore); |
49 void setOffset(int offset); | 49 void setOffset(int offset); |
50 | 50 |
51 void setToBeforeChild(Node*); | 51 void setToBeforeChild(Node&); |
52 void setToStartOfNode(PassRefPtr<Node>); | 52 void setToStartOfNode(PassRefPtr<Node>); |
53 void setToEndOfNode(PassRefPtr<Node>); | 53 void setToEndOfNode(PassRefPtr<Node>); |
54 | 54 |
55 void childBeforeWillBeRemoved(); | 55 void childBeforeWillBeRemoved(); |
56 void invalidateOffset() const; | 56 void invalidateOffset() const; |
57 void ensureOffsetIsValid() const; | 57 void ensureOffsetIsValid() const; |
58 | 58 |
59 private: | 59 private: |
60 static const int invalidOffset = -1; | 60 static const int invalidOffset = -1; |
61 | 61 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 129 |
130 inline void RangeBoundaryPoint::setOffset(int offset) | 130 inline void RangeBoundaryPoint::setOffset(int offset) |
131 { | 131 { |
132 ASSERT(m_containerNode); | 132 ASSERT(m_containerNode); |
133 ASSERT(m_containerNode->offsetInCharacters()); | 133 ASSERT(m_containerNode->offsetInCharacters()); |
134 ASSERT(m_offsetInContainer >= 0); | 134 ASSERT(m_offsetInContainer >= 0); |
135 ASSERT(!m_childBeforeBoundary); | 135 ASSERT(!m_childBeforeBoundary); |
136 m_offsetInContainer = offset; | 136 m_offsetInContainer = offset; |
137 } | 137 } |
138 | 138 |
139 inline void RangeBoundaryPoint::setToBeforeChild(Node* child) | 139 inline void RangeBoundaryPoint::setToBeforeChild(Node& child) |
140 { | 140 { |
141 ASSERT(child); | 141 ASSERT(child.parentNode()); |
142 ASSERT(child->parentNode()); | 142 m_childBeforeBoundary = child.previousSibling(); |
143 m_childBeforeBoundary = child->previousSibling(); | 143 m_containerNode = child.parentNode(); |
144 m_containerNode = child->parentNode(); | |
145 m_offsetInContainer = m_childBeforeBoundary ? invalidOffset : 0; | 144 m_offsetInContainer = m_childBeforeBoundary ? invalidOffset : 0; |
146 } | 145 } |
147 | 146 |
148 inline void RangeBoundaryPoint::setToStartOfNode(PassRefPtr<Node> container) | 147 inline void RangeBoundaryPoint::setToStartOfNode(PassRefPtr<Node> container) |
149 { | 148 { |
150 ASSERT(container); | 149 ASSERT(container); |
151 m_containerNode = container; | 150 m_containerNode = container; |
152 m_offsetInContainer = 0; | 151 m_offsetInContainer = 0; |
153 m_childBeforeBoundary = 0; | 152 m_childBeforeBoundary = 0; |
154 } | 153 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } else { | 190 } else { |
192 if (a.offset() != b.offset()) | 191 if (a.offset() != b.offset()) |
193 return false; | 192 return false; |
194 } | 193 } |
195 return true; | 194 return true; |
196 } | 195 } |
197 | 196 |
198 } | 197 } |
199 | 198 |
200 #endif | 199 #endif |
OLD | NEW |