Ignore contiguous composition event.
[framework/web/webkit-efl.git] / Source / WebKit2 / Shared / WebWheelEvent.cpp
1 /*
2  * Copyright (C) 2010 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
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.
12  *
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.
24  */
25
26 #include "config.h"
27 #include "WebEvent.h"
28
29 #include "Arguments.h"
30 #include "WebCoreArgumentCoders.h"
31
32 using namespace WebCore;
33
34 namespace WebKit {    
35
36 WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Granularity granularity, Modifiers modifiers, double timestamp)
37     : WebEvent(type, modifiers, timestamp)
38     , m_position(position)
39     , m_globalPosition(globalPosition)
40     , m_delta(delta)
41     , m_wheelTicks(wheelTicks)
42     , m_granularity(granularity)
43     , m_directionInvertedFromDevice(false)
44 #if PLATFORM(MAC)
45     , m_phase(PhaseNone)
46     , m_hasPreciseScrollingDeltas(false)
47     , m_scrollCount(0)
48 #endif
49 {
50     ASSERT(isWheelEventType(type));
51 }
52
53 #if PLATFORM(MAC)
54 WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Granularity granularity, bool directionInvertedFromDevice, Phase phase, Phase momentumPhase, bool hasPreciseScrollingDeltas, uint32_t scrollCount, const WebCore::FloatSize& unacceleratedScrollingDelta, Modifiers modifiers, double timestamp)
55     : WebEvent(type, modifiers, timestamp)
56     , m_position(position)
57     , m_globalPosition(globalPosition)
58     , m_delta(delta)
59     , m_wheelTicks(wheelTicks)
60     , m_granularity(granularity)
61     , m_directionInvertedFromDevice(directionInvertedFromDevice)
62     , m_phase(phase)
63     , m_momentumPhase(momentumPhase)
64     , m_hasPreciseScrollingDeltas(hasPreciseScrollingDeltas)
65     , m_scrollCount(scrollCount)
66     , m_unacceleratedScrollingDelta(unacceleratedScrollingDelta)
67 {
68     ASSERT(isWheelEventType(type));
69 }
70 #endif
71
72 void WebWheelEvent::encode(CoreIPC::ArgumentEncoder* encoder) const
73 {
74     WebEvent::encode(encoder);
75
76     encoder->encode(m_position);
77     encoder->encode(m_globalPosition);
78     encoder->encode(m_delta);
79     encoder->encode(m_wheelTicks);
80     encoder->encode(m_granularity);
81     encoder->encode(m_directionInvertedFromDevice);
82 #if PLATFORM(MAC)
83     encoder->encode(m_phase);
84     encoder->encode(m_momentumPhase);
85     encoder->encode(m_hasPreciseScrollingDeltas);
86     encoder->encode(m_scrollCount);
87     encoder->encode(m_unacceleratedScrollingDelta);
88 #endif
89 }
90
91 bool WebWheelEvent::decode(CoreIPC::ArgumentDecoder* decoder, WebWheelEvent& t)
92 {
93     if (!WebEvent::decode(decoder, t))
94         return false;
95     if (!decoder->decode(t.m_position))
96         return false;
97     if (!decoder->decode(t.m_globalPosition))
98         return false;
99     if (!decoder->decode(t.m_delta))
100         return false;
101     if (!decoder->decode(t.m_wheelTicks))
102         return false;
103     if (!decoder->decode(t.m_granularity))
104         return false;
105     if (!decoder->decode(t.m_directionInvertedFromDevice))
106         return false;
107 #if PLATFORM(MAC)
108     if (!decoder->decode(t.m_phase))
109         return false;
110     if (!decoder->decode(t.m_momentumPhase))
111         return false;
112     if (!decoder->decode(t.m_hasPreciseScrollingDeltas))
113         return false;
114     if (!decoder->decode(t.m_scrollCount))
115         return false;
116     if (!decoder->decode(t.m_unacceleratedScrollingDelta))
117         return false;
118 #endif
119     return true;
120 }
121
122 bool WebWheelEvent::isWheelEventType(Type type)
123 {
124     return type == Wheel;
125 }
126
127 } // namespace WebKit