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

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

Issue 188033005: Have Position deal with more references (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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
« no previous file with comments | « Source/core/html/HTMLTextFormControlElement.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 return node->dispatchEvent(Event::createCancelableBubble(EventTypeNames::sel ectstart)); 389 return node->dispatchEvent(Event::createCancelableBubble(EventTypeNames::sel ectstart));
390 } 390 }
391 391
392 static VisibleSelection expandSelectionToRespectUserSelectAll(Node* targetNode, const VisibleSelection& selection) 392 static VisibleSelection expandSelectionToRespectUserSelectAll(Node* targetNode, const VisibleSelection& selection)
393 { 393 {
394 Node* rootUserSelectAll = Position::rootUserSelectAllForNode(targetNode); 394 Node* rootUserSelectAll = Position::rootUserSelectAllForNode(targetNode);
395 if (!rootUserSelectAll) 395 if (!rootUserSelectAll)
396 return selection; 396 return selection;
397 397
398 VisibleSelection newSelection(selection); 398 VisibleSelection newSelection(selection);
399 newSelection.setBase(positionBeforeNode(rootUserSelectAll).upstream(CanCross EditingBoundary)); 399 newSelection.setBase(positionBeforeNode(*rootUserSelectAll).upstream(CanCros sEditingBoundary));
400 newSelection.setExtent(positionAfterNode(rootUserSelectAll).downstream(CanCr ossEditingBoundary)); 400 newSelection.setExtent(positionAfterNode(*rootUserSelectAll).downstream(CanC rossEditingBoundary));
401 401
402 return newSelection; 402 return newSelection;
403 } 403 }
404 404
405 bool EventHandler::updateSelectionForMouseDownDispatchingSelectStart(Node* targe tNode, const VisibleSelection& selection, TextGranularity granularity) 405 bool EventHandler::updateSelectionForMouseDownDispatchingSelectStart(Node* targe tNode, const VisibleSelection& selection, TextGranularity granularity)
406 { 406 {
407 if (Position::nodeIsUserSelectNone(targetNode)) 407 if (Position::nodeIsUserSelectNone(targetNode))
408 return false; 408 return false;
409 409
410 if (!dispatchSelectStart(targetNode)) 410 if (!dispatchSelectStart(targetNode))
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 772
773 if (m_selectionInitiationState != ExtendedSelection) { 773 if (m_selectionInitiationState != ExtendedSelection) {
774 // Always extend selection here because it's caused by a mouse drag 774 // Always extend selection here because it's caused by a mouse drag
775 m_selectionInitiationState = ExtendedSelection; 775 m_selectionInitiationState = ExtendedSelection;
776 newSelection = VisibleSelection(targetPosition); 776 newSelection = VisibleSelection(targetPosition);
777 } 777 }
778 778
779 if (RuntimeEnabledFeatures::userSelectAllEnabled()) { 779 if (RuntimeEnabledFeatures::userSelectAllEnabled()) {
780 Node* rootUserSelectAllForMousePressNode = Position::rootUserSelectAllFo rNode(m_mousePressNode.get()); 780 Node* rootUserSelectAllForMousePressNode = Position::rootUserSelectAllFo rNode(m_mousePressNode.get());
781 if (rootUserSelectAllForMousePressNode && rootUserSelectAllForMousePress Node == Position::rootUserSelectAllForNode(target)) { 781 if (rootUserSelectAllForMousePressNode && rootUserSelectAllForMousePress Node == Position::rootUserSelectAllForNode(target)) {
782 newSelection.setBase(positionBeforeNode(rootUserSelectAllForMousePre ssNode).upstream(CanCrossEditingBoundary)); 782 newSelection.setBase(positionBeforeNode(*rootUserSelectAllForMousePr essNode).upstream(CanCrossEditingBoundary));
783 newSelection.setExtent(positionAfterNode(rootUserSelectAllForMousePr essNode).downstream(CanCrossEditingBoundary)); 783 newSelection.setExtent(positionAfterNode(*rootUserSelectAllForMouseP ressNode).downstream(CanCrossEditingBoundary));
784 } else { 784 } else {
785 // Reset base for user select all when base is inside user-select-al l area and extent < base. 785 // Reset base for user select all when base is inside user-select-al l area and extent < base.
786 if (rootUserSelectAllForMousePressNode && comparePositions(target->r enderer()->positionForPoint(hitTestResult.localPoint()), m_mousePressNode->rende rer()->positionForPoint(m_dragStartPos)) < 0) 786 if (rootUserSelectAllForMousePressNode && comparePositions(target->r enderer()->positionForPoint(hitTestResult.localPoint()), m_mousePressNode->rende rer()->positionForPoint(m_dragStartPos)) < 0)
787 newSelection.setBase(positionAfterNode(rootUserSelectAllForMouse PressNode).downstream(CanCrossEditingBoundary)); 787 newSelection.setBase(positionAfterNode(*rootUserSelectAllForMous ePressNode).downstream(CanCrossEditingBoundary));
788 788
789 Node* rootUserSelectAllForTarget = Position::rootUserSelectAllForNod e(target); 789 Node* rootUserSelectAllForTarget = Position::rootUserSelectAllForNod e(target);
790 if (rootUserSelectAllForTarget && m_mousePressNode->renderer() && co mparePositions(target->renderer()->positionForPoint(hitTestResult.localPoint()), m_mousePressNode->renderer()->positionForPoint(m_dragStartPos)) < 0) 790 if (rootUserSelectAllForTarget && m_mousePressNode->renderer() && co mparePositions(target->renderer()->positionForPoint(hitTestResult.localPoint()), m_mousePressNode->renderer()->positionForPoint(m_dragStartPos)) < 0)
791 newSelection.setExtent(positionBeforeNode(rootUserSelectAllForTa rget).upstream(CanCrossEditingBoundary)); 791 newSelection.setExtent(positionBeforeNode(*rootUserSelectAllForT arget).upstream(CanCrossEditingBoundary));
792 else if (rootUserSelectAllForTarget && m_mousePressNode->renderer()) 792 else if (rootUserSelectAllForTarget && m_mousePressNode->renderer())
793 newSelection.setExtent(positionAfterNode(rootUserSelectAllForTar get).downstream(CanCrossEditingBoundary)); 793 newSelection.setExtent(positionAfterNode(*rootUserSelectAllForTa rget).downstream(CanCrossEditingBoundary));
794 else 794 else
795 newSelection.setExtent(targetPosition); 795 newSelection.setExtent(targetPosition);
796 } 796 }
797 } else { 797 } else {
798 newSelection.setExtent(targetPosition); 798 newSelection.setExtent(targetPosition);
799 } 799 }
800 800
801 if (m_frame->selection().granularity() != CharacterGranularity) 801 if (m_frame->selection().granularity() != CharacterGranularity)
802 newSelection.expandUsingGranularity(m_frame->selection().granularity()); 802 newSelection.expandUsingGranularity(m_frame->selection().granularity());
803 803
(...skipping 3221 matching lines...) Expand 10 before | Expand all | Expand 10 after
4025 unsigned EventHandler::accessKeyModifiers() 4025 unsigned EventHandler::accessKeyModifiers()
4026 { 4026 {
4027 #if OS(MACOSX) 4027 #if OS(MACOSX)
4028 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 4028 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
4029 #else 4029 #else
4030 return PlatformEvent::AltKey; 4030 return PlatformEvent::AltKey;
4031 #endif 4031 #endif
4032 } 4032 }
4033 4033
4034 } // namespace WebCore 4034 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/HTMLTextFormControlElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698