Open Bug 416226 Opened 16 years ago Updated 2 years ago

Need specific event to notify fullZoom changes

Categories

(Core :: DOM: Events, defect, P5)

defect

Tracking

()

People

(Reporter: glazou, Unassigned)

References

Details

Attachments

(1 file, 1 obsolete file)

If an extension to FF3 changes the fullZoom factor directly through the markupDocumentViewer, the zoom factor in the UI (and in other codes/extensions dealing with it) is not updated because we have no way to notify these codes the fullZoom factor changed. I suggest a specific event to do that, dispatched when |nsIMarkupDocumentViewer.SetFullZoom()| succeeds.
taking bug
Assignee: nobody → daniel
This is related to bug 303405.
Attached patch fix #1 (obsolete) — Splinter Review
Comment on attachment 302576 [details] [diff] [review]
fix #1

>+  nsEvent evt(PR_TRUE, NS_FULLZOOMCHANGED);
>+  // XXX Dispatching to |window|, but using |document| as the target.
>+  evt.target = mDocument;
We should limit this hack, hopefully to load/unload events which can't be changed without
breaking lots of sites.

>+    { &nsGkAtoms::onfullzoomchanged,             { NS_FULLZOOMCHANGED, EventNameType_All }},
Do we need to add support for the new attribute? Would it be enough to be able to use
window.addEventListener("FullZoomChanged", ...);

If yes, then it is enough to just call
nsContentUtils::DispatchTrustedEvent(mDocument, mDocument->GetWindow(), "FullZoomChanged", PR_TRUE, PR_TRUE, nsnull);
in nsDocumentViewer.cpp. No need to create new nsEvent type or anything.
And perhaps the event shouldn't bubble. That way event listeners (in chrome)
for bubble phase wouldn't get called when subwindows get zoomed.
But if someone really wants to catch also those events, using capturing
listener would allow that.
Still one comment. I'd say it is better to dispatch the event after viewmanager update batch. Usually better to avoid running scripts while in a vm batch (though that is safe).
So my general comments:

1)  I don't like adding yet another completely undocumented event.  We need to have some documentation to go with this (devmo?).
2)  I don't like adding yet another non-gecko-namespaced event, though perhaps it's OK.
3)  Executing script in the middle of CallChildren might or might not be a good idea.  I guess the call on the prescontext might do that anyway, so this stuff might already be prone to crashes and exploits (since we hold no strong ref to the prescontext or presshell here).... But making it easier to hook in evil code seems like a dubious thing security-wise.
(In reply to comment #8)
> So my general comments:
> 
> 1)  I don't like adding yet another completely undocumented event.  We need to
> have some documentation to go with this (devmo?).

Sure. No checkin about this w/o doc.

> 3)  Executing script in the middle of CallChildren might or might not be a good
> idea.  I guess the call on the prescontext might do that anyway, so this stuff
> might already be prone to crashes and exploits (since we hold no strong ref to
> the prescontext or presshell here).... But making it easier to hook in evil
> code seems like a dubious thing security-wise.

I chose this way of doing because it was really unintrusive in terms of existing code. We can of course dispatch the event after the completion of CallChildren, and that will solve the multiple-event-per-window problem.
Blocks: 468835
Product: Core → Core Graveyard
The event could be called MozFullZoomChanged and it should be sent asynchronously
or using a script runner.
Assignee: daniel → nobody
Component: GFX → DOM: Events
Product: Core Graveyard → Core
QA Contact: general → events
Priority: -- → P5
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: