Commit 1fbd4d9f authored by mjs's avatar mjs

Reviewed by Don.

        * khtml/dom/dom2_events.cpp:
        (UIEvent::layerX): Added to support nonstandard Mozilla
	event.layerX property.
	(UIEvent::layerY): Added to support nonstandard Mozilla
	event.layerY property.
        * khtml/dom/dom2_events.h:
        * khtml/ecma/kjs_events.cpp:
        (DOMUIEvent::getValueProperty): Implemented layerX and layerY
        * khtml/ecma/kjs_events.h:
        * khtml/ecma/kjs_events.lut.h:
        * khtml/xml/dom2_eventsimpl.cpp:
        (MouseEventImpl::MouseEventImpl): Added call to computeLayerPos.
        (MouseEventImpl::computeLayerPos): Compute layer position.
        (MouseEventImpl::layerX): Added.
        (MouseEventImpl::layerY): Added.
        (MouseEventImpl::initMouseEvent): Added call to computeLayerPos.
        * khtml/xml/dom2_eventsimpl.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3048 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e2cdae93
2002-12-13 Maciej Stachowiak <mjs@apple.com>
Reviewed by Don.
* khtml/dom/dom2_events.cpp:
(UIEvent::layerX): Added to support nonstandard Mozilla
event.layerX property.
(UIEvent::layerY): Added to support nonstandard Mozilla
event.layerY property.
* khtml/dom/dom2_events.h:
* khtml/ecma/kjs_events.cpp:
(DOMUIEvent::getValueProperty): Implemented layerX and layerY
* khtml/ecma/kjs_events.h:
* khtml/ecma/kjs_events.lut.h:
* khtml/xml/dom2_eventsimpl.cpp:
(MouseEventImpl::MouseEventImpl): Added call to computeLayerPos.
(MouseEventImpl::computeLayerPos): Compute layer position.
(MouseEventImpl::layerX): Added.
(MouseEventImpl::layerY): Added.
(MouseEventImpl::initMouseEvent): Added call to computeLayerPos.
* khtml/xml/dom2_eventsimpl.h:
2002-12-13 David Hyatt <hyatt@apple.com>
Fix for 314799, image at wired.com doesn't show up. Block
......
2002-12-13 Maciej Stachowiak <mjs@apple.com>
Reviewed by Don.
* khtml/dom/dom2_events.cpp:
(UIEvent::layerX): Added to support nonstandard Mozilla
event.layerX property.
(UIEvent::layerY): Added to support nonstandard Mozilla
event.layerY property.
* khtml/dom/dom2_events.h:
* khtml/ecma/kjs_events.cpp:
(DOMUIEvent::getValueProperty): Implemented layerX and layerY
* khtml/ecma/kjs_events.h:
* khtml/ecma/kjs_events.lut.h:
* khtml/xml/dom2_eventsimpl.cpp:
(MouseEventImpl::MouseEventImpl): Added call to computeLayerPos.
(MouseEventImpl::computeLayerPos): Compute layer position.
(MouseEventImpl::layerX): Added.
(MouseEventImpl::layerY): Added.
(MouseEventImpl::initMouseEvent): Added call to computeLayerPos.
* khtml/xml/dom2_eventsimpl.h:
2002-12-13 David Hyatt <hyatt@apple.com>
Fix for 314799, image at wired.com doesn't show up. Block
......
......@@ -279,7 +279,6 @@ int UIEvent::pageX() const
return 0;
}
int UIEvent::pageY() const
{
if (!impl)
......@@ -292,7 +291,29 @@ int UIEvent::pageY() const
return 0;
}
int UIEvent::layerX() const
{
if (!impl)
throw DOMException(DOMException::INVALID_STATE_ERR);
MouseEventImpl *mouseEvent = dynamic_cast<MouseEventImpl*>(impl);
if (mouseEvent)
return mouseEvent->layerX();
else
return 0;
}
int UIEvent::layerY() const
{
if (!impl)
throw DOMException(DOMException::INVALID_STATE_ERR);
MouseEventImpl *mouseEvent = dynamic_cast<MouseEventImpl*>(impl);
if (mouseEvent)
return mouseEvent->layerY();
else
return 0;
}
void UIEvent::initUIEvent(const DOMString &typeArg,
bool canBubbleArg,
......
......@@ -328,12 +328,19 @@ public:
int keyCode() const;
/**
* Non-standard extensions to support Netscape-style pageX and pageY event property.
* Non-standard extensions to support Netscape-style pageX and pageY event properties.
*
*/
int pageX() const;
int pageY() const;
/**
* Non-standard extensions to support Netscape-style layerX and layerY event properties.
*
*/
int layerX() const;
int layerY() const;
/**
* The initUIEvent method is used to initialize the value of a UIEvent
* created through the DocumentEvent interface. This method may only be
......
......@@ -343,6 +343,8 @@ const ClassInfo DOMUIEvent::info = { "UIEvent", &DOMEvent::info, &DOMUIEventTabl
view DOMUIEvent::View DontDelete|ReadOnly
detail DOMUIEvent::Detail DontDelete|ReadOnly
keyCode DOMUIEvent::KeyCode DontDelete|ReadOnly
layerX DOMUIEvent::LayerX DontDelete|ReadOnly
layerY DOMUIEvent::LayerY DontDelete|ReadOnly
pageX DOMUIEvent::PageX DontDelete|ReadOnly
pageY DOMUIEvent::PageY DontDelete|ReadOnly
@end
......@@ -372,6 +374,10 @@ Value DOMUIEvent::getValueProperty(ExecState *exec, int token) const
return Number(static_cast<DOM::UIEvent>(event).detail());
case KeyCode:
return Number(static_cast<DOM::UIEvent>(event).keyCode());
case LayerX:
return Number(static_cast<DOM::UIEvent>(event).layerX());
case LayerY:
return Number(static_cast<DOM::UIEvent>(event).layerY());
case PageX:
return Number(static_cast<DOM::UIEvent>(event).pageX());
case PageY:
......
......@@ -107,7 +107,7 @@ namespace KJS {
// no put - all read-only
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { View, Detail, KeyCode, PageX, PageY, InitUIEvent };
enum { View, Detail, KeyCode, LayerX, LayerY, PageX, PageY, InitUIEvent };
DOM::UIEvent toUIEvent() const { return static_cast<DOM::UIEvent>(event); }
};
......
......@@ -76,11 +76,11 @@ const struct HashTable EventExceptionConstructorTable = { 2, 1, EventExceptionCo
namespace KJS {
const struct HashEntry DOMUIEventTableEntries[] = {
{ 0, 0, 0, 0, 0 },
{ "layerY", DOMUIEvent::LayerY, DontDelete|ReadOnly, 0, 0 },
{ "pageX", DOMUIEvent::PageX, DontDelete|ReadOnly, 0, 0 },
{ "detail", DOMUIEvent::Detail, DontDelete|ReadOnly, 0, &DOMUIEventTableEntries[6] },
{ "view", DOMUIEvent::View, DontDelete|ReadOnly, 0, &DOMUIEventTableEntries[5] },
{ 0, 0, 0, 0, 0 },
{ "layerX", DOMUIEvent::LayerX, DontDelete|ReadOnly, 0, 0 },
{ "keyCode", DOMUIEvent::KeyCode, DontDelete|ReadOnly, 0, 0 },
{ "pageY", DOMUIEvent::PageY, DontDelete|ReadOnly, 0, 0 }
};
......
......@@ -25,6 +25,9 @@
#include "xml/dom2_eventsimpl.h"
#include "xml/dom_stringimpl.h"
#include "xml/dom_nodeimpl.h"
#include "xml/dom_docimpl.h"
#include "rendering/render_object.h"
#include "rendering/render_layer.h"
#include <kdebug.h>
......@@ -405,6 +408,35 @@ MouseEventImpl::MouseEventImpl(EventId _id,
m_relatedTarget = relatedTargetArg;
if (m_relatedTarget)
m_relatedTarget->ref();
computeLayerPos();
}
void MouseEventImpl::computeLayerPos()
{
m_layerX = m_clientX;
m_layerY = m_clientY;
DocumentImpl *doc = view()->document();
if (!doc) {
return;
}
khtml::RenderObject::NodeInfo renderInfo(true, false);
doc->renderer()->layer()->nodeAtPoint(renderInfo, m_clientX, m_clientY);
NodeImpl *node = renderInfo.innerNonSharedNode();
while (node && !node->renderer()) {
node = node->parent();
}
if (!node) {
return;
}
node->renderer()->enclosingLayer()->updateLayerPosition();
m_layerX -= node->renderer()->enclosingLayer()->xPos();
m_layerY -= node->renderer()->enclosingLayer()->yPos();
}
MouseEventImpl::~MouseEventImpl()
......@@ -433,6 +465,16 @@ long MouseEventImpl::clientY() const
return m_clientY;
}
long MouseEventImpl::layerX() const
{
return m_layerX;
}
long MouseEventImpl::layerY() const
{
return m_layerY;
}
bool MouseEventImpl::ctrlKey() const
{
return m_ctrlKey;
......@@ -496,6 +538,7 @@ void MouseEventImpl::initMouseEvent(const DOMString &typeArg,
m_relatedTarget = relatedTargetArg.handle();
if (m_relatedTarget)
m_relatedTarget->ref();
computeLayerPos();
}
//---------------------------------------------------------------------------------------------
......
......@@ -192,6 +192,8 @@ public:
long screenY() const;
long clientX() const;
long clientY() const;
long layerX() const;
long layerY() const;
bool ctrlKey() const;
bool shiftKey() const;
bool altKey() const;
......@@ -220,12 +222,16 @@ protected:
long m_screenY;
long m_clientX;
long m_clientY;
long m_layerX;
long m_layerY;
bool m_ctrlKey;
bool m_altKey;
bool m_shiftKey;
bool m_metaKey;
unsigned short m_button;
NodeImpl *m_relatedTarget;
private:
void computeLayerPos();
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment