Display an error page for error URLs in WebEnginePart
ClosedPublic

Authored by stefanocrocco on May 1 2018, 4:09 PM.

Details

Summary

When asked to display an error URL, WebEnginePart displayed another
error telling that the web page "error:/..." can't be reached.

To avoid this, add a scheme handler for the "error" scheme to the default
profile. The handler replies with the html code read from an error.html page
with placeholders replaced by the error details contained in the URL.

The code used to produce the error page is taken, with small changes, by
webpage.cpp from KWebKitPart. The error page, too is taken from KWebKitPart and
modified a little.

Test Plan

Entered an invalid URL in address bar and checked that the error message was
displayed correctly.

Diff Detail

Repository
R226 Konqueror
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
stefanocrocco requested review of this revision.May 1 2018, 4:09 PM
stefanocrocco created this revision.
stefanocrocco edited the summary of this revision. (Show Details)May 1 2018, 4:28 PM
dfaure requested changes to this revision.May 1 2018, 5:09 PM

Nice! I remember that this was sorely missing when I was using that part :-)

webenginepart/src/webenginepart.cpp
90

missing space after if

webenginepart/src/webengineparterrorschemehandler.cpp
46

if you move this to the ctor init list, you can make the variable const.

52

no space before (

But I would split this; if the icon is not found, iconPath returns an empty string, and QFile doesn't like that (-> runtime warning) to better test that first.

61

unnecessary, the QFile destructor closes the file.

102

and suddenly from this point on, there are spaces inside parenthesis? ;-) weird...

webenginepart/src/webengineparterrorschemehandler.h
31

missing space before ':'

This revision now requires changes to proceed.May 1 2018, 5:09 PM
stefanocrocco updated this revision to Diff 33421.EditedMay 1 2018, 6:41 PM

Made corrections as required

anthonyfieroni added inline comments.
webenginepart/src/error.html
4

Why not use %1, %2, %3, other % should be doubled.

dfaure requested changes to this revision.May 1 2018, 8:45 PM

Thanks for the fixes, here are a few more nitpicks ;)

webenginepart/src/webengineparterrorschemehandler.cpp
52

missing space after if ;)

(and before the opening curly brace)

108

remove space before first '('

109

remove space inside (), add one before {

128

isEmpty() would be better than isNull(), no?

141

no space before '('

142

isEmpty() would be better than isNull, no?

159

should be if (!causes.isEmpty()), as a general rule (we don't need the actual count)

167

same

This revision now requires changes to proceed.May 1 2018, 8:45 PM

Fixed issues requested by dfaure

stefanocrocco added inline comments.May 2 2018, 6:39 PM
webenginepart/src/error.html
4

Do you mean replacing TITLE, DIRECTION, ICON_PATH and TEXT with %1, %2 and so on, then using QString::arg to replace the placeholders with the actual values?

anthonyfieroni added inline comments.May 2 2018, 7:07 PM
webenginepart/src/error.html
4

Yes.

dfaure added a comment.May 3 2018, 7:56 AM

In both cases the same fragility exists, in case one of the replacement strings contains one of the placeholders --- unless you use multi-arg, i.e. myString.arg(title, direction, m_warningIconData, ...)

dfaure added inline comments.May 3 2018, 7:58 AM
webenginepart/src/webenginepart.cpp
90

missing space before {

webenginepart/src/webengineparterrorschemehandler.cpp
109

too many spaces inside parenthesis, on this line.

122

remove space before (

anthonyfieroni added a comment.EditedMay 3 2018, 8:31 AM

@dfaure you're right except that replaced string can contain other one, since TEXT is the last this isn't so impossible :)

dfaure added a comment.May 3 2018, 8:36 AM

I don't understand the "except" in your reply.

The fact that "replaced string can contain other one" is exactly what I'm pointing out... but that's only a problem with replace(a,b) or .arg(a).arg(b).arg(c). Multi-arg doesn't have that problem.

Used QString::arg instead of QString::replace and fixed spaces

I've received no more comments on this review request even if I believe I made all requested changes. Did I miss something? Should I check the "Done" checkbox for each change to notify that it has been made? It's not clear whether those checkboxes are for the reviewers' use or mine.

dfaure accepted this revision.Jun 24 2018, 11:19 AM

Sorry, I failed to re-read it after you made the fixes.

The standard procedure in this case is to "ping" the reviewer in the review, which you just did ;)

This revision is now accepted and ready to land.Jun 24 2018, 11:19 AM
This revision was automatically updated to reflect the committed changes.