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 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 { | 1756 { |
1757 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H
itTestRequest::Active | HitTestRequest::IgnoreClipping; | 1757 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H
itTestRequest::Active | HitTestRequest::IgnoreClipping; |
1758 HitTestResult result(request, contentsPoint); | 1758 HitTestResult result(request, contentsPoint); |
1759 frame->document()->layoutView()->hitTest(result); | 1759 frame->document()->layoutView()->hitTest(result); |
1760 | 1760 |
1761 if (Node* node = result.innerNode()) | 1761 if (Node* node = result.innerNode()) |
1762 return frame->selection().selection().visiblePositionRespectingEditingBo
undary(result.localPoint(), node); | 1762 return frame->selection().selection().visiblePositionRespectingEditingBo
undary(result.localPoint(), node); |
1763 return VisiblePosition(); | 1763 return VisiblePosition(); |
1764 } | 1764 } |
1765 | 1765 |
| 1766 template <typename Strategy> |
| 1767 static bool inRenderedText(const PositionAlgorithm<Strategy>& position) |
| 1768 { |
| 1769 Node* const anchorNode = position.anchorNode(); |
| 1770 if (!anchorNode || !anchorNode->isTextNode()) |
| 1771 return false; |
| 1772 |
| 1773 LayoutObject* layoutObject = anchorNode->layoutObject(); |
| 1774 if (!layoutObject) |
| 1775 return false; |
| 1776 |
| 1777 const int offsetInNode = position.computeEditingOffset(); |
| 1778 LayoutText* textLayoutObject = toLayoutText(layoutObject); |
| 1779 for (InlineTextBox *box = textLayoutObject->firstTextBox(); box; box = box->
nextTextBox()) { |
| 1780 if (offsetInNode < static_cast<int>(box->start()) && !textLayoutObject->
containsReversedText()) { |
| 1781 // The offset we're looking for is before this node |
| 1782 // this means the offset must be in content that is |
| 1783 // not laid out. Return false. |
| 1784 return false; |
| 1785 } |
| 1786 if (box->containsCaretOffset(offsetInNode)) { |
| 1787 // Return false for offsets inside composed characters. |
| 1788 return offsetInNode == 0 || offsetInNode == textLayoutObject->nextOf
fset(textLayoutObject->previousOffset(offsetInNode)); |
| 1789 } |
| 1790 } |
| 1791 |
| 1792 return false; |
| 1793 } |
| 1794 |
1766 static Node* nextRenderedEditable(Node* node) | 1795 static Node* nextRenderedEditable(Node* node) |
1767 { | 1796 { |
1768 for (node = nextAtomicLeafNode(*node); node; node = nextAtomicLeafNode(*node
)) { | 1797 for (node = nextAtomicLeafNode(*node); node; node = nextAtomicLeafNode(*node
)) { |
1769 LayoutObject* layoutObject = node->layoutObject(); | 1798 LayoutObject* layoutObject = node->layoutObject(); |
1770 if (!layoutObject) | 1799 if (!layoutObject) |
1771 continue; | 1800 continue; |
1772 if (!node->hasEditableStyle()) | 1801 if (!node->hasEditableStyle()) |
1773 continue; | 1802 continue; |
1774 // TODO(yosin) We should have a function to check |InlineBox| types | 1803 // TODO(yosin) We should have a function to check |InlineBox| types |
1775 // in layout rather than using |InlineBox| here. See also | 1804 // in layout rather than using |InlineBox| here. See also |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2291 { | 2320 { |
2292 return isVisuallyEquivalentCandidateAlgorithm<EditingStrategy>(position); | 2321 return isVisuallyEquivalentCandidateAlgorithm<EditingStrategy>(position); |
2293 } | 2322 } |
2294 | 2323 |
2295 bool isVisuallyEquivalentCandidate(const PositionInComposedTree& position) | 2324 bool isVisuallyEquivalentCandidate(const PositionInComposedTree& position) |
2296 { | 2325 { |
2297 return isVisuallyEquivalentCandidateAlgorithm<EditingInComposedTreeStrategy>
(position); | 2326 return isVisuallyEquivalentCandidateAlgorithm<EditingInComposedTreeStrategy>
(position); |
2298 } | 2327 } |
2299 | 2328 |
2300 } // namespace blink | 2329 } // namespace blink |
OLD | NEW |