| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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
etTouchesMap; |
| 3590 TargetTouchesMap touchesByTarget; | 3591 TargetTouchesMap 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3705 pagePoint = documentPointForWindowPoint(targetFrame, point.pos()); | 3706 pagePoint = documentPointForWindowPoint(targetFrame, point.pos()); |
| 3706 } | 3707 } |
| 3707 | 3708 |
| 3708 float scaleFactor = targetFrame->pageZoomFactor(); | 3709 float scaleFactor = targetFrame->pageZoomFactor(); |
| 3709 | 3710 |
| 3710 int adjustedPageX = lroundf(pagePoint.x() / scaleFactor); | 3711 int adjustedPageX = lroundf(pagePoint.x() / scaleFactor); |
| 3711 int adjustedPageY = lroundf(pagePoint.y() / scaleFactor); | 3712 int adjustedPageY = lroundf(pagePoint.y() / scaleFactor); |
| 3712 int adjustedRadiusX = lroundf(point.radiusX() / scaleFactor); | 3713 int adjustedRadiusX = lroundf(point.radiusX() / scaleFactor); |
| 3713 int adjustedRadiusY = lroundf(point.radiusY() / scaleFactor); | 3714 int adjustedRadiusY = lroundf(point.radiusY() / scaleFactor); |
| 3714 | 3715 |
| 3715 RefPtr<Touch> touch = Touch::create(targetFrame, touchTarget.get(), poin
t.id(), | 3716 RefPtrWillBeRawPtr<Touch> touch = Touch::create(targetFrame, touchTarget
.get(), point.id(), |
| 3716 point.screenPos().x(), point.screenP
os().y(), | 3717 point.screenPos().x(), point.screenP
os().y(), |
| 3717 adjustedPageX, adjustedPageY, | 3718 adjustedPageX, adjustedPageY, |
| 3718 adjustedRadiusX, adjustedRadiusY, | 3719 adjustedRadiusX, adjustedRadiusY, |
| 3719 point.rotationAngle(), point.force()
); | 3720 point.rotationAngle(), point.force()
); |
| 3720 | 3721 |
| 3721 // Ensure this target's touch list exists, even if it ends up empty, so
it can always be passed to TouchEvent::Create below. | 3722 // Ensure this target's touch list exists, even if it ends up empty, so
it can always be passed to TouchEvent::Create below. |
| 3722 TargetTouchesMap::iterator targetTouchesIterator = touchesByTarget.find(
touchTarget.get()); | 3723 TargetTouchesMap::iterator targetTouchesIterator = touchesByTarget.find(
touchTarget.get()); |
| 3723 if (targetTouchesIterator == touchesByTarget.end()) { | 3724 if (targetTouchesIterator == touchesByTarget.end()) { |
| 3724 touchesByTarget.set(touchTarget.get(), TouchList::create()); | 3725 touchesByTarget.set(touchTarget.get(), TouchList::create()); |
| 3725 targetTouchesIterator = touchesByTarget.find(touchTarget.get()); | 3726 targetTouchesIterator = touchesByTarget.find(touchTarget.get()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3745 changedTouches[pointState].m_touches->append(touch); | 3746 changedTouches[pointState].m_touches->append(touch); |
| 3746 changedTouches[pointState].m_targets.add(touchTarget); | 3747 changedTouches[pointState].m_targets.add(touchTarget); |
| 3747 } | 3748 } |
| 3748 } | 3749 } |
| 3749 m_touchPressed = touches->length() > 0; | 3750 m_touchPressed = touches->length() > 0; |
| 3750 if (allTouchReleased) | 3751 if (allTouchReleased) |
| 3751 m_originatingTouchPointDocument.clear(); | 3752 m_originatingTouchPointDocument.clear(); |
| 3752 | 3753 |
| 3753 // Now iterate the changedTouches list and m_targets within it, sending even
ts to the targets as required. | 3754 // Now iterate the changedTouches list and m_targets within it, sending even
ts to the targets as required. |
| 3754 bool swallowedEvent = false; | 3755 bool swallowedEvent = false; |
| 3755 RefPtr<TouchList> emptyList = TouchList::create(); | 3756 RefPtrWillBeRawPtr<TouchList> emptyList = TouchList::create(); |
| 3756 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state
) { | 3757 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state
) { |
| 3757 if (!changedTouches[state].m_touches) | 3758 if (!changedTouches[state].m_touches) |
| 3758 continue; | 3759 continue; |
| 3759 | 3760 |
| 3760 // When sending a touch cancel event, use empty touches and targetTouche
s lists. | 3761 // When sending a touch cancel event, use empty touches and targetTouche
s lists. |
| 3761 bool isTouchCancelEvent = (state == PlatformTouchPoint::TouchCancelled); | 3762 bool isTouchCancelEvent = (state == PlatformTouchPoint::TouchCancelled); |
| 3762 RefPtr<TouchList>& effectiveTouches(isTouchCancelEvent ? emptyList : tou
ches); | 3763 RefPtrWillBeRawPtr<TouchList>& effectiveTouches(isTouchCancelEvent ? emp
tyList : touches); |
| 3763 const AtomicString& stateName(eventNameForTouchPointState(static_cast<Pl
atformTouchPoint::State>(state))); | 3764 const AtomicString& stateName(eventNameForTouchPointState(static_cast<Pl
atformTouchPoint::State>(state))); |
| 3764 const EventTargetSet& targetsForState = changedTouches[state].m_targets; | 3765 const EventTargetSet& targetsForState = changedTouches[state].m_targets; |
| 3765 | 3766 |
| 3766 for (EventTargetSet::const_iterator it = targetsForState.begin(); it !=
targetsForState.end(); ++it) { | 3767 for (EventTargetSet::const_iterator it = targetsForState.begin(); it !=
targetsForState.end(); ++it) { |
| 3767 EventTarget* touchEventTarget = it->get(); | 3768 EventTarget* touchEventTarget = it->get(); |
| 3768 RefPtr<TouchList> targetTouches(isTouchCancelEvent ? emptyList : tou
chesByTarget.get(touchEventTarget)); | 3769 RefPtrWillBeRawPtr<TouchList> targetTouches(isTouchCancelEvent ? emp
tyList.get() : touchesByTarget.get(touchEventTarget)); |
| 3769 ASSERT(targetTouches); | 3770 ASSERT(targetTouches); |
| 3770 | 3771 |
| 3771 RefPtr<TouchEvent> touchEvent = | 3772 RefPtr<TouchEvent> touchEvent = |
| 3772 TouchEvent::create(effectiveTouches.get(), targetTouches.get(),
changedTouches[state].m_touches.get(), | 3773 TouchEvent::create(effectiveTouches.get(), targetTouches.get(),
changedTouches[state].m_touches.get(), |
| 3773 stateName, touchEventTarget->toNode()->document().domWindow(
), | 3774 stateName, touchEventTarget->toNode()->document().domWindow(
), |
| 3774 0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey(
), event.metaKey()); | 3775 0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey(
), event.metaKey()); |
| 3775 touchEventTarget->toNode()->dispatchTouchEvent(touchEvent.get()); | 3776 touchEventTarget->toNode()->dispatchTouchEvent(touchEvent.get()); |
| 3776 swallowedEvent = swallowedEvent || touchEvent->defaultPrevented() ||
touchEvent->defaultHandled(); | 3777 swallowedEvent = swallowedEvent || touchEvent->defaultPrevented() ||
touchEvent->defaultHandled(); |
| 3777 } | 3778 } |
| 3778 } | 3779 } |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4021 unsigned EventHandler::accessKeyModifiers() | 4022 unsigned EventHandler::accessKeyModifiers() |
| 4022 { | 4023 { |
| 4023 #if OS(MACOSX) | 4024 #if OS(MACOSX) |
| 4024 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4025 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 4025 #else | 4026 #else |
| 4026 return PlatformEvent::AltKey; | 4027 return PlatformEvent::AltKey; |
| 4027 #endif | 4028 #endif |
| 4028 } | 4029 } |
| 4029 | 4030 |
| 4030 } // namespace WebCore | 4031 } // namespace WebCore |
| OLD | NEW |