| 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(bool clipToVisibleContent) const | 1718 FloatRect FrameSelection::bounds() const |
| 1719 { | 1719 { |
| 1720 m_frame->document()->updateRenderTreeIfNeeded(); | 1720 m_frame->document()->updateRenderTreeIfNeeded(); |
| 1721 | 1721 |
| 1722 FrameView* view = m_frame->view(); | 1722 FrameView* view = m_frame->view(); |
| 1723 RenderView* renderView = m_frame->contentRenderer(); | 1723 RenderView* renderView = m_frame->contentRenderer(); |
| 1724 | 1724 |
| 1725 if (!view || !renderView) | 1725 if (!view || !renderView) |
| 1726 return FloatRect(); | 1726 return FloatRect(); |
| 1727 | 1727 |
| 1728 LayoutRect selectionRect = renderView->selectionBounds(clipToVisibleContent)
; | 1728 LayoutRect selectionRect = renderView->selectionBounds(); |
| 1729 return clipToVisibleContent ? intersection(selectionRect, view->visibleConte
ntRect()) : selectionRect; | 1729 return selectionRect; |
| 1730 } | 1730 } |
| 1731 | 1731 |
| 1732 static inline HTMLFormElement* associatedFormElement(HTMLElement& element) | 1732 static inline HTMLFormElement* associatedFormElement(HTMLElement& element) |
| 1733 { | 1733 { |
| 1734 if (isHTMLFormElement(element)) | 1734 if (isHTMLFormElement(element)) |
| 1735 return &toHTMLFormElement(element); | 1735 return &toHTMLFormElement(element); |
| 1736 return element.formOwner(); | 1736 return element.formOwner(); |
| 1737 } | 1737 } |
| 1738 | 1738 |
| 1739 // Scans logically forward from "start", including any child frames. | 1739 // Scans logically forward from "start", including any child frames. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1780 { | 1780 { |
| 1781 LayoutRect rect; | 1781 LayoutRect rect; |
| 1782 | 1782 |
| 1783 switch (selectionType()) { | 1783 switch (selectionType()) { |
| 1784 case NoSelection: | 1784 case NoSelection: |
| 1785 return; | 1785 return; |
| 1786 case CaretSelection: | 1786 case CaretSelection: |
| 1787 rect = absoluteCaretBounds(); | 1787 rect = absoluteCaretBounds(); |
| 1788 break; | 1788 break; |
| 1789 case RangeSelection: | 1789 case RangeSelection: |
| 1790 rect = revealExtentOption == RevealExtent ? VisiblePosition(extent()).ab
soluteCaretBounds() : enclosingIntRect(bounds(false)); | 1790 rect = revealExtentOption == RevealExtent ? VisiblePosition(extent()).ab
soluteCaretBounds() : enclosingIntRect(bounds()); |
| 1791 break; | 1791 break; |
| 1792 } | 1792 } |
| 1793 | 1793 |
| 1794 Position start = this->start(); | 1794 Position start = this->start(); |
| 1795 ASSERT(start.deprecatedNode()); | 1795 ASSERT(start.deprecatedNode()); |
| 1796 if (start.deprecatedNode() && start.deprecatedNode()->renderer()) { | 1796 if (start.deprecatedNode() && start.deprecatedNode()->renderer()) { |
| 1797 // FIXME: This code only handles scrolling the startContainer's layer, b
ut | 1797 // FIXME: This code only handles scrolling the startContainer's layer, b
ut |
| 1798 // the selection rect could intersect more than just that. | 1798 // the selection rect could intersect more than just that. |
| 1799 // See <rdar://problem/4799899>. | 1799 // See <rdar://problem/4799899>. |
| 1800 if (start.deprecatedNode()->renderer()->scrollRectToVisible(rect, alignm
ent, alignment)) | 1800 if (start.deprecatedNode()->renderer()->scrollRectToVisible(rect, alignm
ent, alignment)) |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1931 sel.showTreeForThis(); | 1931 sel.showTreeForThis(); |
| 1932 } | 1932 } |
| 1933 | 1933 |
| 1934 void showTree(const blink::FrameSelection* sel) | 1934 void showTree(const blink::FrameSelection* sel) |
| 1935 { | 1935 { |
| 1936 if (sel) | 1936 if (sel) |
| 1937 sel->showTreeForThis(); | 1937 sel->showTreeForThis(); |
| 1938 } | 1938 } |
| 1939 | 1939 |
| 1940 #endif | 1940 #endif |
| OLD | NEW |