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 "RuntimeEnabledFeatures.h" |
32 #include "SVGNames.h" | 33 #include "SVGNames.h" |
33 #include "bindings/v8/ExceptionStatePlaceholder.h" | 34 #include "bindings/v8/ExceptionStatePlaceholder.h" |
34 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
35 #include "core/dom/DocumentEventQueue.h" | 36 #include "core/dom/DocumentEventQueue.h" |
36 #include "core/dom/DocumentMarkerController.h" | 37 #include "core/dom/DocumentMarkerController.h" |
37 #include "core/dom/EventNames.h" | 38 #include "core/dom/EventNames.h" |
38 #include "core/dom/EventPathWalker.h" | 39 #include "core/dom/EventPathWalker.h" |
39 #include "core/dom/FullscreenElementStack.h" | 40 #include "core/dom/FullscreenElementStack.h" |
40 #include "core/dom/KeyboardEvent.h" | 41 #include "core/dom/KeyboardEvent.h" |
41 #include "core/dom/MouseEvent.h" | 42 #include "core/dom/MouseEvent.h" |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 static inline bool dispatchSelectStart(Node* node) | 376 static inline bool dispatchSelectStart(Node* node) |
376 { | 377 { |
377 if (!node || !node->renderer()) | 378 if (!node || !node->renderer()) |
378 return true; | 379 return true; |
379 | 380 |
380 return node->dispatchEvent(Event::create(eventNames().selectstartEvent, true
, true)); | 381 return node->dispatchEvent(Event::create(eventNames().selectstartEvent, true
, true)); |
381 } | 382 } |
382 | 383 |
383 static VisibleSelection expandSelectionToRespectUserSelectAll(Node* targetNode,
const VisibleSelection& selection) | 384 static VisibleSelection expandSelectionToRespectUserSelectAll(Node* targetNode,
const VisibleSelection& selection) |
384 { | 385 { |
385 #if ENABLE(USERSELECT_ALL) | |
386 Node* rootUserSelectAll = Position::rootUserSelectAllForNode(targetNode); | 386 Node* rootUserSelectAll = Position::rootUserSelectAllForNode(targetNode); |
387 if (!rootUserSelectAll) | 387 if (!rootUserSelectAll) |
388 return selection; | 388 return selection; |
389 | 389 |
390 VisibleSelection newSelection(selection); | 390 VisibleSelection newSelection(selection); |
391 newSelection.setBase(positionBeforeNode(rootUserSelectAll).upstream(CanCross
EditingBoundary)); | 391 newSelection.setBase(positionBeforeNode(rootUserSelectAll).upstream(CanCross
EditingBoundary)); |
392 newSelection.setExtent(positionAfterNode(rootUserSelectAll).downstream(CanCr
ossEditingBoundary)); | 392 newSelection.setExtent(positionAfterNode(rootUserSelectAll).downstream(CanCr
ossEditingBoundary)); |
393 | 393 |
394 return newSelection; | 394 return newSelection; |
395 #else | |
396 UNUSED_PARAM(targetNode); | |
397 return selection; | |
398 #endif | |
399 } | 395 } |
400 | 396 |
401 bool EventHandler::updateSelectionForMouseDownDispatchingSelectStart(Node* targe
tNode, const VisibleSelection& selection, TextGranularity granularity) | 397 bool EventHandler::updateSelectionForMouseDownDispatchingSelectStart(Node* targe
tNode, const VisibleSelection& selection, TextGranularity granularity) |
402 { | 398 { |
403 if (Position::nodeIsUserSelectNone(targetNode)) | 399 if (Position::nodeIsUserSelectNone(targetNode)) |
404 return false; | 400 return false; |
405 | 401 |
406 if (!dispatchSelectStart(targetNode)) | 402 if (!dispatchSelectStart(targetNode)) |
407 return false; | 403 return false; |
408 | 404 |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 | 760 |
765 if (m_selectionInitiationState == HaveNotStartedSelection && !dispatchSelect
Start(target)) | 761 if (m_selectionInitiationState == HaveNotStartedSelection && !dispatchSelect
Start(target)) |
766 return; | 762 return; |
767 | 763 |
768 if (m_selectionInitiationState != ExtendedSelection) { | 764 if (m_selectionInitiationState != ExtendedSelection) { |
769 // Always extend selection here because it's caused by a mouse drag | 765 // Always extend selection here because it's caused by a mouse drag |
770 m_selectionInitiationState = ExtendedSelection; | 766 m_selectionInitiationState = ExtendedSelection; |
771 newSelection = VisibleSelection(targetPosition); | 767 newSelection = VisibleSelection(targetPosition); |
772 } | 768 } |
773 | 769 |
774 #if ENABLE(USERSELECT_ALL) | 770 if (RuntimeEnabledFeatures::userSelectAllEnabled()) { |
775 Node* rootUserSelectAllForMousePressNode = Position::rootUserSelectAllForNod
e(m_mousePressNode.get()); | 771 Node* rootUserSelectAllForMousePressNode = Position::rootUserSelectAllFo
rNode(m_mousePressNode.get()); |
776 if (rootUserSelectAllForMousePressNode && rootUserSelectAllForMousePressNode
== Position::rootUserSelectAllForNode(target)) { | 772 if (rootUserSelectAllForMousePressNode && rootUserSelectAllForMousePress
Node == Position::rootUserSelectAllForNode(target)) { |
777 newSelection.setBase(positionBeforeNode(rootUserSelectAllForMousePressNo
de).upstream(CanCrossEditingBoundary)); | 773 newSelection.setBase(positionBeforeNode(rootUserSelectAllForMousePre
ssNode).upstream(CanCrossEditingBoundary)); |
778 newSelection.setExtent(positionAfterNode(rootUserSelectAllForMousePressN
ode).downstream(CanCrossEditingBoundary)); | 774 newSelection.setExtent(positionAfterNode(rootUserSelectAllForMousePr
essNode).downstream(CanCrossEditingBoundary)); |
| 775 } else { |
| 776 // Reset base for user select all when base is inside user-select-al
l area and extent < base. |
| 777 if (rootUserSelectAllForMousePressNode && comparePositions(target->r
enderer()->positionForPoint(hitTestResult.localPoint()), m_mousePressNode->rende
rer()->positionForPoint(m_dragStartPos)) < 0) |
| 778 newSelection.setBase(positionAfterNode(rootUserSelectAllForMouse
PressNode).downstream(CanCrossEditingBoundary)); |
| 779 |
| 780 Node* rootUserSelectAllForTarget = Position::rootUserSelectAllForNod
e(target); |
| 781 if (rootUserSelectAllForTarget && m_mousePressNode->renderer() && co
mparePositions(target->renderer()->positionForPoint(hitTestResult.localPoint()),
m_mousePressNode->renderer()->positionForPoint(m_dragStartPos)) < 0) |
| 782 newSelection.setExtent(positionBeforeNode(rootUserSelectAllForTa
rget).upstream(CanCrossEditingBoundary)); |
| 783 else if (rootUserSelectAllForTarget && m_mousePressNode->renderer()) |
| 784 newSelection.setExtent(positionAfterNode(rootUserSelectAllForTar
get).downstream(CanCrossEditingBoundary)); |
| 785 else |
| 786 newSelection.setExtent(targetPosition); |
| 787 } |
779 } else { | 788 } else { |
780 // Reset base for user select all when base is inside user-select-all ar
ea and extent < base. | 789 newSelection.setExtent(targetPosition); |
781 if (rootUserSelectAllForMousePressNode && comparePositions(target->rende
rer()->positionForPoint(hitTestResult.localPoint()), m_mousePressNode->renderer(
)->positionForPoint(m_dragStartPos)) < 0) | |
782 newSelection.setBase(positionAfterNode(rootUserSelectAllForMousePres
sNode).downstream(CanCrossEditingBoundary)); | |
783 | |
784 Node* rootUserSelectAllForTarget = Position::rootUserSelectAllForNode(ta
rget); | |
785 if (rootUserSelectAllForTarget && m_mousePressNode->renderer() && compar
ePositions(target->renderer()->positionForPoint(hitTestResult.localPoint()), m_m
ousePressNode->renderer()->positionForPoint(m_dragStartPos)) < 0) | |
786 newSelection.setExtent(positionBeforeNode(rootUserSelectAllForTarget
).upstream(CanCrossEditingBoundary)); | |
787 else if (rootUserSelectAllForTarget && m_mousePressNode->renderer()) | |
788 newSelection.setExtent(positionAfterNode(rootUserSelectAllForTarget)
.downstream(CanCrossEditingBoundary)); | |
789 else | |
790 newSelection.setExtent(targetPosition); | |
791 } | 790 } |
792 #else | |
793 newSelection.setExtent(targetPosition); | |
794 #endif | |
795 | 791 |
796 if (m_frame->selection()->granularity() != CharacterGranularity) | 792 if (m_frame->selection()->granularity() != CharacterGranularity) |
797 newSelection.expandUsingGranularity(m_frame->selection()->granularity())
; | 793 newSelection.expandUsingGranularity(m_frame->selection()->granularity())
; |
798 | 794 |
799 m_frame->selection()->setNonDirectionalSelectionIfNeeded(newSelection, m_fra
me->selection()->granularity(), | 795 m_frame->selection()->setNonDirectionalSelectionIfNeeded(newSelection, m_fra
me->selection()->granularity(), |
800 FrameSelection::AdjustEndpointsAtBidiBoundary); | 796 FrameSelection::AdjustEndpointsAtBidiBoundary); |
801 } | 797 } |
802 | 798 |
803 void EventHandler::lostMouseCapture() | 799 void EventHandler::lostMouseCapture() |
804 { | 800 { |
(...skipping 3035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3840 unsigned EventHandler::accessKeyModifiers() | 3836 unsigned EventHandler::accessKeyModifiers() |
3841 { | 3837 { |
3842 #if OS(DARWIN) | 3838 #if OS(DARWIN) |
3843 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3839 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3844 #else | 3840 #else |
3845 return PlatformEvent::AltKey; | 3841 return PlatformEvent::AltKey; |
3846 #endif | 3842 #endif |
3847 } | 3843 } |
3848 | 3844 |
3849 } // namespace WebCore | 3845 } // namespace WebCore |
OLD | NEW |