1db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block/* 2db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * Copyright (C) 2010 Apple Inc. All rights reserved. 3db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * 4db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * Redistribution and use in source and binary forms, with or without 5db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * modification, are permitted provided that the following conditions 6db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * are met: 7db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * 1. Redistributions of source code must retain the above copyright 8db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * notice, this list of conditions and the following disclaimer. 9db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * 2. Redistributions in binary form must reproduce the above copyright 10db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * notice, this list of conditions and the following disclaimer in the 11db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * documentation and/or other materials provided with the distribution. 12db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * 13db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * THE POSSIBILITY OF SUCH DAMAGE. 24db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block */ 25db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block 262fc2651226baac27029e38c9d6ef883fa32084dbSteve Block#include "config.h" 2765f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch#include "WebEvent.h" 28db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block 292fc2651226baac27029e38c9d6ef883fa32084dbSteve Block#if ENABLE(TOUCH_EVENTS) 302fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 3165f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch#include "ArgumentCoders.h" 3265f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch#include "Arguments.h" 33db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block 3465f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdochnamespace WebKit { 35dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch 3665f03d4f644ce73618e5f4f50dd694b26f55ae12Ben MurdochWebTouchEvent::WebTouchEvent(WebEvent::Type type, Vector<WebPlatformTouchPoint> touchPoints, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, Modifiers modifiers, double timestamp) 3765f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch : WebEvent(type, modifiers, timestamp) 3865f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch , m_touchPoints(touchPoints) 3965f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch , m_ctrlKey(ctrlKey) 4065f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch , m_altKey(altKey) 4165f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch , m_shiftKey(shiftKey) 4265f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch , m_metaKey(metaKey) 43dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch{ 4465f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch ASSERT(isTouchEventType(type)); 45dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch} 46dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch 4765f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdochvoid WebTouchEvent::encode(CoreIPC::ArgumentEncoder* encoder) const 48dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch{ 4965f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch WebEvent::encode(encoder); 50db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block 5165f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch encoder->encode(CoreIPC::In(m_touchPoints)); 52db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block} 53db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block 5465f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdochbool WebTouchEvent::decode(CoreIPC::ArgumentDecoder* decoder, WebTouchEvent& t) 55db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block{ 5665f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch if (!WebEvent::decode(decoder, t)) 5765f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch return false; 5865f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 5965f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch return decoder->decode(CoreIPC::Out(t.m_touchPoints)); 60db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block} 61db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block 6265f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdochbool WebTouchEvent::isTouchEventType(Type type) 63db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block{ 6465f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch return type == TouchStart || type == TouchMove || type == TouchEnd || type == TouchCancel; 65db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block} 6665f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 6765f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch} // namespace WebKit 68db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block 6965f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch#endif // ENABLE(TOUCH_EVENTS) 70