OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. |
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 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1708 return extractSelectedText(*this, TextIteratorDefaultBehavior); | 1708 return extractSelectedText(*this, TextIteratorDefaultBehavior); |
1709 } | 1709 } |
1710 | 1710 |
1711 String FrameSelection::selectedTextForClipboard() const | 1711 String FrameSelection::selectedTextForClipboard() const |
1712 { | 1712 { |
1713 if (m_frame->settings() && m_frame->settings()->selectionIncludesAltImageTex
t()) | 1713 if (m_frame->settings() && m_frame->settings()->selectionIncludesAltImageTex
t()) |
1714 return extractSelectedText(*this, TextIteratorEmitsImageAltText); | 1714 return extractSelectedText(*this, TextIteratorEmitsImageAltText); |
1715 return selectedText(); | 1715 return selectedText(); |
1716 } | 1716 } |
1717 | 1717 |
1718 FloatRect FrameSelection::bounds() const | 1718 LayoutRect FrameSelection::bounds() const |
| 1719 { |
| 1720 FrameView* view = m_frame->view(); |
| 1721 if (!view) |
| 1722 return LayoutRect(); |
| 1723 |
| 1724 return intersection(unclippedBounds(), view->visibleContentRect()); |
| 1725 } |
| 1726 |
| 1727 LayoutRect FrameSelection::unclippedBounds() const |
1719 { | 1728 { |
1720 m_frame->document()->updateRenderTreeIfNeeded(); | 1729 m_frame->document()->updateRenderTreeIfNeeded(); |
1721 | 1730 |
1722 FrameView* view = m_frame->view(); | 1731 FrameView* view = m_frame->view(); |
1723 RenderView* renderView = m_frame->contentRenderer(); | 1732 RenderView* renderView = m_frame->contentRenderer(); |
1724 | 1733 |
1725 if (!view || !renderView) | 1734 if (!view || !renderView) |
1726 return FloatRect(); | 1735 return LayoutRect(); |
1727 | 1736 |
1728 LayoutRect selectionRect = renderView->selectionBounds(); | 1737 return renderView->selectionBounds(); |
1729 return selectionRect; | |
1730 } | 1738 } |
1731 | 1739 |
1732 static inline HTMLFormElement* associatedFormElement(HTMLElement& element) | 1740 static inline HTMLFormElement* associatedFormElement(HTMLElement& element) |
1733 { | 1741 { |
1734 if (isHTMLFormElement(element)) | 1742 if (isHTMLFormElement(element)) |
1735 return &toHTMLFormElement(element); | 1743 return &toHTMLFormElement(element); |
1736 return element.formOwner(); | 1744 return element.formOwner(); |
1737 } | 1745 } |
1738 | 1746 |
1739 // Scans logically forward from "start", including any child frames. | 1747 // Scans logically forward from "start", including any child frames. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1780 { | 1788 { |
1781 LayoutRect rect; | 1789 LayoutRect rect; |
1782 | 1790 |
1783 switch (selectionType()) { | 1791 switch (selectionType()) { |
1784 case NoSelection: | 1792 case NoSelection: |
1785 return; | 1793 return; |
1786 case CaretSelection: | 1794 case CaretSelection: |
1787 rect = absoluteCaretBounds(); | 1795 rect = absoluteCaretBounds(); |
1788 break; | 1796 break; |
1789 case RangeSelection: | 1797 case RangeSelection: |
1790 rect = revealExtentOption == RevealExtent ? VisiblePosition(extent()).ab
soluteCaretBounds() : enclosingIntRect(bounds()); | 1798 rect = revealExtentOption == RevealExtent ? VisiblePosition(extent()).ab
soluteCaretBounds() : enclosingIntRect(unclippedBounds()); |
1791 break; | 1799 break; |
1792 } | 1800 } |
1793 | 1801 |
1794 Position start = this->start(); | 1802 Position start = this->start(); |
1795 ASSERT(start.deprecatedNode()); | 1803 ASSERT(start.deprecatedNode()); |
1796 if (start.deprecatedNode() && start.deprecatedNode()->renderer()) { | 1804 if (start.deprecatedNode() && start.deprecatedNode()->renderer()) { |
1797 // FIXME: This code only handles scrolling the startContainer's layer, b
ut | 1805 // FIXME: This code only handles scrolling the startContainer's layer, b
ut |
1798 // the selection rect could intersect more than just that. | 1806 // the selection rect could intersect more than just that. |
1799 // See <rdar://problem/4799899>. | 1807 // See <rdar://problem/4799899>. |
1800 if (start.deprecatedNode()->renderer()->scrollRectToVisible(rect, alignm
ent, alignment)) | 1808 if (start.deprecatedNode()->renderer()->scrollRectToVisible(rect, alignm
ent, alignment)) |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 sel.showTreeForThis(); | 1940 sel.showTreeForThis(); |
1933 } | 1941 } |
1934 | 1942 |
1935 void showTree(const blink::FrameSelection* sel) | 1943 void showTree(const blink::FrameSelection* sel) |
1936 { | 1944 { |
1937 if (sel) | 1945 if (sel) |
1938 sel->showTreeForThis(); | 1946 sel->showTreeForThis(); |
1939 } | 1947 } |
1940 | 1948 |
1941 #endif | 1949 #endif |
OLD | NEW |