Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008, The Android Open Source Project |
| 3 | * Copyright (C) 2012 Research In Motion Limited. All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * * Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * * Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY |
| 15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 | */ |
| 26 | |
| 27 | #include "config.h" |
| 28 | |
| 29 | #include "core/dom/TouchEvent.h" |
| 30 | |
| 31 | #include "core/dom/EventDispatcher.h" |
| 32 | #include "core/dom/EventNames.h" |
| 33 | #include "core/dom/EventRetargeter.h" |
| 34 | #include "core/dom/TouchList.h" |
| 35 | |
| 36 | namespace WebCore { |
| 37 | |
| 38 | TouchEvent::TouchEvent() |
| 39 | { |
| 40 | ScriptWrappable::init(this); |
| 41 | } |
| 42 | |
| 43 | TouchEvent::TouchEvent(TouchList* touches, TouchList* targetTouches, |
Ben Murdoch | 02772c6 | 2013-07-26 10:21:05 +0100 | [diff] [blame] | 44 | TouchList* changedTouches, const AtomicString& type, |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 45 | PassRefPtr<AbstractView> view, int screenX, int screenY, int pageX, int pageY, |
| 46 | bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) |
| 47 | : MouseRelatedEvent(type, true, true, view, 0, IntPoint(screenX, screenY), |
| 48 | IntPoint(pageX, pageY), |
| 49 | IntPoint(0, 0), |
| 50 | ctrlKey, altKey, shiftKey, metaKey) |
| 51 | , m_touches(touches) |
| 52 | , m_targetTouches(targetTouches) |
| 53 | , m_changedTouches(changedTouches) |
| 54 | { |
| 55 | ScriptWrappable::init(this); |
| 56 | } |
| 57 | |
| 58 | TouchEvent::~TouchEvent() |
| 59 | { |
| 60 | } |
| 61 | |
| 62 | void TouchEvent::initTouchEvent(TouchList* touches, TouchList* targetTouches, |
Ben Murdoch | 02772c6 | 2013-07-26 10:21:05 +0100 | [diff] [blame] | 63 | TouchList* changedTouches, const AtomicString& type, |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 64 | PassRefPtr<AbstractView> view, int screenX, int screenY, int clientX, int clientY, |
| 65 | bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) |
| 66 | { |
| 67 | if (dispatched()) |
| 68 | return; |
| 69 | |
| 70 | initUIEvent(type, true, true, view, 0); |
| 71 | |
| 72 | m_touches = touches; |
| 73 | m_targetTouches = targetTouches; |
| 74 | m_changedTouches = changedTouches; |
| 75 | m_screenLocation = IntPoint(screenX, screenY); |
| 76 | m_ctrlKey = ctrlKey; |
| 77 | m_altKey = altKey; |
| 78 | m_shiftKey = shiftKey; |
| 79 | m_metaKey = metaKey; |
| 80 | initCoordinates(IntPoint(clientX, clientY)); |
| 81 | } |
| 82 | |
| 83 | const AtomicString& TouchEvent::interfaceName() const |
| 84 | { |
| 85 | return eventNames().interfaceForTouchEvent; |
| 86 | } |
| 87 | |
| 88 | bool TouchEvent::isTouchEvent() const |
| 89 | { |
| 90 | return true; |
| 91 | } |
| 92 | |
| 93 | PassRefPtr<TouchEventDispatchMediator> TouchEventDispatchMediator::create(PassRefPtr<TouchEvent> touchEvent) |
| 94 | { |
| 95 | return adoptRef(new TouchEventDispatchMediator(touchEvent)); |
| 96 | } |
| 97 | |
| 98 | TouchEventDispatchMediator::TouchEventDispatchMediator(PassRefPtr<TouchEvent> touchEvent) |
| 99 | : EventDispatchMediator(touchEvent) |
| 100 | { |
| 101 | } |
| 102 | |
| 103 | TouchEvent* TouchEventDispatchMediator::event() const |
| 104 | { |
| 105 | return static_cast<TouchEvent*>(EventDispatchMediator::event()); |
| 106 | } |
| 107 | |
| 108 | bool TouchEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const |
| 109 | { |
| 110 | EventRetargeter::adjustForTouchEvent(dispatcher->node(), *event()); |
| 111 | return dispatcher->dispatch(); |
| 112 | } |
| 113 | |
| 114 | } // namespace WebCore |