Bug 32639 - jump on right place in page on reload
Summary: jump on right place in page on reload
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
: 40573 70217 79025 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-09-18 20:03 UTC by sean
Modified: 2006-09-07 17:53 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Y Glodt 2001-09-18 19:59:46 UTC
(*** This bug was imported into bugs.kde.org ***)

Package: khtml
Version: 2.2.1
Severity: wishlist
Installed from: suse 7.2 rpms
Compiler: gcc version 2.95.3
OS: Linux 2.4.9-ac10
OS/Compiler notes: /

Hello

when you load a page that takes more than one screen (in length) and 
hit "Reload" it would be great when konqueror would jump to the place 
where you've been and not stay on top of the page.

thank you
yves
Comment 1 Kai Lahmann 2003-06-15 01:56:53 UTC
*** Bug 40573 has been marked as a duplicate of this bug. ***
Comment 2 Leo Savernik 2004-03-01 10:53:57 UTC
As of KDE 3.2.0, this still holds true.

Even Netscape Navigator 3 does remember the scroll position on reload, so it's an old feature that people have had lots of time to become accustomed to.
Comment 3 Stephan Kulow 2004-05-19 12:03:33 UTC
Replaced y.glodt@vo.lu with sean@digitalspinner.com due to bounces by reporter
Comment 4 Leo Savernik 2004-06-19 22:47:41 UTC
CVS commit by savernik: 

Remember scroll position when reloading a page. Currently works only on toplevel pages, but it was about time that *something* was done.

CCMAIL: 32639-done@bugs.kde.org


  M +28 -0     khtml_part.cpp   1.1009
  M +5 -2      khtml_part.h   1.259
  M +2 -2      khtmlview.cpp   1.639


--- kdelibs/khtml/khtml_part.cpp  #1.1008:1.1009
@@ -569,4 +569,13 @@ bool KHTMLPart::openURL( const KURL &url
   }
 
+  // Save offset of viewport when page is reloaded to be compliant
+  // to every other capable browser out there.
+  if (args.reload) {
+    args.xOffset = d->m_view->contentsX();
+    args.yOffset = d->m_view->contentsY();
+    d->m_extension->setURLArgs(args);
+    connect(d->m_view, SIGNAL(finishedLayout()), this, SLOT(restoreScrollPosition()));
+  }
+
   if (!d->m_restored)
     closeURL();
@@ -6327,4 +6336,23 @@ void KHTMLPart::emitCaretPositionChanged
 }
 
+void KHTMLPart::restoreScrollPosition()
+{
+  KParts::URLArgs args = d->m_extension->urlArgs();
+  if (!args.reload) {
+    disconnect(d->m_view, SIGNAL(finishedLayout()), this, SLOT(restoreScrollPosition()));
+    return;     // should not happen
+  }
+
+  // Check whether the viewport has become large enough to encompass the stored
+  // offsets. If the document has been fully loaded, force the new coordinates,
+  // even if the canvas is too short (can happen when user resizes the window
+  // during loading).
+  if (d->m_view->contentsHeight() - d->m_view->visibleHeight() >= args.yOffset
+      || d->m_bComplete) {
+    d->m_view->setContentsPos(args.xOffset, args.yOffset);
+    disconnect(d->m_view, SIGNAL(finishedLayout()), this, SLOT(restoreScrollPosition()));
+  }
+}
+
 KWallet::Wallet* KHTMLPart::wallet()
 {

--- kdelibs/khtml/khtml_part.h  #1.258:1.259
@@ -1420,5 +1420,8 @@ private slots:
   void jsErrorDialogContextMenu();
 
-
+  /**
+   * @internal
+   */
+  void restoreScrollPosition();
 
 private:

--- kdelibs/khtml/khtmlview.cpp  #1.638:1.639
@@ -631,4 +631,6 @@ void KHTMLView::layout()
         root->setLayouted(false);
         root->layout();
+
+        emit finishedLayout();
 #if 0
     ElementImpl *listitem = m_part->xmlDocImpl()->getElementById("__test_element__");
@@ -656,6 +658,4 @@ void KHTMLView::layout()
     d->layoutTimerId = 0;
     d->layoutSchedulingEnabled=true;
-    
-    emit finishedLayout();
 }
 


Comment 5 Leo Savernik 2004-06-27 15:44:51 UTC
*** Bug 79025 has been marked as a duplicate of this bug. ***
Comment 6 Iñaki Baz Castillo 2006-01-22 23:50:58 UTC
KDE 3.5.
I still see the same bug when reloading a page. The position is not kept.

It's occurs in www.barrapunto.com for example (the 90% of times). When I press F5 sometimes Konqueror goes to the beginning of the page, sometimes to a previous but not last position...
Comment 7 Leo Savernik 2006-09-07 17:53:26 UTC
*** Bug 70217 has been marked as a duplicate of this bug. ***