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 | |
2568 layoutObject = node->layoutObject(); | |
2569 if (!layoutObject) | |
2570 return LayoutRect(); | |
2571 | |
2572 InlineBoxPosition boxPosition = | |
2573 computeInlineBoxPosition(position.position(), position.affinity()); | |
2574 | |
2575 if (!boxPosition.inlineBox) | |
2576 return LayoutRect(); | |
2577 | |
2578 layoutObject = LineLayoutAPIShim::layoutObjectFrom( | |
2579 boxPosition.inlineBox->getLineLayoutItem()); | |
2580 | |
2581 LayoutRect rect = layoutObject->localCaretRect(boxPosition.inlineBox, | |
2582 boxPosition.offsetInBox); | |
2563 | 2583 |
2564 if (rect.isEmpty()) | 2584 if (rect.isEmpty()) |
joone
2017/01/20 02:07:29
If boxPosition.inlineBox isn't InlineTextBox, loca
yosin_UTC9
2017/01/20 04:28:29
We need to have a test case of this. I think BR or
| |
2565 return rect; | 2585 return rect; |
2566 | 2586 |
2567 InlineBoxPosition boxPosition = | |
2568 computeInlineBoxPosition(position.position(), position.affinity()); | |
2569 | |
2570 InlineTextBox* box = toInlineTextBox(boxPosition.inlineBox); | 2587 InlineTextBox* box = toInlineTextBox(boxPosition.inlineBox); |
yosin_UTC9
2017/01/20 04:28:29
We need to handle if |boxPosition.inlineBox| isn't
| |
2571 if (layoutObject->style()->isHorizontalWritingMode()) { | 2588 if (layoutObject->style()->isHorizontalWritingMode()) { |
2572 rect.setY(box->root().selectionTop()); | 2589 rect.setY(box->root().selectionTop()); |
2573 rect.setHeight(box->root().selectionHeight()); | 2590 rect.setHeight(box->root().selectionHeight()); |
2574 return rect; | 2591 return rect; |
2575 } | 2592 } |
2576 | 2593 |
2577 rect.setX(box->root().selectionTop()); | 2594 rect.setX(box->root().selectionTop()); |
2578 rect.setWidth(box->root().selectionHeight()); | 2595 rect.setWidth(box->root().selectionHeight()); |
2579 return rect; | 2596 return rect; |
2580 } | 2597 } |
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3902 | 3919 |
3903 VisiblePositionInFlatTree previousPositionOf( | 3920 VisiblePositionInFlatTree previousPositionOf( |
3904 const VisiblePositionInFlatTree& visiblePosition, | 3921 const VisiblePositionInFlatTree& visiblePosition, |
3905 EditingBoundaryCrossingRule rule) { | 3922 EditingBoundaryCrossingRule rule) { |
3906 DCHECK(visiblePosition.isValid()) << visiblePosition; | 3923 DCHECK(visiblePosition.isValid()) << visiblePosition; |
3907 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>( | 3924 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>( |
3908 visiblePosition.deepEquivalent(), rule); | 3925 visiblePosition.deepEquivalent(), rule); |
3909 } | 3926 } |
3910 | 3927 |
3911 } // namespace blink | 3928 } // namespace blink |
OLD | NEW |