2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #ifndef MouseRelatedEvent_h
25 #define MouseRelatedEvent_h
27 #include "LayoutTypes.h"
28 #include "UIEventWithKeyState.h"
32 // Internal only: Helper class for what's common between mouse and wheel events.
33 class MouseRelatedEvent : public UIEventWithKeyState {
35 // Note that these values are adjusted to counter the effects of zoom, so that values
36 // exposed via DOM APIs are invariant under zooming.
37 int screenX() const { return m_screenLocation.x(); }
38 int screenY() const { return m_screenLocation.y(); }
39 const LayoutPoint& screenLocation() const { return m_screenLocation; }
40 int clientX() const { return m_clientLocation.x(); }
41 int clientY() const { return m_clientLocation.y(); }
42 const LayoutPoint& clientLocation() const { return m_clientLocation; }
47 bool isSimulated() const { return m_isSimulated; }
48 virtual int pageX() const;
49 virtual int pageY() const;
50 virtual const LayoutPoint& pageLocation() const;
54 // Page point in "absolute" coordinates (i.e. post-zoomed, page-relative coords,
55 // usable with RenderObject::absoluteToLocal).
56 const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; }
57 void setAbsoluteLocation(const LayoutPoint& p) { m_absoluteLocation = p; }
61 MouseRelatedEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>,
62 int detail, const LayoutPoint& screenLocation, const LayoutPoint& windowLocation,
63 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool isSimulated = false);
65 void initCoordinates();
66 void initCoordinates(const LayoutPoint& clientLocation);
67 virtual void receivedTarget();
69 void computePageLocation();
70 void computeRelativePosition();
72 // Expose these so MouseEvent::initMouseEvent can set them.
73 LayoutPoint m_screenLocation;
74 LayoutPoint m_clientLocation;
77 LayoutPoint m_pageLocation;
78 LayoutPoint m_layerLocation;
79 LayoutPoint m_offsetLocation;
80 LayoutPoint m_absoluteLocation;
82 bool m_hasCachedRelativePosition;
85 } // namespace WebCore
87 #endif // MouseRelatedEvent_h