| 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 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1520 m_frame->document()->setFocusedElement(nullptr); | 1520 m_frame->document()->setFocusedElement(nullptr); |
| 1521 } | 1521 } |
| 1522 } | 1522 } |
| 1523 | 1523 |
| 1524 String FrameSelection::selectedText() const | 1524 String FrameSelection::selectedText() const |
| 1525 { | 1525 { |
| 1526 // We remove '\0' characters because they are not visibly rendered to the us
er. | 1526 // We remove '\0' characters because they are not visibly rendered to the us
er. |
| 1527 return plainText(toNormalizedRange().get()).replace(0, ""); | 1527 return plainText(toNormalizedRange().get()).replace(0, ""); |
| 1528 } | 1528 } |
| 1529 | 1529 |
| 1530 FloatRect FrameSelection::bounds(bool clipToVisibleContent) const | 1530 FloatRect FrameSelection::bounds() const |
| 1531 { | 1531 { |
| 1532 m_frame->document()->updateRenderTreeIfNeeded(); | 1532 m_frame->document()->updateRenderTreeIfNeeded(); |
| 1533 | 1533 |
| 1534 FrameView* view = m_frame->view(); | 1534 FrameView* view = m_frame->view(); |
| 1535 RenderView* renderView = m_frame->contentRenderer(); | 1535 RenderView* renderView = m_frame->contentRenderer(); |
| 1536 | 1536 |
| 1537 if (!view || !renderView) | 1537 if (!view || !renderView) |
| 1538 return FloatRect(); | 1538 return FloatRect(); |
| 1539 | 1539 |
| 1540 LayoutRect selectionRect = renderView->selectionBounds(clipToVisibleContent)
; | 1540 return renderView->selectionBounds(); |
| 1541 return clipToVisibleContent ? intersection(selectionRect, view->visibleConte
ntRect()) : selectionRect; | |
| 1542 } | 1541 } |
| 1543 | 1542 |
| 1544 void FrameSelection::revealSelection(const ScrollAlignment& alignment, RevealExt
entOption revealExtentOption) | 1543 void FrameSelection::revealSelection(const ScrollAlignment& alignment, RevealExt
entOption revealExtentOption) |
| 1545 { | 1544 { |
| 1546 LayoutRect rect; | 1545 LayoutRect rect; |
| 1547 | 1546 |
| 1548 switch (selectionType()) { | 1547 switch (selectionType()) { |
| 1549 case NoSelection: | 1548 case NoSelection: |
| 1550 return; | 1549 return; |
| 1551 case CaretSelection: | 1550 case CaretSelection: |
| 1552 rect = absoluteCaretBounds(); | 1551 rect = absoluteCaretBounds(); |
| 1553 break; | 1552 break; |
| 1554 case RangeSelection: | 1553 case RangeSelection: |
| 1555 rect = revealExtentOption == RevealExtent ? VisiblePosition(extent()).ab
soluteCaretBounds() : enclosingIntRect(bounds(false)); | 1554 rect = revealExtentOption == RevealExtent ? VisiblePosition(extent()).ab
soluteCaretBounds() : enclosingIntRect(bounds()); |
| 1556 break; | 1555 break; |
| 1557 } | 1556 } |
| 1558 | 1557 |
| 1559 Position start = this->start(); | 1558 Position start = this->start(); |
| 1560 ASSERT(start.deprecatedNode()); | 1559 ASSERT(start.deprecatedNode()); |
| 1561 if (start.deprecatedNode() && start.deprecatedNode()->renderer()) { | 1560 if (start.deprecatedNode() && start.deprecatedNode()->renderer()) { |
| 1562 // FIXME: This code only handles scrolling the startContainer's layer, b
ut | 1561 // FIXME: This code only handles scrolling the startContainer's layer, b
ut |
| 1563 // the selection rect could intersect more than just that. | 1562 // the selection rect could intersect more than just that. |
| 1564 // See <rdar://problem/4799899>. | 1563 // See <rdar://problem/4799899>. |
| 1565 if (start.deprecatedNode()->renderer()->scrollRectToVisible(rect, alignm
ent, alignment)) | 1564 if (start.deprecatedNode()->renderer()->scrollRectToVisible(rect, alignm
ent, alignment)) |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 sel.showTreeForThis(); | 1674 sel.showTreeForThis(); |
| 1676 } | 1675 } |
| 1677 | 1676 |
| 1678 void showTree(const blink::FrameSelection* sel) | 1677 void showTree(const blink::FrameSelection* sel) |
| 1679 { | 1678 { |
| 1680 if (sel) | 1679 if (sel) |
| 1681 sel->showTreeForThis(); | 1680 sel->showTreeForThis(); |
| 1682 } | 1681 } |
| 1683 | 1682 |
| 1684 #endif | 1683 #endif |
| OLD | NEW |