OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 inline bool operator!=(const Position& a, const Position& b) | 238 inline bool operator!=(const Position& a, const Position& b) |
239 { | 239 { |
240 return !(a == b); | 240 return !(a == b); |
241 } | 241 } |
242 | 242 |
243 // We define position creation functions to make callsites more readable. | 243 // We define position creation functions to make callsites more readable. |
244 // These are inline to prevent ref-churn when returning a Position object. | 244 // These are inline to prevent ref-churn when returning a Position object. |
245 // If we ever add a PassPosition we can make these non-inline. | 245 // If we ever add a PassPosition we can make these non-inline. |
246 | 246 |
247 inline Position positionInParentBeforeNode(const Node* node) | 247 inline Position positionInParentBeforeNode(const Node& node) |
248 { | 248 { |
249 // FIXME: This should ASSERT(node->parentNode()) | 249 // FIXME: This should ASSERT(node.parentNode()) |
250 // At least one caller currently hits this ASSERT though, which indicates | 250 // At least one caller currently hits this ASSERT though, which indicates |
251 // that the caller is trying to make a position relative to a disconnected n
ode (which is likely an error) | 251 // that the caller is trying to make a position relative to a disconnected n
ode (which is likely an error) |
252 // Specifically, editing/deleting/delete-ligature-001.html crashes with ASSE
RT(node->parentNode()) | 252 // Specifically, editing/deleting/delete-ligature-001.html crashes with ASSE
RT(node->parentNode()) |
253 return Position(node->parentNode(), node->nodeIndex(), Position::PositionIsO
ffsetInAnchor); | 253 return Position(node.parentNode(), node.nodeIndex(), Position::PositionIsOff
setInAnchor); |
254 } | 254 } |
255 | 255 |
256 inline Position positionInParentAfterNode(const Node* node) | 256 inline Position positionInParentAfterNode(const Node& node) |
257 { | 257 { |
258 ASSERT(node->parentNode()); | 258 ASSERT(node.parentNode()); |
259 return Position(node->parentNode(), node->nodeIndex() + 1, Position::Positio
nIsOffsetInAnchor); | 259 return Position(node.parentNode(), node.nodeIndex() + 1, Position::PositionI
sOffsetInAnchor); |
260 } | 260 } |
261 | 261 |
262 // positionBeforeNode and positionAfterNode return neighbor-anchored positions,
construction is O(1) | 262 // positionBeforeNode and positionAfterNode return neighbor-anchored positions,
construction is O(1) |
263 inline Position positionBeforeNode(Node* anchorNode) | 263 inline Position positionBeforeNode(Node* anchorNode) |
264 { | 264 { |
265 ASSERT(anchorNode); | 265 ASSERT(anchorNode); |
266 return Position(anchorNode, Position::PositionIsBeforeAnchor); | 266 return Position(anchorNode, Position::PositionIsBeforeAnchor); |
267 } | 267 } |
268 | 268 |
269 inline Position positionAfterNode(Node* anchorNode) | 269 inline Position positionAfterNode(Node* anchorNode) |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 340 |
341 } // namespace WebCore | 341 } // namespace WebCore |
342 | 342 |
343 #ifndef NDEBUG | 343 #ifndef NDEBUG |
344 // Outside the WebCore namespace for ease of invocation from gdb. | 344 // Outside the WebCore namespace for ease of invocation from gdb. |
345 void showTree(const WebCore::Position&); | 345 void showTree(const WebCore::Position&); |
346 void showTree(const WebCore::Position*); | 346 void showTree(const WebCore::Position*); |
347 #endif | 347 #endif |
348 | 348 |
349 #endif // Position_h | 349 #endif // Position_h |
OLD | NEW |