Closed Bug 242234 Opened 17 years ago Closed 17 years ago

support onclick type attributes

Categories

(Core :: SVG, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: sicking, Assigned: sicking)

Details

Attachments

(4 files, 2 obsolete files)

Attached patch WIPSplinter Review
Assignee: alex → bugmail
Status: NEW → ASSIGNED
This is where we run into the evt/event issue I guess.
Yes. It's probably not a big problem implementation wise, the bigger issue is
going to be webauthors.
tor pointed out that the argument name 'event' is decided in the function
nsJSContext::CompileEventHandler. Specifically in the |gEventArgv| variable.
Unfortunatly that function doesn't know which element (or namespace thereof) the
eventhandler is sitting on, so we'll probably have to add another argument
Attached patch merge to tip, use "evt" (obsolete) — Splinter Review
(do we have to hardcode the event name in two places?)
Orginally I was thinking of passing the namespace down to CompileEventHandler,
but jst didn't want it knowing about namespaces and suggested passing the
character string around.  I'll see what he thinks of using a aIsSVG flag instead.
I'm fine with the current way I think, though maybe I'd prefer to pass an atom.
Of course, I'd be fine with a bool too (which could be expanded to an enum in
case some another WG smokes a little too much weed too).
Attached patch clean up evt/event (obsolete) — Splinter Review
Attachment #151984 - Attachment is obsolete: true
There are two problems with this patch, which probably be addressed as
followup bugs/patches.

  * Some event names will be wrong - mozilla's event code generates html
    events (ex. "focus") instead of the DOM names (ex. "DOMfocus").  Fixing
    this would involve changing the event manager and probably some other
    code.

  * Only one "onload" is allowed, as it gets hooked up to the window object.
    This is a problem shared with html.
As a compromise that hopefully will provide the least surprise until the
matter of multiple onloads is addressed, this patch will only allow "onload"
on the root node.  While this won't help mixed namespace documents, it
should be useful for initialization in standalone svg files.
Attachment #152064 - Attachment is obsolete: true
Attachment #152529 - Flags: review?(bryner)
Comment on attachment 152529 [details] [diff] [review]
onload only on root

Looks ok to me; i'd suggest having jst sr=
Attachment #152529 - Flags: review?(bryner) → review+
Attachment #152529 - Flags: superreview?(jst)
Comment on attachment 152529 [details] [diff] [review]
onload only on root

+nsContentUtils::GetEventArgName(PRInt32 aNameSpaceID)
+{
+  if (aNameSpaceID == kNameSpaceID_SVG)
+    return gSVGEventName;
+  else
+    return gEventName;
+}

I'd loose the else-after-return there :-)

sr=jst
Attachment #152529 - Flags: superreview?(jst) → superreview+
Checked in.  Bug 252631 filed about the one onload per document limit.
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Slight problem with xbl handlers:

If you now attach a binding to an element in the SVG namespace and the binding
contains a handler, then the handler's event parameter is undefined (it is now
called 'evt'). I guess that's a bad thing; xbl handler event args should always
be called 'event' as given by the xbl specs.
Testcases:
http://www.croczilla.com/svg/samples/xbl1/ : not working anymore because event
is not defined in xbl1-bindings.xml line 72

http://www.croczilla.com/svg/samples/xbl-shapes/ : still working, since the
elements bound are not in the svg namespace
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Another problem:
onload doesn't appear to be working.
Testcase: http://www.croczilla.com/~alex/testcases/onload.svg
Attached patch repair onloadSplinter Review
The onload problem was caused by two things:

  * onload wasn't being accepted as an event name

  * check for root element was going wrong because <svg> is parsed before
    being added to the document

Jonas, why did you seperate off most of the event attributes into
IsGraphicElementEventName?
Comment on attachment 154119 [details] [diff] [review]
repair onload

>Index: nsSVGElement.cpp
>-          mDocument->GetRootContent() == NS_STATIC_CAST(nsIContent*, this)) {
>+          mDocument->GetRootContent() == NULL) {

Ack, this is a big hack. This will no longer enforce the root-element
requirement, but rather some empty-document requirement. Which in theory could
be any element if a DOM is created in javascript. I think it's ok for now
though since onload will be changed anyway later on. Please add a comment
though.

The reason i had a separate IsGraphicElementEventName is that many elements
will have only those eventattributes. My idea was that different elements will
override IsEventName and all "graphic elements" will in their implementation
call IsGraphicElementEventName.
Attachment #154119 - Flags: review+
> mDocument->GetRootContent() == NULL

yay, scc and jst would slap you hard for that. Make that
!mDocument->GetRootContent()
Onload fix checked in with the test changed and the comment expanded.
Attachment #154141 - Flags: superreview?(jst)
Comment on attachment 154141 [details] [diff] [review]
always compile xbl bindings with XBL namespace event name

sr=jst
Attachment #154141 - Flags: superreview?(jst) → superreview+
XBL binding patch checked in.
Status: REOPENED → RESOLVED
Closed: 17 years ago17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.