Closed Bug 195905 Opened 21 years ago Closed 21 years ago

[FIX]Clicking on link does not activate it (line with tall image and link)

Categories

(Core :: Layout, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla1.6alpha

People

(Reporter: jss, Assigned: bzbarsky)

References

()

Details

(Whiteboard: edt_x3)

Attachments

(3 files)

If I go to the page above, and try to click on "Postscript" (in "Symbols 1-527
(also available in PostScript)."), the link is not activated but the browser
scrolls back up to the top of the image to the right of the bullet point. The
same is true for all the other links.

The html goes something like
<ul>
<li>Some text <a href="blah">link</a> <img src="large.gif">
<li>...
</ul>

This is with Mozilla 1.3b on Linux.
I should clarify. By experimenting, the window should be wide enough to display
the bullet point and image side-by-side, and short enough so that all the image
cannot be displayed enough. Clicking on the link moves to the top of the image,
rather than going to the link.
Also fails on Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3b)
Gecko/20030210
I bet the issue is that ScrollFrameIntoView scrolls to the top of the line box
for inline frames
(http://lxr.mozilla.org/seamonkey/source/layout/html/base/src/nsPresShell.cpp#4302);
in this case the line box is huge (because of the replaced inline <img>) and so
we scroll to hell-knows-where.

The code in question was added for bug 38280, and if the link were wrapped
around the image the scrolling may indeed be desired behavior....  So we need to
try to fix this without regressing bug 38280
Assignee: asa → bzbarsky
OS: Linux → All
Priority: -- → P1
Hardware: PC → All
Target Milestone: --- → mozilla1.4beta
Version: Other Branch → Trunk
How about we scroll the top of the line box to the top of the scrolled area,
unless that puts the bottom of the line box below the bottom of the scrolled
area, in which case we put the bottom of the line box at the bottom of the
scrolled area?
That won't really fix this bug.  The problem is that if we move the <a> such that the
mouseup no longer happens inside it, we get no click event on it, hence do not follow
the link.  With that proposal, following the link will become possible
if it is near the bottom of the viewport, but not otherwise.

On the other hand, this is exactly the distinction that's supposed to
be addressed by the scroll position flags, no?

The behavior of SCROLL_ANYWHERE and SCROLL_IF_NOT_VISIBLE is not clearly
differentiated in nsIPresShell, but I'd think that one of them would do the right thing
here....  (in fact, the definition of SCROLL_ANYWHERE sounds like
SCROLL_IF_NOT_VISIBLE to me; all this stuff could use some documenting
and cleanup  :( )
*** Bug 200332 has been marked as a duplicate of this bug. ***
*** Bug 200565 has been marked as a duplicate of this bug. ***
Summary: Clicking on link does not activate it → Clicking on link does not activate it (line with tall image and link)
Component: Browser-General → Layout: Misc Code
QA Contact: asa → ian
Whiteboard: edt_x3
I don't think it's a problem with the flags. One of the problems is that the
rect we are trying to scroll into view is wrong ... it's the dimension of the
frame we truly want to scroll placed at the top of the line. That's what
dbaron's bug  202977 is about.

So what will this patch I am attaching break? It suppresses scrolling when we
focus content by a mouse click. We really shouldn't be scrolling objects when
the user clicks on them since as this bug points out, we could scroll it out
from underneath the mouse.
That will make some things weird... eg clicking a link or textbox that's
partially offscreen will not scroll to it.

I'm not sure whether scrolling to such is desirable or not, come to think of
it... aaronl?  Thoughts?
Comment on attachment 121440 [details] [diff] [review]
Patch to prevent scrolling when focusing by mouse click.

Doh, I just realized I attached a slightly older diff file, the only difference
between what is in my tree and the attached patch is that I have:


+  else if (didSuppress && focusController) {


instead of:


+  else if (didSuppress) {
Boris, in my current build I don't see that clicking in a textfield that's
partially offscreen scrolls to it.
Attached patch Proposed patchSplinter Review
The basic idea here is that if we are asked to scroll a frame "anywhere" and
the frame has a nonzero height, then we should not get the line box.  This
keeps the case of "link to named anchor" working, since that scrolls to "top",
not "anywhere", and deals with the original problem in bug 38280 (which was an
inline frame with a zero height).

I've tested all the testcases in both bugs, and this seems like the most
reasonable approach...
Comment on attachment 132259 [details] [diff] [review]
Same as diff -w FOR REVIEW ONLY

David, what do you think?
Attachment #132259 - Flags: superreview?(dbaron)
Attachment #132259 - Flags: review?(dbaron)
Summary: Clicking on link does not activate it (line with tall image and link) → [FIX]Clicking on link does not activate it (line with tall image and link)
Target Milestone: mozilla1.4beta → mozilla1.6alpha
Comment on attachment 132259 [details] [diff] [review]
Same as diff -w FOR REVIEW ONLY

>+  if (frameBounds.height == 0 || aVPercent != NS_PRESSHELL_SCROLL_ANYWHERE) {

I think I prefer not checking the height here.	I think it's better to get the
whole line in view in the general case.  (Consider a definition in the middle
of a paragraph with a tall image in the line being scrolled to.)  r+sr=dbaron
with that change.

I also wonder how this interacts with the things discussed in bug 66619.
Attachment #132259 - Flags: superreview?(dbaron)
Attachment #132259 - Flags: superreview+
Attachment #132259 - Flags: review?(dbaron)
Attachment #132259 - Flags: review+
David, the line height check is so that we will get the whole line into view
_either_ if the scroll is "not anywhere" _or_ if the height is 0.  Removing that
check makes us scroll the whole line into view in fewer cases (and you say you
want that to happen as often as possible)...  It still won't regress bug 38280,
so I don't mind removing that check, but it's your call.  Please let me know.

As for bug 66619, that bug and this one are diametrically opposed in the current
setup.  Both clicking on the link and tabbing to it focus it; focus is what
triggers the scrolling.  In the click case, you want the link to scroll as
little as possible, otherwise you get this bug.  In the tab case, bug 66619 is
asking for a lot of scrolling (scrolling to the top of the link no matter what,
basically).  As long as both scrolls are triggered from the same place in the
code with identical values of the "scroll percentage", there is no way to fix both.
Checked in
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Product: Core → Core Graveyard
Component: Layout: Misc Code → Layout
Product: Core Graveyard → Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: