15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/* 25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright 2008, The Android Open Source Project 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2012 Research In Motion Limited. All rights reserved. 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without 65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * are met: 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * * Redistributions of source code must retain the above copyright 95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer. 105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * * Redistributions in binary form must reproduce the above copyright 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer in the 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * documentation and/or other materials provided with the distribution. 135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */ 265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef TouchEvent_h 285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define TouchEvent_h 295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3006f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)#include "core/events/EventDispatchMediator.h" 3106f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)#include "core/events/MouseRelatedEvent.h" 3253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/dom/TouchList.h" 335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)namespace WebCore { 355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class TouchEvent : public MouseRelatedEvent { 375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)public: 385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) virtual ~TouchEvent(); 395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static PassRefPtr<TouchEvent> create() 415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return adoptRef(new TouchEvent); 435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 4402772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch static PassRefPtr<TouchEvent> create(TouchList* touches, 4502772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch TouchList* targetTouches, TouchList* changedTouches, 465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const AtomicString& type, PassRefPtr<AbstractView> view, 475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int screenX, int screenY, int pageX, int pageY, 485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) 495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return adoptRef(new TouchEvent(touches, targetTouches, changedTouches, 515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) type, view, screenX, screenY, pageX, pageY, 525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ctrlKey, altKey, shiftKey, metaKey)); 535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void initTouchEvent(TouchList* touches, TouchList* targetTouches, 5602772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch TouchList* changedTouches, const AtomicString& type, 5702772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch PassRefPtr<AbstractView> view, int screenX, int screenY, 585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int clientX, int clientY, 595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); 605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) TouchList* touches() const { return m_touches.get(); } 625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) TouchList* targetTouches() const { return m_targetTouches.get(); } 635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) TouchList* changedTouches() const { return m_changedTouches.get(); } 64926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 65926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) void setTouches(PassRefPtr<TouchList> touches) { m_touches = touches; } 66926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) void setTargetTouches(PassRefPtr<TouchList> targetTouches) { m_targetTouches = targetTouches; } 67926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) void setChangedTouches(PassRefPtr<TouchList> changedTouches) { m_changedTouches = changedTouches; } 68926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) virtual bool isTouchEvent() const OVERRIDE; 705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) virtual const AtomicString& interfaceName() const; 725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)private: 745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) TouchEvent(); 755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) TouchEvent(TouchList* touches, TouchList* targetTouches, 765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) TouchList* changedTouches, const AtomicString& type, 775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) PassRefPtr<AbstractView>, int screenX, int screenY, int pageX, 785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int pageY, 795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); 805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) RefPtr<TouchList> m_touches; 825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) RefPtr<TouchList> m_targetTouches; 835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) RefPtr<TouchList> m_changedTouches; 845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}; 855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 86926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)class TouchEventDispatchMediator : public EventDispatchMediator { 87926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)public: 88926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) static PassRefPtr<TouchEventDispatchMediator> create(PassRefPtr<TouchEvent>); 89926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 90926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)private: 91926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) explicit TouchEventDispatchMediator(PassRefPtr<TouchEvent>); 92926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) TouchEvent* event() const; 93926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) virtual bool dispatchEvent(EventDispatcher*) const OVERRIDE; 94926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}; 95926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 96f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)DEFINE_EVENT_TYPE_CASTS(TouchEvent); 97926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} // namespace WebCore 995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif // TouchEvent_h 101