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

Side by Side Diff: Source/core/editing/VisiblePosition.cpp

Issue 1259243007: Make VisiblePosition::characterAfter() not to use Position::containerText() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-04T10:45:01 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 | no next file » | 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, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. 3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 } 652 }
653 653
654 // When not at a line wrap, make sure to end up with DOWNSTREAM affinity. 654 // When not at a line wrap, make sure to end up with DOWNSTREAM affinity.
655 if (!inSameLine(PositionWithAffinityTemplate<Strategy>(deepPosition, DOWNSTR EAM), PositionWithAffinityTemplate<Strategy>(deepPosition, UPSTREAM))) 655 if (!inSameLine(PositionWithAffinityTemplate<Strategy>(deepPosition, DOWNSTR EAM), PositionWithAffinityTemplate<Strategy>(deepPosition, UPSTREAM)))
656 return; 656 return;
657 m_affinity = DOWNSTREAM; 657 m_affinity = DOWNSTREAM;
658 } 658 }
659 659
660 UChar32 VisiblePosition::characterAfter() const 660 UChar32 VisiblePosition::characterAfter() const
661 { 661 {
662 // We canonicalize to the first of two equivalent candidates, but the second of the two candidates 662 // We canonicalize to the first of two equivalent candidates, but the second
663 // is the one that will be inside the text node containing the character aft er this visible position. 663 // of the two candidates is the one that will be inside the text node
664 // containing the character after this visible position.
664 Position pos = m_deepPosition.downstream(); 665 Position pos = m_deepPosition.downstream();
665 if (!pos.containerNode() || !pos.containerNode()->isTextNode() || !pos.isOff setInAnchor()) 666 if (!pos.isOffsetInAnchor())
667 return 0;
668 Node* containerNode = pos.containerNode();
669 if (!containerNode || !containerNode->isTextNode())
666 return 0; 670 return 0;
667 unsigned offset = static_cast<unsigned>(pos.offsetInContainerNode()); 671 unsigned offset = static_cast<unsigned>(pos.offsetInContainerNode());
668 Text* textNode = pos.containerText(); 672 Text* textNode = toText(containerNode);
669 unsigned length = textNode->length(); 673 unsigned length = textNode->length();
670 if (offset >= length) 674 if (offset >= length)
671 return 0; 675 return 0;
672 676
673 return textNode->data().characterStartingAt(offset); 677 return textNode->data().characterStartingAt(offset);
674 } 678 }
675 679
676 LayoutRect VisiblePosition::localCaretRect(LayoutObject*& layoutObject) const 680 LayoutRect VisiblePosition::localCaretRect(LayoutObject*& layoutObject) const
677 { 681 {
678 PositionWithAffinity positionWithAffinity(m_deepPosition, m_affinity); 682 PositionWithAffinity positionWithAffinity(m_deepPosition, m_affinity);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 else 765 else
762 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); 766 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n");
763 } 767 }
764 768
765 void showTree(const blink::VisiblePosition& vpos) 769 void showTree(const blink::VisiblePosition& vpos)
766 { 770 {
767 vpos.showTreeForThis(); 771 vpos.showTreeForThis();
768 } 772 }
769 773
770 #endif 774 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698