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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 } | 358 } |
359 | 359 |
360 static Position nextRootInlineBoxCandidatePosition( | 360 static Position nextRootInlineBoxCandidatePosition( |
361 Node* node, | 361 Node* node, |
362 const VisiblePosition& visiblePosition, | 362 const VisiblePosition& visiblePosition, |
363 EditableType editableType) { | 363 EditableType editableType) { |
364 DCHECK(visiblePosition.isValid()) << visiblePosition; | 364 DCHECK(visiblePosition.isValid()) << visiblePosition; |
365 ContainerNode* highestRoot = | 365 ContainerNode* highestRoot = |
366 highestEditableRoot(visiblePosition.deepEquivalent(), editableType); | 366 highestEditableRoot(visiblePosition.deepEquivalent(), editableType); |
367 Node* nextNode = nextLeafWithSameEditability(node, editableType); | 367 Node* nextNode = nextLeafWithSameEditability(node, editableType); |
368 while (nextNode && (!nextNode->layoutObject() || | 368 while ( |
369 inSameLine(createVisiblePosition( | 369 nextNode && |
370 firstPositionInOrBeforeNode(nextNode)), | 370 (!nextNode->layoutObject() || |
371 visiblePosition))) | 371 inSameLine(createVisiblePosition(firstPositionInOrBeforeNode(nextNode)), |
| 372 visiblePosition))) |
372 nextNode = nextLeafWithSameEditability(nextNode, ContentIsEditable); | 373 nextNode = nextLeafWithSameEditability(nextNode, ContentIsEditable); |
373 | 374 |
374 while (nextNode && !nextNode->isShadowRoot()) { | 375 while (nextNode && !nextNode->isShadowRoot()) { |
375 if (highestEditableRoot(firstPositionInOrBeforeNode(nextNode), | 376 if (highestEditableRoot(firstPositionInOrBeforeNode(nextNode), |
376 editableType) != highestRoot) | 377 editableType) != highestRoot) |
377 break; | 378 break; |
378 | 379 |
379 Position pos; | 380 Position pos; |
380 pos = Position::editingPositionOf(nextNode, caretMinOffset(nextNode)); | 381 pos = Position::editingPositionOf(nextNode, caretMinOffset(nextNode)); |
381 | 382 |
(...skipping 1954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2336 if (equivalent == position || | 2337 if (equivalent == position || |
2337 downstreamIgnoringEditingBoundaries(equivalent) == position) | 2338 downstreamIgnoringEditingBoundaries(equivalent) == position) |
2338 return InlineBoxPosition(inlineBox, caretOffset); | 2339 return InlineBoxPosition(inlineBox, caretOffset); |
2339 } | 2340 } |
2340 | 2341 |
2341 return computeInlineBoxPosition(equivalent, TextAffinity::Upstream, | 2342 return computeInlineBoxPosition(equivalent, TextAffinity::Upstream, |
2342 primaryDirection); | 2343 primaryDirection); |
2343 } | 2344 } |
2344 if (layoutObject->isBox()) { | 2345 if (layoutObject->isBox()) { |
2345 inlineBox = toLayoutBox(layoutObject)->inlineBoxWrapper(); | 2346 inlineBox = toLayoutBox(layoutObject)->inlineBoxWrapper(); |
2346 if (!inlineBox || (caretOffset > inlineBox->caretMinOffset() && | 2347 if (!inlineBox || |
2347 caretOffset < inlineBox->caretMaxOffset())) | 2348 (caretOffset > inlineBox->caretMinOffset() && |
| 2349 caretOffset < inlineBox->caretMaxOffset())) |
2348 return InlineBoxPosition(inlineBox, caretOffset); | 2350 return InlineBoxPosition(inlineBox, caretOffset); |
2349 } | 2351 } |
2350 } else { | 2352 } else { |
2351 LayoutText* textLayoutObject = toLayoutText(layoutObject); | 2353 LayoutText* textLayoutObject = toLayoutText(layoutObject); |
2352 | 2354 |
2353 InlineTextBox* box; | 2355 InlineTextBox* box; |
2354 InlineTextBox* candidate = 0; | 2356 InlineTextBox* candidate = 0; |
2355 | 2357 |
2356 for (box = textLayoutObject->firstTextBox(); box; | 2358 for (box = textLayoutObject->firstTextBox(); box; |
2357 box = box->nextTextBox()) { | 2359 box = box->nextTextBox()) { |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2741 if (textOffset < static_cast<int>(box->start()) && | 2743 if (textOffset < static_cast<int>(box->start()) && |
2742 !textLayoutObject->containsReversedText()) { | 2744 !textLayoutObject->containsReversedText()) { |
2743 // The offset we're looking for is before this node | 2745 // The offset we're looking for is before this node |
2744 // this means the offset must be in content that is | 2746 // this means the offset must be in content that is |
2745 // not laid out. Return false. | 2747 // not laid out. Return false. |
2746 return false; | 2748 return false; |
2747 } | 2749 } |
2748 if (box->containsCaretOffset(textOffset)) { | 2750 if (box->containsCaretOffset(textOffset)) { |
2749 // Return false for offsets inside composed characters. | 2751 // Return false for offsets inside composed characters. |
2750 return textOffset == 0 || | 2752 return textOffset == 0 || |
2751 textOffset == nextGraphemeBoundaryOf(anchorNode, | 2753 textOffset == |
2752 previousGraphemeBoundaryOf( | 2754 nextGraphemeBoundaryOf( |
2753 anchorNode, textOffset)); | 2755 anchorNode, |
| 2756 previousGraphemeBoundaryOf(anchorNode, textOffset)); |
2754 } | 2757 } |
2755 } | 2758 } |
2756 | 2759 |
2757 return false; | 2760 return false; |
2758 } | 2761 } |
2759 | 2762 |
2760 bool rendersInDifferentPosition(const Position& position1, | 2763 bool rendersInDifferentPosition(const Position& position1, |
2761 const Position& position2) { | 2764 const Position& position2) { |
2762 if (position1.isNull() || position2.isNull()) | 2765 if (position1.isNull() || position2.isNull()) |
2763 return false; | 2766 return false; |
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3928 | 3931 |
3929 VisiblePositionInFlatTree previousPositionOf( | 3932 VisiblePositionInFlatTree previousPositionOf( |
3930 const VisiblePositionInFlatTree& visiblePosition, | 3933 const VisiblePositionInFlatTree& visiblePosition, |
3931 EditingBoundaryCrossingRule rule) { | 3934 EditingBoundaryCrossingRule rule) { |
3932 DCHECK(visiblePosition.isValid()) << visiblePosition; | 3935 DCHECK(visiblePosition.isValid()) << visiblePosition; |
3933 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>( | 3936 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>( |
3934 visiblePosition.deepEquivalent(), rule); | 3937 visiblePosition.deepEquivalent(), rule); |
3935 } | 3938 } |
3936 | 3939 |
3937 } // namespace blink | 3940 } // namespace blink |
OLD | NEW |