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

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

Issue 1675163002: Rename ComposedTree to FlatTree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip Created 4 years, 10 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, 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 return prev; 155 return prev;
156 156
157 return next; 157 return next;
158 } 158 }
159 159
160 Position canonicalPositionOf(const Position& position) 160 Position canonicalPositionOf(const Position& position)
161 { 161 {
162 return canonicalPosition(position); 162 return canonicalPosition(position);
163 } 163 }
164 164
165 PositionInComposedTree canonicalPositionOf(const PositionInComposedTree& positio n) 165 PositionInFlatTree canonicalPositionOf(const PositionInFlatTree& position)
166 { 166 {
167 return canonicalPosition(position); 167 return canonicalPosition(position);
168 } 168 }
169 169
170 template <typename Strategy> 170 template <typename Strategy>
171 static PositionWithAffinityTemplate<Strategy> honorEditingBoundaryAtOrBefore(con st PositionWithAffinityTemplate<Strategy>& pos, const PositionTemplate<Strategy> & anchor) 171 static PositionWithAffinityTemplate<Strategy> honorEditingBoundaryAtOrBefore(con st PositionWithAffinityTemplate<Strategy>& pos, const PositionTemplate<Strategy> & anchor)
172 { 172 {
173 if (pos.isNull()) 173 if (pos.isNull())
174 return pos; 174 return pos;
175 175
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 return c; 867 return c;
868 } 868 }
869 return previousBoundary(p, startWordBoundary); 869 return previousBoundary(p, startWordBoundary);
870 } 870 }
871 871
872 VisiblePosition startOfWord(const VisiblePosition& c, EWordSide side) 872 VisiblePosition startOfWord(const VisiblePosition& c, EWordSide side)
873 { 873 {
874 return startOfWordAlgorithm<EditingStrategy>(c, side); 874 return startOfWordAlgorithm<EditingStrategy>(c, side);
875 } 875 }
876 876
877 VisiblePositionInComposedTree startOfWord(const VisiblePositionInComposedTree& c , EWordSide side) 877 VisiblePositionInFlatTree startOfWord(const VisiblePositionInFlatTree& c, EWordS ide side)
878 { 878 {
879 return startOfWordAlgorithm<EditingInComposedTreeStrategy>(c, side); 879 return startOfWordAlgorithm<EditingInFlatTreeStrategy>(c, side);
880 } 880 }
881 881
882 static unsigned endWordBoundary(const UChar* characters, unsigned length, unsign ed offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMoreC ontext) 882 static unsigned endWordBoundary(const UChar* characters, unsigned length, unsign ed offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMoreC ontext)
883 { 883 {
884 ASSERT(offset <= length); 884 ASSERT(offset <= length);
885 if (mayHaveMoreContext && endOfFirstWordBoundaryContext(characters + offset, length - offset) == static_cast<int>(length - offset)) { 885 if (mayHaveMoreContext && endOfFirstWordBoundaryContext(characters + offset, length - offset) == static_cast<int>(length - offset)) {
886 needMoreContext = true; 886 needMoreContext = true;
887 return length; 887 return length;
888 } 888 }
889 needMoreContext = false; 889 needMoreContext = false;
(...skipping 16 matching lines...) Expand all
906 } 906 }
907 907
908 return nextBoundary(p, endWordBoundary); 908 return nextBoundary(p, endWordBoundary);
909 } 909 }
910 910
911 VisiblePosition endOfWord(const VisiblePosition& c, EWordSide side) 911 VisiblePosition endOfWord(const VisiblePosition& c, EWordSide side)
912 { 912 {
913 return endOfWordAlgorithm<EditingStrategy>(c, side); 913 return endOfWordAlgorithm<EditingStrategy>(c, side);
914 } 914 }
915 915
916 VisiblePositionInComposedTree endOfWord(const VisiblePositionInComposedTree& c, EWordSide side) 916 VisiblePositionInFlatTree endOfWord(const VisiblePositionInFlatTree& c, EWordSid e side)
917 { 917 {
918 return endOfWordAlgorithm<EditingInComposedTreeStrategy>(c, side); 918 return endOfWordAlgorithm<EditingInFlatTreeStrategy>(c, side);
919 } 919 }
920 920
921 static unsigned previousWordPositionBoundary(const UChar* characters, unsigned l ength, unsigned offset, BoundarySearchContextAvailability mayHaveMoreContext, bo ol& needMoreContext) 921 static unsigned previousWordPositionBoundary(const UChar* characters, unsigned l ength, unsigned offset, BoundarySearchContextAvailability mayHaveMoreContext, bo ol& needMoreContext)
922 { 922 {
923 if (mayHaveMoreContext && !startOfLastWordBoundaryContext(characters, offset )) { 923 if (mayHaveMoreContext && !startOfLastWordBoundaryContext(characters, offset )) {
924 needMoreContext = true; 924 needMoreContext = true;
925 return 0; 925 return 0;
926 } 926 }
927 needMoreContext = false; 927 needMoreContext = false;
928 return findNextWordFromIndex(characters, length, offset, false); 928 return findNextWordFromIndex(characters, length, offset, false);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=49107 for detail. 1002 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=49107 for detail.
1003 PositionWithAffinityTemplate<Strategy> visPos = startPositionForLine(c, UseI nlineBoxOrdering); 1003 PositionWithAffinityTemplate<Strategy> visPos = startPositionForLine(c, UseI nlineBoxOrdering);
1004 return honorEditingBoundaryAtOrBefore(visPos, c.position()); 1004 return honorEditingBoundaryAtOrBefore(visPos, c.position());
1005 } 1005 }
1006 1006
1007 static PositionWithAffinity startOfLine(const PositionWithAffinity& currentPosit ion) 1007 static PositionWithAffinity startOfLine(const PositionWithAffinity& currentPosit ion)
1008 { 1008 {
1009 return startOfLineAlgorithm<EditingStrategy>(currentPosition); 1009 return startOfLineAlgorithm<EditingStrategy>(currentPosition);
1010 } 1010 }
1011 1011
1012 static PositionInComposedTreeWithAffinity startOfLine(const PositionInComposedTr eeWithAffinity& currentPosition) 1012 static PositionInFlatTreeWithAffinity startOfLine(const PositionInFlatTreeWithAf finity& currentPosition)
1013 { 1013 {
1014 return startOfLineAlgorithm<EditingInComposedTreeStrategy>(currentPosition); 1014 return startOfLineAlgorithm<EditingInFlatTreeStrategy>(currentPosition);
1015 } 1015 }
1016 1016
1017 // FIXME: Rename this function to reflect the fact it ignores bidi levels. 1017 // FIXME: Rename this function to reflect the fact it ignores bidi levels.
1018 VisiblePosition startOfLine(const VisiblePosition& currentPosition) 1018 VisiblePosition startOfLine(const VisiblePosition& currentPosition)
1019 { 1019 {
1020 return createVisiblePosition(startOfLine(currentPosition.toPositionWithAffin ity())); 1020 return createVisiblePosition(startOfLine(currentPosition.toPositionWithAffin ity()));
1021 } 1021 }
1022 1022
1023 VisiblePositionInComposedTree startOfLine(const VisiblePositionInComposedTree& c urrentPosition) 1023 VisiblePositionInFlatTree startOfLine(const VisiblePositionInFlatTree& currentPo sition)
1024 { 1024 {
1025 return createVisiblePosition(startOfLine(currentPosition.toPositionWithAffin ity())); 1025 return createVisiblePosition(startOfLine(currentPosition.toPositionWithAffin ity()));
1026 } 1026 }
1027 1027
1028 template <typename Strategy> 1028 template <typename Strategy>
1029 static PositionWithAffinityTemplate<Strategy> logicalStartOfLineAlgorithm(const PositionWithAffinityTemplate<Strategy>& c) 1029 static PositionWithAffinityTemplate<Strategy> logicalStartOfLineAlgorithm(const PositionWithAffinityTemplate<Strategy>& c)
1030 { 1030 {
1031 // TODO: this is the current behavior that might need to be fixed. 1031 // TODO: this is the current behavior that might need to be fixed.
1032 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=49107 for detail. 1032 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=49107 for detail.
1033 PositionWithAffinityTemplate<Strategy> visPos = startPositionForLine(c, UseL ogicalOrdering); 1033 PositionWithAffinityTemplate<Strategy> visPos = startPositionForLine(c, UseL ogicalOrdering);
1034 1034
1035 if (ContainerNode* editableRoot = highestEditableRoot(c.position())) { 1035 if (ContainerNode* editableRoot = highestEditableRoot(c.position())) {
1036 if (!editableRoot->contains(visPos.position().computeContainerNode())) 1036 if (!editableRoot->contains(visPos.position().computeContainerNode()))
1037 return PositionWithAffinityTemplate<Strategy>(PositionTemplate<Strat egy>::firstPositionInNode(editableRoot)); 1037 return PositionWithAffinityTemplate<Strategy>(PositionTemplate<Strat egy>::firstPositionInNode(editableRoot));
1038 } 1038 }
1039 1039
1040 return honorEditingBoundaryAtOrBefore(visPos, c.position()); 1040 return honorEditingBoundaryAtOrBefore(visPos, c.position());
1041 } 1041 }
1042 1042
1043 VisiblePosition logicalStartOfLine(const VisiblePosition& currentPosition) 1043 VisiblePosition logicalStartOfLine(const VisiblePosition& currentPosition)
1044 { 1044 {
1045 return createVisiblePosition(logicalStartOfLineAlgorithm<EditingStrategy>(cu rrentPosition.toPositionWithAffinity())); 1045 return createVisiblePosition(logicalStartOfLineAlgorithm<EditingStrategy>(cu rrentPosition.toPositionWithAffinity()));
1046 } 1046 }
1047 1047
1048 VisiblePositionInComposedTree logicalStartOfLine(const VisiblePositionInComposed Tree& currentPosition) 1048 VisiblePositionInFlatTree logicalStartOfLine(const VisiblePositionInFlatTree& cu rrentPosition)
1049 { 1049 {
1050 return createVisiblePosition(logicalStartOfLineAlgorithm<EditingInComposedTr eeStrategy>(currentPosition.toPositionWithAffinity())); 1050 return createVisiblePosition(logicalStartOfLineAlgorithm<EditingInFlatTreeSt rategy>(currentPosition.toPositionWithAffinity()));
1051 } 1051 }
1052 1052
1053 template <typename Strategy> 1053 template <typename Strategy>
1054 static VisiblePositionTemplate<Strategy> endPositionForLine(const VisiblePositio nTemplate<Strategy>& c, LineEndpointComputationMode mode) 1054 static VisiblePositionTemplate<Strategy> endPositionForLine(const VisiblePositio nTemplate<Strategy>& c, LineEndpointComputationMode mode)
1055 { 1055 {
1056 if (c.isNull()) 1056 if (c.isNull())
1057 return VisiblePositionTemplate<Strategy>(); 1057 return VisiblePositionTemplate<Strategy>();
1058 1058
1059 RootInlineBox* rootBox = RenderedPosition(c).rootBox(); 1059 RootInlineBox* rootBox = RenderedPosition(c).rootBox();
1060 if (!rootBox) { 1060 if (!rootBox) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 1130
1131 return honorEditingBoundaryAtOrAfter(visPos, currentPosition.deepEquivalent( )); 1131 return honorEditingBoundaryAtOrAfter(visPos, currentPosition.deepEquivalent( ));
1132 } 1132 }
1133 1133
1134 // TODO(yosin) Rename this function to reflect the fact it ignores bidi levels. 1134 // TODO(yosin) Rename this function to reflect the fact it ignores bidi levels.
1135 VisiblePosition endOfLine(const VisiblePosition& currentPosition) 1135 VisiblePosition endOfLine(const VisiblePosition& currentPosition)
1136 { 1136 {
1137 return endOfLineAlgorithm<EditingStrategy>(currentPosition); 1137 return endOfLineAlgorithm<EditingStrategy>(currentPosition);
1138 } 1138 }
1139 1139
1140 VisiblePositionInComposedTree endOfLine(const VisiblePositionInComposedTree& cur rentPosition) 1140 VisiblePositionInFlatTree endOfLine(const VisiblePositionInFlatTree& currentPosi tion)
1141 { 1141 {
1142 return endOfLineAlgorithm<EditingInComposedTreeStrategy>(currentPosition); 1142 return endOfLineAlgorithm<EditingInFlatTreeStrategy>(currentPosition);
1143 } 1143 }
1144 1144
1145 template <typename Strategy> 1145 template <typename Strategy>
1146 static bool inSameLogicalLine(const VisiblePositionTemplate<Strategy>& a, const VisiblePositionTemplate<Strategy>& b) 1146 static bool inSameLogicalLine(const VisiblePositionTemplate<Strategy>& a, const VisiblePositionTemplate<Strategy>& b)
1147 { 1147 {
1148 return a.isNotNull() && logicalStartOfLine(a).deepEquivalent() == logicalSta rtOfLine(b).deepEquivalent(); 1148 return a.isNotNull() && logicalStartOfLine(a).deepEquivalent() == logicalSta rtOfLine(b).deepEquivalent();
1149 } 1149 }
1150 1150
1151 template <typename Strategy> 1151 template <typename Strategy>
1152 VisiblePositionTemplate<Strategy> logicalEndOfLineAlgorithm(const VisiblePositio nTemplate<Strategy>& currentPosition) 1152 VisiblePositionTemplate<Strategy> logicalEndOfLineAlgorithm(const VisiblePositio nTemplate<Strategy>& currentPosition)
(...skipping 19 matching lines...) Expand all
1172 } 1172 }
1173 1173
1174 return honorEditingBoundaryAtOrAfter(visPos, currentPosition.deepEquivalent( )); 1174 return honorEditingBoundaryAtOrAfter(visPos, currentPosition.deepEquivalent( ));
1175 } 1175 }
1176 1176
1177 VisiblePosition logicalEndOfLine(const VisiblePosition& currentPosition) 1177 VisiblePosition logicalEndOfLine(const VisiblePosition& currentPosition)
1178 { 1178 {
1179 return logicalEndOfLineAlgorithm<EditingStrategy>(currentPosition); 1179 return logicalEndOfLineAlgorithm<EditingStrategy>(currentPosition);
1180 } 1180 }
1181 1181
1182 VisiblePositionInComposedTree logicalEndOfLine(const VisiblePositionInComposedTr ee& currentPosition) 1182 VisiblePositionInFlatTree logicalEndOfLine(const VisiblePositionInFlatTree& curr entPosition)
1183 { 1183 {
1184 return logicalEndOfLineAlgorithm<EditingInComposedTreeStrategy>(currentPosit ion); 1184 return logicalEndOfLineAlgorithm<EditingInFlatTreeStrategy>(currentPosition) ;
1185 } 1185 }
1186 1186
1187 template <typename Strategy> 1187 template <typename Strategy>
1188 bool inSameLineAlgorithm(const PositionWithAffinityTemplate<Strategy>& position1 , const PositionWithAffinityTemplate<Strategy>& position2) 1188 bool inSameLineAlgorithm(const PositionWithAffinityTemplate<Strategy>& position1 , const PositionWithAffinityTemplate<Strategy>& position2)
1189 { 1189 {
1190 if (position1.isNull() || position2.isNull()) 1190 if (position1.isNull() || position2.isNull())
1191 return false; 1191 return false;
1192 PositionWithAffinityTemplate<Strategy> startOfLine1 = startOfLine(position1) ; 1192 PositionWithAffinityTemplate<Strategy> startOfLine1 = startOfLine(position1) ;
1193 PositionWithAffinityTemplate<Strategy> startOfLine2 = startOfLine(position2) ; 1193 PositionWithAffinityTemplate<Strategy> startOfLine2 = startOfLine(position2) ;
1194 if (startOfLine1 == startOfLine2) 1194 if (startOfLine1 == startOfLine2)
1195 return true; 1195 return true;
1196 PositionTemplate<Strategy> canonicalized1 = canonicalPositionOf(startOfLine1 .position()); 1196 PositionTemplate<Strategy> canonicalized1 = canonicalPositionOf(startOfLine1 .position());
1197 if (canonicalized1 == startOfLine2.position()) 1197 if (canonicalized1 == startOfLine2.position())
1198 return true; 1198 return true;
1199 return canonicalized1 == canonicalPositionOf(startOfLine2.position()); 1199 return canonicalized1 == canonicalPositionOf(startOfLine2.position());
1200 } 1200 }
1201 1201
1202 bool inSameLine(const PositionWithAffinity& a, const PositionWithAffinity& b) 1202 bool inSameLine(const PositionWithAffinity& a, const PositionWithAffinity& b)
1203 { 1203 {
1204 return inSameLineAlgorithm<EditingStrategy>(a, b); 1204 return inSameLineAlgorithm<EditingStrategy>(a, b);
1205 } 1205 }
1206 1206
1207 bool inSameLine(const PositionInComposedTreeWithAffinity& position1, const Posit ionInComposedTreeWithAffinity& position2) 1207 bool inSameLine(const PositionInFlatTreeWithAffinity& position1, const PositionI nFlatTreeWithAffinity& position2)
1208 { 1208 {
1209 return inSameLineAlgorithm<EditingInComposedTreeStrategy>(position1, positio n2); 1209 return inSameLineAlgorithm<EditingInFlatTreeStrategy>(position1, position2);
1210 } 1210 }
1211 1211
1212 bool inSameLine(const VisiblePosition& position1, const VisiblePosition& positio n2) 1212 bool inSameLine(const VisiblePosition& position1, const VisiblePosition& positio n2)
1213 { 1213 {
1214 return inSameLine(position1.toPositionWithAffinity(), position2.toPositionWi thAffinity()); 1214 return inSameLine(position1.toPositionWithAffinity(), position2.toPositionWi thAffinity());
1215 } 1215 }
1216 1216
1217 bool inSameLine(const VisiblePositionInComposedTree& position1, const VisiblePos itionInComposedTree& position2) 1217 bool inSameLine(const VisiblePositionInFlatTree& position1, const VisiblePositio nInFlatTree& position2)
1218 { 1218 {
1219 return inSameLine(position1.toPositionWithAffinity(), position2.toPositionWi thAffinity()); 1219 return inSameLine(position1.toPositionWithAffinity(), position2.toPositionWi thAffinity());
1220 } 1220 }
1221 1221
1222 template <typename Strategy> 1222 template <typename Strategy>
1223 bool isStartOfLineAlgorithm(const VisiblePositionTemplate<Strategy>& p) 1223 bool isStartOfLineAlgorithm(const VisiblePositionTemplate<Strategy>& p)
1224 { 1224 {
1225 return p.isNotNull() && p.deepEquivalent() == startOfLine(p).deepEquivalent( ); 1225 return p.isNotNull() && p.deepEquivalent() == startOfLine(p).deepEquivalent( );
1226 } 1226 }
1227 1227
1228 bool isStartOfLine(const VisiblePosition& p) 1228 bool isStartOfLine(const VisiblePosition& p)
1229 { 1229 {
1230 return isStartOfLineAlgorithm<EditingStrategy>(p); 1230 return isStartOfLineAlgorithm<EditingStrategy>(p);
1231 } 1231 }
1232 1232
1233 bool isStartOfLine(const VisiblePositionInComposedTree& p) 1233 bool isStartOfLine(const VisiblePositionInFlatTree& p)
1234 { 1234 {
1235 return isStartOfLineAlgorithm<EditingInComposedTreeStrategy>(p); 1235 return isStartOfLineAlgorithm<EditingInFlatTreeStrategy>(p);
1236 } 1236 }
1237 1237
1238 template <typename Strategy> 1238 template <typename Strategy>
1239 bool isEndOfLineAlgorithm(const VisiblePositionTemplate<Strategy>& p) 1239 bool isEndOfLineAlgorithm(const VisiblePositionTemplate<Strategy>& p)
1240 { 1240 {
1241 return p.isNotNull() && p.deepEquivalent() == endOfLine(p).deepEquivalent(); 1241 return p.isNotNull() && p.deepEquivalent() == endOfLine(p).deepEquivalent();
1242 } 1242 }
1243 1243
1244 bool isEndOfLine(const VisiblePosition& p) 1244 bool isEndOfLine(const VisiblePosition& p)
1245 { 1245 {
1246 return isEndOfLineAlgorithm<EditingStrategy>(p); 1246 return isEndOfLineAlgorithm<EditingStrategy>(p);
1247 } 1247 }
1248 1248
1249 bool isEndOfLine(const VisiblePositionInComposedTree& p) 1249 bool isEndOfLine(const VisiblePositionInFlatTree& p)
1250 { 1250 {
1251 return isEndOfLineAlgorithm<EditingInComposedTreeStrategy>(p); 1251 return isEndOfLineAlgorithm<EditingInFlatTreeStrategy>(p);
1252 } 1252 }
1253 1253
1254 template <typename Strategy> 1254 template <typename Strategy>
1255 static bool isLogicalEndOfLineAlgorithm(const VisiblePositionTemplate<Strategy>& p) 1255 static bool isLogicalEndOfLineAlgorithm(const VisiblePositionTemplate<Strategy>& p)
1256 { 1256 {
1257 return p.isNotNull() && p.deepEquivalent() == logicalEndOfLine(p).deepEquiva lent(); 1257 return p.isNotNull() && p.deepEquivalent() == logicalEndOfLine(p).deepEquiva lent();
1258 } 1258 }
1259 1259
1260 bool isLogicalEndOfLine(const VisiblePosition& p) 1260 bool isLogicalEndOfLine(const VisiblePosition& p)
1261 { 1261 {
1262 return isLogicalEndOfLineAlgorithm<EditingStrategy>(p); 1262 return isLogicalEndOfLineAlgorithm<EditingStrategy>(p);
1263 } 1263 }
1264 1264
1265 bool isLogicalEndOfLine(const VisiblePositionInComposedTree& p) 1265 bool isLogicalEndOfLine(const VisiblePositionInFlatTree& p)
1266 { 1266 {
1267 return isLogicalEndOfLineAlgorithm<EditingInComposedTreeStrategy>(p); 1267 return isLogicalEndOfLineAlgorithm<EditingInFlatTreeStrategy>(p);
1268 } 1268 }
1269 1269
1270 static inline LayoutPoint absoluteLineDirectionPointToLocalPointInBlock(RootInli neBox* root, LayoutUnit lineDirectionPoint) 1270 static inline LayoutPoint absoluteLineDirectionPointToLocalPointInBlock(RootInli neBox* root, LayoutUnit lineDirectionPoint)
1271 { 1271 {
1272 ASSERT(root); 1272 ASSERT(root);
1273 LayoutBlockFlow& containingBlock = root->block(); 1273 LayoutBlockFlow& containingBlock = root->block();
1274 FloatPoint absoluteBlockPoint = containingBlock.localToAbsolute(FloatPoint() ); 1274 FloatPoint absoluteBlockPoint = containingBlock.localToAbsolute(FloatPoint() );
1275 if (containingBlock.hasOverflowClip()) 1275 if (containingBlock.hasOverflowClip())
1276 absoluteBlockPoint -= FloatSize(containingBlock.scrolledContentOffset()) ; 1276 absoluteBlockPoint -= FloatSize(containingBlock.scrolledContentOffset()) ;
1277 1277
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 static VisiblePositionTemplate<Strategy> startOfSentenceAlgorithm(const VisibleP ositionTemplate<Strategy>& c) 1403 static VisiblePositionTemplate<Strategy> startOfSentenceAlgorithm(const VisibleP ositionTemplate<Strategy>& c)
1404 { 1404 {
1405 return previousBoundary(c, startSentenceBoundary); 1405 return previousBoundary(c, startSentenceBoundary);
1406 } 1406 }
1407 1407
1408 VisiblePosition startOfSentence(const VisiblePosition& c) 1408 VisiblePosition startOfSentence(const VisiblePosition& c)
1409 { 1409 {
1410 return startOfSentenceAlgorithm<EditingStrategy>(c); 1410 return startOfSentenceAlgorithm<EditingStrategy>(c);
1411 } 1411 }
1412 1412
1413 VisiblePositionInComposedTree startOfSentence(const VisiblePositionInComposedTre e& c) 1413 VisiblePositionInFlatTree startOfSentence(const VisiblePositionInFlatTree& c)
1414 { 1414 {
1415 return startOfSentenceAlgorithm<EditingInComposedTreeStrategy>(c); 1415 return startOfSentenceAlgorithm<EditingInFlatTreeStrategy>(c);
1416 } 1416 }
1417 1417
1418 static unsigned endSentenceBoundary(const UChar* characters, unsigned length, un signed, BoundarySearchContextAvailability, bool&) 1418 static unsigned endSentenceBoundary(const UChar* characters, unsigned length, un signed, BoundarySearchContextAvailability, bool&)
1419 { 1419 {
1420 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); 1420 TextBreakIterator* iterator = sentenceBreakIterator(characters, length);
1421 return iterator->next(); 1421 return iterator->next();
1422 } 1422 }
1423 1423
1424 // TODO(yosin) This includes the space after the punctuation that marks the end 1424 // TODO(yosin) This includes the space after the punctuation that marks the end
1425 // of the sentence. 1425 // of the sentence.
1426 template <typename Strategy> 1426 template <typename Strategy>
1427 static VisiblePositionTemplate<Strategy> endOfSentenceAlgorithm(const VisiblePos itionTemplate<Strategy>& c) 1427 static VisiblePositionTemplate<Strategy> endOfSentenceAlgorithm(const VisiblePos itionTemplate<Strategy>& c)
1428 { 1428 {
1429 return nextBoundary(c, endSentenceBoundary); 1429 return nextBoundary(c, endSentenceBoundary);
1430 } 1430 }
1431 1431
1432 VisiblePosition endOfSentence(const VisiblePosition& c) 1432 VisiblePosition endOfSentence(const VisiblePosition& c)
1433 { 1433 {
1434 return endOfSentenceAlgorithm<EditingStrategy>(c); 1434 return endOfSentenceAlgorithm<EditingStrategy>(c);
1435 } 1435 }
1436 1436
1437 VisiblePositionInComposedTree endOfSentence(const VisiblePositionInComposedTree& c) 1437 VisiblePositionInFlatTree endOfSentence(const VisiblePositionInFlatTree& c)
1438 { 1438 {
1439 return endOfSentenceAlgorithm<EditingInComposedTreeStrategy>(c); 1439 return endOfSentenceAlgorithm<EditingInFlatTreeStrategy>(c);
1440 } 1440 }
1441 1441
1442 static unsigned previousSentencePositionBoundary(const UChar* characters, unsign ed length, unsigned, BoundarySearchContextAvailability, bool&) 1442 static unsigned previousSentencePositionBoundary(const UChar* characters, unsign ed length, unsigned, BoundarySearchContextAvailability, bool&)
1443 { 1443 {
1444 // FIXME: This is identical to startSentenceBoundary. I'm pretty sure that's not right. 1444 // FIXME: This is identical to startSentenceBoundary. I'm pretty sure that's not right.
1445 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); 1445 TextBreakIterator* iterator = sentenceBreakIterator(characters, length);
1446 // FIXME: The following function can return -1; we don't handle that. 1446 // FIXME: The following function can return -1; we don't handle that.
1447 return iterator->preceding(length); 1447 return iterator->preceding(length);
1448 } 1448 }
1449 1449
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 return createVisiblePosition(PositionTemplate<Strategy>(node, offset)); 1541 return createVisiblePosition(PositionTemplate<Strategy>(node, offset));
1542 1542
1543 return createVisiblePosition(PositionTemplate<Strategy>(node, type)); 1543 return createVisiblePosition(PositionTemplate<Strategy>(node, type));
1544 } 1544 }
1545 1545
1546 VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossi ngRule boundaryCrossingRule) 1546 VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossi ngRule boundaryCrossingRule)
1547 { 1547 {
1548 return startOfParagraphAlgorithm<EditingStrategy>(c, boundaryCrossingRule); 1548 return startOfParagraphAlgorithm<EditingStrategy>(c, boundaryCrossingRule);
1549 } 1549 }
1550 1550
1551 VisiblePositionInComposedTree startOfParagraph(const VisiblePositionInComposedTr ee& c, EditingBoundaryCrossingRule boundaryCrossingRule) 1551 VisiblePositionInFlatTree startOfParagraph(const VisiblePositionInFlatTree& c, E ditingBoundaryCrossingRule boundaryCrossingRule)
1552 { 1552 {
1553 return startOfParagraphAlgorithm<EditingInComposedTreeStrategy>(c, boundaryC rossingRule); 1553 return startOfParagraphAlgorithm<EditingInFlatTreeStrategy>(c, boundaryCross ingRule);
1554 } 1554 }
1555 1555
1556 template <typename Strategy> 1556 template <typename Strategy>
1557 static VisiblePositionTemplate<Strategy> endOfParagraphAlgorithm(const VisiblePo sitionTemplate<Strategy>& c, EditingBoundaryCrossingRule boundaryCrossingRule) 1557 static VisiblePositionTemplate<Strategy> endOfParagraphAlgorithm(const VisiblePo sitionTemplate<Strategy>& c, EditingBoundaryCrossingRule boundaryCrossingRule)
1558 { 1558 {
1559 if (c.isNull()) 1559 if (c.isNull())
1560 return VisiblePositionTemplate<Strategy>(); 1560 return VisiblePositionTemplate<Strategy>();
1561 1561
1562 const PositionTemplate<Strategy> p = c.deepEquivalent(); 1562 const PositionTemplate<Strategy> p = c.deepEquivalent();
1563 Node* startNode = p.anchorNode(); 1563 Node* startNode = p.anchorNode();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 return createVisiblePosition(PositionTemplate<Strategy>(node, offset)); 1628 return createVisiblePosition(PositionTemplate<Strategy>(node, offset));
1629 1629
1630 return createVisiblePosition(PositionTemplate<Strategy>(node, type)); 1630 return createVisiblePosition(PositionTemplate<Strategy>(node, type));
1631 } 1631 }
1632 1632
1633 VisiblePosition endOfParagraph(const VisiblePosition& c, EditingBoundaryCrossing Rule boundaryCrossingRule) 1633 VisiblePosition endOfParagraph(const VisiblePosition& c, EditingBoundaryCrossing Rule boundaryCrossingRule)
1634 { 1634 {
1635 return endOfParagraphAlgorithm<EditingStrategy>(c, boundaryCrossingRule); 1635 return endOfParagraphAlgorithm<EditingStrategy>(c, boundaryCrossingRule);
1636 } 1636 }
1637 1637
1638 VisiblePositionInComposedTree endOfParagraph(const VisiblePositionInComposedTree & c, EditingBoundaryCrossingRule boundaryCrossingRule) 1638 VisiblePositionInFlatTree endOfParagraph(const VisiblePositionInFlatTree& c, Edi tingBoundaryCrossingRule boundaryCrossingRule)
1639 { 1639 {
1640 return endOfParagraphAlgorithm<EditingInComposedTreeStrategy>(c, boundaryCro ssingRule); 1640 return endOfParagraphAlgorithm<EditingInFlatTreeStrategy>(c, boundaryCrossin gRule);
1641 } 1641 }
1642 1642
1643 // FIXME: isStartOfParagraph(startOfNextParagraph(pos)) is not always true 1643 // FIXME: isStartOfParagraph(startOfNextParagraph(pos)) is not always true
1644 VisiblePosition startOfNextParagraph(const VisiblePosition& visiblePosition) 1644 VisiblePosition startOfNextParagraph(const VisiblePosition& visiblePosition)
1645 { 1645 {
1646 VisiblePosition paragraphEnd(endOfParagraph(visiblePosition, CanSkipOverEdit ingBoundary)); 1646 VisiblePosition paragraphEnd(endOfParagraph(visiblePosition, CanSkipOverEdit ingBoundary));
1647 VisiblePosition afterParagraphEnd(nextPositionOf(paragraphEnd, CannotCrossEd itingBoundary)); 1647 VisiblePosition afterParagraphEnd(nextPositionOf(paragraphEnd, CannotCrossEd itingBoundary));
1648 // The position after the last position in the last cell of a table 1648 // The position after the last position in the last cell of a table
1649 // is not the start of the next paragraph. 1649 // is not the start of the next paragraph.
1650 if (isFirstPositionAfterTable(afterParagraphEnd)) 1650 if (isFirstPositionAfterTable(afterParagraphEnd))
(...skipping 10 matching lines...) Expand all
1661 static bool isStartOfParagraphAlgorithm(const VisiblePositionTemplate<Strategy>& pos, EditingBoundaryCrossingRule boundaryCrossingRule) 1661 static bool isStartOfParagraphAlgorithm(const VisiblePositionTemplate<Strategy>& pos, EditingBoundaryCrossingRule boundaryCrossingRule)
1662 { 1662 {
1663 return pos.isNotNull() && pos.deepEquivalent() == startOfParagraph(pos, boun daryCrossingRule).deepEquivalent(); 1663 return pos.isNotNull() && pos.deepEquivalent() == startOfParagraph(pos, boun daryCrossingRule).deepEquivalent();
1664 } 1664 }
1665 1665
1666 bool isStartOfParagraph(const VisiblePosition& pos, EditingBoundaryCrossingRule boundaryCrossingRule) 1666 bool isStartOfParagraph(const VisiblePosition& pos, EditingBoundaryCrossingRule boundaryCrossingRule)
1667 { 1667 {
1668 return isStartOfParagraphAlgorithm<EditingStrategy>(pos, boundaryCrossingRul e); 1668 return isStartOfParagraphAlgorithm<EditingStrategy>(pos, boundaryCrossingRul e);
1669 } 1669 }
1670 1670
1671 bool isStartOfParagraph(const VisiblePositionInComposedTree& pos, EditingBoundar yCrossingRule boundaryCrossingRule) 1671 bool isStartOfParagraph(const VisiblePositionInFlatTree& pos, EditingBoundaryCro ssingRule boundaryCrossingRule)
1672 { 1672 {
1673 return isStartOfParagraphAlgorithm<EditingInComposedTreeStrategy>(pos, bound aryCrossingRule); 1673 return isStartOfParagraphAlgorithm<EditingInFlatTreeStrategy>(pos, boundaryC rossingRule);
1674 } 1674 }
1675 1675
1676 template <typename Strategy> 1676 template <typename Strategy>
1677 static bool isEndOfParagraphAlgorithm(const VisiblePositionTemplate<Strategy>& p os, EditingBoundaryCrossingRule boundaryCrossingRule) 1677 static bool isEndOfParagraphAlgorithm(const VisiblePositionTemplate<Strategy>& p os, EditingBoundaryCrossingRule boundaryCrossingRule)
1678 { 1678 {
1679 return pos.isNotNull() && pos.deepEquivalent() == endOfParagraph(pos, bounda ryCrossingRule).deepEquivalent(); 1679 return pos.isNotNull() && pos.deepEquivalent() == endOfParagraph(pos, bounda ryCrossingRule).deepEquivalent();
1680 } 1680 }
1681 1681
1682 bool isEndOfParagraph(const VisiblePosition& pos, EditingBoundaryCrossingRule bo undaryCrossingRule) 1682 bool isEndOfParagraph(const VisiblePosition& pos, EditingBoundaryCrossingRule bo undaryCrossingRule)
1683 { 1683 {
1684 return isEndOfParagraphAlgorithm<EditingStrategy>(pos, boundaryCrossingRule) ; 1684 return isEndOfParagraphAlgorithm<EditingStrategy>(pos, boundaryCrossingRule) ;
1685 } 1685 }
1686 1686
1687 bool isEndOfParagraph(const VisiblePositionInComposedTree& pos, EditingBoundaryC rossingRule boundaryCrossingRule) 1687 bool isEndOfParagraph(const VisiblePositionInFlatTree& pos, EditingBoundaryCross ingRule boundaryCrossingRule)
1688 { 1688 {
1689 return isEndOfParagraphAlgorithm<EditingInComposedTreeStrategy>(pos, boundar yCrossingRule); 1689 return isEndOfParagraphAlgorithm<EditingInFlatTreeStrategy>(pos, boundaryCro ssingRule);
1690 } 1690 }
1691 1691
1692 VisiblePosition previousParagraphPosition(const VisiblePosition& p, LayoutUnit x ) 1692 VisiblePosition previousParagraphPosition(const VisiblePosition& p, LayoutUnit x )
1693 { 1693 {
1694 VisiblePosition pos = p; 1694 VisiblePosition pos = p;
1695 do { 1695 do {
1696 VisiblePosition n = previousLinePosition(pos, x); 1696 VisiblePosition n = previousLinePosition(pos, x);
1697 if (n.isNull() || n.deepEquivalent() == pos.deepEquivalent()) 1697 if (n.isNull() || n.deepEquivalent() == pos.deepEquivalent())
1698 break; 1698 break;
1699 pos = n; 1699 pos = n;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 return VisiblePositionTemplate<Strategy>(); 1754 return VisiblePositionTemplate<Strategy>();
1755 1755
1756 return createVisiblePosition(PositionTemplate<Strategy>::firstPositionInNode (node->document().documentElement())); 1756 return createVisiblePosition(PositionTemplate<Strategy>::firstPositionInNode (node->document().documentElement()));
1757 } 1757 }
1758 1758
1759 VisiblePosition startOfDocument(const VisiblePosition& c) 1759 VisiblePosition startOfDocument(const VisiblePosition& c)
1760 { 1760 {
1761 return startOfDocumentAlgorithm<EditingStrategy>(c); 1761 return startOfDocumentAlgorithm<EditingStrategy>(c);
1762 } 1762 }
1763 1763
1764 VisiblePositionInComposedTree startOfDocument(const VisiblePositionInComposedTre e& c) 1764 VisiblePositionInFlatTree startOfDocument(const VisiblePositionInFlatTree& c)
1765 { 1765 {
1766 return startOfDocumentAlgorithm<EditingInComposedTreeStrategy>(c); 1766 return startOfDocumentAlgorithm<EditingInFlatTreeStrategy>(c);
1767 } 1767 }
1768 1768
1769 template <typename Strategy> 1769 template <typename Strategy>
1770 static VisiblePositionTemplate<Strategy> endOfDocumentAlgorithm(const VisiblePos itionTemplate<Strategy>& visiblePosition) 1770 static VisiblePositionTemplate<Strategy> endOfDocumentAlgorithm(const VisiblePos itionTemplate<Strategy>& visiblePosition)
1771 { 1771 {
1772 Node* node = visiblePosition.deepEquivalent().anchorNode(); 1772 Node* node = visiblePosition.deepEquivalent().anchorNode();
1773 if (!node || !node->document().documentElement()) 1773 if (!node || !node->document().documentElement())
1774 return VisiblePositionTemplate<Strategy>(); 1774 return VisiblePositionTemplate<Strategy>();
1775 1775
1776 Element* doc = node->document().documentElement(); 1776 Element* doc = node->document().documentElement();
1777 return createVisiblePosition(PositionTemplate<Strategy>::lastPositionInNode( doc)); 1777 return createVisiblePosition(PositionTemplate<Strategy>::lastPositionInNode( doc));
1778 } 1778 }
1779 1779
1780 VisiblePosition endOfDocument(const VisiblePosition& c) 1780 VisiblePosition endOfDocument(const VisiblePosition& c)
1781 { 1781 {
1782 return endOfDocumentAlgorithm<EditingStrategy>(c); 1782 return endOfDocumentAlgorithm<EditingStrategy>(c);
1783 } 1783 }
1784 1784
1785 VisiblePositionInComposedTree endOfDocument(const VisiblePositionInComposedTree& c) 1785 VisiblePositionInFlatTree endOfDocument(const VisiblePositionInFlatTree& c)
1786 { 1786 {
1787 return endOfDocumentAlgorithm<EditingInComposedTreeStrategy>(c); 1787 return endOfDocumentAlgorithm<EditingInFlatTreeStrategy>(c);
1788 } 1788 }
1789 1789
1790 bool isStartOfDocument(const VisiblePosition& p) 1790 bool isStartOfDocument(const VisiblePosition& p)
1791 { 1791 {
1792 return p.isNotNull() && previousPositionOf(p, CanCrossEditingBoundary).isNul l(); 1792 return p.isNotNull() && previousPositionOf(p, CanCrossEditingBoundary).isNul l();
1793 } 1793 }
1794 1794
1795 bool isEndOfDocument(const VisiblePosition& p) 1795 bool isEndOfDocument(const VisiblePosition& p)
1796 { 1796 {
1797 return p.isNotNull() && nextPositionOf(p, CanCrossEditingBoundary).isNull(); 1797 return p.isNotNull() && nextPositionOf(p, CanCrossEditingBoundary).isNull();
(...skipping 19 matching lines...) Expand all
1817 return createVisiblePosition(lastPositionInNode(highestRoot)); 1817 return createVisiblePosition(lastPositionInNode(highestRoot));
1818 } 1818 }
1819 1819
1820 bool isEndOfEditableOrNonEditableContent(const VisiblePosition& position) 1820 bool isEndOfEditableOrNonEditableContent(const VisiblePosition& position)
1821 { 1821 {
1822 return position.isNotNull() && nextPositionOf(position).isNull(); 1822 return position.isNotNull() && nextPositionOf(position).isNull();
1823 } 1823 }
1824 1824
1825 // TODO(yosin) We should rename |isEndOfEditableOrNonEditableContent()| what 1825 // TODO(yosin) We should rename |isEndOfEditableOrNonEditableContent()| what
1826 // this function does, e.g. |isLastVisiblePositionOrEndOfInnerEditor()|. 1826 // this function does, e.g. |isLastVisiblePositionOrEndOfInnerEditor()|.
1827 bool isEndOfEditableOrNonEditableContent(const VisiblePositionInComposedTree& po sition) 1827 bool isEndOfEditableOrNonEditableContent(const VisiblePositionInFlatTree& positi on)
1828 { 1828 {
1829 if (position.isNull()) 1829 if (position.isNull())
1830 return false; 1830 return false;
1831 const VisiblePositionInComposedTree nextPosition = nextPositionOf(position); 1831 const VisiblePositionInFlatTree nextPosition = nextPositionOf(position);
1832 if (nextPosition.isNull()) 1832 if (nextPosition.isNull())
1833 return true; 1833 return true;
1834 // In DOM version, following condition, the last position of inner editor 1834 // In DOM version, following condition, the last position of inner editor
1835 // of INPUT/TEXTAREA element, by |nextPosition().isNull()|, because of 1835 // of INPUT/TEXTAREA element, by |nextPosition().isNull()|, because of
1836 // an inner editor is an only leaf node. 1836 // an inner editor is an only leaf node.
1837 if (!nextPosition.deepEquivalent().isAfterAnchor()) 1837 if (!nextPosition.deepEquivalent().isAfterAnchor())
1838 return false; 1838 return false;
1839 return isHTMLTextFormControlElement(nextPosition.deepEquivalent().anchorNode ()); 1839 return isHTMLTextFormControlElement(nextPosition.deepEquivalent().anchorNode ());
1840 } 1840 }
1841 1841
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
2078 static InlineBoxPosition computeInlineBoxPositionTemplate(const PositionTemplate <Strategy>& position, TextAffinity affinity) 2078 static InlineBoxPosition computeInlineBoxPositionTemplate(const PositionTemplate <Strategy>& position, TextAffinity affinity)
2079 { 2079 {
2080 return computeInlineBoxPositionTemplate<Strategy>(position, affinity, primar yDirectionOf(*position.anchorNode())); 2080 return computeInlineBoxPositionTemplate<Strategy>(position, affinity, primar yDirectionOf(*position.anchorNode()));
2081 } 2081 }
2082 2082
2083 InlineBoxPosition computeInlineBoxPosition(const Position& position, TextAffinit y affinity) 2083 InlineBoxPosition computeInlineBoxPosition(const Position& position, TextAffinit y affinity)
2084 { 2084 {
2085 return computeInlineBoxPositionTemplate<EditingStrategy>(position, affinity) ; 2085 return computeInlineBoxPositionTemplate<EditingStrategy>(position, affinity) ;
2086 } 2086 }
2087 2087
2088 InlineBoxPosition computeInlineBoxPosition(const PositionInComposedTree& positio n, TextAffinity affinity) 2088 InlineBoxPosition computeInlineBoxPosition(const PositionInFlatTree& position, T extAffinity affinity)
2089 { 2089 {
2090 return computeInlineBoxPositionTemplate<EditingInComposedTreeStrategy>(posit ion, affinity); 2090 return computeInlineBoxPositionTemplate<EditingInFlatTreeStrategy>(position, affinity);
2091 } 2091 }
2092 2092
2093 InlineBoxPosition computeInlineBoxPosition(const VisiblePosition& position) 2093 InlineBoxPosition computeInlineBoxPosition(const VisiblePosition& position)
2094 { 2094 {
2095 return computeInlineBoxPosition(position.deepEquivalent(), position.affinity ()); 2095 return computeInlineBoxPosition(position.deepEquivalent(), position.affinity ());
2096 } 2096 }
2097 2097
2098 InlineBoxPosition computeInlineBoxPosition(const VisiblePositionInComposedTree& position) 2098 InlineBoxPosition computeInlineBoxPosition(const VisiblePositionInFlatTree& posi tion)
2099 { 2099 {
2100 return computeInlineBoxPosition(position.deepEquivalent(), position.affinity ()); 2100 return computeInlineBoxPosition(position.deepEquivalent(), position.affinity ());
2101 } 2101 }
2102 2102
2103 InlineBoxPosition computeInlineBoxPosition(const Position& position, TextAffinit y affinity, TextDirection primaryDirection) 2103 InlineBoxPosition computeInlineBoxPosition(const Position& position, TextAffinit y affinity, TextDirection primaryDirection)
2104 { 2104 {
2105 return computeInlineBoxPositionTemplate<EditingStrategy>(position, affinity, primaryDirection); 2105 return computeInlineBoxPositionTemplate<EditingStrategy>(position, affinity, primaryDirection);
2106 } 2106 }
2107 2107
2108 InlineBoxPosition computeInlineBoxPosition(const PositionInComposedTree& positio n, TextAffinity affinity, TextDirection primaryDirection) 2108 InlineBoxPosition computeInlineBoxPosition(const PositionInFlatTree& position, T extAffinity affinity, TextDirection primaryDirection)
2109 { 2109 {
2110 return computeInlineBoxPositionTemplate<EditingInComposedTreeStrategy>(posit ion, affinity, primaryDirection); 2110 return computeInlineBoxPositionTemplate<EditingInFlatTreeStrategy>(position, affinity, primaryDirection);
2111 } 2111 }
2112 2112
2113 template <typename Strategy> 2113 template <typename Strategy>
2114 LayoutRect localCaretRectOfPositionTemplate(const PositionWithAffinityTemplate<S trategy>& position, LayoutObject*& layoutObject) 2114 LayoutRect localCaretRectOfPositionTemplate(const PositionWithAffinityTemplate<S trategy>& position, LayoutObject*& layoutObject)
2115 { 2115 {
2116 if (position.position().isNull()) { 2116 if (position.position().isNull()) {
2117 layoutObject = nullptr; 2117 layoutObject = nullptr;
2118 return LayoutRect(); 2118 return LayoutRect();
2119 } 2119 }
2120 Node* node = position.position().anchorNode(); 2120 Node* node = position.position().anchorNode();
2121 2121
2122 layoutObject = node->layoutObject(); 2122 layoutObject = node->layoutObject();
2123 if (!layoutObject) 2123 if (!layoutObject)
2124 return LayoutRect(); 2124 return LayoutRect();
2125 2125
2126 InlineBoxPosition boxPosition = computeInlineBoxPosition(position.position() , position.affinity()); 2126 InlineBoxPosition boxPosition = computeInlineBoxPosition(position.position() , position.affinity());
2127 2127
2128 if (boxPosition.inlineBox) 2128 if (boxPosition.inlineBox)
2129 layoutObject = LineLayoutAPIShim::layoutObjectFrom(boxPosition.inlineBox ->lineLayoutItem()); 2129 layoutObject = LineLayoutAPIShim::layoutObjectFrom(boxPosition.inlineBox ->lineLayoutItem());
2130 2130
2131 return layoutObject->localCaretRect(boxPosition.inlineBox, boxPosition.offse tInBox); 2131 return layoutObject->localCaretRect(boxPosition.inlineBox, boxPosition.offse tInBox);
2132 } 2132 }
2133 2133
2134 LayoutRect localCaretRectOfPosition(const PositionWithAffinity& position, Layout Object*& layoutObject) 2134 LayoutRect localCaretRectOfPosition(const PositionWithAffinity& position, Layout Object*& layoutObject)
2135 { 2135 {
2136 return localCaretRectOfPositionTemplate<EditingStrategy>(position, layoutObj ect); 2136 return localCaretRectOfPositionTemplate<EditingStrategy>(position, layoutObj ect);
2137 } 2137 }
2138 2138
2139 LayoutRect localCaretRectOfPosition(const PositionInComposedTreeWithAffinity& po sition, LayoutObject*& layoutObject) 2139 LayoutRect localCaretRectOfPosition(const PositionInFlatTreeWithAffinity& positi on, LayoutObject*& layoutObject)
2140 { 2140 {
2141 return localCaretRectOfPositionTemplate<EditingInComposedTreeStrategy>(posit ion, layoutObject); 2141 return localCaretRectOfPositionTemplate<EditingInFlatTreeStrategy>(position, layoutObject);
2142 } 2142 }
2143 2143
2144 static int boundingBoxLogicalHeight(LayoutObject *o, const IntRect &rect) 2144 static int boundingBoxLogicalHeight(LayoutObject *o, const IntRect &rect)
2145 { 2145 {
2146 return o->style()->isHorizontalWritingMode() ? rect.height() : rect.width(); 2146 return o->style()->isHorizontalWritingMode() ? rect.height() : rect.width();
2147 } 2147 }
2148 2148
2149 bool hasRenderedNonAnonymousDescendantsWithHeight(LayoutObject* layoutObject) 2149 bool hasRenderedNonAnonymousDescendantsWithHeight(LayoutObject* layoutObject)
2150 { 2150 {
2151 LayoutObject* stop = layoutObject->nextInPreOrderAfterChildren(); 2151 LayoutObject* stop = layoutObject->nextInPreOrderAfterChildren();
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
2580 } 2580 }
2581 } 2581 }
2582 return lastVisible.deprecatedComputePosition(); 2582 return lastVisible.deprecatedComputePosition();
2583 } 2583 }
2584 2584
2585 Position mostBackwardCaretPosition(const Position& position, EditingBoundaryCros singRule rule) 2585 Position mostBackwardCaretPosition(const Position& position, EditingBoundaryCros singRule rule)
2586 { 2586 {
2587 return mostBackwardCaretPosition<EditingStrategy>(position, rule); 2587 return mostBackwardCaretPosition<EditingStrategy>(position, rule);
2588 } 2588 }
2589 2589
2590 PositionInComposedTree mostBackwardCaretPosition(const PositionInComposedTree& p osition, EditingBoundaryCrossingRule rule) 2590 PositionInFlatTree mostBackwardCaretPosition(const PositionInFlatTree& position, EditingBoundaryCrossingRule rule)
2591 { 2591 {
2592 return mostBackwardCaretPosition<EditingInComposedTreeStrategy>(position, ru le); 2592 return mostBackwardCaretPosition<EditingInFlatTreeStrategy>(position, rule);
2593 } 2593 }
2594 2594
2595 template <typename Strategy> 2595 template <typename Strategy>
2596 PositionTemplate<Strategy> mostForwardCaretPosition(const PositionTemplate<Strat egy>& position, EditingBoundaryCrossingRule rule) 2596 PositionTemplate<Strategy> mostForwardCaretPosition(const PositionTemplate<Strat egy>& position, EditingBoundaryCrossingRule rule)
2597 { 2597 {
2598 TRACE_EVENT0("input", "VisibleUnits::mostForwardCaretPosition"); 2598 TRACE_EVENT0("input", "VisibleUnits::mostForwardCaretPosition");
2599 2599
2600 Node* startNode = position.anchorNode(); 2600 Node* startNode = position.anchorNode();
2601 if (!startNode) 2601 if (!startNode)
2602 return PositionTemplate<Strategy>(); 2602 return PositionTemplate<Strategy>();
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2712 } 2712 }
2713 2713
2714 return lastVisible.deprecatedComputePosition(); 2714 return lastVisible.deprecatedComputePosition();
2715 } 2715 }
2716 2716
2717 Position mostForwardCaretPosition(const Position& position, EditingBoundaryCross ingRule rule) 2717 Position mostForwardCaretPosition(const Position& position, EditingBoundaryCross ingRule rule)
2718 { 2718 {
2719 return mostForwardCaretPosition<EditingStrategy>(position, rule); 2719 return mostForwardCaretPosition<EditingStrategy>(position, rule);
2720 } 2720 }
2721 2721
2722 PositionInComposedTree mostForwardCaretPosition(const PositionInComposedTree& po sition, EditingBoundaryCrossingRule rule) 2722 PositionInFlatTree mostForwardCaretPosition(const PositionInFlatTree& position, EditingBoundaryCrossingRule rule)
2723 { 2723 {
2724 return mostForwardCaretPosition<EditingInComposedTreeStrategy>(position, rul e); 2724 return mostForwardCaretPosition<EditingInFlatTreeStrategy>(position, rule);
2725 } 2725 }
2726 2726
2727 // Returns true if the visually equivalent positions around have different 2727 // Returns true if the visually equivalent positions around have different
2728 // editability. A position is considered at editing boundary if one of the 2728 // editability. A position is considered at editing boundary if one of the
2729 // following is true: 2729 // following is true:
2730 // 1. It is the first position in the node and the next visually equivalent 2730 // 1. It is the first position in the node and the next visually equivalent
2731 // position is non editable. 2731 // position is non editable.
2732 // 2. It is the last position in the node and the previous visually equivalent 2732 // 2. It is the last position in the node and the previous visually equivalent
2733 // position is non editable. 2733 // position is non editable.
2734 // 3. It is an editable position and both the next and previous visually 2734 // 3. It is an editable position and both the next and previous visually
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2810 } 2810 }
2811 2811
2812 return false; 2812 return false;
2813 } 2813 }
2814 2814
2815 bool isVisuallyEquivalentCandidate(const Position& position) 2815 bool isVisuallyEquivalentCandidate(const Position& position)
2816 { 2816 {
2817 return isVisuallyEquivalentCandidateAlgorithm<EditingStrategy>(position); 2817 return isVisuallyEquivalentCandidateAlgorithm<EditingStrategy>(position);
2818 } 2818 }
2819 2819
2820 bool isVisuallyEquivalentCandidate(const PositionInComposedTree& position) 2820 bool isVisuallyEquivalentCandidate(const PositionInFlatTree& position)
2821 { 2821 {
2822 return isVisuallyEquivalentCandidateAlgorithm<EditingInComposedTreeStrategy> (position); 2822 return isVisuallyEquivalentCandidateAlgorithm<EditingInFlatTreeStrategy>(pos ition);
2823 } 2823 }
2824 2824
2825 template <typename Strategy> 2825 template <typename Strategy>
2826 static IntRect absoluteCaretBoundsOfAlgorithm(const VisiblePositionTemplate<Stra tegy>& visiblePosition) 2826 static IntRect absoluteCaretBoundsOfAlgorithm(const VisiblePositionTemplate<Stra tegy>& visiblePosition)
2827 { 2827 {
2828 LayoutObject* layoutObject; 2828 LayoutObject* layoutObject;
2829 LayoutRect localRect = localCaretRectOfPosition(visiblePosition.toPositionWi thAffinity(), layoutObject); 2829 LayoutRect localRect = localCaretRectOfPosition(visiblePosition.toPositionWi thAffinity(), layoutObject);
2830 if (localRect.isEmpty() || !layoutObject) 2830 if (localRect.isEmpty() || !layoutObject)
2831 return IntRect(); 2831 return IntRect();
2832 2832
2833 return layoutObject->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoun dingBox(); 2833 return layoutObject->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoun dingBox();
2834 } 2834 }
2835 2835
2836 IntRect absoluteCaretBoundsOf(const VisiblePosition& visiblePosition) 2836 IntRect absoluteCaretBoundsOf(const VisiblePosition& visiblePosition)
2837 { 2837 {
2838 return absoluteCaretBoundsOfAlgorithm<EditingStrategy>(visiblePosition); 2838 return absoluteCaretBoundsOfAlgorithm<EditingStrategy>(visiblePosition);
2839 } 2839 }
2840 2840
2841 IntRect absoluteCaretBoundsOf(const VisiblePositionInComposedTree& visiblePositi on) 2841 IntRect absoluteCaretBoundsOf(const VisiblePositionInFlatTree& visiblePosition)
2842 { 2842 {
2843 return absoluteCaretBoundsOfAlgorithm<EditingInComposedTreeStrategy>(visible Position); 2843 return absoluteCaretBoundsOfAlgorithm<EditingInFlatTreeStrategy>(visiblePosi tion);
2844 } 2844 }
2845 2845
2846 template <typename Strategy> 2846 template <typename Strategy>
2847 static VisiblePositionTemplate<Strategy> skipToEndOfEditingBoundary(const Visibl ePositionTemplate<Strategy>& pos, const PositionTemplate<Strategy>& anchor) 2847 static VisiblePositionTemplate<Strategy> skipToEndOfEditingBoundary(const Visibl ePositionTemplate<Strategy>& pos, const PositionTemplate<Strategy>& anchor)
2848 { 2848 {
2849 if (pos.isNull()) 2849 if (pos.isNull())
2850 return pos; 2850 return pos;
2851 2851
2852 ContainerNode* highestRoot = highestEditableRoot(anchor); 2852 ContainerNode* highestRoot = highestEditableRoot(anchor);
2853 ContainerNode* highestRootOfPos = highestEditableRoot(pos.deepEquivalent()); 2853 ContainerNode* highestRootOfPos = highestEditableRoot(pos.deepEquivalent());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2886 return 0; 2886 return 0;
2887 2887
2888 return textNode->data().characterStartingAt(offset); 2888 return textNode->data().characterStartingAt(offset);
2889 } 2889 }
2890 2890
2891 UChar32 characterAfter(const VisiblePosition& visiblePosition) 2891 UChar32 characterAfter(const VisiblePosition& visiblePosition)
2892 { 2892 {
2893 return characterAfterAlgorithm<EditingStrategy>(visiblePosition); 2893 return characterAfterAlgorithm<EditingStrategy>(visiblePosition);
2894 } 2894 }
2895 2895
2896 UChar32 characterAfter(const VisiblePositionInComposedTree& visiblePosition) 2896 UChar32 characterAfter(const VisiblePositionInFlatTree& visiblePosition)
2897 { 2897 {
2898 return characterAfterAlgorithm<EditingInComposedTreeStrategy>(visiblePositio n); 2898 return characterAfterAlgorithm<EditingInFlatTreeStrategy>(visiblePosition);
2899 } 2899 }
2900 2900
2901 template <typename Strategy> 2901 template <typename Strategy>
2902 static UChar32 characterBeforeAlgorithm(const VisiblePositionTemplate<Strategy>& visiblePosition) 2902 static UChar32 characterBeforeAlgorithm(const VisiblePositionTemplate<Strategy>& visiblePosition)
2903 { 2903 {
2904 return characterAfter(previousPositionOf(visiblePosition)); 2904 return characterAfter(previousPositionOf(visiblePosition));
2905 } 2905 }
2906 2906
2907 UChar32 characterBefore(const VisiblePosition& visiblePosition) 2907 UChar32 characterBefore(const VisiblePosition& visiblePosition)
2908 { 2908 {
2909 return characterBeforeAlgorithm<EditingStrategy>(visiblePosition); 2909 return characterBeforeAlgorithm<EditingStrategy>(visiblePosition);
2910 } 2910 }
2911 2911
2912 UChar32 characterBefore(const VisiblePositionInComposedTree& visiblePosition) 2912 UChar32 characterBefore(const VisiblePositionInFlatTree& visiblePosition)
2913 { 2913 {
2914 return characterBeforeAlgorithm<EditingInComposedTreeStrategy>(visiblePositi on); 2914 return characterBeforeAlgorithm<EditingInFlatTreeStrategy>(visiblePosition);
2915 } 2915 }
2916 2916
2917 template <typename Strategy> 2917 template <typename Strategy>
2918 static PositionTemplate<Strategy> leftVisuallyDistinctCandidate(const VisiblePos itionTemplate<Strategy>& visiblePosition) 2918 static PositionTemplate<Strategy> leftVisuallyDistinctCandidate(const VisiblePos itionTemplate<Strategy>& visiblePosition)
2919 { 2919 {
2920 const PositionTemplate<Strategy> deepPosition = visiblePosition.deepEquivale nt(); 2920 const PositionTemplate<Strategy> deepPosition = visiblePosition.deepEquivale nt();
2921 PositionTemplate<Strategy> p = deepPosition; 2921 PositionTemplate<Strategy> p = deepPosition;
2922 2922
2923 if (p.isNull()) 2923 if (p.isNull())
2924 return PositionTemplate<Strategy>(); 2924 return PositionTemplate<Strategy>();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
3078 ASSERT(left.deepEquivalent() != visiblePosition.deepEquivalent()); 3078 ASSERT(left.deepEquivalent() != visiblePosition.deepEquivalent());
3079 3079
3080 return directionOfEnclosingBlock(left.deepEquivalent()) == LTR ? honorEditin gBoundaryAtOrBefore(left, visiblePosition.deepEquivalent()) : honorEditingBounda ryAtOrAfter(left, visiblePosition.deepEquivalent()); 3080 return directionOfEnclosingBlock(left.deepEquivalent()) == LTR ? honorEditin gBoundaryAtOrBefore(left, visiblePosition.deepEquivalent()) : honorEditingBounda ryAtOrAfter(left, visiblePosition.deepEquivalent());
3081 } 3081 }
3082 3082
3083 VisiblePosition leftPositionOf(const VisiblePosition& visiblePosition) 3083 VisiblePosition leftPositionOf(const VisiblePosition& visiblePosition)
3084 { 3084 {
3085 return leftPositionOfAlgorithm<EditingStrategy>(visiblePosition); 3085 return leftPositionOfAlgorithm<EditingStrategy>(visiblePosition);
3086 } 3086 }
3087 3087
3088 VisiblePositionInComposedTree leftPositionOf(const VisiblePositionInComposedTree & visiblePosition) 3088 VisiblePositionInFlatTree leftPositionOf(const VisiblePositionInFlatTree& visibl ePosition)
3089 { 3089 {
3090 return leftPositionOfAlgorithm<EditingInComposedTreeStrategy>(visiblePositio n); 3090 return leftPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePosition);
3091 } 3091 }
3092 3092
3093 template <typename Strategy> 3093 template <typename Strategy>
3094 static PositionTemplate<Strategy> rightVisuallyDistinctCandidate(const VisiblePo sitionTemplate<Strategy>& visiblePosition) 3094 static PositionTemplate<Strategy> rightVisuallyDistinctCandidate(const VisiblePo sitionTemplate<Strategy>& visiblePosition)
3095 { 3095 {
3096 const PositionTemplate<Strategy> deepPosition = visiblePosition.deepEquivale nt(); 3096 const PositionTemplate<Strategy> deepPosition = visiblePosition.deepEquivale nt();
3097 PositionTemplate<Strategy> p = deepPosition; 3097 PositionTemplate<Strategy> p = deepPosition;
3098 if (p.isNull()) 3098 if (p.isNull())
3099 return PositionTemplate<Strategy>(); 3099 return PositionTemplate<Strategy>();
3100 3100
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
3256 ASSERT(right.deepEquivalent() != visiblePosition.deepEquivalent()); 3256 ASSERT(right.deepEquivalent() != visiblePosition.deepEquivalent());
3257 3257
3258 return directionOfEnclosingBlock(right.deepEquivalent()) == LTR ? honorEditi ngBoundaryAtOrAfter(right, visiblePosition.deepEquivalent()) : honorEditingBound aryAtOrBefore(right, visiblePosition.deepEquivalent()); 3258 return directionOfEnclosingBlock(right.deepEquivalent()) == LTR ? honorEditi ngBoundaryAtOrAfter(right, visiblePosition.deepEquivalent()) : honorEditingBound aryAtOrBefore(right, visiblePosition.deepEquivalent());
3259 } 3259 }
3260 3260
3261 VisiblePosition rightPositionOf(const VisiblePosition& visiblePosition) 3261 VisiblePosition rightPositionOf(const VisiblePosition& visiblePosition)
3262 { 3262 {
3263 return rightPositionOfAlgorithm<EditingStrategy>(visiblePosition); 3263 return rightPositionOfAlgorithm<EditingStrategy>(visiblePosition);
3264 } 3264 }
3265 3265
3266 VisiblePositionInComposedTree rightPositionOf(const VisiblePositionInComposedTre e& visiblePosition) 3266 VisiblePositionInFlatTree rightPositionOf(const VisiblePositionInFlatTree& visib lePosition)
3267 { 3267 {
3268 return rightPositionOfAlgorithm<EditingInComposedTreeStrategy>(visiblePositi on); 3268 return rightPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePosition);
3269 } 3269 }
3270 3270
3271 template <typename Strategy> 3271 template <typename Strategy>
3272 static VisiblePositionTemplate<Strategy> nextPositionOfAlgorithm(const VisiblePo sitionTemplate<Strategy>& visiblePosition, EditingBoundaryCrossingRule rule) 3272 static VisiblePositionTemplate<Strategy> nextPositionOfAlgorithm(const VisiblePo sitionTemplate<Strategy>& visiblePosition, EditingBoundaryCrossingRule rule)
3273 { 3273 {
3274 const VisiblePositionTemplate<Strategy> next = createVisiblePosition(nextVis uallyDistinctCandidate(visiblePosition.deepEquivalent()), visiblePosition.affini ty()); 3274 const VisiblePositionTemplate<Strategy> next = createVisiblePosition(nextVis uallyDistinctCandidate(visiblePosition.deepEquivalent()), visiblePosition.affini ty());
3275 3275
3276 switch (rule) { 3276 switch (rule) {
3277 case CanCrossEditingBoundary: 3277 case CanCrossEditingBoundary:
3278 return next; 3278 return next;
3279 case CannotCrossEditingBoundary: 3279 case CannotCrossEditingBoundary:
3280 return honorEditingBoundaryAtOrAfter(next, visiblePosition.deepEquivalen t()); 3280 return honorEditingBoundaryAtOrAfter(next, visiblePosition.deepEquivalen t());
3281 case CanSkipOverEditingBoundary: 3281 case CanSkipOverEditingBoundary:
3282 return skipToEndOfEditingBoundary(next, visiblePosition.deepEquivalent() ); 3282 return skipToEndOfEditingBoundary(next, visiblePosition.deepEquivalent() );
3283 } 3283 }
3284 ASSERT_NOT_REACHED(); 3284 ASSERT_NOT_REACHED();
3285 return honorEditingBoundaryAtOrAfter(next, visiblePosition.deepEquivalent()) ; 3285 return honorEditingBoundaryAtOrAfter(next, visiblePosition.deepEquivalent()) ;
3286 } 3286 }
3287 3287
3288 VisiblePosition nextPositionOf(const VisiblePosition& visiblePosition, EditingBo undaryCrossingRule rule) 3288 VisiblePosition nextPositionOf(const VisiblePosition& visiblePosition, EditingBo undaryCrossingRule rule)
3289 { 3289 {
3290 return nextPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); 3290 return nextPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule);
3291 } 3291 }
3292 3292
3293 VisiblePositionInComposedTree nextPositionOf(const VisiblePositionInComposedTree & visiblePosition, EditingBoundaryCrossingRule rule) 3293 VisiblePositionInFlatTree nextPositionOf(const VisiblePositionInFlatTree& visibl ePosition, EditingBoundaryCrossingRule rule)
3294 { 3294 {
3295 return nextPositionOfAlgorithm<EditingInComposedTreeStrategy>(visiblePositio n, rule); 3295 return nextPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePosition, r ule);
3296 } 3296 }
3297 3297
3298 template <typename Strategy> 3298 template <typename Strategy>
3299 static VisiblePositionTemplate<Strategy> skipToStartOfEditingBoundary(const Visi blePositionTemplate<Strategy>& pos, const PositionTemplate<Strategy>& anchor) 3299 static VisiblePositionTemplate<Strategy> skipToStartOfEditingBoundary(const Visi blePositionTemplate<Strategy>& pos, const PositionTemplate<Strategy>& anchor)
3300 { 3300 {
3301 if (pos.isNull()) 3301 if (pos.isNull())
3302 return pos; 3302 return pos;
3303 3303
3304 ContainerNode* highestRoot = highestEditableRoot(anchor); 3304 ContainerNode* highestRoot = highestEditableRoot(anchor);
3305 ContainerNode* highestRootOfPos = highestEditableRoot(pos.deepEquivalent()); 3305 ContainerNode* highestRootOfPos = highestEditableRoot(pos.deepEquivalent());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3346 3346
3347 ASSERT_NOT_REACHED(); 3347 ASSERT_NOT_REACHED();
3348 return honorEditingBoundaryAtOrBefore(prev, visiblePosition.deepEquivalent() ); 3348 return honorEditingBoundaryAtOrBefore(prev, visiblePosition.deepEquivalent() );
3349 } 3349 }
3350 3350
3351 VisiblePosition previousPositionOf(const VisiblePosition& visiblePosition, Editi ngBoundaryCrossingRule rule) 3351 VisiblePosition previousPositionOf(const VisiblePosition& visiblePosition, Editi ngBoundaryCrossingRule rule)
3352 { 3352 {
3353 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); 3353 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule);
3354 } 3354 }
3355 3355
3356 VisiblePositionInComposedTree previousPositionOf(const VisiblePositionInComposed Tree& visiblePosition, EditingBoundaryCrossingRule rule) 3356 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi siblePosition, EditingBoundaryCrossingRule rule)
3357 { 3357 {
3358 return previousPositionOfAlgorithm<EditingInComposedTreeStrategy>(visiblePos ition, rule); 3358 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio n, rule);
3359 } 3359 }
3360 3360
3361 } // namespace blink 3361 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698