Chromium Code Reviews| 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) | 892 if (!innerNode || !innerNode->layoutObject()) |
|
yosin_UTC9
2016/12/01 01:51:09
Could you hoist call site of this function or fath
| |
| 896 return false; | 893 return false; |
| 897 innerNode->document().updateStyleAndLayoutTree(); | 894 innerNode->document().updateStyleAndLayoutTree(); |
| 898 bool innerNodeIsSelectable = hasEditableStyle(*innerNode) || | 895 bool innerNodeIsSelectable = hasEditableStyle(*innerNode) || |
| 899 innerNode->isTextNode() || | 896 innerNode->isTextNode() || |
| 900 innerNode->canStartSelection(); | 897 innerNode->canStartSelection(); |
| 901 if (!innerNodeIsSelectable) | 898 if (!innerNodeIsSelectable) |
| 902 return false; | 899 return false; |
| 903 | 900 |
| 904 if (selectClosestWordFromHitTestResult(hitTestResult, | 901 if (selectClosestWordFromHitTestResult(hitTestResult, |
| 905 AppendTrailingWhitespace::DontAppend, | 902 AppendTrailingWhitespace::DontAppend, |
| 906 SelectInputEventType::Touch)) | 903 SelectInputEventType::Touch)) |
| 907 return selection().isAvailable(); | 904 return selection().isAvailable(); |
| 908 | 905 |
| 909 setCaretAtHitTestResult(hitTestResult); | 906 setCaretAtHitTestResult(hitTestResult); |
| 910 return false; | 907 return false; |
| 911 } | 908 } |
| 912 | 909 |
| 913 void SelectionController::handleGestureTwoFingerTap( | 910 void SelectionController::handleGestureTwoFingerTap( |
| 914 const GestureEventWithHitTestResults& targetedEvent) { | 911 const GestureEventWithHitTestResults& targetedEvent) { |
| 915 setCaretAtHitTestResult(targetedEvent.hitTestResult()); | 912 Node* innerNode = targetedEvent.hitTestResult().innerNode(); |
| 913 if (innerNode && innerNode->layoutObject()) | |
| 914 setCaretAtHitTestResult(targetedEvent.hitTestResult()); | |
| 916 } | 915 } |
| 917 | 916 |
| 918 void SelectionController::handleGestureLongTap( | 917 void SelectionController::handleGestureLongTap( |
| 919 const GestureEventWithHitTestResults& targetedEvent) { | 918 const GestureEventWithHitTestResults& targetedEvent) { |
| 920 setCaretAtHitTestResult(targetedEvent.hitTestResult()); | 919 Node* innerNode = targetedEvent.hitTestResult().innerNode(); |
| 920 if (innerNode && innerNode->layoutObject()) | |
| 921 setCaretAtHitTestResult(targetedEvent.hitTestResult()); | |
| 921 } | 922 } |
| 922 | 923 |
| 923 static bool hitTestResultIsMisspelled(const HitTestResult& result) { | 924 static bool hitTestResultIsMisspelled(const HitTestResult& result) { |
| 924 Node* innerNode = result.innerNode(); | 925 Node* innerNode = result.innerNode(); |
| 925 if (!innerNode || !innerNode->layoutObject()) | 926 if (!innerNode || !innerNode->layoutObject()) |
| 926 return false; | 927 return false; |
| 927 VisiblePosition pos = createVisiblePosition( | 928 VisiblePosition pos = createVisiblePosition( |
| 928 innerNode->layoutObject()->positionForPoint(result.localPoint())); | 929 innerNode->layoutObject()->positionForPoint(result.localPoint())); |
| 929 if (pos.isNull()) | 930 if (pos.isNull()) |
| 930 return false; | 931 return false; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1023 return event.event().altKey() && event.isOverLink(); | 1024 return event.event().altKey() && event.isOverLink(); |
| 1024 } | 1025 } |
| 1025 | 1026 |
| 1026 bool isExtendingSelection(const MouseEventWithHitTestResults& event) { | 1027 bool isExtendingSelection(const MouseEventWithHitTestResults& event) { |
| 1027 bool isMouseDownOnLinkOrImage = | 1028 bool isMouseDownOnLinkOrImage = |
| 1028 event.isOverLink() || event.hitTestResult().image(); | 1029 event.isOverLink() || event.hitTestResult().image(); |
| 1029 return event.event().shiftKey() && !isMouseDownOnLinkOrImage; | 1030 return event.event().shiftKey() && !isMouseDownOnLinkOrImage; |
| 1030 } | 1031 } |
| 1031 | 1032 |
| 1032 } // namespace blink | 1033 } // namespace blink |
| OLD | NEW |