Give EventTarget a chrome-only getter that returns the relevant global

RESOLVED FIXED in mozilla24

Status

()

Core
DOM: Events
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: bz, Assigned: bz)

Tracking

unspecified
mozilla24
x86
Mac OS X
Points:
---
Bug Flags:
in-testsuite ?

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

The goal is that given an EventTarget "t" you can do:

  t.dispatchEvent(new t.global.Event("something"));

in chrome code and create the Event with the right permissions that event listeners on the target can touch it.

Questions:

1)  What should the attribute return?  I'm tempted to say "Window" for now...
2)  What should it be named?
Flags: needinfo?(bugs)
(1) Window
(2) ownerGlobal?
Flags: needinfo?(bugs)
Created attachment 756097 [details] [diff] [review]
Give EventTarget a chrome-only getter that returns its global.   idea is that you then do things like t.dispatchEvent(new t.ownerGlobal.Event("something")).
Attachment #756097 - Flags: review?(bugs)
Assignee: nobody → bzbarsky
Comment on attachment 756097 [details] [diff] [review]
Give EventTarget a chrome-only getter that returns its global.   idea is that you then do things like t.dispatchEvent(new t.ownerGlobal.Event("something")).

Hmm, you're returning outer window for nodes and inner window for DETHs.

{ goes to its own line at the beginning of a method.

r- because we need to return always same kind of window, and would be
good to even document that in EventTarget.h
Attachment #756097 - Flags: review?(bugs) → review-
> Hmm, you're returning outer window for nodes and inner window for DETHs.

Doesn't matter for JS callers.  Are you worried about C++ callers?

Do you just always want to see the outer window here?
Flags: needinfo?(bugs)
Created attachment 756158 [details] [diff] [review]
Give EventTarget a chrome-only getter that returns its global.   idea is that you then do things like t.dispatchEvent(new t.ownerGlobal.Event("something")).
Attachment #756158 - Flags: review?(bugs)
Attachment #756097 - Attachment is obsolete: true
Comment on attachment 756158 [details] [diff] [review]
Give EventTarget a chrome-only getter that returns its global.   idea is that you then do things like t.dispatchEvent(new t.ownerGlobal.Event("something")).


>+nsIDOMWindow*
>+nsINode::GetOwnerGlobal()
>+{
>+  return nsPIDOMWindow::GetOuterFromCurrentInner(OwnerDoc()->GetInnerWindow());
>+}
oh, crap. I realized we want to support data documents too.
So this should use GetScriptHandlingObject().
bool dummy;
return nsPIDOMWindow::GetOuterFromCurrentInner(static_cast<nsGlobalWindow*>OwnerDoc()->GetScriptHandlingObject(dummy));
Something like that.


>+  virtual nsIDOMWindow* GetOwnerGlobal() MOZ_OVERRIDE {
{ goes to the next line
>+'WindowProxy': [
>+{
>+    'nativeType': 'nsIDOMWindow',
>+    'concrete': False
>+},
>+{
>+    'workers': True
>+}],
workers True needs some explanation.
Attachment #756158 - Flags: review?(bugs) → review+
Flags: needinfo?(bugs)
> So this should use GetScriptHandlingObject().

Good catch, done.

Addressed the other two as well.

https://hg.mozilla.org/integration/mozilla-inbound/rev/a6de622f9574
Flags: in-testsuite?
Target Milestone: --- → mozilla24
https://hg.mozilla.org/mozilla-central/rev/a6de622f9574
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.