Chromium Code Reviews| 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 2966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2977 | 2977 |
| 2978 // That must mean that |pos| is not editable. Return the next position after | 2978 // That must mean that |pos| is not editable. Return the next position after |
| 2979 // |pos| that is in the same editable region as this position | 2979 // |pos| that is in the same editable region as this position |
| 2980 DCHECK(highestRoot); | 2980 DCHECK(highestRoot); |
| 2981 return firstEditableVisiblePositionAfterPositionInRoot(pos.deepEquivalent(), *highestRoot); | 2981 return firstEditableVisiblePositionAfterPositionInRoot(pos.deepEquivalent(), *highestRoot); |
| 2982 } | 2982 } |
| 2983 | 2983 |
| 2984 template <typename Strategy> | 2984 template <typename Strategy> |
| 2985 static UChar32 characterAfterAlgorithm(const VisiblePositionTemplate<Strategy>& visiblePosition) | 2985 static UChar32 characterAfterAlgorithm(const VisiblePositionTemplate<Strategy>& visiblePosition) |
| 2986 { | 2986 { |
| 2987 // TODO(xiaochengh): Ensure that this function is called with a valid | 2987 DCHECK(visiblePosition.isValid()) << visiblePosition; |
| 2988 // |visiblePosition|, and add |DCHECK(visiblePosition.isValid())| | |
| 2989 // We canonicalize to the first of two equivalent candidates, but the second | 2988 // We canonicalize to the first of two equivalent candidates, but the second |
| 2990 // of the two candidates is the one that will be inside the text node | 2989 // of the two candidates is the one that will be inside the text node |
| 2991 // containing the character after this visible position. | 2990 // containing the character after this visible position. |
| 2992 const PositionTemplate<Strategy> pos = mostForwardCaretPosition(visiblePosit ion.deepEquivalent()); | 2991 const PositionTemplate<Strategy> pos = mostForwardCaretPosition(visiblePosit ion.deepEquivalent()); |
| 2993 if (!pos.isOffsetInAnchor()) | 2992 if (!pos.isOffsetInAnchor()) |
| 2994 return 0; | 2993 return 0; |
| 2995 Node* containerNode = pos.computeContainerNode(); | 2994 Node* containerNode = pos.computeContainerNode(); |
| 2996 if (!containerNode || !containerNode->isTextNode()) | 2995 if (!containerNode || !containerNode->isTextNode()) |
| 2997 return 0; | 2996 return 0; |
| 2998 unsigned offset = static_cast<unsigned>(pos.offsetInContainerNode()); | 2997 unsigned offset = static_cast<unsigned>(pos.offsetInContainerNode()); |
| 2999 Text* textNode = toText(containerNode); | 2998 Text* textNode = toText(containerNode); |
| 3000 unsigned length = textNode->length(); | 2999 unsigned length = textNode->length(); |
| 3001 if (offset >= length) | 3000 if (offset >= length) |
| 3002 return 0; | 3001 return 0; |
| 3003 | 3002 |
| 3004 return textNode->data().characterStartingAt(offset); | 3003 return textNode->data().characterStartingAt(offset); |
| 3005 } | 3004 } |
| 3006 | 3005 |
| 3007 UChar32 characterAfter(const VisiblePosition& visiblePosition) | 3006 UChar32 characterAfter(const VisiblePosition& visiblePosition) |
| 3008 { | 3007 { |
| 3009 return characterAfterAlgorithm<EditingStrategy>(visiblePosition); | 3008 return characterAfterAlgorithm<EditingStrategy>(visiblePosition); |
| 3010 } | 3009 } |
| 3011 | 3010 |
| 3012 UChar32 characterAfter(const VisiblePositionInFlatTree& visiblePosition) | 3011 UChar32 characterAfter(const VisiblePositionInFlatTree& visiblePosition) |
| 3013 { | 3012 { |
| 3014 return characterAfterAlgorithm<EditingInFlatTreeStrategy>(visiblePosition); | 3013 return characterAfterAlgorithm<EditingInFlatTreeStrategy>(visiblePosition); |
| 3015 } | 3014 } |
| 3016 | 3015 |
| 3017 template <typename Strategy> | 3016 template <typename Strategy> |
| 3018 static UChar32 characterBeforeAlgorithm(const VisiblePositionTemplate<Strategy>& visiblePosition) | 3017 static UChar32 characterBeforeAlgorithm(const VisiblePositionTemplate<Strategy>& visiblePosition) |
|
yosin_UTC9
2016/09/27 08:30:53
Not sure how about making |characterAfter()| to ta
Xiaocheng
2016/09/27 08:48:51
Talked offline. A lot of functions in VisibleUnits
| |
| 3019 { | 3018 { |
| 3020 // TODO(xiaochengh): Ensure that this function is called with a valid | 3019 DCHECK(visiblePosition.isValid()) << visiblePosition; |
| 3021 // |visiblePosition|, and add |DCHECK(visiblePosition.isValid())| | |
| 3022 return characterAfter(previousPositionOf(visiblePosition)); | 3020 return characterAfter(previousPositionOf(visiblePosition)); |
| 3023 } | 3021 } |
| 3024 | 3022 |
| 3025 UChar32 characterBefore(const VisiblePosition& visiblePosition) | 3023 UChar32 characterBefore(const VisiblePosition& visiblePosition) |
| 3026 { | 3024 { |
| 3027 return characterBeforeAlgorithm<EditingStrategy>(visiblePosition); | 3025 return characterBeforeAlgorithm<EditingStrategy>(visiblePosition); |
| 3028 } | 3026 } |
| 3029 | 3027 |
| 3030 UChar32 characterBefore(const VisiblePositionInFlatTree& visiblePosition) | 3028 UChar32 characterBefore(const VisiblePositionInFlatTree& visiblePosition) |
| 3031 { | 3029 { |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3480 { | 3478 { |
| 3481 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); | 3479 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); |
| 3482 } | 3480 } |
| 3483 | 3481 |
| 3484 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi siblePosition, EditingBoundaryCrossingRule rule) | 3482 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi siblePosition, EditingBoundaryCrossingRule rule) |
| 3485 { | 3483 { |
| 3486 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio n, rule); | 3484 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio n, rule); |
| 3487 } | 3485 } |
| 3488 | 3486 |
| 3489 } // namespace blink | 3487 } // namespace blink |
| OLD | NEW |