| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2009 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 return toOffsetInAnchor().nodeAsRangeFirstNode(); | 313 return toOffsetInAnchor().nodeAsRangeFirstNode(); |
| 314 if (m_anchorNode->offsetInCharacters()) | 314 if (m_anchorNode->offsetInCharacters()) |
| 315 return m_anchorNode.get(); | 315 return m_anchorNode.get(); |
| 316 if (Node* child = Strategy::childAt(*m_anchorNode, m_offset)) | 316 if (Node* child = Strategy::childAt(*m_anchorNode, m_offset)) |
| 317 return child; | 317 return child; |
| 318 if (!m_offset) | 318 if (!m_offset) |
| 319 return m_anchorNode.get(); | 319 return m_anchorNode.get(); |
| 320 return Strategy::nextSkippingChildren(*m_anchorNode); | 320 return Strategy::nextSkippingChildren(*m_anchorNode); |
| 321 } | 321 } |
| 322 | 322 |
| 323 template <typename Strategy> |
| 324 Node* PositionAlgorithm<Strategy>::nodeAsRangeLastNode() const |
| 325 { |
| 326 if (isNull()) |
| 327 return nullptr; |
| 328 if (Node* pastLastNode = nodeAsRangePastLastNode()) |
| 329 return Strategy::previous(*pastLastNode); |
| 330 return &Strategy::lastWithinOrSelf(*containerNode()); |
| 331 } |
| 332 |
| 323 // An implementation of |Range::pastLastNode()|. | 333 // An implementation of |Range::pastLastNode()|. |
| 324 template <typename Strategy> | 334 template <typename Strategy> |
| 325 Node* PositionAlgorithm<Strategy>::nodeAsRangePastLastNode() const | 335 Node* PositionAlgorithm<Strategy>::nodeAsRangePastLastNode() const |
| 326 { | 336 { |
| 327 if (!m_anchorNode) | 337 if (!m_anchorNode) |
| 328 return nullptr; | 338 return nullptr; |
| 329 if (m_anchorType != PositionIsOffsetInAnchor) | 339 if (m_anchorType != PositionIsOffsetInAnchor) |
| 330 return toOffsetInAnchor().nodeAsRangePastLastNode(); | 340 return toOffsetInAnchor().nodeAsRangePastLastNode(); |
| 331 if (m_anchorNode->offsetInCharacters()) | 341 if (m_anchorNode->offsetInCharacters()) |
| 332 return Strategy::nextSkippingChildren(*m_anchorNode); | 342 return Strategy::nextSkippingChildren(*m_anchorNode); |
| (...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 | 1535 |
| 1526 void showTree(const blink::Position* pos) | 1536 void showTree(const blink::Position* pos) |
| 1527 { | 1537 { |
| 1528 if (pos) | 1538 if (pos) |
| 1529 pos->showTreeForThis(); | 1539 pos->showTreeForThis(); |
| 1530 else | 1540 else |
| 1531 fprintf(stderr, "Cannot showTree for (nil)\n"); | 1541 fprintf(stderr, "Cannot showTree for (nil)\n"); |
| 1532 } | 1542 } |
| 1533 | 1543 |
| 1534 #endif | 1544 #endif |
| OLD | NEW |