WebCore/dom/MouseRelatedEvent.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     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 "IntPoint.h"
       
    28 #include "UIEventWithKeyState.h"
       
    29 
       
    30 namespace 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_screenX; }
       
    38         int screenY() const { return m_screenY; }
       
    39         int clientX() const { return m_clientX; }
       
    40         int clientY() const { return m_clientY; }
       
    41         int layerX() const { return m_layerX; }
       
    42         int layerY() const { return m_layerY; }
       
    43         int offsetX() const { return m_offsetX; }
       
    44         int offsetY() const { return m_offsetY; }
       
    45         bool isSimulated() const { return m_isSimulated; }
       
    46         virtual int pageX() const;
       
    47         virtual int pageY() const;
       
    48         int x() const;
       
    49         int y() const;
       
    50 
       
    51         // Page point in "absolute" coordinates (i.e. post-zoomed, page-relative coords,
       
    52         // usable with RenderObject::absoluteToLocal).
       
    53         IntPoint absoluteLocation() const { return m_absoluteLocation; }
       
    54         void setAbsoluteLocation(const IntPoint& p) { m_absoluteLocation = p; }
       
    55     
       
    56     protected:
       
    57         MouseRelatedEvent();
       
    58         MouseRelatedEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>,
       
    59                           int detail, int screenX, int screenY, int pageX, int pageY,
       
    60                           bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool isSimulated = false);
       
    61 
       
    62         void initCoordinates();
       
    63         void initCoordinates(int clientX, int clientY);
       
    64         virtual void receivedTarget();
       
    65 
       
    66         void computePageLocation();
       
    67         
       
    68         // Expose these so MouseEvent::initMouseEvent can set them.
       
    69         int m_screenX;
       
    70         int m_screenY;
       
    71         int m_clientX;
       
    72         int m_clientY;
       
    73 
       
    74     private:
       
    75         int m_pageX;
       
    76         int m_pageY;
       
    77         int m_layerX;
       
    78         int m_layerY;
       
    79         int m_offsetX;
       
    80         int m_offsetY;
       
    81         IntPoint m_absoluteLocation;
       
    82         bool m_isSimulated;
       
    83     };
       
    84 
       
    85 } // namespace WebCore
       
    86 
       
    87 #endif // MouseRelatedEvent_h