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

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

Issue 329393006: Share a user gesture indicator across touch event sequences (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 m_lastKnownMouseGlobalPosition = IntPoint(); 288 m_lastKnownMouseGlobalPosition = IntPoint();
289 m_lastMouseDownUserGestureToken.clear(); 289 m_lastMouseDownUserGestureToken.clear();
290 m_mousePressNode = nullptr; 290 m_mousePressNode = nullptr;
291 m_mousePressed = false; 291 m_mousePressed = false;
292 m_capturesDragging = false; 292 m_capturesDragging = false;
293 m_capturingMouseEventsNode = nullptr; 293 m_capturingMouseEventsNode = nullptr;
294 m_latchedWheelEventNode = nullptr; 294 m_latchedWheelEventNode = nullptr;
295 m_previousWheelScrolledNode = nullptr; 295 m_previousWheelScrolledNode = nullptr;
296 m_targetForTouchID.clear(); 296 m_targetForTouchID.clear();
297 m_touchSequenceDocument.clear(); 297 m_touchSequenceDocument.clear();
298 m_touchSequenceUserGestureToken.clear();
298 m_scrollGestureHandlingNode = nullptr; 299 m_scrollGestureHandlingNode = nullptr;
299 m_lastHitTestResultOverWidget = false; 300 m_lastHitTestResultOverWidget = false;
300 m_previousGestureScrolledNode = nullptr; 301 m_previousGestureScrolledNode = nullptr;
301 m_scrollbarHandlingScrollGesture = nullptr; 302 m_scrollbarHandlingScrollGesture = nullptr;
302 m_maxMouseMovedDuration = 0; 303 m_maxMouseMovedDuration = 0;
303 m_baseEventType = PlatformEvent::NoType; 304 m_baseEventType = PlatformEvent::NoType;
304 m_didStartDrag = false; 305 m_didStartDrag = false;
305 m_touchPressed = false; 306 m_touchPressed = false;
306 m_mouseDownMayStartSelect = false; 307 m_mouseDownMayStartSelect = false;
307 m_mouseDownMayStartDrag = false; 308 m_mouseDownMayStartDrag = false;
(...skipping 3088 matching lines...) Expand 10 before | Expand all | Expand 10 after
3396 frame->contentRenderer()->hitTest(HitTestRequest(hitType), result); 3397 frame->contentRenderer()->hitTest(HitTestRequest(hitType), result);
3397 return result; 3398 return result;
3398 } 3399 }
3399 3400
3400 bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) 3401 bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
3401 { 3402 {
3402 TRACE_EVENT0("webkit", "EventHandler::handleTouchEvent"); 3403 TRACE_EVENT0("webkit", "EventHandler::handleTouchEvent");
3403 3404
3404 const Vector<PlatformTouchPoint>& points = event.touchPoints(); 3405 const Vector<PlatformTouchPoint>& points = event.touchPoints();
3405 3406
3406 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
3407
3408 unsigned i; 3407 unsigned i;
3409 bool freshTouchEvents = true; 3408 bool freshTouchEvents = true;
3410 bool allTouchReleased = true; 3409 bool allTouchReleased = true;
3411 for (i = 0; i < points.size(); ++i) { 3410 for (i = 0; i < points.size(); ++i) {
3412 const PlatformTouchPoint& point = points[i]; 3411 const PlatformTouchPoint& point = points[i];
3413 if (point.state() != PlatformTouchPoint::TouchPressed) 3412 if (point.state() != PlatformTouchPoint::TouchPressed)
3414 freshTouchEvents = false; 3413 freshTouchEvents = false;
3415 if (point.state() != PlatformTouchPoint::TouchReleased && point.state() != PlatformTouchPoint::TouchCancelled) 3414 if (point.state() != PlatformTouchPoint::TouchReleased && point.state() != PlatformTouchPoint::TouchCancelled)
3416 allTouchReleased = false; 3415 allTouchReleased = false;
3417 } 3416 }
3418 if (freshTouchEvents) { 3417 if (freshTouchEvents) {
3419 // Ideally we'd ASSERT !m_touchSequenceDocument here since we should 3418 // Ideally we'd ASSERT !m_touchSequenceDocument here since we should
3420 // have cleared the active document when we saw the last release. But we 3419 // have cleared the active document when we saw the last release. But we
3421 // have some tests that violate this, ClusterFuzz could trigger it, and 3420 // have some tests that violate this, ClusterFuzz could trigger it, and
3422 // there may be cases where the browser doesn't reliably release all 3421 // there may be cases where the browser doesn't reliably release all
3423 // touches. http://crbug.com/345372 tracks this. 3422 // touches. http://crbug.com/345372 tracks this.
3424 m_touchSequenceDocument.clear(); 3423 m_touchSequenceDocument.clear();
3424 m_touchSequenceUserGestureToken.clear();
3425 } 3425 }
3426 3426
3427 OwnPtr<UserGestureIndicator> gestureIndicator;
3428
3429 if (m_touchSequenceUserGestureToken)
3430 gestureIndicator = adoptPtr(new UserGestureIndicator(m_touchSequenceUser GestureToken.release()));
3431 else
3432 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessin gUserGesture));
Rick Byers 2014/06/12 20:45:53 Looks like the mouse code takes an indicator only
jochen (gone - plz use gerrit) 2014/06/12 21:09:55 no idea, however, if we want to change that, I thi
3433
3434 m_touchSequenceUserGestureToken = gestureIndicator->currentToken();
3435
3427 ASSERT(m_frame->view()); 3436 ASSERT(m_frame->view());
3428 if (m_touchSequenceDocument && (!m_touchSequenceDocument->frame() || !m_touc hSequenceDocument->frame()->view())) { 3437 if (m_touchSequenceDocument && (!m_touchSequenceDocument->frame() || !m_touc hSequenceDocument->frame()->view())) {
3429 // If the active touch document has no frame or view, it's probably bein g destroyed 3438 // If the active touch document has no frame or view, it's probably bein g destroyed
3430 // so we can't dispatch events. 3439 // so we can't dispatch events.
3431 return false; 3440 return false;
3432 } 3441 }
3433 3442
3434 // First do hit tests for any new touch points. 3443 // First do hit tests for any new touch points.
3435 for (i = 0; i < points.size(); ++i) { 3444 for (i = 0; i < points.size(); ++i) {
3436 const PlatformTouchPoint& point = points[i]; 3445 const PlatformTouchPoint& point = points[i];
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3479 m_frame->page()->chrome().client().setTouchAction(effectiveTouch Action); 3488 m_frame->page()->chrome().client().setTouchAction(effectiveTouch Action);
3480 } 3489 }
3481 } 3490 }
3482 3491
3483 m_touchPressed = !allTouchReleased; 3492 m_touchPressed = !allTouchReleased;
3484 3493
3485 // If there's no document receiving touch events, or no handlers on the 3494 // If there's no document receiving touch events, or no handlers on the
3486 // document set to receive the events, then we can skip all the rest of 3495 // document set to receive the events, then we can skip all the rest of
3487 // this work. 3496 // this work.
3488 if (!m_touchSequenceDocument || !m_touchSequenceDocument->hasTouchEventHandl ers() || !m_touchSequenceDocument->frame()) { 3497 if (!m_touchSequenceDocument || !m_touchSequenceDocument->hasTouchEventHandl ers() || !m_touchSequenceDocument->frame()) {
3489 if (allTouchReleased) 3498 if (allTouchReleased) {
3490 m_touchSequenceDocument.clear(); 3499 m_touchSequenceDocument.clear();
3500 m_touchSequenceUserGestureToken.clear();
3501 }
3491 return false; 3502 return false;
3492 } 3503 }
3493 3504
3494 // Build up the lists to use for the 'touches', 'targetTouches' and 3505 // Build up the lists to use for the 'touches', 'targetTouches' and
3495 // 'changedTouches' attributes in the JS event. See 3506 // 'changedTouches' attributes in the JS event. See
3496 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these 3507 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these
3497 // lists fit together. 3508 // lists fit together.
3498 3509
3499 // Holds the complete set of touches on the screen. 3510 // Holds the complete set of touches on the screen.
3500 RefPtrWillBeRawPtr<TouchList> touches = TouchList::create(); 3511 RefPtrWillBeRawPtr<TouchList> touches = TouchList::create();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
3594 // explicitly here. See https://bugs.webkit.org/show_bug.cgi?id=37609 3605 // explicitly here. See https://bugs.webkit.org/show_bug.cgi?id=37609
3595 // for further discussion about the TouchStationary state. 3606 // for further discussion about the TouchStationary state.
3596 if (pointState != PlatformTouchPoint::TouchStationary && knownTarget) { 3607 if (pointState != PlatformTouchPoint::TouchStationary && knownTarget) {
3597 ASSERT(pointState < PlatformTouchPoint::TouchStateEnd); 3608 ASSERT(pointState < PlatformTouchPoint::TouchStateEnd);
3598 if (!changedTouches[pointState].m_touches) 3609 if (!changedTouches[pointState].m_touches)
3599 changedTouches[pointState].m_touches = TouchList::create(); 3610 changedTouches[pointState].m_touches = TouchList::create();
3600 changedTouches[pointState].m_touches->append(touch); 3611 changedTouches[pointState].m_touches->append(touch);
3601 changedTouches[pointState].m_targets.add(touchTarget); 3612 changedTouches[pointState].m_targets.add(touchTarget);
3602 } 3613 }
3603 } 3614 }
3604 if (allTouchReleased) 3615 if (allTouchReleased) {
3605 m_touchSequenceDocument.clear(); 3616 m_touchSequenceDocument.clear();
3617 m_touchSequenceUserGestureToken.clear();
3618 }
3606 3619
3607 // Now iterate the changedTouches list and m_targets within it, sending 3620 // Now iterate the changedTouches list and m_targets within it, sending
3608 // events to the targets as required. 3621 // events to the targets as required.
3609 bool swallowedEvent = false; 3622 bool swallowedEvent = false;
3610 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state ) { 3623 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state ) {
3611 if (!changedTouches[state].m_touches) 3624 if (!changedTouches[state].m_touches)
3612 continue; 3625 continue;
3613 3626
3614 const AtomicString& stateName(eventNameForTouchPointState(static_cast<Pl atformTouchPoint::State>(state))); 3627 const AtomicString& stateName(eventNameForTouchPointState(static_cast<Pl atformTouchPoint::State>(state)));
3615 const EventTargetSet& targetsForState = changedTouches[state].m_targets; 3628 const EventTargetSet& targetsForState = changedTouches[state].m_targets;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
3751 unsigned EventHandler::accessKeyModifiers() 3764 unsigned EventHandler::accessKeyModifiers()
3752 { 3765 {
3753 #if OS(MACOSX) 3766 #if OS(MACOSX)
3754 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3767 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3755 #else 3768 #else
3756 return PlatformEvent::AltKey; 3769 return PlatformEvent::AltKey;
3757 #endif 3770 #endif
3758 } 3771 }
3759 3772
3760 } // namespace WebCore 3773 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698