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

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

Issue 1774123006: Implement link selection on alt+mouse drag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove static and rename function. Created 4 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
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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 newSelection.expandUsingGranularity(ParagraphGranularity); 425 newSelection.expandUsingGranularity(ParagraphGranularity);
426 } 426 }
427 427
428 return updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSe lectionToRespectUserSelectAll(innerNode, newSelection), ParagraphGranularity); 428 return updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSe lectionToRespectUserSelectAll(innerNode, newSelection), ParagraphGranularity);
429 } 429 }
430 430
431 void SelectionController::handleMousePressEvent(const MouseEventWithHitTestResul ts& event) 431 void SelectionController::handleMousePressEvent(const MouseEventWithHitTestResul ts& event)
432 { 432 {
433 // If we got the event back, that must mean it wasn't prevented, 433 // If we got the event back, that must mean it wasn't prevented,
434 // so it's allowed to start a drag or selection if it wasn't in a scrollbar. 434 // so it's allowed to start a drag or selection if it wasn't in a scrollbar.
435 m_mouseDownMayStartSelect = canMouseDownStartSelect(event.innerNode()) && !e vent.scrollbar(); 435 m_mouseDownMayStartSelect = (canMouseDownStartSelect(event.innerNode()) || m ayBeLinkSelection(event))
436 && !event.scrollbar();
436 m_mouseDownWasSingleClickInSelection = false; 437 m_mouseDownWasSingleClickInSelection = false;
437 // Avoid double-tap touch gesture confusion by restricting multi-click side 438 // Avoid double-tap touch gesture confusion by restricting multi-click side
438 // effects, e.g., word selection, to editable regions. 439 // effects, e.g., word selection, to editable regions.
439 m_mouseDownAllowsMultiClick = !event.event().fromTouch() || selection().hasE ditableStyle(); 440 m_mouseDownAllowsMultiClick = !event.event().fromTouch() || selection().hasE ditableStyle();
440 } 441 }
441 442
442 void SelectionController::handleMouseDraggedEvent(const MouseEventWithHitTestRes ults& event, const IntPoint& mouseDownPos, const LayoutPoint& dragStartPos, Node * mousePressNode, const IntPoint& lastKnownMousePosition) 443 void SelectionController::handleMouseDraggedEvent(const MouseEventWithHitTestRes ults& event, const IntPoint& mouseDownPos, const LayoutPoint& dragStartPos, Node * mousePressNode, const IntPoint& lastKnownMousePosition)
443 { 444 {
444 if (m_selectionState != SelectionState::ExtendedSelection) { 445 if (m_selectionState != SelectionState::ExtendedSelection) {
445 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active ); 446 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active );
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 void SelectionController::sendContextMenuEvent(const MouseEventWithHitTestResult s& mev, const LayoutPoint& position) 556 void SelectionController::sendContextMenuEvent(const MouseEventWithHitTestResult s& mev, const LayoutPoint& position)
556 { 557 {
557 if (selection().contains(position) 558 if (selection().contains(position)
558 || mev.scrollbar() 559 || mev.scrollbar()
559 // FIXME: In the editable case, word selection sometimes selects content that isn't underneath the mouse. 560 // FIXME: In the editable case, word selection sometimes selects content that isn't underneath the mouse.
560 // If the selection is non-editable, we do word selection to make it eas ier to use the contextual menu items 561 // If the selection is non-editable, we do word selection to make it eas ier to use the contextual menu items
561 // available for text selections. But only if we're above text. 562 // available for text selections. But only if we're above text.
562 || !(selection().isContentEditable() || (mev.innerNode() && mev.innerNod e()->isTextNode()))) 563 || !(selection().isContentEditable() || (mev.innerNode() && mev.innerNod e()->isTextNode())))
563 return; 564 return;
564 565
565 m_mouseDownMayStartSelect = true; // context menu events are always allowed to perform a selection 566 // Context menu events are always allowed to perform a selection.
567 TemporaryChange<bool> mouseDownMayStartSelectChange(m_mouseDownMayStartSelec t, true);
566 568
567 if (mev.hitTestResult().isMisspelled()) 569 if (mev.hitTestResult().isMisspelled())
568 return selectClosestMisspellingFromMouseEvent(mev); 570 return selectClosestMisspellingFromMouseEvent(mev);
569 571
570 if (!m_frame->editor().behavior().shouldSelectOnContextualMenuClick()) 572 if (!m_frame->editor().behavior().shouldSelectOnContextualMenuClick())
571 return; 573 return;
572 574
573 selectClosestWordOrLinkFromMouseEvent(mev); 575 selectClosestWordOrLinkFromMouseEvent(mev);
574 } 576 }
575 577
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 m_selectionState = SelectionState::PlacedCaret; 618 m_selectionState = SelectionState::PlacedCaret;
617 else 619 else
618 m_selectionState = SelectionState::HaveNotStartedSelection; 620 m_selectionState = SelectionState::HaveNotStartedSelection;
619 } 621 }
620 622
621 FrameSelection& SelectionController::selection() const 623 FrameSelection& SelectionController::selection() const
622 { 624 {
623 return m_frame->selection(); 625 return m_frame->selection();
624 } 626 }
625 627
628 bool mayBeLinkSelection(const MouseEventWithHitTestResults& event)
tkent 2016/03/25 03:33:02 This looks "isLinkSelection" to me. Why "mayBe"?
629 {
630 return event.event().altKey() && event.isOverLink();
631 }
632
626 } // namespace blink 633 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698