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

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

Issue 189773005: Revert of Have Position deal with more references (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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/editing/VisibleSelection.cpp ('k') | Source/core/editing/htmlediting.h » ('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 * 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 Node* highestRoot = highestEditableRoot(visiblePosition.deepEquivalent(), ed itableType); 82 Node* highestRoot = highestEditableRoot(visiblePosition.deepEquivalent(), ed itableType);
83 Node* previousNode = previousLeafWithSameEditability(node, editableType); 83 Node* previousNode = previousLeafWithSameEditability(node, editableType);
84 84
85 while (previousNode && (!previousNode->renderer() || inSameLine(VisiblePosit ion(firstPositionInOrBeforeNode(previousNode)), visiblePosition))) 85 while (previousNode && (!previousNode->renderer() || inSameLine(VisiblePosit ion(firstPositionInOrBeforeNode(previousNode)), visiblePosition)))
86 previousNode = previousLeafWithSameEditability(previousNode, editableTyp e); 86 previousNode = previousLeafWithSameEditability(previousNode, editableTyp e);
87 87
88 while (previousNode && !previousNode->isShadowRoot()) { 88 while (previousNode && !previousNode->isShadowRoot()) {
89 if (highestEditableRoot(firstPositionInOrBeforeNode(previousNode), edita bleType) != highestRoot) 89 if (highestEditableRoot(firstPositionInOrBeforeNode(previousNode), edita bleType) != highestRoot)
90 break; 90 break;
91 91
92 Position pos = previousNode->hasTagName(brTag) ? positionBeforeNode(*pre viousNode) : 92 Position pos = previousNode->hasTagName(brTag) ? positionBeforeNode(prev iousNode) :
93 createLegacyEditingPosition(previousNode, caretMaxOffset(previousNod e)); 93 createLegacyEditingPosition(previousNode, caretMaxOffset(previousNod e));
94 94
95 if (pos.isCandidate()) 95 if (pos.isCandidate())
96 return pos; 96 return pos;
97 97
98 previousNode = previousLeafWithSameEditability(previousNode, editableTyp e); 98 previousNode = previousLeafWithSameEditability(previousNode, editableTyp e);
99 } 99 }
100 return Position(); 100 return Position();
101 } 101 }
102 102
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 return VisiblePosition(); 738 return VisiblePosition();
739 739
740 startNode = startBox->renderer().nonPseudoNode(); 740 startNode = startBox->renderer().nonPseudoNode();
741 if (startNode) 741 if (startNode)
742 break; 742 break;
743 743
744 startBox = startBox->nextLeafChild(); 744 startBox = startBox->nextLeafChild();
745 } 745 }
746 } 746 }
747 747
748 return VisiblePosition(startNode->isTextNode() ? Position(toText(startNode), toInlineTextBox(startBox)->start()) : positionBeforeNode(*startNode)); 748 return VisiblePosition(startNode->isTextNode() ? Position(toText(startNode), toInlineTextBox(startBox)->start()) : positionBeforeNode(startNode));
749 } 749 }
750 750
751 static VisiblePosition startOfLine(const VisiblePosition& c, LineEndpointComputa tionMode mode) 751 static VisiblePosition startOfLine(const VisiblePosition& c, LineEndpointComputa tionMode mode)
752 { 752 {
753 // TODO: this is the current behavior that might need to be fixed. 753 // TODO: this is the current behavior that might need to be fixed.
754 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=49107 for detail. 754 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=49107 for detail.
755 VisiblePosition visPos = startPositionForLine(c, mode); 755 VisiblePosition visPos = startPositionForLine(c, mode);
756 756
757 if (mode == UseLogicalOrdering) { 757 if (mode == UseLogicalOrdering) {
758 if (Node* editableRoot = highestEditableRoot(c.deepEquivalent())) { 758 if (Node* editableRoot = highestEditableRoot(c.deepEquivalent())) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 endNode = endBox->renderer().nonPseudoNode(); 807 endNode = endBox->renderer().nonPseudoNode();
808 if (endNode) 808 if (endNode)
809 break; 809 break;
810 810
811 endBox = endBox->prevLeafChild(); 811 endBox = endBox->prevLeafChild();
812 } 812 }
813 } 813 }
814 814
815 Position pos; 815 Position pos;
816 if (endNode->hasTagName(brTag)) 816 if (endNode->hasTagName(brTag))
817 pos = positionBeforeNode(*endNode); 817 pos = positionBeforeNode(endNode);
818 else if (endBox->isInlineTextBox() && endNode->isTextNode()) { 818 else if (endBox->isInlineTextBox() && endNode->isTextNode()) {
819 InlineTextBox* endTextBox = toInlineTextBox(endBox); 819 InlineTextBox* endTextBox = toInlineTextBox(endBox);
820 int endOffset = endTextBox->start(); 820 int endOffset = endTextBox->start();
821 if (!endTextBox->isLineBreak()) 821 if (!endTextBox->isLineBreak())
822 endOffset += endTextBox->len(); 822 endOffset += endTextBox->len();
823 pos = Position(toText(endNode), endOffset); 823 pos = Position(toText(endNode), endOffset);
824 } else 824 } else
825 pos = positionAfterNode(*endNode); 825 pos = positionAfterNode(endNode);
826 826
827 return VisiblePosition(pos, VP_UPSTREAM_IF_POSSIBLE); 827 return VisiblePosition(pos, VP_UPSTREAM_IF_POSSIBLE);
828 } 828 }
829 829
830 static bool inSameLogicalLine(const VisiblePosition& a, const VisiblePosition& b ) 830 static bool inSameLogicalLine(const VisiblePosition& a, const VisiblePosition& b )
831 { 831 {
832 return a.isNotNull() && logicalStartOfLine(a) == logicalStartOfLine(b); 832 return a.isNotNull() && logicalStartOfLine(a) == logicalStartOfLine(b);
833 } 833 }
834 834
835 static VisiblePosition endOfLine(const VisiblePosition& c, LineEndpointComputati onMode mode) 835 static VisiblePosition endOfLine(const VisiblePosition& c, LineEndpointComputati onMode mode)
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 1079
1080 VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossi ngRule boundaryCrossingRule) 1080 VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossi ngRule boundaryCrossingRule)
1081 { 1081 {
1082 Position p = c.deepEquivalent(); 1082 Position p = c.deepEquivalent();
1083 Node* startNode = p.deprecatedNode(); 1083 Node* startNode = p.deprecatedNode();
1084 1084
1085 if (!startNode) 1085 if (!startNode)
1086 return VisiblePosition(); 1086 return VisiblePosition();
1087 1087
1088 if (isRenderedAsNonInlineTableImageOrHR(startNode)) 1088 if (isRenderedAsNonInlineTableImageOrHR(startNode))
1089 return VisiblePosition(positionBeforeNode(*startNode)); 1089 return VisiblePosition(positionBeforeNode(startNode));
1090 1090
1091 Node* startBlock = enclosingBlock(startNode); 1091 Node* startBlock = enclosingBlock(startNode);
1092 1092
1093 Node* node = startNode; 1093 Node* node = startNode;
1094 Node* highestRoot = highestEditableRoot(p); 1094 Node* highestRoot = highestEditableRoot(p);
1095 int offset = p.deprecatedEditingOffset(); 1095 int offset = p.deprecatedEditingOffset();
1096 Position::AnchorType type = p.anchorType(); 1096 Position::AnchorType type = p.anchorType();
1097 1097
1098 Node* n = startNode; 1098 Node* n = startNode;
1099 bool startNodeIsEditable = startNode->rendererIsEditable(); 1099 bool startNodeIsEditable = startNode->rendererIsEditable();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 1156
1157 VisiblePosition endOfParagraph(const VisiblePosition &c, EditingBoundaryCrossing Rule boundaryCrossingRule) 1157 VisiblePosition endOfParagraph(const VisiblePosition &c, EditingBoundaryCrossing Rule boundaryCrossingRule)
1158 { 1158 {
1159 if (c.isNull()) 1159 if (c.isNull())
1160 return VisiblePosition(); 1160 return VisiblePosition();
1161 1161
1162 Position p = c.deepEquivalent(); 1162 Position p = c.deepEquivalent();
1163 Node* startNode = p.deprecatedNode(); 1163 Node* startNode = p.deprecatedNode();
1164 1164
1165 if (isRenderedAsNonInlineTableImageOrHR(startNode)) 1165 if (isRenderedAsNonInlineTableImageOrHR(startNode))
1166 return VisiblePosition(positionAfterNode(*startNode)); 1166 return VisiblePosition(positionAfterNode(startNode));
1167 1167
1168 Node* startBlock = enclosingBlock(startNode); 1168 Node* startBlock = enclosingBlock(startNode);
1169 Node* stayInsideBlock = startBlock; 1169 Node* stayInsideBlock = startBlock;
1170 1170
1171 Node* node = startNode; 1171 Node* node = startNode;
1172 Node* highestRoot = highestEditableRoot(p); 1172 Node* highestRoot = highestEditableRoot(p);
1173 int offset = p.deprecatedEditingOffset(); 1173 int offset = p.deprecatedEditingOffset();
1174 Position::AnchorType type = p.anchorType(); 1174 Position::AnchorType type = p.anchorType();
1175 1175
1176 Node* n = startNode; 1176 Node* n = startNode;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 { 1384 {
1385 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c); 1385 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c);
1386 } 1386 }
1387 1387
1388 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire ction) 1388 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire ction)
1389 { 1389 {
1390 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c); 1390 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c);
1391 } 1391 }
1392 1392
1393 } 1393 }
OLDNEW
« no previous file with comments | « Source/core/editing/VisibleSelection.cpp ('k') | Source/core/editing/htmlediting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698