Closed Bug 1309 Opened 26 years ago Closed 26 years ago

Mouse events fire twice on absolutely positioned elements

Categories

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

x86
Other
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: angus, Assigned: joki)

Details

Try out this test case. When it isn't absolutely positioned, it works fine. But when absolutely positioned, my handler is called twice for each mousedown event. Here's a test case: <html> <head> <script> function handle(e) { var myp = document.createElement("P"); var mytext = document.createTextNode(e.type); myp.appendChild(mytext); document.getElementsByTagName("BODY")[0].appendChild(myp); } </script> </head> <body> <p onmousedown="handle(event)" style="position: absolute; left:200px; top:200px; width: 150px; background-color: #cccccc;"> The event will appear in a unique paragraph for each mousedown event. Press your mouse down on me to try it. If you see 2 paragraphs, that's bad. If you see one, that's good. </p> </body> </html>
Status: NEW → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
The events were being dispatched through both the view and frame hierarchies and therefore hitting the target twice. The proper route should be through the view route. I've commented out the route through the bodyFrame and once these frames have a separate list of their absolutely positioned kids we just have to not dispatch through them.
Pinged originator yesterday for verification of bug; unable to determine whether the behavior in the 12.1.98 build is as expected. (Specifically, clicking on the paragraph results in the paragraph's layout becoming completely munged, and row after row of "onmousedown"s in the left-hand portion of the page; I guess the 'onmousedown's are technically in separate paragraphs in an HTML sense, as there are line breaks between them, but I'd rather defer to reporter on this one.)
I'm not seeing any munging of the paragraph contents at all. For each time I click on the parapgraph I get a single "onmousedown" appearing on the left side of the page, each beneath the next. This should be the intended behavior. Could you describe the paragraph munging more?
Hi, Tom --- Sure. The munging starts the moment the first "onmousedown" is drawn that results in the need for the viewer to scroll downwards. (Still using xpviewer, 12.1.98 build on Win NT 4.0 SP3) If you partially cover up the column of "onmousedown"s with another application (in this case, Communicator 4.5) after this munging has occured and then return to it, the portion of the "onmousedown" text that the viewer redraws is vertically offset. I'll send you a .BMP file by E-mail illustrating both of these points, to make this easier.
BTW --- I've noticed that it only appears to happen if you shrink the window a bit (say, 250 pixels vertical space for the viewer's content region.)
I've reassigned this to kipp@netscape.com as a new bug (#1756). I don't really want to clutter this one up any further as the defect is separte and not related to this original bug. So I think we can verify this.
Status: RESOLVED → VERIFIED
Thanks, Tom! This bug is now verified.
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.