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

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

Issue 1245843003: [CodeHealth] Use Position::anchorNode instead of deprecatedNode. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 return node->hasEditableStyle(editableType); 275 return node->hasEditableStyle(editableType);
276 } 276 }
277 277
278 bool isEditablePosition(const PositionInComposedTree& p, EditableType editableTy pe, EUpdateStyle updateStyle) 278 bool isEditablePosition(const PositionInComposedTree& p, EditableType editableTy pe, EUpdateStyle updateStyle)
279 { 279 {
280 return isEditablePosition(toPositionInDOMTree(p), editableType, updateStyle) ; 280 return isEditablePosition(toPositionInDOMTree(p), editableType, updateStyle) ;
281 } 281 }
282 282
283 bool isAtUnsplittableElement(const Position& pos) 283 bool isAtUnsplittableElement(const Position& pos)
284 { 284 {
285 Node* node = pos.deprecatedNode(); 285 Node* node = pos.anchorNode();
286 return (node == editableRootForPosition(pos) || node == enclosingNodeOfType( pos, &isTableCell)); 286 return (node == editableRootForPosition(pos) || node == enclosingNodeOfType( pos, &isTableCell));
287 } 287 }
288 288
289 289
290 bool isRichlyEditablePosition(const Position& p, EditableType editableType) 290 bool isRichlyEditablePosition(const Position& p, EditableType editableType)
291 { 291 {
292 Node* node = p.deprecatedNode(); 292 Node* node = p.anchorNode();
293 if (!node) 293 if (!node)
294 return false; 294 return false;
295 295
296 if (isRenderedHTMLTableElement(node)) 296 if (isRenderedHTMLTableElement(node))
297 node = node->parentNode(); 297 node = node->parentNode();
298 298
299 return node->layoutObjectIsRichlyEditable(editableType); 299 return node->layoutObjectIsRichlyEditable(editableType);
300 } 300 }
301 301
302 Element* editableRootForPosition(const Position& p, EditableType editableType) 302 Element* editableRootForPosition(const Position& p, EditableType editableType)
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 } 412 }
413 413
414 VisiblePosition firstEditableVisiblePositionAfterPositionInRoot(const Position& position, ContainerNode* highestRoot) 414 VisiblePosition firstEditableVisiblePositionAfterPositionInRoot(const Position& position, ContainerNode* highestRoot)
415 { 415 {
416 // position falls before highestRoot. 416 // position falls before highestRoot.
417 if (comparePositions(position, firstPositionInNode(highestRoot)) == -1 && hi ghestRoot->hasEditableStyle()) 417 if (comparePositions(position, firstPositionInNode(highestRoot)) == -1 && hi ghestRoot->hasEditableStyle())
418 return VisiblePosition(firstPositionInNode(highestRoot)); 418 return VisiblePosition(firstPositionInNode(highestRoot));
419 419
420 Position editablePosition = position; 420 Position editablePosition = position;
421 421
422 if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) { 422 if (position.anchorNode()->treeScope() != highestRoot->treeScope()) {
423 Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(edit ablePosition.deprecatedNode()); 423 Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(edit ablePosition.anchorNode());
424 if (!shadowAncestor) 424 if (!shadowAncestor)
425 return VisiblePosition(); 425 return VisiblePosition();
426 426
427 editablePosition = positionAfterNode(shadowAncestor); 427 editablePosition = positionAfterNode(shadowAncestor);
428 } 428 }
429 429
430 while (editablePosition.deprecatedNode() && !isEditablePosition(editablePosi tion) && editablePosition.deprecatedNode()->isDescendantOf(highestRoot)) 430 while (editablePosition.anchorNode() && !isEditablePosition(editablePosition ) && editablePosition.anchorNode()->isDescendantOf(highestRoot))
431 editablePosition = isAtomicNode(editablePosition.deprecatedNode()) ? pos itionInParentAfterNode(*editablePosition.deprecatedNode()) : nextVisuallyDistinc tCandidate(editablePosition); 431 editablePosition = isAtomicNode(editablePosition.anchorNode()) ? positio nInParentAfterNode(*editablePosition.anchorNode()) : nextVisuallyDistinctCandida te(editablePosition);
432 432
433 if (editablePosition.deprecatedNode() && editablePosition.deprecatedNode() ! = highestRoot && !editablePosition.deprecatedNode()->isDescendantOf(highestRoot) ) 433 if (editablePosition.anchorNode() && editablePosition.anchorNode() != highes tRoot && !editablePosition.anchorNode()->isDescendantOf(highestRoot))
434 return VisiblePosition(); 434 return VisiblePosition();
435 435
436 return VisiblePosition(editablePosition); 436 return VisiblePosition(editablePosition);
437 } 437 }
438 438
439 VisiblePosition lastEditableVisiblePositionBeforePositionInRoot(const Position& position, ContainerNode* highestRoot) 439 VisiblePosition lastEditableVisiblePositionBeforePositionInRoot(const Position& position, ContainerNode* highestRoot)
440 { 440 {
441 return VisiblePosition(lastEditablePositionBeforePositionInRoot(position, hi ghestRoot)); 441 return VisiblePosition(lastEditablePositionBeforePositionInRoot(position, hi ghestRoot));
442 } 442 }
443 443
444 template <typename PositionType> 444 template <typename PositionType>
445 PositionType lastEditablePositionBeforePositionInRootAlgorithm(const PositionTyp e& position, Node* highestRoot) 445 PositionType lastEditablePositionBeforePositionInRootAlgorithm(const PositionTyp e& position, Node* highestRoot)
446 { 446 {
447 // When position falls after highestRoot, the result is easy to compute. 447 // When position falls after highestRoot, the result is easy to compute.
448 if (position.compareTo(PositionType::lastPositionInNode(highestRoot)) == 1) 448 if (position.compareTo(PositionType::lastPositionInNode(highestRoot)) == 1)
449 return PositionType::lastPositionInNode(highestRoot); 449 return PositionType::lastPositionInNode(highestRoot);
450 450
451 PositionType editablePosition = position; 451 PositionType editablePosition = position;
452 452
453 if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) { 453 if (position.anchorNode()->treeScope() != highestRoot->treeScope()) {
454 Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(edit ablePosition.deprecatedNode()); 454 Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(edit ablePosition.anchorNode());
455 if (!shadowAncestor) 455 if (!shadowAncestor)
456 return PositionType(); 456 return PositionType();
457 457
458 editablePosition = PositionType::firstPositionInOrBeforeNode(shadowAnces tor); 458 editablePosition = PositionType::firstPositionInOrBeforeNode(shadowAnces tor);
459 } 459 }
460 460
461 while (editablePosition.deprecatedNode() && !isEditablePosition(editablePosi tion) && editablePosition.deprecatedNode()->isDescendantOf(highestRoot)) 461 while (editablePosition.anchorNode() && !isEditablePosition(editablePosition ) && editablePosition.anchorNode()->isDescendantOf(highestRoot))
462 editablePosition = isAtomicNode(editablePosition.deprecatedNode()) ? Pos itionType::inParentBeforeNode(*editablePosition.deprecatedNode()) : previousVisu allyDistinctCandidate(editablePosition); 462 editablePosition = isAtomicNode(editablePosition.anchorNode()) ? Positio nType::inParentBeforeNode(*editablePosition.anchorNode()) : previousVisuallyDist inctCandidate(editablePosition);
463 463
464 if (editablePosition.deprecatedNode() && editablePosition.deprecatedNode() ! = highestRoot && !editablePosition.deprecatedNode()->isDescendantOf(highestRoot) ) 464 if (editablePosition.anchorNode() && editablePosition.anchorNode() != highes tRoot && !editablePosition.anchorNode()->isDescendantOf(highestRoot))
465 return PositionType(); 465 return PositionType();
466 return editablePosition; 466 return editablePosition;
467 } 467 }
468 468
469 Position lastEditablePositionBeforePositionInRoot(const Position& position, Node * highestRoot) 469 Position lastEditablePositionBeforePositionInRoot(const Position& position, Node * highestRoot)
470 { 470 {
471 return lastEditablePositionBeforePositionInRootAlgorithm<Position>(position, highestRoot); 471 return lastEditablePositionBeforePositionInRootAlgorithm<Position>(position, highestRoot);
472 } 472 }
473 473
474 PositionInComposedTree lastEditablePositionBeforePositionInRoot(const PositionIn ComposedTree& position, Node* highestRoot) 474 PositionInComposedTree lastEditablePositionBeforePositionInRoot(const PositionIn ComposedTree& position, Node* highestRoot)
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 593
594 if (layoutObject->style()->isFloating()) 594 if (layoutObject->style()->isFloating())
595 return true; 595 return true;
596 596
597 return false; 597 return false;
598 } 598 }
599 599
600 static HTMLElement* firstInSpecialElement(const Position& pos) 600 static HTMLElement* firstInSpecialElement(const Position& pos)
601 { 601 {
602 Element* rootEditableElement = pos.containerNode()->rootEditableElement(); 602 Element* rootEditableElement = pos.containerNode()->rootEditableElement();
603 for (Node* n = pos.deprecatedNode(); n && n->rootEditableElement() == rootEd itableElement; n = n->parentNode()) { 603 for (Node* n = pos.anchorNode(); n && n->rootEditableElement() == rootEditab leElement; n = n->parentNode()) {
604 if (isSpecialHTMLElement(*n)) { 604 if (isSpecialHTMLElement(*n)) {
605 HTMLElement* specialElement = toHTMLElement(n); 605 HTMLElement* specialElement = toHTMLElement(n);
606 VisiblePosition vPos = VisiblePosition(pos, DOWNSTREAM); 606 VisiblePosition vPos = VisiblePosition(pos, DOWNSTREAM);
607 VisiblePosition firstInElement = VisiblePosition(firstPositionInOrBe foreNode(specialElement), DOWNSTREAM); 607 VisiblePosition firstInElement = VisiblePosition(firstPositionInOrBe foreNode(specialElement), DOWNSTREAM);
608 if (isRenderedTableElement(specialElement) && vPos == firstInElement .next()) 608 if (isRenderedTableElement(specialElement) && vPos == firstInElement .next())
609 return specialElement; 609 return specialElement;
610 if (vPos == firstInElement) 610 if (vPos == firstInElement)
611 return specialElement; 611 return specialElement;
612 } 612 }
613 } 613 }
614 return 0; 614 return 0;
615 } 615 }
616 616
617 static HTMLElement* lastInSpecialElement(const Position& pos) 617 static HTMLElement* lastInSpecialElement(const Position& pos)
618 { 618 {
619 Element* rootEditableElement = pos.containerNode()->rootEditableElement(); 619 Element* rootEditableElement = pos.containerNode()->rootEditableElement();
620 for (Node* n = pos.deprecatedNode(); n && n->rootEditableElement() == rootEd itableElement; n = n->parentNode()) { 620 for (Node* n = pos.anchorNode(); n && n->rootEditableElement() == rootEditab leElement; n = n->parentNode()) {
621 if (isSpecialHTMLElement(*n)) { 621 if (isSpecialHTMLElement(*n)) {
622 HTMLElement* specialElement = toHTMLElement(n); 622 HTMLElement* specialElement = toHTMLElement(n);
623 VisiblePosition vPos = VisiblePosition(pos, DOWNSTREAM); 623 VisiblePosition vPos = VisiblePosition(pos, DOWNSTREAM);
624 VisiblePosition lastInElement = VisiblePosition(lastPositionInOrAfte rNode(specialElement), DOWNSTREAM); 624 VisiblePosition lastInElement = VisiblePosition(lastPositionInOrAfte rNode(specialElement), DOWNSTREAM);
625 if (isRenderedTableElement(specialElement) && vPos == lastInElement. previous()) 625 if (isRenderedTableElement(specialElement) && vPos == lastInElement. previous())
626 return specialElement; 626 return specialElement;
627 if (vPos == lastInElement) 627 if (vPos == lastInElement)
628 return specialElement; 628 return specialElement;
629 } 629 }
630 } 630 }
631 return 0; 631 return 0;
632 } 632 }
633 633
634 Position positionBeforeContainingSpecialElement(const Position& pos, HTMLElement ** containingSpecialElement) 634 Position positionBeforeContainingSpecialElement(const Position& pos, HTMLElement ** containingSpecialElement)
635 { 635 {
636 HTMLElement* n = firstInSpecialElement(pos); 636 HTMLElement* n = firstInSpecialElement(pos);
637 if (!n) 637 if (!n)
638 return pos; 638 return pos;
639 Position result = positionInParentBeforeNode(*n); 639 Position result = positionInParentBeforeNode(*n);
640 if (result.isNull() || result.deprecatedNode()->rootEditableElement() != pos .deprecatedNode()->rootEditableElement()) 640 if (result.isNull() || result.anchorNode()->rootEditableElement() != pos.anc horNode()->rootEditableElement())
641 return pos; 641 return pos;
642 if (containingSpecialElement) 642 if (containingSpecialElement)
643 *containingSpecialElement = n; 643 *containingSpecialElement = n;
644 return result; 644 return result;
645 } 645 }
646 646
647 Position positionAfterContainingSpecialElement(const Position& pos, HTMLElement* * containingSpecialElement) 647 Position positionAfterContainingSpecialElement(const Position& pos, HTMLElement* * containingSpecialElement)
648 { 648 {
649 HTMLElement* n = lastInSpecialElement(pos); 649 HTMLElement* n = lastInSpecialElement(pos);
650 if (!n) 650 if (!n)
651 return pos; 651 return pos;
652 Position result = positionInParentAfterNode(*n); 652 Position result = positionInParentAfterNode(*n);
653 if (result.isNull() || result.deprecatedNode()->rootEditableElement() != pos .deprecatedNode()->rootEditableElement()) 653 if (result.isNull() || result.anchorNode()->rootEditableElement() != pos.anc horNode()->rootEditableElement())
654 return pos; 654 return pos;
655 if (containingSpecialElement) 655 if (containingSpecialElement)
656 *containingSpecialElement = n; 656 *containingSpecialElement = n;
657 return result; 657 return result;
658 } 658 }
659 659
660 Element* isFirstPositionAfterTable(const VisiblePosition& visiblePosition) 660 Element* isFirstPositionAfterTable(const VisiblePosition& visiblePosition)
661 { 661 {
662 Position upstream(visiblePosition.deepEquivalent().upstream()); 662 Position upstream(visiblePosition.deepEquivalent().upstream());
663 if (isRenderedTableElement(upstream.deprecatedNode()) && upstream.atLastEdit ingPositionForNode()) 663 if (isRenderedTableElement(upstream.anchorNode()) && upstream.atLastEditingP ositionForNode())
664 return toElement(upstream.deprecatedNode()); 664 return toElement(upstream.anchorNode());
665 665
666 return 0; 666 return 0;
667 } 667 }
668 668
669 Element* isLastPositionBeforeTable(const VisiblePosition& visiblePosition) 669 Element* isLastPositionBeforeTable(const VisiblePosition& visiblePosition)
670 { 670 {
671 Position downstream(visiblePosition.deepEquivalent().downstream()); 671 Position downstream(visiblePosition.deepEquivalent().downstream());
672 if (isRenderedTableElement(downstream.deprecatedNode()) && downstream.atFirs tEditingPositionForNode()) 672 if (isRenderedTableElement(downstream.anchorNode()) && downstream.atFirstEdi tingPositionForNode())
673 return toElement(downstream.deprecatedNode()); 673 return toElement(downstream.anchorNode());
674 674
675 return 0; 675 return 0;
676 } 676 }
677 677
678 static Node* previousNodeConsideringAtomicNodes(const Node& start) 678 static Node* previousNodeConsideringAtomicNodes(const Node& start)
679 { 679 {
680 if (start.previousSibling()) { 680 if (start.previousSibling()) {
681 Node* node = start.previousSibling(); 681 Node* node = start.previousSibling();
682 while (!isAtomicNode(node) && node->lastChild()) 682 while (!isAtomicNode(node) && node->lastChild())
683 node = node->lastChild(); 683 node = node->lastChild();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 { 751 {
752 return n && n->layoutObject() && n->layoutObject()->isListItem(); 752 return n && n->layoutObject() && n->layoutObject()->isListItem();
753 } 753 }
754 754
755 Element* enclosingElementWithTag(const Position& p, const QualifiedName& tagName ) 755 Element* enclosingElementWithTag(const Position& p, const QualifiedName& tagName )
756 { 756 {
757 if (p.isNull()) 757 if (p.isNull())
758 return 0; 758 return 0;
759 759
760 ContainerNode* root = highestEditableRoot(p); 760 ContainerNode* root = highestEditableRoot(p);
761 Element* ancestor = p.deprecatedNode()->isElementNode() ? toElement(p.deprec atedNode()) : p.deprecatedNode()->parentElement(); 761 Element* ancestor = p.anchorNode()->isElementNode() ? toElement(p.anchorNode ()) : p.anchorNode()->parentElement();
762 for (; ancestor; ancestor = ancestor->parentElement()) { 762 for (; ancestor; ancestor = ancestor->parentElement()) {
763 if (root && !ancestor->hasEditableStyle()) 763 if (root && !ancestor->hasEditableStyle())
764 continue; 764 continue;
765 if (ancestor->hasTagName(tagName)) 765 if (ancestor->hasTagName(tagName))
766 return ancestor; 766 return ancestor;
767 if (ancestor == root) 767 if (ancestor == root)
768 return 0; 768 return 0;
769 } 769 }
770 770
771 return 0; 771 return 0;
772 } 772 }
773 773
774 Node* enclosingNodeOfType(const Position& p, bool (*nodeIsOfType)(const Node*), EditingBoundaryCrossingRule rule) 774 Node* enclosingNodeOfType(const Position& p, bool (*nodeIsOfType)(const Node*), EditingBoundaryCrossingRule rule)
775 { 775 {
776 // FIXME: support CanSkipCrossEditingBoundary 776 // FIXME: support CanSkipCrossEditingBoundary
777 ASSERT(rule == CanCrossEditingBoundary || rule == CannotCrossEditingBoundary ); 777 ASSERT(rule == CanCrossEditingBoundary || rule == CannotCrossEditingBoundary );
778 if (p.isNull()) 778 if (p.isNull())
779 return 0; 779 return 0;
780 780
781 ContainerNode* root = rule == CannotCrossEditingBoundary ? highestEditableRo ot(p) : 0; 781 ContainerNode* root = rule == CannotCrossEditingBoundary ? highestEditableRo ot(p) : 0;
782 for (Node* n = p.deprecatedNode(); n; n = n->parentNode()) { 782 for (Node* n = p.anchorNode(); n; n = n->parentNode()) {
783 // Don't return a non-editable node if the input position was editable, since 783 // Don't return a non-editable node if the input position was editable, since
784 // the callers from editing will no doubt want to perform editing inside the returned node. 784 // the callers from editing will no doubt want to perform editing inside the returned node.
785 if (root && !n->hasEditableStyle()) 785 if (root && !n->hasEditableStyle())
786 continue; 786 continue;
787 if (nodeIsOfType(n)) 787 if (nodeIsOfType(n))
788 return n; 788 return n;
789 if (n == root) 789 if (n == root)
790 return 0; 790 return 0;
791 } 791 }
792 792
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 Element* enclosingTableCell(const Position& p) 840 Element* enclosingTableCell(const Position& p)
841 { 841 {
842 return toElement(enclosingNodeOfType(p, isTableCell)); 842 return toElement(enclosingNodeOfType(p, isTableCell));
843 } 843 }
844 844
845 Element* enclosingAnchorElement(const Position& p) 845 Element* enclosingAnchorElement(const Position& p)
846 { 846 {
847 if (p.isNull()) 847 if (p.isNull())
848 return 0; 848 return 0;
849 849
850 for (Element* ancestor = ElementTraversal::firstAncestorOrSelf(*p.deprecated Node()); ancestor; ancestor = ElementTraversal::firstAncestor(*ancestor)) { 850 for (Element* ancestor = ElementTraversal::firstAncestorOrSelf(*p.anchorNode ()); ancestor; ancestor = ElementTraversal::firstAncestor(*ancestor)) {
851 if (ancestor->isLink()) 851 if (ancestor->isLink())
852 return ancestor; 852 return ancestor;
853 } 853 }
854 return 0; 854 return 0;
855 } 855 }
856 856
857 HTMLElement* enclosingList(Node* node) 857 HTMLElement* enclosingList(Node* node)
858 { 858 {
859 if (!node) 859 if (!node)
860 return 0; 860 return 0;
(...skipping 26 matching lines...) Expand all
887 return 0; 887 return 0;
888 } 888 }
889 889
890 return 0; 890 return 0;
891 } 891 }
892 892
893 // FIXME: This method should not need to call isStartOfParagraph/isEndOfParagrap h 893 // FIXME: This method should not need to call isStartOfParagraph/isEndOfParagrap h
894 Node* enclosingEmptyListItem(const VisiblePosition& visiblePos) 894 Node* enclosingEmptyListItem(const VisiblePosition& visiblePos)
895 { 895 {
896 // Check that position is on a line by itself inside a list item 896 // Check that position is on a line by itself inside a list item
897 Node* listChildNode = enclosingListChild(visiblePos.deepEquivalent().depreca tedNode()); 897 Node* listChildNode = enclosingListChild(visiblePos.deepEquivalent().anchorN ode());
898 if (!listChildNode || !isStartOfParagraph(visiblePos) || !isEndOfParagraph(v isiblePos)) 898 if (!listChildNode || !isStartOfParagraph(visiblePos) || !isEndOfParagraph(v isiblePos))
899 return 0; 899 return 0;
900 900
901 VisiblePosition firstInListChild(firstPositionInOrBeforeNode(listChildNode)) ; 901 VisiblePosition firstInListChild(firstPositionInOrBeforeNode(listChildNode)) ;
902 VisiblePosition lastInListChild(lastPositionInOrAfterNode(listChildNode)); 902 VisiblePosition lastInListChild(lastPositionInOrAfterNode(listChildNode));
903 903
904 if (firstInListChild != visiblePos || lastInListChild != visiblePos) 904 if (firstInListChild != visiblePos || lastInListChild != visiblePos)
905 return 0; 905 return 0;
906 906
907 return listChildNode; 907 return listChildNode;
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 bool isSpace = option == ConsiderNonCollapsibleWhitespace ? (isSpaceOrNewlin e(characterAfterVisiblePosition) || characterAfterVisiblePosition == noBreakSpac eCharacter) : isCollapsibleWhitespace(characterAfterVisiblePosition); 1151 bool isSpace = option == ConsiderNonCollapsibleWhitespace ? (isSpaceOrNewlin e(characterAfterVisiblePosition) || characterAfterVisiblePosition == noBreakSpac eCharacter) : isCollapsibleWhitespace(characterAfterVisiblePosition);
1152 // The space must not be in another paragraph and it must be editable. 1152 // The space must not be in another paragraph and it must be editable.
1153 if (isSpace && !isEndOfParagraph(visiblePosition) && visiblePosition.next(Ca nnotCrossEditingBoundary).isNotNull()) 1153 if (isSpace && !isEndOfParagraph(visiblePosition) && visiblePosition.next(Ca nnotCrossEditingBoundary).isNotNull())
1154 return position; 1154 return position;
1155 return Position(); 1155 return Position();
1156 } 1156 }
1157 1157
1158 unsigned numEnclosingMailBlockquotes(const Position& p) 1158 unsigned numEnclosingMailBlockquotes(const Position& p)
1159 { 1159 {
1160 unsigned num = 0; 1160 unsigned num = 0;
1161 for (Node* n = p.deprecatedNode(); n; n = n->parentNode()) 1161 for (Node* n = p.anchorNode(); n; n = n->parentNode())
1162 if (isMailHTMLBlockquoteElement(n)) 1162 if (isMailHTMLBlockquoteElement(n))
1163 num++; 1163 num++;
1164 1164
1165 return num; 1165 return num;
1166 } 1166 }
1167 1167
1168 void updatePositionForNodeRemoval(Position& position, Node& node) 1168 void updatePositionForNodeRemoval(Position& position, Node& node)
1169 { 1169 {
1170 if (position.isNull()) 1170 if (position.isNull())
1171 return; 1171 return;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 { 1253 {
1254 VisibleSelection newSelection(original); 1254 VisibleSelection newSelection(original);
1255 VisiblePosition startOfSelection(newSelection.visibleStart()); 1255 VisiblePosition startOfSelection(newSelection.visibleStart());
1256 VisiblePosition endOfSelection(newSelection.visibleEnd()); 1256 VisiblePosition endOfSelection(newSelection.visibleEnd());
1257 1257
1258 // If the end of the selection to modify is just after a table, and 1258 // If the end of the selection to modify is just after a table, and
1259 // if the start of the selection is inside that table, then the last paragra ph 1259 // if the start of the selection is inside that table, then the last paragra ph
1260 // that we'll want modify is the last one inside the table, not the table it self 1260 // that we'll want modify is the last one inside the table, not the table it self
1261 // (a table is itself a paragraph). 1261 // (a table is itself a paragraph).
1262 if (Element* table = isFirstPositionAfterTable(endOfSelection)) 1262 if (Element* table = isFirstPositionAfterTable(endOfSelection))
1263 if (startOfSelection.deepEquivalent().deprecatedNode()->isDescendantOf(t able)) 1263 if (startOfSelection.deepEquivalent().anchorNode()->isDescendantOf(table ))
1264 newSelection = VisibleSelection(startOfSelection, endOfSelection.pre vious(CannotCrossEditingBoundary)); 1264 newSelection = VisibleSelection(startOfSelection, endOfSelection.pre vious(CannotCrossEditingBoundary));
1265 1265
1266 // If the start of the selection to modify is just before a table, 1266 // If the start of the selection to modify is just before a table,
1267 // and if the end of the selection is inside that table, then the first para graph 1267 // and if the end of the selection is inside that table, then the first para graph
1268 // we'll want to modify is the first one inside the table, not the paragraph 1268 // we'll want to modify is the first one inside the table, not the paragraph
1269 // containing the table itself. 1269 // containing the table itself.
1270 if (Element* table = isLastPositionBeforeTable(startOfSelection)) 1270 if (Element* table = isLastPositionBeforeTable(startOfSelection))
1271 if (endOfSelection.deepEquivalent().deprecatedNode()->isDescendantOf(tab le)) 1271 if (endOfSelection.deepEquivalent().anchorNode()->isDescendantOf(table))
1272 newSelection = VisibleSelection(startOfSelection.next(CannotCrossEdi tingBoundary), endOfSelection); 1272 newSelection = VisibleSelection(startOfSelection.next(CannotCrossEdi tingBoundary), endOfSelection);
1273 1273
1274 return newSelection; 1274 return newSelection;
1275 } 1275 }
1276 1276
1277 // FIXME: indexForVisiblePosition and visiblePositionForIndex use TextIterators to convert between 1277 // FIXME: indexForVisiblePosition and visiblePositionForIndex use TextIterators to convert between
1278 // VisiblePositions and indices. But TextIterator iteration using TextIteratorEm itsCharactersBetweenAllVisiblePositions 1278 // VisiblePositions and indices. But TextIterator iteration using TextIteratorEm itsCharactersBetweenAllVisiblePositions
1279 // does not exactly match VisiblePosition iteration, so using them to preserve a selection during an editing 1279 // does not exactly match VisiblePosition iteration, so using them to preserve a selection during an editing
1280 // opertion is unreliable. TextIterator's TextIteratorEmitsCharactersBetweenAllV isiblePositions mode needs to be fixed, 1280 // opertion is unreliable. TextIterator's TextIteratorEmitsCharactersBetweenAllV isiblePositions mode needs to be fixed,
1281 // or these functions need to be changed to iterate using actual VisiblePosition s. 1281 // or these functions need to be changed to iterate using actual VisiblePosition s.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 // if the selection starts just before a paragraph break, skip over it 1395 // if the selection starts just before a paragraph break, skip over it
1396 if (isEndOfParagraph(visiblePosition)) 1396 if (isEndOfParagraph(visiblePosition))
1397 return visiblePosition.next().deepEquivalent().downstream(); 1397 return visiblePosition.next().deepEquivalent().downstream();
1398 1398
1399 // otherwise, make sure to be at the start of the first selected node, 1399 // otherwise, make sure to be at the start of the first selected node,
1400 // instead of possibly at the end of the last node before the selection 1400 // instead of possibly at the end of the last node before the selection
1401 return visiblePosition.deepEquivalent().downstream(); 1401 return visiblePosition.deepEquivalent().downstream();
1402 } 1402 }
1403 1403
1404 } // namespace blink 1404 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/VisibleUnits.cpp ('k') | Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698