don't discard iframe children.
[kdelibs.git] / khtml / khtml_events.cpp
blob1500301c1d360bd21d61927d1b7cbe97eee6392b
1 /* This file is part of the KDE project
2 Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "khtml_events.h"
21 #include "rendering/render_object.h"
22 #include "xml/dom_nodeimpl.h"
23 #include "xml/dom_position.h"
25 using namespace khtml;
26 using namespace DOM;
28 class khtml::MouseEvent::MouseEventPrivate
32 khtml::MouseEvent::MouseEvent( const char *name, QMouseEvent *qmouseEvent, int x, int y,
33 const DOM::DOMString &url, const DOM::DOMString& target,
34 const DOM::Node &innerNode )
35 : KParts::Event( name ), m_qmouseEvent( qmouseEvent ), m_x( x ), m_y( y ),
36 m_url( url ), m_target(target), m_innerNode( innerNode )
38 d = 0;
39 if (innerNode.handle() && innerNode.handle()->renderer())
40 innerNode.handle()->renderer()->absolutePosition(m_nodeAbsX, m_nodeAbsY);
43 khtml::MouseEvent::~MouseEvent()
45 delete d;
48 long khtml::MouseEvent::offset() const
50 Position pos;
51 if (innerNode().handle()) {
52 // FIXME: Shouldn't be necessary to skip text nodes.
53 DOM::Node inner = innerNode();
54 if (inner.nodeType() == Node::TEXT_NODE)
55 inner = inner.parentNode();
56 pos = inner.handle()->positionForCoordinates(m_x, m_y);
58 return pos.offset();
61 const char *khtml::MousePressEvent::s_strMousePressEvent = "khtml/Events/MousePressEvent";
63 const char *khtml::MouseDoubleClickEvent::s_strMouseDoubleClickEvent = "khtml/Events/MouseDoubleClickEvent";
65 const char *khtml::MouseMoveEvent::s_strMouseMoveEvent = "khtml/Events/MouseMoveEvent";
67 const char *khtml::MouseReleaseEvent::s_strMouseReleaseEvent = "khtml/Events/MouseReleaseEvent";
69 const char *khtml::DrawContentsEvent::s_strDrawContentsEvent = "khtml/Events/DrawContentsEvent";
71 class khtml::DrawContentsEvent::DrawContentsEventPrivate
73 public:
74 DrawContentsEventPrivate()
77 ~DrawContentsEventPrivate()
82 khtml::DrawContentsEvent::DrawContentsEvent( QPainter *painter, int clipx, int clipy, int clipw, int cliph )
83 : KParts::Event( s_strDrawContentsEvent ), m_painter( painter ), m_clipx( clipx ), m_clipy( clipy ),
84 m_clipw( clipw ), m_cliph( cliph )
86 d = new DrawContentsEventPrivate;
89 khtml::DrawContentsEvent::~DrawContentsEvent()
91 delete d;