| 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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 RenderView* renderer = m_frame->contentRenderer(); | 691 RenderView* renderer = m_frame->contentRenderer(); |
| 692 if (!renderer) | 692 if (!renderer) |
| 693 return; | 693 return; |
| 694 | 694 |
| 695 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H
itTestRequest::Move | HitTestRequest::DisallowShadowContent); | 695 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H
itTestRequest::Move | HitTestRequest::DisallowShadowContent); |
| 696 HitTestResult result(view->windowToContents(m_lastKnownMousePosition)); | 696 HitTestResult result(view->windowToContents(m_lastKnownMousePosition)); |
| 697 renderer->hitTest(request, result); | 697 renderer->hitTest(request, result); |
| 698 updateSelectionForMouseDrag(result); | 698 updateSelectionForMouseDrag(result); |
| 699 } | 699 } |
| 700 | 700 |
| 701 static VisiblePosition selectionExtentRespectingEditingBoundary(const VisibleSel
ection& selection, const LayoutPoint& localPoint, Node* targetNode) | |
| 702 { | |
| 703 LayoutPoint selectionEndPoint = localPoint; | |
| 704 Element* editableElement = selection.rootEditableElement(); | |
| 705 | |
| 706 if (!targetNode->renderer()) | |
| 707 return VisiblePosition(); | |
| 708 | |
| 709 if (editableElement && !editableElement->contains(targetNode)) { | |
| 710 if (!editableElement->renderer()) | |
| 711 return VisiblePosition(); | |
| 712 | |
| 713 FloatPoint absolutePoint = targetNode->renderer()->localToAbsolute(Float
Point(selectionEndPoint)); | |
| 714 selectionEndPoint = roundedLayoutPoint(editableElement->renderer()->abso
luteToLocal(absolutePoint)); | |
| 715 targetNode = editableElement; | |
| 716 } | |
| 717 | |
| 718 return targetNode->renderer()->positionForPoint(selectionEndPoint); | |
| 719 } | |
| 720 | |
| 721 void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
t) | 701 void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
t) |
| 722 { | 702 { |
| 723 if (!m_mouseDownMayStartSelect) | 703 if (!m_mouseDownMayStartSelect) |
| 724 return; | 704 return; |
| 725 | 705 |
| 726 Node* target = hitTestResult.targetNode(); | 706 Node* target = hitTestResult.targetNode(); |
| 727 if (!target) | 707 if (!target) |
| 728 return; | 708 return; |
| 729 | 709 |
| 730 VisiblePosition targetPosition = selectionExtentRespectingEditingBoundary(m_
frame->selection()->selection(), hitTestResult.localPoint(), target); | 710 VisiblePosition targetPosition = m_frame->selection()->selection().visiblePo
sitionRespectingEditingBoundary(hitTestResult.localPoint(), target); |
| 731 | |
| 732 // Don't modify the selection if we're not on a node. | 711 // Don't modify the selection if we're not on a node. |
| 733 if (targetPosition.isNull()) | 712 if (targetPosition.isNull()) |
| 734 return; | 713 return; |
| 735 | 714 |
| 736 // Restart the selection if this is the first mouse move. This work is usual
ly | 715 // Restart the selection if this is the first mouse move. This work is usual
ly |
| 737 // done in handleMousePressEvent, but not if the mouse press was on an exist
ing selection. | 716 // done in handleMousePressEvent, but not if the mouse press was on an exist
ing selection. |
| 738 VisibleSelection newSelection = m_frame->selection()->selection(); | 717 VisibleSelection newSelection = m_frame->selection()->selection(); |
| 739 | 718 |
| 740 // Special case to limit selection to the containing block for SVG text. | 719 // Special case to limit selection to the containing block for SVG text. |
| 741 // FIXME: Isn't there a better non-SVG-specific way to do this? | 720 // FIXME: Isn't there a better non-SVG-specific way to do this? |
| (...skipping 3163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3905 unsigned EventHandler::accessKeyModifiers() | 3884 unsigned EventHandler::accessKeyModifiers() |
| 3906 { | 3885 { |
| 3907 #if OS(DARWIN) | 3886 #if OS(DARWIN) |
| 3908 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3887 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 3909 #else | 3888 #else |
| 3910 return PlatformEvent::AltKey; | 3889 return PlatformEvent::AltKey; |
| 3911 #endif | 3890 #endif |
| 3912 } | 3891 } |
| 3913 | 3892 |
| 3914 } // namespace WebCore | 3893 } // namespace WebCore |
| OLD | NEW |