2 * Copyright (C) 2010 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
29 #include "Arguments.h"
30 #include "WebCoreArgumentCoders.h"
32 using namespace WebCore;
36 WebMouseEvent::WebMouseEvent()
38 , m_button(static_cast<uint32_t>(NoButton))
44 , m_didActivateWebView(false)
49 WebMouseEvent::WebMouseEvent(Type type, Button button, const IntPoint& position, const IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers modifiers, double timestamp)
50 : WebEvent(type, modifiers, timestamp)
52 , m_position(position)
53 , m_globalPosition(globalPosition)
57 , m_clickCount(clickCount)
59 , m_didActivateWebView(false)
62 ASSERT(isMouseEventType(type));
66 WebMouseEvent::WebMouseEvent(Type type, Button button, const IntPoint& position, const IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers modifiers, double timestamp, bool didActivateWebView)
67 : WebEvent(type, modifiers, timestamp)
69 , m_position(position)
70 , m_globalPosition(globalPosition)
74 , m_clickCount(clickCount)
75 , m_didActivateWebView(didActivateWebView)
77 ASSERT(isMouseEventType(type));
81 WebMouseEvent::WebMouseEvent(const WebMouseEvent& event, float pageScaleFactor)
82 : WebEvent(event.type(), event.modifiers(), event.timestamp())
83 , m_button(event.button())
84 , m_position(WebCore::IntPoint(event.position().x() / pageScaleFactor, event.position().y() / pageScaleFactor))
85 , m_globalPosition(m_position + (event.globalPosition() - event.position()))
86 , m_deltaX(event.deltaX())
87 , m_deltaY(event.deltaY())
88 , m_deltaZ(event.deltaZ())
89 , m_clickCount(event.clickCount())
91 , m_didActivateWebView(false)
96 void WebMouseEvent::encode(CoreIPC::ArgumentEncoder* encoder) const
98 WebEvent::encode(encoder);
101 // Include m_didActivateWebView on Windows.
102 encoder->encode(CoreIPC::In(m_button, m_position, m_globalPosition, m_deltaX, m_deltaY, m_deltaZ, m_clickCount, m_didActivateWebView));
104 encoder->encode(CoreIPC::In(m_button, m_position, m_globalPosition, m_deltaX, m_deltaY, m_deltaZ, m_clickCount));
108 bool WebMouseEvent::decode(CoreIPC::ArgumentDecoder* decoder, WebMouseEvent& t)
110 if (!WebEvent::decode(decoder, t))
114 // Include m_didActivateWebView on Windows.
115 return decoder->decode(CoreIPC::Out(t.m_button, t.m_position, t.m_globalPosition, t.m_deltaX, t.m_deltaY, t.m_deltaZ, t.m_clickCount, t.m_didActivateWebView));
117 return decoder->decode(CoreIPC::Out(t.m_button, t.m_position, t.m_globalPosition, t.m_deltaX, t.m_deltaY, t.m_deltaZ, t.m_clickCount));
121 bool WebMouseEvent::isMouseEventType(Type type)
123 return type == MouseDown || type == MouseUp || type == MouseMove;
126 } // namespace WebKit