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 * 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 bool SelectionController::handleMousePressEventDoubleClick(const MouseEventWithH
itTestResults& event) | 401 bool SelectionController::handleMousePressEventDoubleClick(const MouseEventWithH
itTestResults& event) |
402 { | 402 { |
403 TRACE_EVENT0("blink", "SelectionController::handleMousePressEventDoubleClick
"); | 403 TRACE_EVENT0("blink", "SelectionController::handleMousePressEventDoubleClick
"); |
404 | 404 |
405 if (!selection().isAvailable()) | 405 if (!selection().isAvailable()) |
406 return false; | 406 return false; |
407 | 407 |
408 if (!m_mouseDownAllowsMultiClick) | 408 if (!m_mouseDownAllowsMultiClick) |
409 return handleMousePressEventSingleClick(event); | 409 return handleMousePressEventSingleClick(event); |
410 | 410 |
411 if (event.event().button() != LeftButton) | 411 if (event.event().pointerProperties().button != WebPointerProperties::Button
::Left) |
412 return false; | 412 return false; |
413 | 413 |
414 if (selection().isRange()) { | 414 if (selection().isRange()) { |
415 // A double-click when range is already selected | 415 // A double-click when range is already selected |
416 // should not change the selection. So, do not call | 416 // should not change the selection. So, do not call |
417 // selectClosestWordFromMouseEvent, but do set | 417 // selectClosestWordFromMouseEvent, but do set |
418 // m_beganSelectingText to prevent handleMouseReleaseEvent | 418 // m_beganSelectingText to prevent handleMouseReleaseEvent |
419 // from setting caret selection. | 419 // from setting caret selection. |
420 m_selectionState = SelectionState::ExtendedSelection; | 420 m_selectionState = SelectionState::ExtendedSelection; |
421 } else { | 421 } else { |
422 selectClosestWordFromMouseEvent(event); | 422 selectClosestWordFromMouseEvent(event); |
423 } | 423 } |
424 return true; | 424 return true; |
425 } | 425 } |
426 | 426 |
427 bool SelectionController::handleMousePressEventTripleClick(const MouseEventWithH
itTestResults& event) | 427 bool SelectionController::handleMousePressEventTripleClick(const MouseEventWithH
itTestResults& event) |
428 { | 428 { |
429 TRACE_EVENT0("blink", "SelectionController::handleMousePressEventTripleClick
"); | 429 TRACE_EVENT0("blink", "SelectionController::handleMousePressEventTripleClick
"); |
430 | 430 |
431 if (!selection().isAvailable()) { | 431 if (!selection().isAvailable()) { |
432 // editing/shadow/doubleclick-on-meter-in-shadow-crash.html reach here. | 432 // editing/shadow/doubleclick-on-meter-in-shadow-crash.html reach here. |
433 return false; | 433 return false; |
434 } | 434 } |
435 | 435 |
436 if (!m_mouseDownAllowsMultiClick) | 436 if (!m_mouseDownAllowsMultiClick) |
437 return handleMousePressEventSingleClick(event); | 437 return handleMousePressEventSingleClick(event); |
438 | 438 |
439 if (event.event().button() != LeftButton) | 439 if (event.event().pointerProperties().button != WebPointerProperties::Button
::Left) |
440 return false; | 440 return false; |
441 | 441 |
442 Node* innerNode = event.innerNode(); | 442 Node* innerNode = event.innerNode(); |
443 if (!(innerNode && innerNode->layoutObject() && m_mouseDownMayStartSelect)) | 443 if (!(innerNode && innerNode->layoutObject() && m_mouseDownMayStartSelect)) |
444 return false; | 444 return false; |
445 | 445 |
446 VisibleSelectionInFlatTree newSelection; | 446 VisibleSelectionInFlatTree newSelection; |
447 const VisiblePositionInFlatTree& pos = visiblePositionOfHitTestResult(event.
hitTestResult()); | 447 const VisiblePositionInFlatTree& pos = visiblePositionOfHitTestResult(event.
hitTestResult()); |
448 if (pos.isNotNull()) { | 448 if (pos.isNotNull()) { |
449 newSelection = VisibleSelectionInFlatTree(pos); | 449 newSelection = VisibleSelectionInFlatTree(pos); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 | 507 |
508 bool handled = false; | 508 bool handled = false; |
509 m_mouseDownMayStartSelect = false; | 509 m_mouseDownMayStartSelect = false; |
510 // Clear the selection if the mouse didn't move after the last mouse | 510 // Clear the selection if the mouse didn't move after the last mouse |
511 // press and it's not a context menu click. We do this so when clicking | 511 // press and it's not a context menu click. We do this so when clicking |
512 // on the selection, the selection goes away. However, if we are | 512 // on the selection, the selection goes away. However, if we are |
513 // editing, place the caret. | 513 // editing, place the caret. |
514 if (m_mouseDownWasSingleClickInSelection && m_selectionState != SelectionSta
te::ExtendedSelection | 514 if (m_mouseDownWasSingleClickInSelection && m_selectionState != SelectionSta
te::ExtendedSelection |
515 && dragStartPos == event.event().position() | 515 && dragStartPos == event.event().position() |
516 && selection().isRange() | 516 && selection().isRange() |
517 && event.event().button() != RightButton) { | 517 && event.event().pointerProperties().button != WebPointerProperties::But
ton::Right) { |
518 VisibleSelectionInFlatTree newSelection; | 518 VisibleSelectionInFlatTree newSelection; |
519 Node* node = event.innerNode(); | 519 Node* node = event.innerNode(); |
520 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBr
owsingEnabled(); | 520 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBr
owsingEnabled(); |
521 if (node && node->layoutObject() && (caretBrowsing || hasEditableStyle(*
node))) { | 521 if (node && node->layoutObject() && (caretBrowsing || hasEditableStyle(*
node))) { |
522 const VisiblePositionInFlatTree pos = visiblePositionOfHitTestResult
(event.hitTestResult()); | 522 const VisiblePositionInFlatTree pos = visiblePositionOfHitTestResult
(event.hitTestResult()); |
523 newSelection = VisibleSelectionInFlatTree(pos); | 523 newSelection = VisibleSelectionInFlatTree(pos); |
524 } | 524 } |
525 | 525 |
526 setSelectionIfNeeded(selection(), newSelection); | 526 setSelectionIfNeeded(selection(), newSelection); |
527 | 527 |
528 handled = true; | 528 handled = true; |
529 } | 529 } |
530 | 530 |
531 selection().notifyLayoutObjectOfSelectionChange(UserTriggered); | 531 selection().notifyLayoutObjectOfSelectionChange(UserTriggered); |
532 | 532 |
533 selection().selectFrameElementInParentIfFullySelected(); | 533 selection().selectFrameElementInParentIfFullySelected(); |
534 | 534 |
535 if (event.event().button() == MiddleButton && !event.isOverLink()) { | 535 if (event.event().pointerProperties().button == WebPointerProperties::Button
::Middle && !event.isOverLink()) { |
536 // Ignore handled, since we want to paste to where the caret was placed
anyway. | 536 // Ignore handled, since we want to paste to where the caret was placed
anyway. |
537 handled = handlePasteGlobalSelection(event.event()) || handled; | 537 handled = handlePasteGlobalSelection(event.event()) || handled; |
538 } | 538 } |
539 | 539 |
540 return handled; | 540 return handled; |
541 } | 541 } |
542 | 542 |
543 bool SelectionController::handlePasteGlobalSelection(const PlatformMouseEvent& m
ouseEvent) | 543 bool SelectionController::handlePasteGlobalSelection(const PlatformMouseEvent& m
ouseEvent) |
544 { | 544 { |
545 // If the event was a middle click, attempt to copy global selection in afte
r | 545 // If the event was a middle click, attempt to copy global selection in afte
r |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 return event.event().altKey() && event.isOverLink(); | 672 return event.event().altKey() && event.isOverLink(); |
673 } | 673 } |
674 | 674 |
675 bool isExtendingSelection(const MouseEventWithHitTestResults& event) | 675 bool isExtendingSelection(const MouseEventWithHitTestResults& event) |
676 { | 676 { |
677 bool isMouseDownOnLinkOrImage = event.isOverLink() || event.hitTestResult().
image(); | 677 bool isMouseDownOnLinkOrImage = event.isOverLink() || event.hitTestResult().
image(); |
678 return event.event().shiftKey() && !isMouseDownOnLinkOrImage; | 678 return event.event().shiftKey() && !isMouseDownOnLinkOrImage; |
679 } | 679 } |
680 | 680 |
681 } // namespace blink | 681 } // namespace blink |
OLD | NEW |