OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 2803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2814 template <typename Strategy> | 2814 template <typename Strategy> |
2815 static PositionTemplate<Strategy> mostBackwardCaretPosition( | 2815 static PositionTemplate<Strategy> mostBackwardCaretPosition( |
2816 const PositionTemplate<Strategy>& position, | 2816 const PositionTemplate<Strategy>& position, |
2817 EditingBoundaryCrossingRule rule) { | 2817 EditingBoundaryCrossingRule rule) { |
2818 TRACE_EVENT0("input", "VisibleUnits::mostBackwardCaretPosition"); | 2818 TRACE_EVENT0("input", "VisibleUnits::mostBackwardCaretPosition"); |
2819 | 2819 |
2820 Node* startNode = position.anchorNode(); | 2820 Node* startNode = position.anchorNode(); |
2821 if (!startNode) | 2821 if (!startNode) |
2822 return PositionTemplate<Strategy>(); | 2822 return PositionTemplate<Strategy>(); |
2823 | 2823 |
| 2824 if (!startNode->document().frame()->selection().inUpdateSelectionIfNeeded()) |
| 2825 DCHECK(!startNode->document().needsLayoutTreeUpdate()); |
2824 // iterate backward from there, looking for a qualified position | 2826 // iterate backward from there, looking for a qualified position |
2825 Node* boundary = enclosingVisualBoundary<Strategy>(startNode); | 2827 Node* boundary = enclosingVisualBoundary<Strategy>(startNode); |
2826 // FIXME: PositionIterator should respect Before and After positions. | 2828 // FIXME: PositionIterator should respect Before and After positions. |
2827 PositionIteratorAlgorithm<Strategy> lastVisible( | 2829 PositionIteratorAlgorithm<Strategy> lastVisible( |
2828 position.isAfterAnchor() | 2830 position.isAfterAnchor() |
2829 ? PositionTemplate<Strategy>::editingPositionOf( | 2831 ? PositionTemplate<Strategy>::editingPositionOf( |
2830 position.anchorNode(), | 2832 position.anchorNode(), |
2831 Strategy::caretMaxOffset(*position.anchorNode())) | 2833 Strategy::caretMaxOffset(*position.anchorNode())) |
2832 : position); | 2834 : position); |
2833 PositionIteratorAlgorithm<Strategy> currentPos = lastVisible; | 2835 PositionIteratorAlgorithm<Strategy> currentPos = lastVisible; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2988 template <typename Strategy> | 2990 template <typename Strategy> |
2989 PositionTemplate<Strategy> mostForwardCaretPosition( | 2991 PositionTemplate<Strategy> mostForwardCaretPosition( |
2990 const PositionTemplate<Strategy>& position, | 2992 const PositionTemplate<Strategy>& position, |
2991 EditingBoundaryCrossingRule rule) { | 2993 EditingBoundaryCrossingRule rule) { |
2992 TRACE_EVENT0("input", "VisibleUnits::mostForwardCaretPosition"); | 2994 TRACE_EVENT0("input", "VisibleUnits::mostForwardCaretPosition"); |
2993 | 2995 |
2994 Node* startNode = position.anchorNode(); | 2996 Node* startNode = position.anchorNode(); |
2995 if (!startNode) | 2997 if (!startNode) |
2996 return PositionTemplate<Strategy>(); | 2998 return PositionTemplate<Strategy>(); |
2997 | 2999 |
| 3000 if (!startNode->document().frame()->selection().inUpdateSelectionIfNeeded()) |
| 3001 DCHECK(!startNode->document().needsLayoutTreeUpdate()); |
2998 // iterate forward from there, looking for a qualified position | 3002 // iterate forward from there, looking for a qualified position |
2999 Node* boundary = enclosingVisualBoundary<Strategy>(startNode); | 3003 Node* boundary = enclosingVisualBoundary<Strategy>(startNode); |
3000 // FIXME: PositionIterator should respect Before and After positions. | 3004 // FIXME: PositionIterator should respect Before and After positions. |
3001 PositionIteratorAlgorithm<Strategy> lastVisible( | 3005 PositionIteratorAlgorithm<Strategy> lastVisible( |
3002 position.isAfterAnchor() | 3006 position.isAfterAnchor() |
3003 ? PositionTemplate<Strategy>::editingPositionOf( | 3007 ? PositionTemplate<Strategy>::editingPositionOf( |
3004 position.anchorNode(), | 3008 position.anchorNode(), |
3005 Strategy::caretMaxOffset(*position.anchorNode())) | 3009 Strategy::caretMaxOffset(*position.anchorNode())) |
3006 : position); | 3010 : position); |
3007 PositionIteratorAlgorithm<Strategy> currentPos = lastVisible; | 3011 PositionIteratorAlgorithm<Strategy> currentPos = lastVisible; |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3901 | 3905 |
3902 VisiblePositionInFlatTree previousPositionOf( | 3906 VisiblePositionInFlatTree previousPositionOf( |
3903 const VisiblePositionInFlatTree& visiblePosition, | 3907 const VisiblePositionInFlatTree& visiblePosition, |
3904 EditingBoundaryCrossingRule rule) { | 3908 EditingBoundaryCrossingRule rule) { |
3905 DCHECK(visiblePosition.isValid()) << visiblePosition; | 3909 DCHECK(visiblePosition.isValid()) << visiblePosition; |
3906 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>( | 3910 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>( |
3907 visiblePosition.deepEquivalent(), rule); | 3911 visiblePosition.deepEquivalent(), rule); |
3908 } | 3912 } |
3909 | 3913 |
3910 } // namespace blink | 3914 } // namespace blink |
OLD | NEW |