Closed Bug 115253 Opened 23 years ago Closed 22 years ago

[FIX]Comboxes can't be opened in DIV with scrolls !

Categories

(Core :: Layout: Form Controls, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla1.2beta

People

(Reporter: stephane.barbaray, Assigned: bzbarsky)

References

()

Details

(Keywords: html4, Whiteboard: [HTML4-17.6])

Attachments

(3 files)

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:0.9.6+)
Gecko/20011213
BuildID:    2001121313

Try to click on the comboxes they won't open at all, this will work only if the
Div container have overflow not set to scroll or auto

Reproducible: Always
Steps to Reproduce:
1. wait for comboboxes to appear instead of "Veuillez patienter" (please wait in
french)
2. Try to open any of the comboboxes

Actual Results:  nothing!!!

Expected Results:  combo's list shown!

This never worked since at least this summer
seen on linux too.
Severity: normal → major
Status: UNCONFIRMED → NEW
Ever confirmed: true
Hardware: PC → All
This probably doesn't have anything to do with what you changed, but could you 
take a look?
Assignee: rods → jkeiser
Well... the only things that we changed since the last summer is the overflow
set to scroll instead of none and a fixed height in the div, so it could have
never ever worked because I never tried it like that before! Furthermore setting
actually the 'overflow' back to 'none' will make the thing working again but I'd
need those combos in a scrolled div finally... :->
Hmmm.  No funky assertions showing up on a debug build.  This will take some
printfs I think.
*** Bug 116091 has been marked as a duplicate of this bug. ***
Any luck with this one?  We're having problem with a web app that won't let us
open select boxes if they're DIV as describe initially.
Attachment #69440 - Attachment is patch: false
Attachment #69440 - Attachment mime type: text/plain → text/html
The problem that we're having here is that screenX and screenY in the mouse
event are actually *different* when the mouse enters the scrollbar.  This
happens anytime you have a <select> inside of a scrolling <div>.  (Just simple
text did not cause this to happen.)

The exact amount of the difference, in fact, is the (x,y) position of the <div>
within the window (or possibly the <select>, not sure which).  This (x,y) is
being subtracted from the real screenX / screenY somewhere.

This causes the combobox not to open because it does not detect that the click
was in the combobox.  All click and mouse move events, in fact, will be wrong.

rods, bz, does this ring any bells?
jkeiser, as I move my mouse over that testcase screenX/Y vary continously....
the only discontinuous coordinates I see are layerX/Y.

And yes, I _do_ see the select not opening.
Hmm, I still see the discontinuity.  Please note that it's only about a
discontinuity of 60 (twips?).  It is most noticeable in the Y; the X is so close
to the left edge that it is imperceptible in this case.  When I first moved the
mouse around just now, in fact, I didn't see it (though I may just not have
looked hard, it's hard to spot), but I did see it soon thereafter.  Try moving
it around for a while, then bringing the mouse down into the combobox slowly
from above.

And it is definitely the cause of the problem in the code, at least on my system
(i.e. if I make that function return true, it will drop down, though that breaks
other things).  The code gets all the way up to this check and then this test
fails just before actually dropping down the combobox.

Could be Linux-only, but then that would mean there was a separate problem on
another platform with exactly the same symptoms.  That seems unlikely to me.
Ah, OK.  I see it too....  It sounds like something isn't walking up the views
properly to get the absolute offset?

I am not familiar with how (or where) we calculate that stuff, but here's a
hypothesis about how it usually works:

1. We walk up the views to find the position relative to the document.
2. We add the document's relative position to the browser.
3. We add the browser's relative position to the screen.

At a guess, I'd say (1) is stopping at the DIV (or the select?) and the other 2
steps are still working correctly.
Just did some testing; it appears that it is the DIV's top/left position that is
"subtracted" from screenX/Y, not the select's.

If you don't have a select in there, though, it doesn't do this.
Want something even cooler?  In a debug build I do _not_ see the discontinuity.
 The numbers are correct.

However, when I click on the select and drop it down using alt-down the popup is
just shifted up a bit in the opt build (as expected).  In the debug build, the
popup is outside the browser window, down and to the right.
This is a big thing, but there are other big things on the list too.  1.1.
Target Milestone: --- → mozilla1.1
Keywords: html4
Whiteboard: [HTML4-17.6]
QA Contact: madhur → tpreston
*** Bug 166706 has been marked as a duplicate of this bug. ***
Is there a fix for this on the horizon? 1.1 is out (see comment #16) and it's
still broken.
Attached patch Proposed patchSplinter Review
OK.  So the root cause of the problem was the following code in the "we have a
parent widget" branch:

-	 viewOffset.x += po.x;
-	 viewOffset.y += po.y;

and then if we have a widget

-	   aAbsoluteTwipsRect.x += po.x - bounds.x;
-	   aAbsoluteTwipsRect.y += po.y - bounds.y;

followed by

-      aAbsoluteTwipsRect.x += viewOffset.x;
-      aAbsoluteTwipsRect.y += viewOffset.y;

The net effect of this was to count "po" twice in the origin calculation.  This
caused the y-coord we calculated for the rect's origin to be wrong, with the
ensuing chaos.

So I fixed that.... then moved to nsCOMPtr's for the nsIWidget, then figured
out that the nsIScrollableView code was completely wrong (it always used
containingView, which is never updated after it's first gotten!) and utterly
unnecessary.

Then I decided I might as well rewrite the whole thing from scratch.  The basic
idea of the new code is to get the closest enclosing view for the frame, then
to walk up the view hierarchy till we get to a view with a widget. Once we
reach such a beast, grab its screen position and break out.

This shouldn't regress bug 35291 (I wish that had a testcase or something!),
since we start by checkin the widget of the frame's containing view, not the
widget of its parent (as the code did pre-35291)
Alternate approach would be to leave the code as-is except for:

-	   aAbsoluteTwipsRect.x += po.x - bounds.x;
-	   aAbsoluteTwipsRect.y += po.y - bounds.y;
+	   aAbsoluteTwipsRect.x -= bounds.x;
+	   aAbsoluteTwipsRect.y -= bounds.y;
I meant the "we have a parent view" branch in comment 19.
My vote: fix it, then fix it Right (if the first fix isn't Right). :)
Comment on attachment 97917 [details] [diff] [review]
Proposed patch

The patch looks good for what it does, but I am rather surprised that
GetPosition() works relative to screen coordinates rather than scrolled
coordinates.  Are you sure this is the case?  I mean, besides the fact that
this patch works :)
I'm pretty sure that that's the case.  But I'll double-check with roc... (as a
note, when I tried some scrolled divs everything was peachy as long as I did not
add in scroll positions.  When I did, things broke).
GetPosition() suffices because of the structure of views in scrolling elements.
There is a scroll port view with a widget, which contains a scrolled view. When
the element is scrolled down by N units, the scrolled view is at an offset of -N
to the scroll port view. GetPosition() picks this up and gets you into the
coordinate space of the scroll port before you look at its widget.
Comment on attachment 97917 [details] [diff] [review]
Proposed patch

r=jkeiser
Attachment #97917 - Flags: review+
taking
Assignee: jkeiser → bzbarsky
Priority: -- → P1
Summary: Comboxes can't be opened in DIV with scrolls ! → [FIX]Comboxes can't be opened in DIV with scrolls !
Target Milestone: mozilla1.1alpha → mozilla1.2beta
fixed for 1.2b
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
*** Bug 177469 has been marked as a duplicate of this bug. ***
*** Bug 96756 has been marked as a duplicate of this bug. ***
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: