Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(589)

Side by Side Diff: Source/core/dom/Position.cpp

Issue 1263033003: Make PositionAlgorithm<Strategy>::next() to use Strategy::index() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-03T16:32:43 Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/core/dom/PositionTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/PositionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698