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

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

Issue 185413023: Oilpan: move Touch related objects to the oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Avoid MSVC local class member function restriction Created 6 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
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 #include "core/rendering/RenderFlowThread.h" 81 #include "core/rendering/RenderFlowThread.h"
82 #include "core/rendering/RenderLayer.h" 82 #include "core/rendering/RenderLayer.h"
83 #include "core/rendering/RenderTextControlSingleLine.h" 83 #include "core/rendering/RenderTextControlSingleLine.h"
84 #include "core/rendering/RenderView.h" 84 #include "core/rendering/RenderView.h"
85 #include "core/rendering/RenderWidget.h" 85 #include "core/rendering/RenderWidget.h"
86 #include "core/rendering/style/CursorList.h" 86 #include "core/rendering/style/CursorList.h"
87 #include "core/rendering/style/RenderStyle.h" 87 #include "core/rendering/style/RenderStyle.h"
88 #include "core/svg/SVGDocument.h" 88 #include "core/svg/SVGDocument.h"
89 #include "core/svg/SVGElementInstance.h" 89 #include "core/svg/SVGElementInstance.h"
90 #include "core/svg/SVGUseElement.h" 90 #include "core/svg/SVGUseElement.h"
91 #include "heap/Handle.h"
91 #include "platform/PlatformGestureEvent.h" 92 #include "platform/PlatformGestureEvent.h"
92 #include "platform/PlatformKeyboardEvent.h" 93 #include "platform/PlatformKeyboardEvent.h"
93 #include "platform/PlatformTouchEvent.h" 94 #include "platform/PlatformTouchEvent.h"
94 #include "platform/PlatformWheelEvent.h" 95 #include "platform/PlatformWheelEvent.h"
95 #include "platform/WindowsKeyboardCodes.h" 96 #include "platform/WindowsKeyboardCodes.h"
96 #include "platform/geometry/FloatPoint.h" 97 #include "platform/geometry/FloatPoint.h"
97 #include "platform/graphics/Image.h" 98 #include "platform/graphics/Image.h"
98 #include "platform/scroll/ScrollAnimator.h" 99 #include "platform/scroll/ScrollAnimator.h"
99 #include "platform/scroll/Scrollbar.h" 100 #include "platform/scroll/Scrollbar.h"
100 #include "wtf/Assertions.h" 101 #include "wtf/Assertions.h"
(...skipping 3474 matching lines...) Expand 10 before | Expand all | Expand 10 after
3575 return result; 3576 return result;
3576 } 3577 }
3577 3578
3578 bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) 3579 bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
3579 { 3580 {
3580 // First build up the lists to use for the 'touches', 'targetTouches' and 'c hangedTouches' attributes 3581 // First build up the lists to use for the 'touches', 'targetTouches' and 'c hangedTouches' attributes
3581 // in the JS event. See http://www.sitepen.com/blog/2008/07/10/touching-and- gesturing-on-the-iphone/ 3582 // in the JS event. See http://www.sitepen.com/blog/2008/07/10/touching-and- gesturing-on-the-iphone/
3582 // for an overview of how these lists fit together. 3583 // for an overview of how these lists fit together.
3583 3584
3584 // Holds the complete set of touches on the screen and will be used as the ' touches' list in the JS event. 3585 // Holds the complete set of touches on the screen and will be used as the ' touches' list in the JS event.
3585 RefPtr<TouchList> touches = TouchList::create(); 3586 RefPtrWillBeRawPtr<TouchList> touches = TouchList::create();
3586 3587
3587 // A different view on the 'touches' list above, filtered and grouped by eve nt target. Used for the 3588 // A different view on the 'touches' list above, filtered and grouped by eve nt target. Used for the
3588 // 'targetTouches' list in the JS event. 3589 // 'targetTouches' list in the JS event.
3589 typedef HashMap<EventTarget*, RefPtr<TouchList> > TargetTouchesMap; 3590 typedef WillBeHeapHashMap<EventTarget*, RefPtrWillBeMember<TouchList> > Targ etTouchesHeapMap;
3590 TargetTouchesMap touchesByTarget; 3591 TargetTouchesHeapMap touchesByTarget;
3591 3592
3592 // Array of touches per state, used to assemble the 'changedTouches' list in the JS event. 3593 // Array of touches per state, used to assemble the 'changedTouches' list in the JS event.
3593 typedef HashSet<RefPtr<EventTarget> > EventTargetSet; 3594 typedef HashSet<RefPtr<EventTarget> > EventTargetSet;
3594 struct { 3595 struct {
3595 // The touches corresponding to the particular change state this struct instance represents. 3596 // The touches corresponding to the particular change state this struct instance represents.
3596 RefPtr<TouchList> m_touches; 3597 RefPtrWillBeRawPtr<TouchList> m_touches;
3597 // Set of targets involved in m_touches. 3598 // Set of targets involved in m_touches.
3598 EventTargetSet m_targets; 3599 EventTargetSet m_targets;
3599 } changedTouches[PlatformTouchPoint::TouchStateEnd]; 3600 } changedTouches[PlatformTouchPoint::TouchStateEnd];
3600 3601
3601 const Vector<PlatformTouchPoint>& points = event.touchPoints(); 3602 const Vector<PlatformTouchPoint>& points = event.touchPoints();
3602 3603
3603 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); 3604 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
3604 3605
3605 unsigned i; 3606 unsigned i;
3606 bool freshTouchEvents = true; 3607 bool freshTouchEvents = true;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
3704 pagePoint = documentPointForWindowPoint(targetFrame, point.pos()); 3705 pagePoint = documentPointForWindowPoint(targetFrame, point.pos());
3705 } 3706 }
3706 3707
3707 float scaleFactor = targetFrame->pageZoomFactor(); 3708 float scaleFactor = targetFrame->pageZoomFactor();
3708 3709
3709 int adjustedPageX = lroundf(pagePoint.x() / scaleFactor); 3710 int adjustedPageX = lroundf(pagePoint.x() / scaleFactor);
3710 int adjustedPageY = lroundf(pagePoint.y() / scaleFactor); 3711 int adjustedPageY = lroundf(pagePoint.y() / scaleFactor);
3711 int adjustedRadiusX = lroundf(point.radiusX() / scaleFactor); 3712 int adjustedRadiusX = lroundf(point.radiusX() / scaleFactor);
3712 int adjustedRadiusY = lroundf(point.radiusY() / scaleFactor); 3713 int adjustedRadiusY = lroundf(point.radiusY() / scaleFactor);
3713 3714
3714 RefPtr<Touch> touch = Touch::create(targetFrame, touchTarget.get(), poin t.id(), 3715 RefPtrWillBeRawPtr<Touch> touch = Touch::create(targetFrame, touchTarget .get(), point.id(),
3715 point.screenPos().x(), point.screenP os().y(), 3716 point.screenPos().x(), point.screenP os().y(),
3716 adjustedPageX, adjustedPageY, 3717 adjustedPageX, adjustedPageY,
3717 adjustedRadiusX, adjustedRadiusY, 3718 adjustedRadiusX, adjustedRadiusY,
3718 point.rotationAngle(), point.force() ); 3719 point.rotationAngle(), point.force() );
3719 3720
3720 // Ensure this target's touch list exists, even if it ends up empty, so it can always be passed to TouchEvent::Create below. 3721 // Ensure this target's touch list exists, even if it ends up empty, so it can always be passed to TouchEvent::Create below.
3721 TargetTouchesMap::iterator targetTouchesIterator = touchesByTarget.find( touchTarget.get()); 3722 TargetTouchesHeapMap::iterator targetTouchesIterator = touchesByTarget.f ind(touchTarget.get());
3722 if (targetTouchesIterator == touchesByTarget.end()) { 3723 if (targetTouchesIterator == touchesByTarget.end()) {
3723 touchesByTarget.set(touchTarget.get(), TouchList::create()); 3724 touchesByTarget.set(touchTarget.get(), TouchList::create());
3724 targetTouchesIterator = touchesByTarget.find(touchTarget.get()); 3725 targetTouchesIterator = touchesByTarget.find(touchTarget.get());
3725 } 3726 }
3726 3727
3727 // touches and targetTouches should only contain information about touch es still on the screen, so if this point is 3728 // touches and targetTouches should only contain information about touch es still on the screen, so if this point is
3728 // released or cancelled it will only appear in the changedTouches list. 3729 // released or cancelled it will only appear in the changedTouches list.
3729 if (pointState != PlatformTouchPoint::TouchReleased && pointState != Pla tformTouchPoint::TouchCancelled) { 3730 if (pointState != PlatformTouchPoint::TouchReleased && pointState != Pla tformTouchPoint::TouchCancelled) {
3730 touches->append(touch); 3731 touches->append(touch);
3731 targetTouchesIterator->value->append(touch); 3732 targetTouchesIterator->value->append(touch);
(...skipping 12 matching lines...) Expand all
3744 changedTouches[pointState].m_touches->append(touch); 3745 changedTouches[pointState].m_touches->append(touch);
3745 changedTouches[pointState].m_targets.add(touchTarget); 3746 changedTouches[pointState].m_targets.add(touchTarget);
3746 } 3747 }
3747 } 3748 }
3748 m_touchPressed = touches->length() > 0; 3749 m_touchPressed = touches->length() > 0;
3749 if (allTouchReleased) 3750 if (allTouchReleased)
3750 m_originatingTouchPointDocument.clear(); 3751 m_originatingTouchPointDocument.clear();
3751 3752
3752 // Now iterate the changedTouches list and m_targets within it, sending even ts to the targets as required. 3753 // Now iterate the changedTouches list and m_targets within it, sending even ts to the targets as required.
3753 bool swallowedEvent = false; 3754 bool swallowedEvent = false;
3754 RefPtr<TouchList> emptyList = TouchList::create(); 3755 RefPtrWillBeRawPtr<TouchList> emptyList = TouchList::create();
3755 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state ) { 3756 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state ) {
3756 if (!changedTouches[state].m_touches) 3757 if (!changedTouches[state].m_touches)
3757 continue; 3758 continue;
3758 3759
3759 // When sending a touch cancel event, use empty touches and targetTouche s lists. 3760 // When sending a touch cancel event, use empty touches and targetTouche s lists.
3760 bool isTouchCancelEvent = (state == PlatformTouchPoint::TouchCancelled); 3761 bool isTouchCancelEvent = (state == PlatformTouchPoint::TouchCancelled);
3761 RefPtr<TouchList>& effectiveTouches(isTouchCancelEvent ? emptyList : tou ches); 3762 RefPtrWillBeRawPtr<TouchList>& effectiveTouches(isTouchCancelEvent ? emp tyList : touches);
3762 const AtomicString& stateName(eventNameForTouchPointState(static_cast<Pl atformTouchPoint::State>(state))); 3763 const AtomicString& stateName(eventNameForTouchPointState(static_cast<Pl atformTouchPoint::State>(state)));
3763 const EventTargetSet& targetsForState = changedTouches[state].m_targets; 3764 const EventTargetSet& targetsForState = changedTouches[state].m_targets;
3764 3765
3765 for (EventTargetSet::const_iterator it = targetsForState.begin(); it != targetsForState.end(); ++it) { 3766 for (EventTargetSet::const_iterator it = targetsForState.begin(); it != targetsForState.end(); ++it) {
3766 EventTarget* touchEventTarget = it->get(); 3767 EventTarget* touchEventTarget = it->get();
3767 RefPtr<TouchList> targetTouches(isTouchCancelEvent ? emptyList : tou chesByTarget.get(touchEventTarget)); 3768 RefPtrWillBeRawPtr<TouchList> targetTouches(isTouchCancelEvent ? emp tyList.get() : touchesByTarget.get(touchEventTarget));
3768 ASSERT(targetTouches); 3769 ASSERT(targetTouches);
3769 3770
3770 RefPtr<TouchEvent> touchEvent = 3771 RefPtr<TouchEvent> touchEvent =
3771 TouchEvent::create(effectiveTouches.get(), targetTouches.get(), changedTouches[state].m_touches.get(), 3772 TouchEvent::create(effectiveTouches.get(), targetTouches.get(), changedTouches[state].m_touches.get(),
3772 stateName, touchEventTarget->toNode()->document().domWindow( ), 3773 stateName, touchEventTarget->toNode()->document().domWindow( ),
3773 0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey( ), event.metaKey()); 3774 0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey( ), event.metaKey());
3774 touchEventTarget->toNode()->dispatchTouchEvent(touchEvent.get()); 3775 touchEventTarget->toNode()->dispatchTouchEvent(touchEvent.get());
3775 swallowedEvent = swallowedEvent || touchEvent->defaultPrevented() || touchEvent->defaultHandled(); 3776 swallowedEvent = swallowedEvent || touchEvent->defaultPrevented() || touchEvent->defaultHandled();
3776 } 3777 }
3777 } 3778 }
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
4025 unsigned EventHandler::accessKeyModifiers() 4026 unsigned EventHandler::accessKeyModifiers()
4026 { 4027 {
4027 #if OS(MACOSX) 4028 #if OS(MACOSX)
4028 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 4029 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
4029 #else 4030 #else
4030 return PlatformEvent::AltKey; 4031 return PlatformEvent::AltKey;
4031 #endif 4032 #endif
4032 } 4033 }
4033 4034
4034 } // namespace WebCore 4035 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/events/TreeScopeEventContext.h ('k') | Source/web/tests/WebInputEventConversionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698