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

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

Issue 421293004: Move Node::enclosingBlockFlowElement() to htmlediting.h (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix nits Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Position.cpp ('k') | Source/core/editing/VisibleSelection.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, 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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 if (prevIsInSameEditableElement && !nextIsInSameEditableElement) 606 if (prevIsInSameEditableElement && !nextIsInSameEditableElement)
607 return prev; 607 return prev;
608 608
609 if (nextIsInSameEditableElement && !prevIsInSameEditableElement) 609 if (nextIsInSameEditableElement && !prevIsInSameEditableElement)
610 return next; 610 return next;
611 611
612 if (!nextIsInSameEditableElement && !prevIsInSameEditableElement) 612 if (!nextIsInSameEditableElement && !prevIsInSameEditableElement)
613 return Position(); 613 return Position();
614 614
615 // The new position should be in the same block flow element. Favor that. 615 // The new position should be in the same block flow element. Favor that.
616 Node* originalBlock = node ? node->enclosingBlockFlowElement() : 0; 616 Node* originalBlock = node ? enclosingBlockFlowElement(*node) : 0;
617 bool nextIsOutsideOriginalBlock = !nextNode->isDescendantOf(originalBlock) & & nextNode != originalBlock; 617 bool nextIsOutsideOriginalBlock = !nextNode->isDescendantOf(originalBlock) & & nextNode != originalBlock;
618 bool prevIsOutsideOriginalBlock = !prevNode->isDescendantOf(originalBlock) & & prevNode != originalBlock; 618 bool prevIsOutsideOriginalBlock = !prevNode->isDescendantOf(originalBlock) & & prevNode != originalBlock;
619 if (nextIsOutsideOriginalBlock && !prevIsOutsideOriginalBlock) 619 if (nextIsOutsideOriginalBlock && !prevIsOutsideOriginalBlock)
620 return prev; 620 return prev;
621 621
622 return next; 622 return next;
623 } 623 }
624 624
625 UChar32 VisiblePosition::characterAfter() const 625 UChar32 VisiblePosition::characterAfter() const
626 { 626 {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 bool setEnd(Range *r, const VisiblePosition &visiblePosition) 751 bool setEnd(Range *r, const VisiblePosition &visiblePosition)
752 { 752 {
753 if (!r) 753 if (!r)
754 return false; 754 return false;
755 Position p = visiblePosition.deepEquivalent().parentAnchoredEquivalent(); 755 Position p = visiblePosition.deepEquivalent().parentAnchoredEquivalent();
756 TrackExceptionState exceptionState; 756 TrackExceptionState exceptionState;
757 r->setEnd(p.containerNode(), p.offsetInContainerNode(), exceptionState); 757 r->setEnd(p.containerNode(), p.offsetInContainerNode(), exceptionState);
758 return !exceptionState.hadException(); 758 return !exceptionState.hadException();
759 } 759 }
760 760
761 Element* enclosingBlockFlowElement(const VisiblePosition &visiblePosition) 761 Element* enclosingBlockFlowElement(const VisiblePosition& visiblePosition)
762 { 762 {
763 if (visiblePosition.isNull()) 763 if (visiblePosition.isNull())
764 return NULL; 764 return 0;
765 765
766 return visiblePosition.deepEquivalent().deprecatedNode()->enclosingBlockFlow Element(); 766 return enclosingBlockFlowElement(*visiblePosition.deepEquivalent().deprecate dNode());
767 } 767 }
768 768
769 bool isFirstVisiblePositionInNode(const VisiblePosition &visiblePosition, const Node *node) 769 bool isFirstVisiblePositionInNode(const VisiblePosition &visiblePosition, const Node *node)
770 { 770 {
771 if (visiblePosition.isNull()) 771 if (visiblePosition.isNull())
772 return false; 772 return false;
773 773
774 if (!visiblePosition.deepEquivalent().containerNode()->isDescendantOf(node)) 774 if (!visiblePosition.deepEquivalent().containerNode()->isDescendantOf(node))
775 return false; 775 return false;
776 776
(...skipping 27 matching lines...) Expand all
804 if (vpos) 804 if (vpos)
805 vpos->showTreeForThis(); 805 vpos->showTreeForThis();
806 } 806 }
807 807
808 void showTree(const blink::VisiblePosition& vpos) 808 void showTree(const blink::VisiblePosition& vpos)
809 { 809 {
810 vpos.showTreeForThis(); 810 vpos.showTreeForThis();
811 } 811 }
812 812
813 #endif 813 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Position.cpp ('k') | Source/core/editing/VisibleSelection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698