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

Side by Side Diff: third_party/WebKit/Source/core/editing/SelectionController.cpp

Issue 2048733002: Selecting with shift+drag results in unexpected drag-n-drop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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 * Copyright (C) 2015 Google Inc. All rights reserved. 5 * Copyright (C) 2015 Google Inc. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 bool SelectionController::handleMousePressEventSingleClick(const MouseEventWithH itTestResults& event) 122 bool SelectionController::handleMousePressEventSingleClick(const MouseEventWithH itTestResults& event)
123 { 123 {
124 TRACE_EVENT0("blink", "SelectionController::handleMousePressEventSingleClick "); 124 TRACE_EVENT0("blink", "SelectionController::handleMousePressEventSingleClick ");
125 125
126 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 126 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
127 Node* innerNode = event.innerNode(); 127 Node* innerNode = event.innerNode();
128 if (!(innerNode && innerNode->layoutObject() && m_mouseDownMayStartSelect)) 128 if (!(innerNode && innerNode->layoutObject() && m_mouseDownMayStartSelect))
129 return false; 129 return false;
130 130
131 // Extend the selection if the Shift key is down, unless the click is in a l ink. 131 // Extend the selection if the Shift key is down, unless the click is in a l ink or image.
132 bool extendSelection = event.event().shiftKey() && !event.isOverLink(); 132 bool extendSelection = isExtendingSelection(event);
133 133
134 // Don't restart the selection when the mouse is pressed on an 134 // Don't restart the selection when the mouse is pressed on an
135 // existing selection so we can allow for text dragging. 135 // existing selection so we can allow for text dragging.
136 if (FrameView* view = m_frame->view()) { 136 if (FrameView* view = m_frame->view()) {
137 LayoutPoint vPoint = view->rootFrameToContents(event.event().position()) ; 137 LayoutPoint vPoint = view->rootFrameToContents(event.event().position()) ;
138 if (!extendSelection && selection().contains(vPoint)) { 138 if (!extendSelection && selection().contains(vPoint)) {
139 m_mouseDownWasSingleClickInSelection = true; 139 m_mouseDownWasSingleClickInSelection = true;
140 return false; 140 return false;
141 } 141 }
142 } 142 }
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 FrameSelection& SelectionController::selection() const 628 FrameSelection& SelectionController::selection() const
629 { 629 {
630 return m_frame->selection(); 630 return m_frame->selection();
631 } 631 }
632 632
633 bool isLinkSelection(const MouseEventWithHitTestResults& event) 633 bool isLinkSelection(const MouseEventWithHitTestResults& event)
634 { 634 {
635 return event.event().altKey() && event.isOverLink(); 635 return event.event().altKey() && event.isOverLink();
636 } 636 }
637 637
638 bool isExtendingSelection(const MouseEventWithHitTestResults& event)
639 {
640 DCHECK_LE(event.event().clickCount(), 1);
641
yosin_UTC9 2016/06/08 01:37:21 nit: no need to have an extra blank line here.
tonikitoo 2016/06/24 18:39:20 The assert was not actually right. I removed it.
642 bool isMouseDownOnLinkOrImage = event.isOverLink() || event.hitTestResult(). image();
643 return event.event().shiftKey() && !isMouseDownOnLinkOrImage;
644 }
645
638 } // namespace blink 646 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698