Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: Source/core/page/EventHandler.cpp

Issue 22751005: Convert USERSELECT_ALL to a runtime enabled feature. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review feedback. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 if (!RuntimeEnabledFeatures::userSelectAllEnabled())
adamk 2013/08/09 22:28:34 Same here as before, the null check will do the ri
387 return selection;
388
386 Node* rootUserSelectAll = Position::rootUserSelectAllForNode(targetNode); 389 Node* rootUserSelectAll = Position::rootUserSelectAllForNode(targetNode);
387 if (!rootUserSelectAll) 390 if (!rootUserSelectAll)
388 return selection; 391 return selection;
389 392
390 VisibleSelection newSelection(selection); 393 VisibleSelection newSelection(selection);
391 newSelection.setBase(positionBeforeNode(rootUserSelectAll).upstream(CanCross EditingBoundary)); 394 newSelection.setBase(positionBeforeNode(rootUserSelectAll).upstream(CanCross EditingBoundary));
392 newSelection.setExtent(positionAfterNode(rootUserSelectAll).downstream(CanCr ossEditingBoundary)); 395 newSelection.setExtent(positionAfterNode(rootUserSelectAll).downstream(CanCr ossEditingBoundary));
393 396
394 return newSelection; 397 return newSelection;
395 #else
396 UNUSED_PARAM(targetNode);
397 return selection;
398 #endif
399 } 398 }
400 399
401 bool EventHandler::updateSelectionForMouseDownDispatchingSelectStart(Node* targe tNode, const VisibleSelection& selection, TextGranularity granularity) 400 bool EventHandler::updateSelectionForMouseDownDispatchingSelectStart(Node* targe tNode, const VisibleSelection& selection, TextGranularity granularity)
402 { 401 {
403 if (Position::nodeIsUserSelectNone(targetNode)) 402 if (Position::nodeIsUserSelectNone(targetNode))
404 return false; 403 return false;
405 404
406 if (!dispatchSelectStart(targetNode)) 405 if (!dispatchSelectStart(targetNode))
407 return false; 406 return false;
408 407
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 763
765 if (m_selectionInitiationState == HaveNotStartedSelection && !dispatchSelect Start(target)) 764 if (m_selectionInitiationState == HaveNotStartedSelection && !dispatchSelect Start(target))
766 return; 765 return;
767 766
768 if (m_selectionInitiationState != ExtendedSelection) { 767 if (m_selectionInitiationState != ExtendedSelection) {
769 // Always extend selection here because it's caused by a mouse drag 768 // Always extend selection here because it's caused by a mouse drag
770 m_selectionInitiationState = ExtendedSelection; 769 m_selectionInitiationState = ExtendedSelection;
771 newSelection = VisibleSelection(targetPosition); 770 newSelection = VisibleSelection(targetPosition);
772 } 771 }
773 772
774 #if ENABLE(USERSELECT_ALL) 773 if (RuntimeEnabledFeatures::userSelectAllEnabled()) {
775 Node* rootUserSelectAllForMousePressNode = Position::rootUserSelectAllForNod e(m_mousePressNode.get()); 774 Node* rootUserSelectAllForMousePressNode = Position::rootUserSelectAllFo rNode(m_mousePressNode.get());
776 if (rootUserSelectAllForMousePressNode && rootUserSelectAllForMousePressNode == Position::rootUserSelectAllForNode(target)) { 775 if (rootUserSelectAllForMousePressNode && rootUserSelectAllForMousePress Node == Position::rootUserSelectAllForNode(target)) {
777 newSelection.setBase(positionBeforeNode(rootUserSelectAllForMousePressNo de).upstream(CanCrossEditingBoundary)); 776 newSelection.setBase(positionBeforeNode(rootUserSelectAllForMousePre ssNode).upstream(CanCrossEditingBoundary));
778 newSelection.setExtent(positionAfterNode(rootUserSelectAllForMousePressN ode).downstream(CanCrossEditingBoundary)); 777 newSelection.setExtent(positionAfterNode(rootUserSelectAllForMousePr essNode).downstream(CanCrossEditingBoundary));
778 } else {
779 // Reset base for user select all when base is inside user-select-al l area and extent < base.
780 if (rootUserSelectAllForMousePressNode && comparePositions(target->r enderer()->positionForPoint(hitTestResult.localPoint()), m_mousePressNode->rende rer()->positionForPoint(m_dragStartPos)) < 0)
781 newSelection.setBase(positionAfterNode(rootUserSelectAllForMouse PressNode).downstream(CanCrossEditingBoundary));
782
783 Node* rootUserSelectAllForTarget = Position::rootUserSelectAllForNod e(target);
784 if (rootUserSelectAllForTarget && m_mousePressNode->renderer() && co mparePositions(target->renderer()->positionForPoint(hitTestResult.localPoint()), m_mousePressNode->renderer()->positionForPoint(m_dragStartPos)) < 0)
785 newSelection.setExtent(positionBeforeNode(rootUserSelectAllForTa rget).upstream(CanCrossEditingBoundary));
786 else if (rootUserSelectAllForTarget && m_mousePressNode->renderer())
787 newSelection.setExtent(positionAfterNode(rootUserSelectAllForTar get).downstream(CanCrossEditingBoundary));
788 else
789 newSelection.setExtent(targetPosition);
790 }
779 } else { 791 } else {
780 // Reset base for user select all when base is inside user-select-all ar ea and extent < base. 792 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 } 793 }
792 #else
793 newSelection.setExtent(targetPosition);
794 #endif
795 794
796 if (m_frame->selection()->granularity() != CharacterGranularity) 795 if (m_frame->selection()->granularity() != CharacterGranularity)
797 newSelection.expandUsingGranularity(m_frame->selection()->granularity()) ; 796 newSelection.expandUsingGranularity(m_frame->selection()->granularity()) ;
798 797
799 m_frame->selection()->setNonDirectionalSelectionIfNeeded(newSelection, m_fra me->selection()->granularity(), 798 m_frame->selection()->setNonDirectionalSelectionIfNeeded(newSelection, m_fra me->selection()->granularity(),
800 FrameSelection::AdjustEndpointsAtBidiBoundary); 799 FrameSelection::AdjustEndpointsAtBidiBoundary);
801 } 800 }
802 801
803 void EventHandler::lostMouseCapture() 802 void EventHandler::lostMouseCapture()
804 { 803 {
(...skipping 3035 matching lines...) Expand 10 before | Expand all | Expand 10 after
3840 unsigned EventHandler::accessKeyModifiers() 3839 unsigned EventHandler::accessKeyModifiers()
3841 { 3840 {
3842 #if OS(DARWIN) 3841 #if OS(DARWIN)
3843 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3842 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3844 #else 3843 #else
3845 return PlatformEvent::AltKey; 3844 return PlatformEvent::AltKey;
3846 #endif 3845 #endif
3847 } 3846 }
3848 3847
3849 } // namespace WebCore 3848 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698