| 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 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 return createVisiblePosition(Position::inParentBeforeNode(*node)); | 1390 return createVisiblePosition(Position::inParentBeforeNode(*node)); |
| 1391 return createVisiblePosition(lineLayoutItem.positionForPoint(pointInLine
)); | 1391 return createVisiblePosition(lineLayoutItem.positionForPoint(pointInLine
)); |
| 1392 } | 1392 } |
| 1393 | 1393 |
| 1394 // Could not find a next line. This means we must already be on the last lin
e. | 1394 // Could not find a next line. This means we must already be on the last lin
e. |
| 1395 // Move to the end of the content in this block, which effectively moves us | 1395 // Move to the end of the content in this block, which effectively moves us |
| 1396 // to the end of the line we're on. | 1396 // to the end of the line we're on. |
| 1397 Element* rootElement = node->hasEditableStyle(editableType) ? node->rootEdit
ableElement(editableType) : node->document().documentElement(); | 1397 Element* rootElement = node->hasEditableStyle(editableType) ? node->rootEdit
ableElement(editableType) : node->document().documentElement(); |
| 1398 if (!rootElement) | 1398 if (!rootElement) |
| 1399 return VisiblePosition(); | 1399 return VisiblePosition(); |
| 1400 return createVisiblePosition(lastPositionInNode(rootElement)); | 1400 return createVisiblePosition(Position::lastPositionInNode(rootElement)); |
| 1401 } | 1401 } |
| 1402 | 1402 |
| 1403 // --------- | 1403 // --------- |
| 1404 | 1404 |
| 1405 static unsigned startSentenceBoundary(const UChar* characters, unsigned length,
unsigned, BoundarySearchContextAvailability, bool&) | 1405 static unsigned startSentenceBoundary(const UChar* characters, unsigned length,
unsigned, BoundarySearchContextAvailability, bool&) |
| 1406 { | 1406 { |
| 1407 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); | 1407 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); |
| 1408 // FIXME: The following function can return -1; we don't handle that. | 1408 // FIXME: The following function can return -1; we don't handle that. |
| 1409 return iterator->preceding(length); | 1409 return iterator->preceding(length); |
| 1410 } | 1410 } |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1730 { | 1730 { |
| 1731 Position position = visiblePosition.deepEquivalent(); | 1731 Position position = visiblePosition.deepEquivalent(); |
| 1732 Element* startBlock = position.computeContainerNode() ? enclosingBlock(posit
ion.computeContainerNode(), rule) : 0; | 1732 Element* startBlock = position.computeContainerNode() ? enclosingBlock(posit
ion.computeContainerNode(), rule) : 0; |
| 1733 return startBlock ? VisiblePosition::firstPositionInNode(startBlock) : Visib
lePosition(); | 1733 return startBlock ? VisiblePosition::firstPositionInNode(startBlock) : Visib
lePosition(); |
| 1734 } | 1734 } |
| 1735 | 1735 |
| 1736 VisiblePosition endOfBlock(const VisiblePosition& visiblePosition, EditingBounda
ryCrossingRule rule) | 1736 VisiblePosition endOfBlock(const VisiblePosition& visiblePosition, EditingBounda
ryCrossingRule rule) |
| 1737 { | 1737 { |
| 1738 Position position = visiblePosition.deepEquivalent(); | 1738 Position position = visiblePosition.deepEquivalent(); |
| 1739 Element* endBlock = position.computeContainerNode() ? enclosingBlock(positio
n.computeContainerNode(), rule) : 0; | 1739 Element* endBlock = position.computeContainerNode() ? enclosingBlock(positio
n.computeContainerNode(), rule) : 0; |
| 1740 return endBlock ? createVisiblePosition(lastPositionInNode(endBlock)) : Visi
blePosition(); | 1740 return endBlock ? createVisiblePosition(Position::lastPositionInNode(endBloc
k)) : VisiblePosition(); |
| 1741 } | 1741 } |
| 1742 | 1742 |
| 1743 bool inSameBlock(const VisiblePosition& a, const VisiblePosition& b) | 1743 bool inSameBlock(const VisiblePosition& a, const VisiblePosition& b) |
| 1744 { | 1744 { |
| 1745 return !a.isNull() && enclosingBlock(a.deepEquivalent().computeContainerNode
()) == enclosingBlock(b.deepEquivalent().computeContainerNode()); | 1745 return !a.isNull() && enclosingBlock(a.deepEquivalent().computeContainerNode
()) == enclosingBlock(b.deepEquivalent().computeContainerNode()); |
| 1746 } | 1746 } |
| 1747 | 1747 |
| 1748 bool isStartOfBlock(const VisiblePosition& pos) | 1748 bool isStartOfBlock(const VisiblePosition& pos) |
| 1749 { | 1749 { |
| 1750 return pos.isNotNull() && pos.deepEquivalent() == startOfBlock(pos, CanCross
EditingBoundary).deepEquivalent(); | 1750 return pos.isNotNull() && pos.deepEquivalent() == startOfBlock(pos, CanCross
EditingBoundary).deepEquivalent(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1818 | 1818 |
| 1819 return VisiblePosition::firstPositionInNode(highestRoot); | 1819 return VisiblePosition::firstPositionInNode(highestRoot); |
| 1820 } | 1820 } |
| 1821 | 1821 |
| 1822 VisiblePosition endOfEditableContent(const VisiblePosition& visiblePosition) | 1822 VisiblePosition endOfEditableContent(const VisiblePosition& visiblePosition) |
| 1823 { | 1823 { |
| 1824 ContainerNode* highestRoot = highestEditableRoot(visiblePosition.deepEquival
ent()); | 1824 ContainerNode* highestRoot = highestEditableRoot(visiblePosition.deepEquival
ent()); |
| 1825 if (!highestRoot) | 1825 if (!highestRoot) |
| 1826 return VisiblePosition(); | 1826 return VisiblePosition(); |
| 1827 | 1827 |
| 1828 return createVisiblePosition(lastPositionInNode(highestRoot)); | 1828 return createVisiblePosition(Position::lastPositionInNode(highestRoot)); |
| 1829 } | 1829 } |
| 1830 | 1830 |
| 1831 bool isEndOfEditableOrNonEditableContent(const VisiblePosition& position) | 1831 bool isEndOfEditableOrNonEditableContent(const VisiblePosition& position) |
| 1832 { | 1832 { |
| 1833 return position.isNotNull() && nextPositionOf(position).isNull(); | 1833 return position.isNotNull() && nextPositionOf(position).isNull(); |
| 1834 } | 1834 } |
| 1835 | 1835 |
| 1836 // TODO(yosin) We should rename |isEndOfEditableOrNonEditableContent()| what | 1836 // TODO(yosin) We should rename |isEndOfEditableOrNonEditableContent()| what |
| 1837 // this function does, e.g. |isLastVisiblePositionOrEndOfInnerEditor()|. | 1837 // this function does, e.g. |isLastVisiblePositionOrEndOfInnerEditor()|. |
| 1838 bool isEndOfEditableOrNonEditableContent(const VisiblePositionInFlatTree& positi
on) | 1838 bool isEndOfEditableOrNonEditableContent(const VisiblePositionInFlatTree& positi
on) |
| (...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3251 { | 3251 { |
| 3252 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); | 3252 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); |
| 3253 } | 3253 } |
| 3254 | 3254 |
| 3255 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi
siblePosition, EditingBoundaryCrossingRule rule) | 3255 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi
siblePosition, EditingBoundaryCrossingRule rule) |
| 3256 { | 3256 { |
| 3257 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio
n, rule); | 3257 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio
n, rule); |
| 3258 } | 3258 } |
| 3259 | 3259 |
| 3260 } // namespace blink | 3260 } // namespace blink |
| OLD | NEW |