| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
| 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 RenderView* renderer = m_frame->contentRenderer(); | 707 RenderView* renderer = m_frame->contentRenderer(); |
| 708 if (!renderer) | 708 if (!renderer) |
| 709 return; | 709 return; |
| 710 | 710 |
| 711 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H
itTestRequest::Move | HitTestRequest::DisallowShadowContent); | 711 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H
itTestRequest::Move | HitTestRequest::DisallowShadowContent); |
| 712 HitTestResult result(view->windowToContents(m_lastKnownMousePosition)); | 712 HitTestResult result(view->windowToContents(m_lastKnownMousePosition)); |
| 713 renderer->hitTest(request, result); | 713 renderer->hitTest(request, result); |
| 714 updateSelectionForMouseDrag(result); | 714 updateSelectionForMouseDrag(result); |
| 715 } | 715 } |
| 716 | 716 |
| 717 static VisiblePosition selectionExtentRespectingEditingBoundary(const VisibleSel
ection& selection, const LayoutPoint& localPoint, Node* targetNode) | |
| 718 { | |
| 719 LayoutPoint selectionEndPoint = localPoint; | |
| 720 Element* editableElement = selection.rootEditableElement(); | |
| 721 | |
| 722 if (!targetNode->renderer()) | |
| 723 return VisiblePosition(); | |
| 724 | |
| 725 if (editableElement && !editableElement->contains(targetNode)) { | |
| 726 if (!editableElement->renderer()) | |
| 727 return VisiblePosition(); | |
| 728 | |
| 729 FloatPoint absolutePoint = targetNode->renderer()->localToAbsolute(Float
Point(selectionEndPoint)); | |
| 730 selectionEndPoint = roundedLayoutPoint(editableElement->renderer()->abso
luteToLocal(absolutePoint)); | |
| 731 targetNode = editableElement; | |
| 732 } | |
| 733 | |
| 734 return targetNode->renderer()->positionForPoint(selectionEndPoint); | |
| 735 } | |
| 736 | |
| 737 void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
t) | 717 void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
t) |
| 738 { | 718 { |
| 739 if (!m_mouseDownMayStartSelect) | 719 if (!m_mouseDownMayStartSelect) |
| 740 return; | 720 return; |
| 741 | 721 |
| 742 Node* target = hitTestResult.targetNode(); | 722 Node* target = hitTestResult.targetNode(); |
| 743 if (!target) | 723 if (!target) |
| 744 return; | 724 return; |
| 745 | 725 |
| 746 VisiblePosition targetPosition = selectionExtentRespectingEditingBoundary(m_
frame->selection()->selection(), hitTestResult.localPoint(), target); | 726 VisiblePosition targetPosition = visiblePositionRespectingEditingBoundary(m_
frame->selection()->selection(), hitTestResult.localPoint(), target); |
| 747 | |
| 748 // Don't modify the selection if we're not on a node. | 727 // Don't modify the selection if we're not on a node. |
| 749 if (targetPosition.isNull()) | 728 if (targetPosition.isNull()) |
| 750 return; | 729 return; |
| 751 | 730 |
| 752 // Restart the selection if this is the first mouse move. This work is usual
ly | 731 // Restart the selection if this is the first mouse move. This work is usual
ly |
| 753 // done in handleMousePressEvent, but not if the mouse press was on an exist
ing selection. | 732 // done in handleMousePressEvent, but not if the mouse press was on an exist
ing selection. |
| 754 VisibleSelection newSelection = m_frame->selection()->selection(); | 733 VisibleSelection newSelection = m_frame->selection()->selection(); |
| 755 | 734 |
| 756 #if ENABLE(SVG) | 735 #if ENABLE(SVG) |
| 757 // Special case to limit selection to the containing block for SVG text. | 736 // Special case to limit selection to the containing block for SVG text. |
| (...skipping 3150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3908 unsigned EventHandler::accessKeyModifiers() | 3887 unsigned EventHandler::accessKeyModifiers() |
| 3909 { | 3888 { |
| 3910 #if OS(DARWIN) | 3889 #if OS(DARWIN) |
| 3911 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3890 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 3912 #else | 3891 #else |
| 3913 return PlatformEvent::AltKey; | 3892 return PlatformEvent::AltKey; |
| 3914 #endif | 3893 #endif |
| 3915 } | 3894 } |
| 3916 | 3895 |
| 3917 } // namespace WebCore | 3896 } // namespace WebCore |
| OLD | NEW |