| 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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 if (!Strategy::hasChildren(*node) && offset < lastOffsetForEditing(node)) { | 457 if (!Strategy::hasChildren(*node) && offset < lastOffsetForEditing(node)) { |
| 458 // There are two reasons child might be 0: | 458 // There are two reasons child might be 0: |
| 459 // 1) The node is node like a text node that is not an element, and th
erefore has no children. | 459 // 1) The node is node like a text node that is not an element, and th
erefore has no children. |
| 460 // Going forward one character at a time is correct. | 460 // Going forward one character at a time is correct. |
| 461 // 2) The new offset is a bogus offset like (<br>, 1), and there is no
child. | 461 // 2) The new offset is a bogus offset like (<br>, 1), and there is no
child. |
| 462 // Going from 0 to 1 is correct. | 462 // Going from 0 to 1 is correct. |
| 463 return createLegacyEditingPosition(node, (moveType == Character) ? unche
ckedNextOffset(node, offset) : offset + 1); | 463 return createLegacyEditingPosition(node, (moveType == Character) ? unche
ckedNextOffset(node, offset) : offset + 1); |
| 464 } | 464 } |
| 465 | 465 |
| 466 if (ContainerNode* parent = Strategy::parent(*node)) | 466 if (ContainerNode* parent = Strategy::parent(*node)) |
| 467 return createLegacyEditingPosition(parent, node->nodeIndex() + 1); | 467 return createLegacyEditingPosition(parent, Strategy::index(*node) + 1); |
| 468 return PositionAlgorithm<Strategy>(*this); | 468 return PositionAlgorithm<Strategy>(*this); |
| 469 } | 469 } |
| 470 | 470 |
| 471 template <typename Strategy> | 471 template <typename Strategy> |
| 472 int PositionAlgorithm<Strategy>::uncheckedPreviousOffset(const Node* n, int curr
ent) | 472 int PositionAlgorithm<Strategy>::uncheckedPreviousOffset(const Node* n, int curr
ent) |
| 473 { | 473 { |
| 474 return n->layoutObject() ? n->layoutObject()->previousOffset(current) : curr
ent - 1; | 474 return n->layoutObject() ? n->layoutObject()->previousOffset(current) : curr
ent - 1; |
| 475 } | 475 } |
| 476 | 476 |
| 477 template <typename Strategy> | 477 template <typename Strategy> |
| (...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 | 1552 |
| 1553 void showTree(const blink::Position* pos) | 1553 void showTree(const blink::Position* pos) |
| 1554 { | 1554 { |
| 1555 if (pos) | 1555 if (pos) |
| 1556 pos->showTreeForThis(); | 1556 pos->showTreeForThis(); |
| 1557 else | 1557 else |
| 1558 fprintf(stderr, "Cannot showTree for (nil)\n"); | 1558 fprintf(stderr, "Cannot showTree for (nil)\n"); |
| 1559 } | 1559 } |
| 1560 | 1560 |
| 1561 #endif | 1561 #endif |
| OLD | NEW |