Closed
Bug 58285
Opened 25 years ago
Closed 24 years ago
scrollTo() function does not scroll when executed after JS writes to browser window
Categories
(Core :: DOM: Core & HTML, defect, P3)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla0.9
People
(Reporter: aoltest, Assigned: jst)
References
()
Details
(Whiteboard: [HAVE FIX])
Attachments
(1 file)
|
262 bytes,
text/html
|
Details |
From Bugzilla Helper:
User-Agent: Mozilla/4.5 [en] (Win95; I)
BuildID: 2000101014
The small snippet of code below is a simple example of the problem. When a JS
function is called to write data to the screen, and then the scrollTo() function
is called afterwards, the scrolling does not work. If a button is placed on the
page that is linked to the scrollTo() function, clicking it does scroll the
page. Therefore, it seems that scrollTo() works only some of the time...
Note that the desired behavior works in both Nav 4.5 and IE 5.5.
Reproducible: Always
Steps to Reproduce:
1. Simply load the page to reproduce the problem.
Actual Results: Document is not scrolled.
Expected Results: Document should have scrolled a ways down.
*CODE*
<html>
<head>
<script>
function printList () {
for (var i=0;i<200;i++) {
document.write(i + "<br>");
}
}
</script>
</head>
<body>
<script>
printList();
scrollTo(0,460);
</script>
</body>
</html>
*END CODE*
Comment 1•25 years ago
|
||
Comment 2•25 years ago
|
||
Confirming on WinNT MN6 branch build 2000102609, Linux trunk build 2000102608.
Changing OS to "All". No errors visible in JavaScript console.
Browser, not engine. Reassigning to DOM Level 0 -
Assignee: rogerl → jst
Status: UNCONFIRMED → NEW
Component: Javascript Engine → DOM Level 0
Ever confirmed: true
OS: Windows 95 → All
QA Contact: pschwartau → desale
| Assignee | ||
Comment 3•24 years ago
|
||
This patch fixes this problem:
Index: nsGlobalWindow.cpp
===================================================================
RCS file: /cvsroot/mozilla/dom/src/base/nsGlobalWindow.cpp,v
retrieving revision 1.366
diff -u -r1.366 nsGlobalWindow.cpp
--- nsGlobalWindow.cpp 2000/12/03 01:21:54 1.366
+++ nsGlobalWindow.cpp 2000/12/14 06:27:55
@@ -1841,6 +1842,8 @@
nsresult result;
nsIScrollableView *view; // no addref/release for views
float p2t, t2p;
+
+ FlushPendingNotifications();
result = GetScrollInfo(&view, &p2t, &t2p);
Accepting and setting milestone to mozilla0.9
Status: NEW → ASSIGNED
Hardware: PC → All
Whiteboard: [HAVE FIX]
Target Milestone: --- → mozilla0.9
| Assignee | ||
Comment 4•24 years ago
|
||
Here's a better patch that fixes all the scroll methods in the window object:
Index: dom/src/base/nsGlobalWindow.cpp
===================================================================
RCS file: /cvsroot/mozilla/dom/src/base/nsGlobalWindow.cpp,v
retrieving revision 1.366
diff -u -r1.366 nsGlobalWindow.cpp
--- nsGlobalWindow.cpp 2000/12/03 01:21:54 1.366
+++ nsGlobalWindow.cpp 2000/12/15 12:52:32
@@ -1843,6 +1845,8 @@
nsIScrollableView *view; // no addref/release for views
float p2t, t2p;
+ FlushPendingNotifications();
+
result = GetScrollInfo(&view, &p2t, &t2p);
if (view) {
@@ -1861,6 +1865,8 @@
nsIScrollableView *view; // no addref/release for views
float p2t, t2p;
+ FlushPendingNotifications();
+
result = GetScrollInfo(&view, &p2t, &t2p);
if (view) {
@@ -1882,6 +1888,8 @@
nsIScrollableView *view = nsnull; // no addref/release for views
float p2t, t2p;
+ FlushPendingNotifications();
+
result = GetScrollInfo(&view, &p2t, &t2p);
if (view)
{
@@ -1896,6 +1904,8 @@
nsresult result;
nsIScrollableView *view = nsnull; // no addref/release for views
float p2t, t2p;
+
+ FlushPendingNotifications();
result = GetScrollInfo(&view, &p2t, &t2p);
if (view)
| Assignee | ||
Comment 5•24 years ago
|
||
Ok, here's an even better fix for this one:
Index: dom/src/base/nsGlobalWindow.cpp
===================================================================
RCS file: /cvsroot/mozilla/dom/src/base/nsGlobalWindow.cpp,v
retrieving revision 1.367
diff -u -r1.367 nsGlobalWindow.cpp
--- nsGlobalWindow.cpp 2000/12/30 19:21:39 1.367
+++ nsGlobalWindow.cpp 2001/01/13 01:27:22
@@ -1466,8 +1466,6 @@
*aScrollX = 0;
- FlushPendingNotifications();
-
GetScrollInfo(&view, &p2t, &t2p);
if (view) {
nscoord xPos, yPos;
@@ -1487,8 +1485,6 @@
*aScrollY = 0;
- FlushPendingNotifications();
-
GetScrollInfo(&view, &p2t, &t2p);
if (view) {
nscoord xPos, yPos;
@@ -4151,6 +4147,10 @@
GlobalWindowImpl::GetScrollInfo(nsIScrollableView **aScrollableView,
float *aP2T, float *aT2P)
{
+ // Flush pending notifications so that the presentation is up to
+ // date.
+ FlushPendingNotifications();
+
nsCOMPtr<nsIPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
if (presContext) {
The location of the new flush isn't perhaps the most logical place (I would have
perhaps put it into the ScrollTo function), but since GetScrollInfo will be
called before we scroll, and there are several implementations of ScrollTo, the
patch above seems reasonable. r=heikki.
| Assignee | ||
Comment 7•24 years ago
|
||
Fix checked in, marking FIXED.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•