Closed Bug 332246 Opened 18 years ago Closed 17 years ago

scrollIntoView(false) doesn't work correctly for inline elements that wrap at multiple lines

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: martijn.martijn, Assigned: martijn.martijn)

References

(Depends on 1 open bug)

Details

(Keywords: testcase)

Attachments

(4 files, 1 obsolete file)

See upcoming testcase.
Clicking on the 'Show bottom' button doesn't work correctly in Mozilla.
It only scrolls the first line into view (from the bottom).
It should show the last line into view from the bottom, like IE6 is doing.
Attached file testcase
Attached patch patch (obsolete) — Splinter Review
This makes it work for me.
Attachment #216762 - Flags: review?(jst)
Comment on attachment 216762 [details] [diff] [review]
patch

Looks good to me, but bz or dbaron should sr.
Attachment #216762 - Flags: superreview?(dbaron)
Attachment #216762 - Flags: review?(jst)
Attachment #216762 - Flags: review+
(In reply to comment #4)
> Would a fix for bug 66619 also fix this?
Yes, I think so. Not sure what the patch in that bug is also trying to fix, though.

Depends on: 66619
Attachment #216762 - Flags: superreview?(dbaron)
Attached file testcase2
The first value in testcase2 returns 101 in current trunk builds, that shouldn't happen, so I filed bug 401904 for it.
Attached patch patchSplinter Review
This is now enough to make it work correctly.
Attachment #216762 - Attachment is obsolete: true
Assignee: general → martijn.martijn
Attached patch mochitestSplinter Review
Attachment #286852 - Flags: review?(dbaron)
Attachment #286845 - Flags: review?(dbaron)
I see this happening on Mac OS X 10.4 as well. To me it does not matter if it is an inline or block element or whether the element text wraps or not. I can reproduce the bug with any element.
Flags: blocking1.9?
OS: Windows XP → All
Hardware: PC → All
This doesn't appear to be a regression from 1.8 - but would take the patch - so marking - for blocking but if you get reviews on patch ask for patch approval
Flags: blocking1.9? → blocking1.9-
Comment on attachment 286845 [details] [diff] [review]
patch

Robert, perhaps you could review?
Attachment #286845 - Flags: review?(dbaron) → review?(roc)
Attachment #286852 - Flags: review?(dbaron) → review?(roc)
Attachment #286845 - Flags: superreview+
Attachment #286845 - Flags: review?(roc)
Attachment #286845 - Flags: review+
Attachment #286845 - Flags: approval1.9+
Robert, you forgot to review (or take a quick look at) the mochitest.
Comment on attachment 286852 [details] [diff] [review]
mochitest

I have very little enthusiasm for reviewing tests :-)
Attachment #286852 - Flags: review?(roc) → review+
Checking in nsGenericHTMLElement.cpp;
/cvsroot/mozilla/content/html/content/src/nsGenericHTMLElement.cpp,v  <--  nsGen
ericHTMLElement.cpp
new revision: 1.745; previous revision: 1.744
done

Checked into trunk.

Checking in Makefile.in;
/cvsroot/mozilla/content/html/content/test/Makefile.in,v  <--  Makefile.in
new revision: 1.35; previous revision: 1.34
done
RCS file: /cvsroot/mozilla/content/html/content/test/test_bug332246.html,v
done
Checking in test_bug332246.html;
/cvsroot/mozilla/content/html/content/test/test_bug332246.html,v  <--  test_bug3
32246.html
initial revision: 1.1
done

Mochitest checked in.
Status: NEW → RESOLVED
Closed: 17 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
MacOSX Darwin 8.8.4 qm-xserve01 dep unit test was failing with the mochitest, so I removed this test from the Makefile.in file for now.
Flags: in-testsuite+ → in-testsuite?
Apparently, it also fails on Linux qm-centos5-01 dep unit test.
Ok, it turns out that Linux qm-centos5-01 dep unit test is failing because it doesn't suffer from bug 401904, so it's failing on the TODO item!

Mac is failing for the first 2 tests, it returns 102 for both of them. I filed bug 411297 for that.

So I guess I could alter the Mochitest to do platform specific test to take all of that into account.
Ok, I added some platform specific checks now in the mochitest, like this:
//bug 401904 for windows, bug 411297 for the Mac
if (navigator.platform == "Win32" || navigator.platform.indexOf("Mac") == 0)
  todo(a1.scrollTop == 100, "Wrong scrollTop value!");
else
  ok(a1.scrollTop == 100, "Wrong scrollTop value!");
a2.scrollIntoView(false);
if (navigator.platform.indexOf("Mac") == 0) //Mac bug 411297 again
  todo((a1.scrollHeight - a1.offsetHeight - a1.scrollTop) == 100, "Wrong (scrollHeight - offsetHeight - scrollTop) value!");
else
  ok((a1.scrollHeight - a1.offsetHeight - a1.scrollTop) == 100, "Wrong (scrollHeight - offsetHeight - scrollTop) value!");

It's ugly, but it should work.
The platform specific checks can be removed as soon as the corresponding bugs would be removed.
Flags: in-testsuite? → in-testsuite+
Since this checkin, on my nightly CVS trunk builds, forums such as the example below now jump to the top of the page when clicking the Prev or Next links with the page scrolled down. In previous nightlies, the scoll position remained where it was when clicking the links.  This is a major nuisance, although I didn't look at the JavaScript being run to see if it was working correctly or incorrectly before.

http://forums.roadbikereview.com/showthread.php?t=116961
Depends on: 411665
Brad, thanks for mentioning this, I filed bug 411665 for it.
Note that IE and Opera do the same, so I actually think that Mozilla is doing the correct thing now (although it looks ugly). But maybe the ugly flash of scrolling can be reduced in some other way.
The most simple thing off course would be if the site in question would fix their broken script.
Depends on: 443732
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: