Commit 1b19b279 authored by kocienda's avatar kocienda

Reviewed by Maciej

	Fix for this bug:

	Radar 3128159 (Netscape non-standard DOM event attribute "which" unsupported)

        * khtml/dom/dom2_events.cpp:
        (UIEvent::which): Added which() definition.
        * khtml/dom/dom2_events.h: Added declarations for which() functions in UIEvent.
        * khtml/ecma/kjs_events.cpp:
        (DOMUIEvent::getValueProperty): Added which property.
        * khtml/ecma/kjs_events.h: Ditto.
        * khtml/ecma/kjs_events.lut.h: File regenerated.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3052 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 957a1b3b
2002-12-14 Ken Kocienda <kocienda@apple.com>
Reviewed by Maciej
Fix for this bug:
Radar 3128159 (Netscape non-standard DOM event attribute "which" unsupported)
* khtml/dom/dom2_events.cpp:
(UIEvent::which): Added which() definition.
* khtml/dom/dom2_events.h: Added declarations for which() functions in UIEvent.
* khtml/ecma/kjs_events.cpp:
(DOMUIEvent::getValueProperty): Added which property.
* khtml/ecma/kjs_events.h: Ditto.
* khtml/ecma/kjs_events.lut.h: File regenerated.
2002-12-13 Richard Williamson <rjw@apple.com>
Fixed 3127310 and 3127920.
......
2002-12-14 Ken Kocienda <kocienda@apple.com>
Reviewed by Maciej
Fix for this bug:
Radar 3128159 (Netscape non-standard DOM event attribute "which" unsupported)
* khtml/dom/dom2_events.cpp:
(UIEvent::which): Added which() definition.
* khtml/dom/dom2_events.h: Added declarations for which() functions in UIEvent.
* khtml/ecma/kjs_events.cpp:
(DOMUIEvent::getValueProperty): Added which property.
* khtml/ecma/kjs_events.h: Ditto.
* khtml/ecma/kjs_events.lut.h: File regenerated.
2002-12-13 Richard Williamson <rjw@apple.com>
Fixed 3127310 and 3127920.
......
......@@ -315,6 +315,29 @@ int UIEvent::layerY() const
return 0;
}
int UIEvent::which() const
{
if (!impl)
throw DOMException(DOMException::INVALID_STATE_ERR);
// Note: This property supports both key events and mouse events
// Value is just like keyCode()
KeyEventImpl *keyEvent = dynamic_cast<KeyEventImpl*>(impl);
if (keyEvent)
return keyEvent->keyVal();
// For khtml, the return values for left, middle and right mouse buttons are 0, 1, 2, respectively.
// For the Netscape "which" property, the return values for left, middle and right mouse buttons are 1, 2, 3, respectively.
// So we can just add 1 to the value returned by calling button().
MouseEventImpl *mouseEvent = dynamic_cast<MouseEventImpl*>(impl);
if (mouseEvent)
return mouseEvent->button() + 1;
return 0;
}
void UIEvent::initUIEvent(const DOMString &typeArg,
bool canBubbleArg,
bool cancelableArg,
......
......@@ -341,6 +341,12 @@ public:
int layerX() const;
int layerY() const;
/**
* Non-standard extension to support Netscape-style "which" event property.
*
*/
int which() const;
/**
* The initUIEvent method is used to initialize the value of a UIEvent
* created through the DocumentEvent interface. This method may only be
......
......@@ -339,7 +339,7 @@ Value KJS::getEventExceptionConstructor(ExecState *exec)
const ClassInfo DOMUIEvent::info = { "UIEvent", &DOMEvent::info, &DOMUIEventTable, 0 };
/*
@begin DOMUIEventTable 5
@begin DOMUIEventTable 8
view DOMUIEvent::View DontDelete|ReadOnly
detail DOMUIEvent::Detail DontDelete|ReadOnly
keyCode DOMUIEvent::KeyCode DontDelete|ReadOnly
......@@ -347,6 +347,7 @@ const ClassInfo DOMUIEvent::info = { "UIEvent", &DOMEvent::info, &DOMUIEventTabl
layerY DOMUIEvent::LayerY DontDelete|ReadOnly
pageX DOMUIEvent::PageX DontDelete|ReadOnly
pageY DOMUIEvent::PageY DontDelete|ReadOnly
which DOMUIEvent::Which DontDelete|ReadOnly
@end
@begin DOMUIEventProtoTable 1
initUIEvent DOMUIEvent::InitUIEvent DontDelete|Function 5
......@@ -382,6 +383,8 @@ Value DOMUIEvent::getValueProperty(ExecState *exec, int token) const
return Number(static_cast<DOM::UIEvent>(event).pageX());
case PageY:
return Number(static_cast<DOM::UIEvent>(event).pageY());
case Which:
return Number(static_cast<DOM::UIEvent>(event).which());
default:
kdWarning() << "Unhandled token in DOMUIEvent::getValueProperty : " << token << endl;
return Undefined();
......
......@@ -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, LayerX, LayerY, PageX, PageY, InitUIEvent };
enum { View, Detail, KeyCode, LayerX, LayerY, PageX, PageY, Which, InitUIEvent };
DOM::UIEvent toUIEvent() const { return static_cast<DOM::UIEvent>(event); }
};
......
......@@ -76,16 +76,21 @@ const struct HashTable EventExceptionConstructorTable = { 2, 1, EventExceptionCo
namespace KJS {
const struct HashEntry DOMUIEventTableEntries[] = {
{ "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] },
{ "layerX", DOMUIEvent::LayerX, DontDelete|ReadOnly, 0, 0 },
{ 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0 },
{ "view", DOMUIEvent::View, DontDelete|ReadOnly, 0, &DOMUIEventTableEntries[8] },
{ "keyCode", DOMUIEvent::KeyCode, DontDelete|ReadOnly, 0, 0 },
{ "pageY", DOMUIEvent::PageY, DontDelete|ReadOnly, 0, 0 }
{ "layerX", DOMUIEvent::LayerX, DontDelete|ReadOnly, 0, &DOMUIEventTableEntries[9] },
{ "layerY", DOMUIEvent::LayerY, DontDelete|ReadOnly, 0, &DOMUIEventTableEntries[10] },
{ 0, 0, 0, 0, 0 },
{ "detail", DOMUIEvent::Detail, DontDelete|ReadOnly, 0, &DOMUIEventTableEntries[11] },
{ "pageX", DOMUIEvent::PageX, DontDelete|ReadOnly, 0, 0 },
{ "pageY", DOMUIEvent::PageY, DontDelete|ReadOnly, 0, 0 },
{ "which", DOMUIEvent::Which, DontDelete|ReadOnly, 0, 0 }
};
const struct HashTable DOMUIEventTable = { 2, 7, DOMUIEventTableEntries, 5 };
const struct HashTable DOMUIEventTable = { 2, 12, DOMUIEventTableEntries, 8 };
}; // namespace
......
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