File: MouseRelatedEvent.h

package info (click to toggle)
webkit2gtk 2.51.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 455,340 kB
  • sloc: cpp: 3,865,253; javascript: 197,710; ansic: 165,177; python: 49,241; asm: 21,868; ruby: 18,095; perl: 16,926; xml: 4,623; sh: 2,409; yacc: 2,356; java: 2,019; lex: 1,330; pascal: 372; makefile: 210
file content (125 lines) | stat: -rw-r--r-- 4,869 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
 * Copyright (C) 2003, 2004, 2005, 2006, 2013 Apple Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 */

#pragma once

#include <WebCore/LayoutPoint.h>
#include <WebCore/UIEventWithKeyState.h>

namespace WebCore {

class LocalFrameView;

struct MouseRelatedEventInit : public EventModifierInit {
    double screenX { 0 };
    double screenY { 0 };
    double movementX { 0 };
    double movementY { 0 };
};

// Internal only: Helper class for what's common between mouse and wheel events.
class MouseRelatedEvent : public UIEventWithKeyState {
    WTF_MAKE_TZONE_OR_ISO_ALLOCATED(MouseRelatedEvent);
public:
    enum class IsSimulated : bool { No, Yes };

    // Note that these values are adjusted to counter the effects of zoom, so that values
    // exposed via DOM APIs are invariant under zooming.
    double screenX() const override;
    double screenY() const override;
    double clientX() const override;
    double clientY() const override;
    const DoublePoint& screenLocation() const { return m_screenLocation; }

    double movementX() const { return m_movementX; }
    double movementY() const { return m_movementY; }

    const DoublePoint& windowLocation() const { return m_windowLocation; }

    const DoublePoint& clientLocation() const { return m_clientLocation; }
    int layerX() override;
    int layerY() override;

    bool isSimulated() const { return m_isSimulated; }
    void setIsSimulated(bool value) { m_isSimulated = value; }
    double pageX() const override;
    double pageY() const override;
    WEBCORE_EXPORT DoublePoint locationInRootViewCoordinates() const;

    // Page point in "absolute" coordinates (i.e. post-zoomed, page-relative coords,
    // usable with RenderObject::absoluteToLocal).
    const DoublePoint& absoluteLocation() const { return m_absoluteLocation; }

    static LocalFrameView* frameViewFromWindowProxy(WindowProxy*);

    static DoublePoint pagePointToClientPoint(DoublePoint pagePoint, LocalFrameView*);
    static DoublePoint pagePointToAbsolutePoint(DoublePoint pagePoint, LocalFrameView*);

    WEBCORE_EXPORT virtual double offsetX();
    WEBCORE_EXPORT virtual double offsetY();

    void computeRelativePosition();

protected:
    MouseRelatedEvent(enum EventInterfaceType);
    MouseRelatedEvent();
    MouseRelatedEvent(enum EventInterfaceType, const AtomString& type, CanBubble, IsCancelable, IsComposed, MonotonicTime, RefPtr<WindowProxy>&&, int detail,
        const DoublePoint& screenLocation, const DoublePoint& windowLocation, double movementX, double movementY, OptionSet<Modifier> modifiers,
        IsSimulated = IsSimulated::No, IsTrusted = IsTrusted::Yes);
    MouseRelatedEvent(enum EventInterfaceType, const AtomString& type, IsCancelable, MonotonicTime, RefPtr<WindowProxy>&&, const DoublePoint& globalLocation, OptionSet<Modifier>);
    MouseRelatedEvent(enum EventInterfaceType, const AtomString& type, const MouseRelatedEventInit&, IsTrusted = IsTrusted::No);

    void initCoordinates();
    void initCoordinates(const DoublePoint& clientLocation);
    void receivedTarget() override;

    void computePageLocation();

    float documentToAbsoluteScaleFactor() const;

    bool hasCachedRelativePosition() const { return m_hasCachedRelativePosition; }

    DoublePoint offsetLocation() const { return m_offsetLocation; }
    DoublePoint pageLocation() const { return m_pageLocation; }

    void setScreenLocation(const DoublePoint& point) { m_screenLocation = point; }

private:
    void init(bool isSimulated, const DoublePoint&);

    double m_movementX { 0 };
    double m_movementY { 0 };
    DoublePoint m_pageLocation;
    LayoutPoint m_layerLocation;
    DoublePoint m_offsetLocation;
    DoublePoint m_absoluteLocation;
    DoublePoint m_windowLocation;

    DoublePoint m_screenLocation;
    DoublePoint m_clientLocation;

    bool m_isSimulated { false };
    bool m_hasCachedRelativePosition { false };
};

} // namespace WebCore