1/* 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. 6 * 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. 11 * 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. 16 * 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. 21 * 22 */ 23 24#ifndef MouseRelatedEvent_h 25#define MouseRelatedEvent_h 26 27#include "LayoutPoint.h" 28#include "UIEventWithKeyState.h" 29 30namespace WebCore { 31 32 // Internal only: Helper class for what's common between mouse and wheel events. 33 class MouseRelatedEvent : public UIEventWithKeyState { 34 public: 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 IntPoint& screenLocation() const { return m_screenLocation; } 40 int clientX() const { return m_clientLocation.x(); } 41 int clientY() const { return m_clientLocation.y(); } 42#if ENABLE(POINTER_LOCK) 43 int webkitMovementX() const { return m_movementDelta.x(); } 44 int webkitMovementY() const { return m_movementDelta.y(); } 45#endif 46 const LayoutPoint& clientLocation() const { return m_clientLocation; } 47 int layerX(); 48 int layerY(); 49 int offsetX(); 50 int offsetY(); 51 bool isSimulated() const { return m_isSimulated; } 52 virtual int pageX() const; 53 virtual int pageY() const; 54 virtual const LayoutPoint& pageLocation() const; 55 int x() const; 56 int y() const; 57 58 // Page point in "absolute" coordinates (i.e. post-zoomed, page-relative coords, 59 // usable with RenderObject::absoluteToLocal). 60 const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; } 61 void setAbsoluteLocation(const LayoutPoint& p) { m_absoluteLocation = p; } 62 63 protected: 64 MouseRelatedEvent(); 65 MouseRelatedEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>, 66 int detail, const IntPoint& screenLocation, const IntPoint& windowLocation, 67#if ENABLE(POINTER_LOCK) 68 const IntPoint& movementDelta, 69#endif 70 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool isSimulated = false); 71 72 void initCoordinates(); 73 void initCoordinates(const LayoutPoint& clientLocation); 74 virtual void receivedTarget(); 75 76 void computePageLocation(); 77 void computeRelativePosition(); 78 79 // Expose these so MouseEvent::initMouseEvent can set them. 80 IntPoint m_screenLocation; 81 LayoutPoint m_clientLocation; 82#if ENABLE(POINTER_LOCK) 83 LayoutPoint m_movementDelta; 84#endif 85 86 private: 87 LayoutPoint m_pageLocation; 88 LayoutPoint m_layerLocation; 89 LayoutPoint m_offsetLocation; 90 LayoutPoint m_absoluteLocation; 91 bool m_isSimulated; 92 bool m_hasCachedRelativePosition; 93 }; 94 95} // namespace WebCore 96 97#endif // MouseRelatedEvent_h 98