| OLD | NEW |
| 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 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1493 } | 1493 } |
| 1494 return 0; | 1494 return 0; |
| 1495 } | 1495 } |
| 1496 | 1496 |
| 1497 template <typename Strategy> | 1497 template <typename Strategy> |
| 1498 PositionAlgorithm<Strategy> downstreamIgnoringEditingBoundaries(PositionAlgorith
m<Strategy> position) | 1498 PositionAlgorithm<Strategy> downstreamIgnoringEditingBoundaries(PositionAlgorith
m<Strategy> position) |
| 1499 { | 1499 { |
| 1500 PositionAlgorithm<Strategy> lastPosition; | 1500 PositionAlgorithm<Strategy> lastPosition; |
| 1501 while (position != lastPosition) { | 1501 while (position != lastPosition) { |
| 1502 lastPosition = position; | 1502 lastPosition = position; |
| 1503 position = position.downstream(CanCrossEditingBoundary); | 1503 position = mostForwardCaretPosition(position, CanCrossEditingBoundary); |
| 1504 } | 1504 } |
| 1505 return position; | 1505 return position; |
| 1506 } | 1506 } |
| 1507 | 1507 |
| 1508 template <typename Strategy> | 1508 template <typename Strategy> |
| 1509 PositionAlgorithm<Strategy> upstreamIgnoringEditingBoundaries(PositionAlgorithm<
Strategy> position) | 1509 PositionAlgorithm<Strategy> upstreamIgnoringEditingBoundaries(PositionAlgorithm<
Strategy> position) |
| 1510 { | 1510 { |
| 1511 PositionAlgorithm<Strategy> lastPosition; | 1511 PositionAlgorithm<Strategy> lastPosition; |
| 1512 while (position != lastPosition) { | 1512 while (position != lastPosition) { |
| 1513 lastPosition = position; | 1513 lastPosition = position; |
| 1514 position = position.upstream(CanCrossEditingBoundary); | 1514 position = mostBackwardCaretPosition(position, CanCrossEditingBoundary); |
| 1515 } | 1515 } |
| 1516 return position; | 1516 return position; |
| 1517 } | 1517 } |
| 1518 | 1518 |
| 1519 template <typename Strategy> | 1519 template <typename Strategy> |
| 1520 static InlineBoxPosition computeInlineBoxPositionAlgorithm(const PositionAlgorit
hm<Strategy>& position, TextAffinity affinity, TextDirection primaryDirection) | 1520 static InlineBoxPosition computeInlineBoxPositionAlgorithm(const PositionAlgorit
hm<Strategy>& position, TextAffinity affinity, TextDirection primaryDirection) |
| 1521 { | 1521 { |
| 1522 InlineBox* inlineBox = nullptr; | 1522 InlineBox* inlineBox = nullptr; |
| 1523 int caretOffset = position.computeEditingOffset(); | 1523 int caretOffset = position.computeEditingOffset(); |
| 1524 Node* const anchorNode = position.anchorNode(); | 1524 Node* const anchorNode = position.anchorNode(); |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2243 // following is true: | 2243 // following is true: |
| 2244 // 1. It is the first position in the node and the next visually equivalent | 2244 // 1. It is the first position in the node and the next visually equivalent |
| 2245 // position is non editable. | 2245 // position is non editable. |
| 2246 // 2. It is the last position in the node and the previous visually equivalent | 2246 // 2. It is the last position in the node and the previous visually equivalent |
| 2247 // position is non editable. | 2247 // position is non editable. |
| 2248 // 3. It is an editable position and both the next and previous visually | 2248 // 3. It is an editable position and both the next and previous visually |
| 2249 // equivalent positions are both non editable. | 2249 // equivalent positions are both non editable. |
| 2250 template <typename Strategy> | 2250 template <typename Strategy> |
| 2251 static bool atEditingBoundary(const PositionAlgorithm<Strategy> positions) | 2251 static bool atEditingBoundary(const PositionAlgorithm<Strategy> positions) |
| 2252 { | 2252 { |
| 2253 PositionAlgorithm<Strategy> nextPosition = positions.downstream(CanCrossEdit
ingBoundary); | 2253 PositionAlgorithm<Strategy> nextPosition = mostForwardCaretPosition(position
s, CanCrossEditingBoundary); |
| 2254 if (positions.atFirstEditingPositionForNode() && nextPosition.isNotNull() &&
!nextPosition.anchorNode()->hasEditableStyle()) | 2254 if (positions.atFirstEditingPositionForNode() && nextPosition.isNotNull() &&
!nextPosition.anchorNode()->hasEditableStyle()) |
| 2255 return true; | 2255 return true; |
| 2256 | 2256 |
| 2257 PositionAlgorithm<Strategy> prevPosition = positions.upstream(CanCrossEditin
gBoundary); | 2257 PositionAlgorithm<Strategy> prevPosition = mostBackwardCaretPosition(positio
ns, CanCrossEditingBoundary); |
| 2258 if (positions.atLastEditingPositionForNode() && prevPosition.isNotNull() &&
!prevPosition.anchorNode()->hasEditableStyle()) | 2258 if (positions.atLastEditingPositionForNode() && prevPosition.isNotNull() &&
!prevPosition.anchorNode()->hasEditableStyle()) |
| 2259 return true; | 2259 return true; |
| 2260 | 2260 |
| 2261 return nextPosition.isNotNull() && !nextPosition.anchorNode()->hasEditableSt
yle() | 2261 return nextPosition.isNotNull() && !nextPosition.anchorNode()->hasEditableSt
yle() |
| 2262 && prevPosition.isNotNull() && !prevPosition.anchorNode()->hasEditableSt
yle(); | 2262 && prevPosition.isNotNull() && !prevPosition.anchorNode()->hasEditableSt
yle(); |
| 2263 } | 2263 } |
| 2264 | 2264 |
| 2265 template <typename Strategy> | 2265 template <typename Strategy> |
| 2266 static bool isVisuallyEquivalentCandidateAlgorithm(const PositionAlgorithm<Strat
egy>& position) | 2266 static bool isVisuallyEquivalentCandidateAlgorithm(const PositionAlgorithm<Strat
egy>& position) |
| 2267 { | 2267 { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2320 { | 2320 { |
| 2321 return isVisuallyEquivalentCandidateAlgorithm<EditingStrategy>(position); | 2321 return isVisuallyEquivalentCandidateAlgorithm<EditingStrategy>(position); |
| 2322 } | 2322 } |
| 2323 | 2323 |
| 2324 bool isVisuallyEquivalentCandidate(const PositionInComposedTree& position) | 2324 bool isVisuallyEquivalentCandidate(const PositionInComposedTree& position) |
| 2325 { | 2325 { |
| 2326 return isVisuallyEquivalentCandidateAlgorithm<EditingInComposedTreeStrategy>
(position); | 2326 return isVisuallyEquivalentCandidateAlgorithm<EditingInComposedTreeStrategy>
(position); |
| 2327 } | 2327 } |
| 2328 | 2328 |
| 2329 } // namespace blink | 2329 } // namespace blink |
| OLD | NEW |