| 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 2541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2552 return layoutObject->localCaretRect(boxPosition.inlineBox, | 2552 return layoutObject->localCaretRect(boxPosition.inlineBox, |
| 2553 boxPosition.offsetInBox); | 2553 boxPosition.offsetInBox); |
| 2554 } | 2554 } |
| 2555 | 2555 |
| 2556 // This function was added because the caret rect that is calculated by | 2556 // This function was added because the caret rect that is calculated by |
| 2557 // using the line top value instead of the selection top. | 2557 // using the line top value instead of the selection top. |
| 2558 template <typename Strategy> | 2558 template <typename Strategy> |
| 2559 LayoutRect localSelectionRectOfPositionTemplate( | 2559 LayoutRect localSelectionRectOfPositionTemplate( |
| 2560 const PositionWithAffinityTemplate<Strategy>& position, | 2560 const PositionWithAffinityTemplate<Strategy>& position, |
| 2561 LayoutObject*& layoutObject) { | 2561 LayoutObject*& layoutObject) { |
| 2562 LayoutRect rect = localCaretRectOfPositionTemplate(position, layoutObject); | 2562 if (position.isNull()) { |
| 2563 layoutObject = nullptr; |
| 2564 return LayoutRect(); |
| 2565 } |
| 2566 Node* node = position.anchorNode(); |
| 2567 layoutObject = node->layoutObject(); |
| 2568 if (!layoutObject) |
| 2569 return LayoutRect(); |
| 2570 |
| 2571 InlineBoxPosition boxPosition = |
| 2572 computeInlineBoxPosition(position.position(), position.affinity()); |
| 2573 |
| 2574 if (!boxPosition.inlineBox) |
| 2575 return LayoutRect(); |
| 2576 |
| 2577 layoutObject = LineLayoutAPIShim::layoutObjectFrom( |
| 2578 boxPosition.inlineBox->getLineLayoutItem()); |
| 2579 |
| 2580 LayoutRect rect = layoutObject->localCaretRect(boxPosition.inlineBox, |
| 2581 boxPosition.offsetInBox); |
| 2563 | 2582 |
| 2564 if (rect.isEmpty()) | 2583 if (rect.isEmpty()) |
| 2565 return rect; | 2584 return rect; |
| 2566 | 2585 |
| 2567 InlineBoxPosition boxPosition = | 2586 InlineBox* const box = boxPosition.inlineBox; |
| 2568 computeInlineBoxPosition(position.position(), position.affinity()); | |
| 2569 | |
| 2570 InlineTextBox* box = toInlineTextBox(boxPosition.inlineBox); | |
| 2571 if (layoutObject->style()->isHorizontalWritingMode()) { | 2587 if (layoutObject->style()->isHorizontalWritingMode()) { |
| 2572 rect.setY(box->root().selectionTop()); | 2588 rect.setY(box->root().selectionTop()); |
| 2573 rect.setHeight(box->root().selectionHeight()); | 2589 rect.setHeight(box->root().selectionHeight()); |
| 2574 return rect; | 2590 return rect; |
| 2575 } | 2591 } |
| 2576 | 2592 |
| 2577 rect.setX(box->root().selectionTop()); | 2593 rect.setX(box->root().selectionTop()); |
| 2578 rect.setWidth(box->root().selectionHeight()); | 2594 rect.setWidth(box->root().selectionHeight()); |
| 2579 return rect; | 2595 return rect; |
| 2580 } | 2596 } |
| (...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3902 | 3918 |
| 3903 VisiblePositionInFlatTree previousPositionOf( | 3919 VisiblePositionInFlatTree previousPositionOf( |
| 3904 const VisiblePositionInFlatTree& visiblePosition, | 3920 const VisiblePositionInFlatTree& visiblePosition, |
| 3905 EditingBoundaryCrossingRule rule) { | 3921 EditingBoundaryCrossingRule rule) { |
| 3906 DCHECK(visiblePosition.isValid()) << visiblePosition; | 3922 DCHECK(visiblePosition.isValid()) << visiblePosition; |
| 3907 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>( | 3923 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>( |
| 3908 visiblePosition.deepEquivalent(), rule); | 3924 visiblePosition.deepEquivalent(), rule); |
| 3909 } | 3925 } |
| 3910 | 3926 |
| 3911 } // namespace blink | 3927 } // namespace blink |
| OLD | NEW |