Chromium Code Reviews| 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 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1513 m_frame->document()->setFocusedElement(nullptr); | 1513 m_frame->document()->setFocusedElement(nullptr); |
| 1514 } | 1514 } |
| 1515 } | 1515 } |
| 1516 | 1516 |
| 1517 String FrameSelection::selectedText() const | 1517 String FrameSelection::selectedText() const |
| 1518 { | 1518 { |
| 1519 // We remove '\0' characters because they are not visibly rendered to the us er. | 1519 // We remove '\0' characters because they are not visibly rendered to the us er. |
| 1520 return plainText(toNormalizedRange().get()).replace(0, ""); | 1520 return plainText(toNormalizedRange().get()).replace(0, ""); |
| 1521 } | 1521 } |
| 1522 | 1522 |
| 1523 FloatRect FrameSelection::bounds() const | |
| 1524 { | |
| 1525 m_frame->document()->updateRenderTreeIfNeeded(); | |
| 1526 | |
| 1527 FrameView* view = m_frame->view(); | |
| 1528 RenderView* renderView = m_frame->contentRenderer(); | |
| 1529 | |
| 1530 if (!view || !renderView) | |
| 1531 return FloatRect(); | |
| 1532 | |
| 1533 return renderView->selectionBounds(); | |
| 1534 } | |
| 1535 | |
| 1536 void FrameSelection::revealSelection(const ScrollAlignment& alignment, RevealExt entOption revealExtentOption) | 1523 void FrameSelection::revealSelection(const ScrollAlignment& alignment, RevealExt entOption revealExtentOption) |
| 1537 { | 1524 { |
| 1538 LayoutRect rect; | 1525 LayoutRect rect; |
| 1539 | 1526 |
| 1540 switch (selectionType()) { | 1527 switch (selectionType()) { |
| 1541 case NoSelection: | 1528 case NoSelection: |
| 1542 return; | 1529 return; |
| 1543 case CaretSelection: | 1530 case CaretSelection: |
| 1544 rect = absoluteCaretBounds(); | 1531 rect = absoluteCaretBounds(); |
| 1545 break; | 1532 break; |
| 1546 case RangeSelection: | 1533 case RangeSelection: |
| 1547 rect = revealExtentOption == RevealExtent ? VisiblePosition(extent()).ab soluteCaretBounds() : enclosingIntRect(bounds()); | 1534 Position position = revealExtentOption == RevealExtent ? extent() : base (); |
|
ojan
2015/01/14 19:49:19
This is the only change in behavior. The rest of t
| |
| 1535 rect = VisiblePosition(position).absoluteCaretBounds(); | |
| 1548 break; | 1536 break; |
| 1549 } | 1537 } |
| 1550 | 1538 |
| 1551 Position start = this->start(); | 1539 Position start = this->start(); |
| 1552 ASSERT(start.deprecatedNode()); | 1540 ASSERT(start.deprecatedNode()); |
| 1553 if (start.deprecatedNode() && start.deprecatedNode()->renderer()) { | 1541 if (start.deprecatedNode() && start.deprecatedNode()->renderer()) { |
| 1554 // FIXME: This code only handles scrolling the startContainer's layer, b ut | 1542 // FIXME: This code only handles scrolling the startContainer's layer, b ut |
| 1555 // the selection rect could intersect more than just that. | 1543 // the selection rect could intersect more than just that. |
| 1556 // See <rdar://problem/4799899>. | 1544 // See <rdar://problem/4799899>. |
| 1557 if (start.deprecatedNode()->renderer()->scrollRectToVisible(rect, alignm ent, alignment)) | 1545 if (start.deprecatedNode()->renderer()->scrollRectToVisible(rect, alignm ent, alignment)) |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1667 sel.showTreeForThis(); | 1655 sel.showTreeForThis(); |
| 1668 } | 1656 } |
| 1669 | 1657 |
| 1670 void showTree(const blink::FrameSelection* sel) | 1658 void showTree(const blink::FrameSelection* sel) |
| 1671 { | 1659 { |
| 1672 if (sel) | 1660 if (sel) |
| 1673 sel->showTreeForThis(); | 1661 sel->showTreeForThis(); |
| 1674 } | 1662 } |
| 1675 | 1663 |
| 1676 #endif | 1664 #endif |
| OLD | NEW |