Closed Bug 865377 Opened 12 years ago Closed 12 years ago

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

Categories

(Core :: DOM: Events, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Details

Attachments

(1 file, 1 obsolete file)

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)
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)
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
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: