Bug 26452 - [Qt] Add ability to prepend an item to the history list
Summary: [Qt] Add ability to prepend an item to the history list
Status: RESOLVED DUPLICATE of bug 30710
Alias: None
Product: WebKit
Classification: Unclassified
Component: History (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other All
: P2 Normal
Assignee: Nobody
Keywords: Qt
Depends on:
Reported: 2009-06-16 11:50 PDT by Adam Treat
Modified: 2009-11-24 07:48 PST (History)
2 users (show)

See Also:

Adds prependItem (3.72 KB, patch)
2009-06-16 12:02 PDT, Adam Treat
no flags Details | Formatted Diff | Diff
updated patch with requested changes (3.62 KB, patch)
2009-06-16 15:39 PDT, rick
eric: review-
Details | Formatted Diff | Diff
Updated WebKit patch for adding prepend API (3.93 KB, patch)
2009-06-22 13:32 PDT, rick
no flags Details | Formatted Diff | Diff
minor cleanups + changelog (5.83 KB, patch)
2009-06-23 08:22 PDT, Benjamin Meyer
manyoso: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Treat 2009-06-16 11:50:11 PDT
Hi, and thanks.  I would like to be able to prepend items to the history list (i.e. put items in the browser's history list before the first one).  The reason is that I am using WebKit as a plug-in.  I want to shut down and restart WebKit, re-loading it with the history that I've kept track of.  To keep it simple, I propose adding a simple "prependItem" to QWebHistory, so that I can do this.
Comment 1 Adam Treat 2009-06-16 12:02:04 PDT
Created attachment 31362 [details]
Adds prependItem
Comment 2 Adam Treat 2009-06-16 12:05:09 PDT
To be clear, the attached patch is from Rick Passeto, not me.
Comment 3 rick 2009-06-16 15:33:36 PDT
From an IRC chat with Kenneth: 
- change prpItem to newItem in both addItem() and prependItem()
- He also asked if ASSERT(newItem) was okay.  It looks like it is
- Also, in qwebhistory.cpp, he asked if WebCore should be namespaced in the file. 
Comment 4 rick 2009-06-16 15:39:56 PDT
Created attachment 31386 [details]
updated patch with requested changes

This is an updated patch based on feedback from kenneth.
Comment 5 Eric Seidel (no email) 2009-06-18 18:20:36 PDT
Comment on attachment 31386 [details]
updated patch with requested changes

ChangeLogs are missing.
Comment 6 rick 2009-06-22 13:32:13 PDT
Created attachment 31670 [details]
Updated WebKit patch for adding prepend API

Another attempt at uploading the patch properly...
Comment 7 Benjamin Meyer 2009-06-23 08:22:28 PDT
Created attachment 31721 [details]
minor cleanups + changelog
Comment 8 Maciej Stachowiak 2009-06-23 20:44:37 PDT
The core code looks ok to me, but since the patch adds Qt API, a Qt person may want to review it.
Comment 9 Adam Treat 2009-06-24 08:08:00 PDT
I am ok with the API except for one thing I'd like to see addressed first:

1) What is wrong with storing the history like other clients do?  Arora also has need to shut down and re-open from time to time with an intact history list.  What is different about your situation as compared to Arora or other Qt clients that already do this with the existing API?
Comment 10 Adam Treat 2009-06-24 08:23:49 PDT
Ok, scratch my last question.  Arora and other clients *do not* restore history in this sense.  There is the QWebHistoryInterface::historyContains method, but that is only for visited links.  You are looking to make the back/forward list persistent across restarts.

However, I have another question... Can't you achieve the same thing with simple 'addItem'?  Why do you need to add 'prependItem' to WebCore?
Comment 11 rick 2009-06-24 13:50:53 PDT
The problem is that addItem() *appends* history items, so if there are already URLs in the history, they come after the current URL.

Even if this weren't so: in the case of re-initializing the history, if you call addItem(URL1), addItem(URL2), ... addItem(URLn),  the problem is that the "current URL" is wrong (it will be URL1).  There isn't API for "make this history item the current item" (there is a "goto this history item", but that's not the same.

Admittedly there are probably alternatives to prependItem, but this seemed simplest.
Comment 12 Adam Treat 2009-06-24 14:21:36 PDT
It seems to me your specific use case is to restore the history on restarting the plugin.  Given this, there should be no prior URLS in the back/forward list, right?

If true, then it seems you could simply append your items in reverse order, no?
Comment 13 Adam Treat 2009-06-25 06:24:59 PDT
Comment on attachment 31721 [details]
minor cleanups + changelog

Take this out of the review queue as it seems things will need to be changed.  For instance, s/addItem/prependItem/ to QWebHistory and also s/const QString &urlString/const QUrl &url/ etc, etc.
Comment 14 Jędrzej Nowacki 2009-10-29 04:32:50 PDT
Functionality of saving and restoring the QWebHistory should be in Qt 4.6.

The bug is similar to bug 30710. I suppose, this one may be closed as duplicated. Please, verify if am I correct.
Comment 15 Jędrzej Nowacki 2009-11-24 07:48:06 PST
I'm closing as duplicate of bug 30710.

*** This bug has been marked as a duplicate of bug 30710 ***