OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
6 * Copyright (C) 2015 Google Inc. All rights reserved. | 6 * Copyright (C) 2015 Google Inc. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 | 645 |
646 const FrameSelection::SetSelectionOptions options = | 646 const FrameSelection::SetSelectionOptions options = |
647 FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle; | 647 FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle; |
648 selection().setSelection(newSelection, options, CursorAlignOnScroll::IfNeeded, | 648 selection().setSelection(newSelection, options, CursorAlignOnScroll::IfNeeded, |
649 granularity); | 649 granularity); |
650 } | 650 } |
651 | 651 |
652 void SelectionController::setCaretAtHitTestResult( | 652 void SelectionController::setCaretAtHitTestResult( |
653 const HitTestResult& hitTestResult) { | 653 const HitTestResult& hitTestResult) { |
654 Node* innerNode = hitTestResult.innerNode(); | 654 Node* innerNode = hitTestResult.innerNode(); |
655 if (!innerNode) | |
656 return; | |
657 | |
658 const VisiblePositionInFlatTree& visibleHitPos = | 655 const VisiblePositionInFlatTree& visibleHitPos = |
659 visiblePositionOfHitTestResult(hitTestResult); | 656 visiblePositionOfHitTestResult(hitTestResult); |
660 const VisiblePositionInFlatTree& visiblePos = | 657 const VisiblePositionInFlatTree& visiblePos = |
661 visibleHitPos.isNull() | 658 visibleHitPos.isNull() |
662 ? createVisiblePosition( | 659 ? createVisiblePosition( |
663 PositionInFlatTree::firstPositionInOrBeforeNode(innerNode)) | 660 PositionInFlatTree::firstPositionInOrBeforeNode(innerNode)) |
664 : visibleHitPos; | 661 : visibleHitPos; |
665 | 662 |
666 updateSelectionForMouseDownDispatchingSelectStart( | 663 updateSelectionForMouseDownDispatchingSelectStart( |
667 innerNode, | 664 innerNode, |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 | 882 |
886 bool SelectionController::handleGestureLongPress( | 883 bool SelectionController::handleGestureLongPress( |
887 const PlatformGestureEvent& gestureEvent, | 884 const PlatformGestureEvent& gestureEvent, |
888 const HitTestResult& hitTestResult) { | 885 const HitTestResult& hitTestResult) { |
889 if (!selection().isAvailable()) | 886 if (!selection().isAvailable()) |
890 return false; | 887 return false; |
891 if (hitTestResult.isLiveLink()) | 888 if (hitTestResult.isLiveLink()) |
892 return false; | 889 return false; |
893 | 890 |
894 Node* innerNode = hitTestResult.innerNode(); | 891 Node* innerNode = hitTestResult.innerNode(); |
895 if (!innerNode) | |
896 return false; | |
897 innerNode->document().updateStyleAndLayoutTree(); | 892 innerNode->document().updateStyleAndLayoutTree(); |
898 bool innerNodeIsSelectable = hasEditableStyle(*innerNode) || | 893 bool innerNodeIsSelectable = hasEditableStyle(*innerNode) || |
899 innerNode->isTextNode() || | 894 innerNode->isTextNode() || |
900 innerNode->canStartSelection(); | 895 innerNode->canStartSelection(); |
901 if (!innerNodeIsSelectable) | 896 if (!innerNodeIsSelectable) |
902 return false; | 897 return false; |
903 | 898 |
904 if (selectClosestWordFromHitTestResult(hitTestResult, | 899 if (selectClosestWordFromHitTestResult(hitTestResult, |
905 AppendTrailingWhitespace::DontAppend, | 900 AppendTrailingWhitespace::DontAppend, |
906 SelectInputEventType::Touch)) | 901 SelectInputEventType::Touch)) |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 return event.event().altKey() && event.isOverLink(); | 1018 return event.event().altKey() && event.isOverLink(); |
1024 } | 1019 } |
1025 | 1020 |
1026 bool isExtendingSelection(const MouseEventWithHitTestResults& event) { | 1021 bool isExtendingSelection(const MouseEventWithHitTestResults& event) { |
1027 bool isMouseDownOnLinkOrImage = | 1022 bool isMouseDownOnLinkOrImage = |
1028 event.isOverLink() || event.hitTestResult().image(); | 1023 event.isOverLink() || event.hitTestResult().image(); |
1029 return event.event().shiftKey() && !isMouseDownOnLinkOrImage; | 1024 return event.event().shiftKey() && !isMouseDownOnLinkOrImage; |
1030 } | 1025 } |
1031 | 1026 |
1032 } // namespace blink | 1027 } // namespace blink |
OLD | NEW |