Bug 55370 - [Qt] QWebView fails to load first page with an Anchor
Summary: [Qt] QWebView fails to load first page with an Anchor
Status: RESOLVED DUPLICATE of bug 32723
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 420+
Hardware: PC All
: P2 Normal
Assignee: Nobody
URL:
Keywords: Qt, QtTriaged
Depends on:
Blocks:
 
Reported: 2011-02-28 05:50 PST by Andy Nichols
Modified: 2011-03-03 08:33 PST (History)
4 users (show)

See Also:


Attachments
Test case code (276 bytes, application/octet-stream)
2011-02-28 07:17 PST, Benjamin Poulain
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Nichols 2011-02-28 05:50:45 PST
If when using QWebView::setUrl() for the first time the URL contains an anchor(ex. #something) then the QWebView will fail to update.  For example:

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QWebView webView;
    webView.show();
    webView.setUrl(QUrl(QString::fromLatin1("http://doc.qt.nokia.com/4.7/qcombobox.html")));
    return a.exec();
}

will successfully update the view to display the page, while:

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QWebView webView;
    webView.show();
    webView.setUrl(QUrl(QString::fromLatin1("http://doc.qt.nokia.com/4.7/qcombobox.html#itemDelegate")));
    return a.exec();
}

Will not update the webview at all.

Calling QWebView::load(QUrl(QString::fromLatin1("http://doc.qt.nokia.com/4.7/qcombobox.html#itemDelegate")));
does work however, but the inconsistency of behavior when using anchors with QWebView::setUrl(...) is cause for concernt.

Also not that the following also works:
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QWebView webView;
    webView.show();
    webView.setUrl(QUrl(QString::fromLatin1("http://doc.qt.nokia.com/4.7/qcombobox.html#itemDelegate")));
    webView.setUrl(QUrl(QString::fromLatin1("http://doc.qt.nokia.com/4.7/qcombobox.html#itemDelegate")));
    return a.exec();
}

It is worth noting that in FrameLoader::loadWithDocumentLoader(DocumentLoader* loader, FrameLoadType type, PassRefPtr<FormState> prpFormState), WebCore/loader/FrameLoader.cpp:2077
if (shouldScrollToAnchor(isFormSubmission, policyChecker()->loadType(), newURL))
returns true for the first call to setUrl above
and false for the second.

Also, the Version of Webkit used is the one included with the Qt Master branch
Comment 1 Benjamin Poulain 2011-02-28 07:17:43 PST
Created attachment 84055 [details]
Test case code
Comment 2 Aparna Nandyal 2011-03-01 03:43:42 PST
This bug is same as https://bugs.webkit.org/show_bug.cgi?id=32723

The root cause of the problem is same in both cases, the calls to 

d->frame->loader()->activeDocumentLoader()->writer()->begin(absolute);
d->frame->loader()->activeDocumentLoader()->writer()->end();

in QWebFrame::setUrl is causing this problem. Im looking into another bug (https://bugs.webkit.org/show_bug.cgi?id=54380) that will possibly refactor this code.
Comment 3 Benjamin Poulain 2011-03-01 04:09:00 PST

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