Closed Bug 131651 Opened 24 years ago Closed 24 years ago

Popup window is blurred on open if opened from a mousedown handler for a link

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

x86
All
defect
Not set
major

Tracking

()

RESOLVED FIXED
mozilla1.0.1

People

(Reporter: bryner, Assigned: bryner)

References

()

Details

(Keywords: regression, topembed+, Whiteboard: [need info])

Attachments

(1 file, 1 obsolete file)

Spun off from bug 120209, as I believe this is a different issue and looks like it's cross-platform. If you have an anchor element with a mousedown handler which opens and focuses a popup window, that popup window will receive a blur as soon as it is opened. The reason for this is that we fire the script event handler first, then we focus the link in our mousedown handling (see nsGenericHTMLElement::HandleDOMEventForAnchors), which refocuses the parent window. This can cause the popup window to close immediately if it has an onblur handler that closes the window.
I tried the obvious approach of checking if the window was active before focusing from nsGenericHTMLElement::HandleDOMEventForAnchors but that didn't work. At the time the check was made via asking the focus controller if it was active, the controller still thought it was since we didn't yet get back to the OS event to deactivate it. So we raced the pop up window's deactivate, and we beat it *but* the global gLastFocusedDocument was correctly set to the new window... so we sent it a blur from SendFocusBlur. It looks like the focus globals are out of synch with the focus controller, and this case gets in the gap.
This fixes it. The part in nsGenericHTMLElement is right, but the part in nsEventStateManager is to deal with this issue of the globals and focus controllers getting out of synch until other events in the event queue are dealt with. It is an interesting case that I handn't really considered before. This probably needs some thought about possible places where keeping these in synch would cause problems. Keeping them in synch also feels like a hack, and I'd like to get rid of the globals entirely, but the focus controllers don't have the right semantics to take over the globals' functionality right now (probably ever), so I'm guessing the right thing will have to wait for post 1.0.
taking on for mozilla 1.0 as I have a patch and it exposes a problem that could be causing other focus issues.
Assignee: joki → saari
OS: Linux → All
Target Milestone: --- → mozilla1.0
Status: NEW → ASSIGNED
Keywords: nsbeta1, topembed
embed triage: topembed+, very visible defect
Keywords: topembedtopembed+
QA Contact: madhur → rakeshmishra
-> bryner. Is there any chance you can run with Saari's patch here?
Assignee: saari → bryner
Status: ASSIGNED → NEW
Does this occur on any top sites?
Whiteboard: [need info]
Yeah, I'll give saari's patch some testing (I've been meaning to do this, haven't gotten around to it).
Status: NEW → ASSIGNED
Navtriage still has no feel for the impact of this bug. Is Parker a top site?
Nav triage team: nsbeta1-
Keywords: nsbeta1nsbeta1-
Target Milestone: mozilla1.0 → mozilla1.0.1
Comment on attachment 75145 [details] [diff] [review] Patch that fixes this. Mildly scary part in nsEventStateManager. r=bryner. This all seems correct to me, and I couldn't find any regressions running with this patch.
Attachment #75145 - Flags: review+
Comment on attachment 75145 [details] [diff] [review] Patch that fixes this. Mildly scary part in nsEventStateManager. sigh, ok. The mildly scary part in EventStateManager has become more scary. This patch causes a regression where if I activate a window right as a new page is loading, focus will get wacked and you won't be able to focus anything until you deactivate and reactivate the window. This is on Linux.
Attachment #75145 - Flags: review+ → needs-work+
Attached patch more spackleSplinter Review
So, in the case that was causing this regression, nextController was null. I added a check for this so that we don't deactivate the previous controller in this situation. Chris, I'm not sure which platform you were testing on where the globals were out of sync; can you retest and make sure this doesn't cause your fix not to work correctly?
Attachment #75145 - Attachment is obsolete: true
Attachment #86986 - Flags: review+
Comment on attachment 86986 [details] [diff] [review] more spackle r=saari from bryner's machine
Comment on attachment 86986 [details] [diff] [review] more spackle sr=hewitt
Attachment #86986 - Flags: superreview+
Checked in on the trunk. Will let this bake for a couple of days before checking in on the branch.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Causing topcrash in the yesterday's Trunk builds. Look at the topcrash bug 151568.
Status: RESOLVED → REOPENED
Keywords: regression
Resolution: FIXED → ---
Blocks: 151568
Nominating for branch approval.
Status: REOPENED → RESOLVED
Closed: 24 years ago24 years ago
Resolution: --- → FIXED
namachi - are you saying this resolved a topcrash, or caused one? the bug you refer to seems to be resolved fixed. Kevin - you marked this one as a very visible defect. is this because the URl referenced is a top site, or that this defect is seen quite often out in the wild?
I don't think this is seen often on real sites. The original bug that this was spawned from bug 120209 was causing problems on a number of sites and is now fixed I'm not sure if the fix needs to go on the branch.
Adding adt1.0.1- based on comment 19.
Keywords: adt1.0.1adt1.0.1-
QA Contact: rakeshmishra → trix
This caused bug 227741, looks like...
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: