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

Side by Side Diff: Source/core/page/EventHandler.cpp

Issue 965203003: Revert 187103 "Fix ignored taps in contextual search on Android" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
« no previous file with comments | « Source/core/page/EventHandler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 else 551 else
552 newSelection = VisibleSelection(start, pos); 552 newSelection = VisibleSelection(start, pos);
553 } 553 }
554 } else 554 } else
555 newSelection.setExtent(pos); 555 newSelection.setExtent(pos);
556 556
557 if (m_frame->selection().granularity() != CharacterGranularity) { 557 if (m_frame->selection().granularity() != CharacterGranularity) {
558 granularity = m_frame->selection().granularity(); 558 granularity = m_frame->selection().granularity();
559 newSelection.expandUsingGranularity(m_frame->selection().granularity ()); 559 newSelection.expandUsingGranularity(m_frame->selection().granularity ());
560 } 560 }
561 } else if (m_selectionInitiationState != ExtendedSelection) { 561 } else {
562 newSelection = expandSelectionToRespectUserSelectAll(innerNode, VisibleS election(visiblePos)); 562 newSelection = expandSelectionToRespectUserSelectAll(innerNode, VisibleS election(visiblePos));
563 } 563 }
564 564
565 // Updating the selection is considered side-effect of the event and so it d oesn't impact the handled state. 565 // Updating the selection is considered side-effect of the event and so it d oesn't impact the handled state.
566 updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection, g ranularity); 566 updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection, g ranularity);
567 return false; 567 return false;
568 } 568 }
569 569
570 static inline bool canMouseDownStartSelect(Node* node) 570 static inline bool canMouseDownStartSelect(Node* node)
571 { 571 {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 if (singleClick) 622 if (singleClick)
623 focusDocumentView(); 623 focusDocumentView();
624 624
625 Node* innerNode = event.innerNode(); 625 Node* innerNode = event.innerNode();
626 626
627 m_mousePressNode = innerNode; 627 m_mousePressNode = innerNode;
628 m_dragStartPos = event.event().position(); 628 m_dragStartPos = event.event().position();
629 629
630 bool swallowEvent = false; 630 bool swallowEvent = false;
631 m_mousePressed = true; 631 m_mousePressed = true;
632 m_selectionInitiationState = HaveNotStartedSelection;
632 633
633 if (event.event().clickCount() == 2) 634 if (event.event().clickCount() == 2)
634 swallowEvent = handleMousePressEventDoubleClick(event); 635 swallowEvent = handleMousePressEventDoubleClick(event);
635 else if (event.event().clickCount() >= 3) 636 else if (event.event().clickCount() >= 3)
636 swallowEvent = handleMousePressEventTripleClick(event); 637 swallowEvent = handleMousePressEventTripleClick(event);
637 else 638 else
638 swallowEvent = handleMousePressEventSingleClick(event); 639 swallowEvent = handleMousePressEventSingleClick(event);
639 640
640 m_mouseDownMayStartAutoscroll = m_mouseDownMayStartSelect 641 m_mouseDownMayStartAutoscroll = m_mouseDownMayStartSelect
641 || (m_mousePressNode && m_mousePressNode->layoutBox() && m_mousePressNod e->layoutBox()->canBeProgramaticallyScrolled()); 642 || (m_mousePressNode && m_mousePressNode->layoutBox() && m_mousePressNod e->layoutBox()->canBeProgramaticallyScrolled());
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 m_resizeScrollableArea->setInResizeMode(true); 1295 m_resizeScrollableArea->setInResizeMode(true);
1295 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p)); 1296 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p));
1296 invalidateClick(); 1297 invalidateClick();
1297 return true; 1298 return true;
1298 } 1299 }
1299 } 1300 }
1300 1301
1301 m_frame->selection().setCaretBlinkingSuspended(true); 1302 m_frame->selection().setCaretBlinkingSuspended(true);
1302 1303
1303 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.inner Node(), m_clickCount, mouseEvent, true); 1304 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.inner Node(), m_clickCount, mouseEvent, true);
1304 // m_selectionInitiationState is initialized after dispatching mousedown eve nt in order not to keep the selection by DOM APIs
1305 // Because we can't give the user the chance to handle the selection by user action like dragging if we keep the selection in case of mousedown.
1306 // FireFox also has the same behavior and it's more compatible with other br owsers.
1307 m_selectionInitiationState = HaveNotStartedSelection;
1308 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, mouseEvent.posit ion(), HitTestRequest::ReadOnly); 1305 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, mouseEvent.posit ion(), HitTestRequest::ReadOnly);
1309 swallowEvent = swallowEvent || handleMouseFocus(MouseEventWithHitTestResults (mouseEvent, hitTestResult)); 1306 swallowEvent = swallowEvent || handleMouseFocus(MouseEventWithHitTestResults (mouseEvent, hitTestResult));
1310 m_capturesDragging = !swallowEvent || mev.scrollbar(); 1307 m_capturesDragging = !swallowEvent || mev.scrollbar();
1311 1308
1312 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults 1309 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults
1313 // in case the scrollbar widget was destroyed when the mouse event was handl ed. 1310 // in case the scrollbar widget was destroyed when the mouse event was handl ed.
1314 if (mev.scrollbar()) { 1311 if (mev.scrollbar()) {
1315 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get(); 1312 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get();
1316 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active ); 1313 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active );
1317 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent); 1314 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent);
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
2287 IntPoint tappedPosition = gestureEvent.position(); 2284 IntPoint tappedPosition = gestureEvent.position();
2288 2285
2289 if (m_clickNode && m_clickNode->isTextNode()) 2286 if (m_clickNode && m_clickNode->isTextNode())
2290 m_clickNode = NodeRenderingTraversal::parent(*m_clickNode); 2287 m_clickNode = NodeRenderingTraversal::parent(*m_clickNode);
2291 2288
2292 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globa lPosition(), 2289 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globa lPosition(),
2293 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), 2290 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(),
2294 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut tonDown), 2291 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut tonDown),
2295 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); 2292 PlatformMouseEvent::FromTouch, gestureEvent.timestamp());
2296 bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown, true); 2293 bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown, true);
2297 m_selectionInitiationState = HaveNotStartedSelection;
2298 if (!swallowMouseDownEvent) 2294 if (!swallowMouseDownEvent)
2299 swallowMouseDownEvent = handleMouseFocus(MouseEventWithHitTestResults(fa keMouseDown, currentHitTest)); 2295 swallowMouseDownEvent = handleMouseFocus(MouseEventWithHitTestResults(fa keMouseDown, currentHitTest));
2300 if (!swallowMouseDownEvent) 2296 if (!swallowMouseDownEvent)
2301 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul ts(fakeMouseDown, currentHitTest)); 2297 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul ts(fakeMouseDown, currentHitTest));
2302 2298
2303 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug. com/398920 2299 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug. com/398920
2304 if (currentHitTest.innerNode()) { 2300 if (currentHitTest.innerNode()) {
2305 LocalFrame* mainFrame = m_frame->localFrameRoot(); 2301 LocalFrame* mainFrame = m_frame->localFrameRoot();
2306 if (mainFrame && mainFrame->view()) 2302 if (mainFrame && mainFrame->view())
2307 mainFrame->view()->updateLayoutAndStyleIfNeededRecursive(); 2303 mainFrame->view()->updateLayoutAndStyleIfNeededRecursive();
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
3035 } 3031 }
3036 3032
3037 void EventHandler::notifyElementActivated() 3033 void EventHandler::notifyElementActivated()
3038 { 3034 {
3039 // Since another element has been set to active, stop current timer and clea r reference. 3035 // Since another element has been set to active, stop current timer and clea r reference.
3040 if (m_activeIntervalTimer.isActive()) 3036 if (m_activeIntervalTimer.isActive())
3041 m_activeIntervalTimer.stop(); 3037 m_activeIntervalTimer.stop();
3042 m_lastDeferredTapElement = nullptr; 3038 m_lastDeferredTapElement = nullptr;
3043 } 3039 }
3044 3040
3045 void EventHandler::notifySelectionChanged()
3046 {
3047 if (m_frame->selection().isRange())
3048 m_selectionInitiationState = ExtendedSelection;
3049 }
3050
3051 bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt) 3041 bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt)
3052 { 3042 {
3053 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do. 3043 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do.
3054 // IE matches lower and upper case access keys regardless of Shift key state - but if both upper and 3044 // IE matches lower and upper case access keys regardless of Shift key state - but if both upper and
3055 // lower case variants are present in a document, the correct element is mat ched based on Shift key state. 3045 // lower case variants are present in a document, the correct element is mat ched based on Shift key state.
3056 // Firefox only matches an access key if Shift is not pressed, and does that case-insensitively. 3046 // Firefox only matches an access key if Shift is not pressed, and does that case-insensitively.
3057 ASSERT(!(accessKeyModifiers() & PlatformEvent::ShiftKey)); 3047 ASSERT(!(accessKeyModifiers() & PlatformEvent::ShiftKey));
3058 if ((evt.modifiers() & ~PlatformEvent::ShiftKey) != accessKeyModifiers()) 3048 if ((evt.modifiers() & ~PlatformEvent::ShiftKey) != accessKeyModifiers())
3059 return false; 3049 return false;
3060 String key = evt.unmodifiedText(); 3050 String key = evt.unmodifiedText();
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
3938 3928
3939 // If it's in the direction to hide the top controls, only consume when the frame can also scroll. 3929 // If it's in the direction to hide the top controls, only consume when the frame can also scroll.
3940 if (m_frame->view()->scrollPosition().y() < m_frame->view()->maximumScrollPo sition().y()) 3930 if (m_frame->view()->scrollPosition().y() < m_frame->view()->maximumScrollPo sition().y())
3941 return true; 3931 return true;
3942 3932
3943 return false; 3933 return false;
3944 } 3934 }
3945 3935
3946 3936
3947 } // namespace blink 3937 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/page/EventHandler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698