Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 return PositionType(); | 223 return PositionType(); |
| 224 } | 224 } |
| 225 | 225 |
| 226 Position nextCandidate(const Position& position) | 226 Position nextCandidate(const Position& position) |
| 227 { | 227 { |
| 228 return nextCandidateAlgorithm<EditingStrategy>(position); | 228 return nextCandidateAlgorithm<EditingStrategy>(position); |
| 229 } | 229 } |
| 230 | 230 |
| 231 Position nextVisuallyDistinctCandidate(const Position& position) | 231 Position nextVisuallyDistinctCandidate(const Position& position) |
| 232 { | 232 { |
| 233 // FIXME: Use PositionIterator instead. | |
|
leviw_travelin_and_unemployed
2015/06/25 00:15:20
We use TODO(name) syntax in Blink now.
changseok
2015/06/25 03:49:39
Done.
| |
| 233 Position p = position; | 234 Position p = position; |
| 234 Position downstreamStart = p.downstream(); | 235 Position downstreamStart = p.downstream(); |
| 235 while (!p.atEndOfTree()) { | 236 while (!p.atEndOfTree()) { |
| 236 p = p.next(Character); | 237 p = p.next(Character); |
| 237 if (p.isCandidate() && p.downstream() != downstreamStart) | 238 if (p.isCandidate() && p.downstream() != downstreamStart) |
| 238 return p; | 239 return p; |
| 240 if (auto* node = p.containerNode()) { | |
| 241 if (!node->layoutObject()) | |
| 242 p = lastPositionInOrAfterNode(node); | |
| 243 } | |
| 239 } | 244 } |
| 240 return Position(); | 245 return Position(); |
| 241 } | 246 } |
| 242 | 247 |
| 243 template <typename Strategy> | 248 template <typename Strategy> |
| 244 typename Strategy::PositionType previousCandidateAlgorithm(const typename Strate gy::PositionType& position) | 249 typename Strategy::PositionType previousCandidateAlgorithm(const typename Strate gy::PositionType& position) |
| 245 { | 250 { |
| 246 using PositionType = typename Strategy::PositionType; | 251 using PositionType = typename Strategy::PositionType; |
| 247 typename Strategy::PositionIteratorType p(position); | 252 typename Strategy::PositionIteratorType p(position); |
| 248 while (!p.atStart()) { | 253 while (!p.atStart()) { |
| 249 p.decrement(); | 254 p.decrement(); |
| 250 if (p.isCandidate()) | 255 if (p.isCandidate()) |
| 251 return p; | 256 return p; |
| 252 } | 257 } |
| 253 return PositionType(); | 258 return PositionType(); |
| 254 } | 259 } |
| 255 | 260 |
| 256 Position previousCandidate(const Position& position) | 261 Position previousCandidate(const Position& position) |
| 257 { | 262 { |
| 258 return previousCandidateAlgorithm<EditingStrategy>(position); | 263 return previousCandidateAlgorithm<EditingStrategy>(position); |
| 259 } | 264 } |
| 260 | 265 |
| 261 template <typename PositionType> | 266 template <typename PositionType> |
| 262 PositionType previousVisuallyDistinctCandidateAlgorithm(const PositionType& posi tion) | 267 PositionType previousVisuallyDistinctCandidateAlgorithm(const PositionType& posi tion) |
| 263 { | 268 { |
| 269 // FIXME: Use PositionIterator instead. | |
| 264 PositionType p = position; | 270 PositionType p = position; |
| 265 PositionType downstreamStart = p.downstream(); | 271 PositionType downstreamStart = p.downstream(); |
| 266 while (!p.atStartOfTree()) { | 272 while (!p.atStartOfTree()) { |
| 267 p = p.previous(Character); | 273 p = p.previous(Character); |
| 268 if (p.isCandidate() && p.downstream() != downstreamStart) | 274 if (p.isCandidate() && p.downstream() != downstreamStart) |
| 269 return p; | 275 return p; |
| 276 if (auto* node = p.containerNode()) { | |
| 277 if (!node->layoutObject()) | |
| 278 p = firstPositionInOrBeforeNode(node); | |
| 279 } | |
| 270 } | 280 } |
| 271 return PositionType(); | 281 return PositionType(); |
| 272 } | 282 } |
| 273 | 283 |
| 274 Position previousVisuallyDistinctCandidate(const Position& position) | 284 Position previousVisuallyDistinctCandidate(const Position& position) |
| 275 { | 285 { |
| 276 return previousVisuallyDistinctCandidateAlgorithm<Position>(position); | 286 return previousVisuallyDistinctCandidateAlgorithm<Position>(position); |
| 277 } | 287 } |
| 278 | 288 |
| 279 VisiblePosition firstEditableVisiblePositionAfterPositionInRoot(const Position& position, ContainerNode* highestRoot) | 289 VisiblePosition firstEditableVisiblePositionAfterPositionInRoot(const Position& position, ContainerNode* highestRoot) |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1208 // if the selection starts just before a paragraph break, skip over it | 1218 // if the selection starts just before a paragraph break, skip over it |
| 1209 if (isEndOfParagraph(visiblePosition)) | 1219 if (isEndOfParagraph(visiblePosition)) |
| 1210 return visiblePosition.next().deepEquivalent().downstream(); | 1220 return visiblePosition.next().deepEquivalent().downstream(); |
| 1211 | 1221 |
| 1212 // otherwise, make sure to be at the start of the first selected node, | 1222 // otherwise, make sure to be at the start of the first selected node, |
| 1213 // instead of possibly at the end of the last node before the selection | 1223 // instead of possibly at the end of the last node before the selection |
| 1214 return visiblePosition.deepEquivalent().downstream(); | 1224 return visiblePosition.deepEquivalent().downstream(); |
| 1215 } | 1225 } |
| 1216 | 1226 |
| 1217 } // namespace blink | 1227 } // namespace blink |
| OLD | NEW |