Chromium Code Reviews| 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 11 matching lines...) Expand all Loading... | |
| 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #include "config.h" | 28 #include "config.h" |
| 29 #include "core/page/EventHandler.h" | 29 #include "core/page/EventHandler.h" |
| 30 | 30 |
| 31 #include "HTMLNames.h" | 31 #include "HTMLNames.h" |
| 32 #include "SVGNames.h" | 32 #include "SVGNames.h" |
|
leviw_travelin_and_unemployed
2013/05/22 23:50:02
I don't think you meant to have all these SVG chan
cjhopman
2013/05/22 23:58:33
Looks like I rebased this change from ps#3 to ps#4
| |
| 33 #include "core/accessibility/AXObjectCache.h" | 33 #include "core/accessibility/AXObjectCache.h" |
| 34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
| 35 #include "core/dom/DocumentEventQueue.h" | 35 #include "core/dom/DocumentEventQueue.h" |
| 36 #include "core/dom/EventNames.h" | 36 #include "core/dom/EventNames.h" |
| 37 #include "core/dom/EventPathWalker.h" | 37 #include "core/dom/EventPathWalker.h" |
| 38 #include "core/dom/ExceptionCodePlaceholder.h" | 38 #include "core/dom/ExceptionCodePlaceholder.h" |
| 39 #include "core/dom/KeyboardEvent.h" | 39 #include "core/dom/KeyboardEvent.h" |
| 40 #include "core/dom/MouseEvent.h" | 40 #include "core/dom/MouseEvent.h" |
| 41 #include "core/dom/TextEvent.h" | 41 #include "core/dom/TextEvent.h" |
| 42 #include "core/dom/TouchEvent.h" | 42 #include "core/dom/TouchEvent.h" |
| (...skipping 648 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 3157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3899 unsigned EventHandler::accessKeyModifiers() | 3878 unsigned EventHandler::accessKeyModifiers() |
| 3900 { | 3879 { |
| 3901 #if OS(DARWIN) | 3880 #if OS(DARWIN) |
| 3902 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3881 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 3903 #else | 3882 #else |
| 3904 return PlatformEvent::AltKey; | 3883 return PlatformEvent::AltKey; |
| 3905 #endif | 3884 #endif |
| 3906 } | 3885 } |
| 3907 | 3886 |
| 3908 } // namespace WebCore | 3887 } // namespace WebCore |
| OLD | NEW |