Bug 67785 - [Qt][WK2] Make QWebError more friendly to QML.
Summary: [Qt][WK2] Make QWebError more friendly to QML.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Alexis Menard (darktears)
URL:
Keywords: Qt, QtTriaged
Depends on:
Blocks:
 
Reported: 2011-09-08 09:23 PDT by Alexis Menard (darktears)
Modified: 2011-09-15 13:15 PDT (History)
7 users (show)

See Also:


Attachments
Patch (8.04 KB, patch)
2011-09-08 09:52 PDT, Alexis Menard (darktears)
no flags Details | Formatted Diff | Diff
Patch (9.73 KB, patch)
2011-09-12 09:56 PDT, Alexis Menard (darktears)
no flags Details | Formatted Diff | Diff
Patch (14.52 KB, patch)
2011-09-13 14:49 PDT, Alexis Menard (darktears)
no flags Details | Formatted Diff | Diff
Patch (15.14 KB, patch)
2011-09-15 06:59 PDT, Alexis Menard (darktears)
no flags Details | Formatted Diff | Diff
Patch (15.23 KB, patch)
2011-09-15 07:12 PDT, Alexis Menard (darktears)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexis Menard (darktears) 2011-09-08 09:23:58 PDT
[Qt][WK2] Make QWebError more friendly to QML.
Comment 1 Alexis Menard (darktears) 2011-09-08 09:52:29 PDT
Created attachment 106750 [details]
Patch
Comment 2 WebKit Review Bot 2011-09-08 09:54:03 PDT
Attachment 106750 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/update-webkit', '--chromium']" exit_code: 2

Last 3072 characters of output:
393
    parsed_url: http://src.chromium.org/svn/trunk/src/build@99393
    should_process: True
    processed: True
    requirements: set(['./'])
  
    name: net
    url: http://src.chromium.org/svn/trunk/src/net@99393
    parsed_url: http://src.chromium.org/svn/trunk/src/net@99393
    should_process: True
    requirements: set(['./'])
  
    name: tools/data_pack
    url: http://src.chromium.org/svn/trunk/src/tools/data_pack@99393
    parsed_url: http://src.chromium.org/svn/trunk/src/tools/data_pack@99393
    should_process: True
    processed: True
    requirements: set(['./'])
  
    name: third_party/ffmpeg
    url: From('chromium_deps', 'src/third_party/ffmpeg')
    should_process: True
    requirements: set(['third_party', 'chromium_deps', './'])
  
    name: tools/generate_stubs
    url: http://src.chromium.org/svn/trunk/src/tools/generate_stubs@99393
    parsed_url: http://src.chromium.org/svn/trunk/src/tools/generate_stubs@99393
    should_process: True
    processed: True
    requirements: set(['./'])
  
    name: third_party/libjpeg_turbo
    url: From('chromium_deps', 'src/third_party/libjpeg_turbo')
    should_process: True
    requirements: set(['third_party', 'chromium_deps', './'])
  
    name: third_party/v8-i18n
    url: From('chromium_deps', 'src/third_party/v8-i18n')
    should_process: True
    requirements: set(['third_party', 'chromium_deps', './'])
  
    name: tools/grit
    url: http://src.chromium.org/svn/trunk/src/tools/grit@99393
    should_process: True
    requirements: set(['./'])
  
    name: base
    url: http://src.chromium.org/svn/trunk/src/base@99393
    should_process: True
    requirements: set(['./'])
  
    name: sql
    url: http://src.chromium.org/svn/trunk/src/sql@99393
    should_process: True
    requirements: set(['./'])
  
    name: v8
    url: From('chromium_deps', 'src/v8')
    should_process: True
    requirements: set(['chromium_deps', './'])
  
    name: testing/gtest
    url: From('chromium_deps', 'src/testing/gtest')
    should_process: True
    requirements: set(['testing', 'chromium_deps', './'])
  
    name: third_party/libwebp
    url: http://src.chromium.org/svn/trunk/src/third_party/libwebp@99393
    should_process: True
    requirements: set(['third_party', './'])
  
    name: googleurl
    url: From('chromium_deps', 'src/googleurl')
    should_process: True
    requirements: set(['chromium_deps', './'])
  
    name: third_party/skia/include
    url: From('chromium_deps', 'src/third_party/skia/include')
    should_process: True
    requirements: set(['third_party', 'chromium_deps', './'])
  
    name: third_party/ots
    url: From('chromium_deps', 'src/third_party/ots')
    should_process: True
    requirements: set(['third_party', 'chromium_deps', './'])
  
    name: third_party/snappy/src
    url: From('chromium_deps', 'src/third_party/snappy/src')
    should_process: True
    requirements: set(['third_party', 'chromium_deps', './'])

Died at Tools/Scripts/update-webkit-chromium line 80.
No such file or directory at Tools/Scripts/update-webkit line 104.


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Alexis Menard (darktears) 2011-09-08 09:55:34 PDT
(In reply to comment #2)
> Attachment 106750 [details] did not pass style-queue:
> 
> Failed to run "['Tools/Scripts/update-webkit', '--chromium']" exit_code: 2
> 
> Last 3072 characters of output:
> 393
>     parsed_url: http://src.chromium.org/svn/trunk/src/build@99393
>     should_process: True
>     processed: True
>     requirements: set(['./'])
> 
>     name: net
>     url: http://src.chromium.org/svn/trunk/src/net@99393
>     parsed_url: http://src.chromium.org/svn/trunk/src/net@99393
>     should_process: True
>     requirements: set(['./'])
> 
>     name: tools/data_pack
>     url: http://src.chromium.org/svn/trunk/src/tools/data_pack@99393
>     parsed_url: http://src.chromium.org/svn/trunk/src/tools/data_pack@99393
>     should_process: True
>     processed: True
>     requirements: set(['./'])
> 
>     name: third_party/ffmpeg
>     url: From('chromium_deps', 'src/third_party/ffmpeg')
>     should_process: True
>     requirements: set(['third_party', 'chromium_deps', './'])
> 
>     name: tools/generate_stubs
>     url: http://src.chromium.org/svn/trunk/src/tools/generate_stubs@99393
>     parsed_url: http://src.chromium.org/svn/trunk/src/tools/generate_stubs@99393
>     should_process: True
>     processed: True
>     requirements: set(['./'])
> 
>     name: third_party/libjpeg_turbo
>     url: From('chromium_deps', 'src/third_party/libjpeg_turbo')
>     should_process: True
>     requirements: set(['third_party', 'chromium_deps', './'])
> 
>     name: third_party/v8-i18n
>     url: From('chromium_deps', 'src/third_party/v8-i18n')
>     should_process: True
>     requirements: set(['third_party', 'chromium_deps', './'])
> 
>     name: tools/grit
>     url: http://src.chromium.org/svn/trunk/src/tools/grit@99393
>     should_process: True
>     requirements: set(['./'])
> 
>     name: base
>     url: http://src.chromium.org/svn/trunk/src/base@99393
>     should_process: True
>     requirements: set(['./'])
> 
>     name: sql
>     url: http://src.chromium.org/svn/trunk/src/sql@99393
>     should_process: True
>     requirements: set(['./'])
> 
>     name: v8
>     url: From('chromium_deps', 'src/v8')
>     should_process: True
>     requirements: set(['chromium_deps', './'])
> 
>     name: testing/gtest
>     url: From('chromium_deps', 'src/testing/gtest')
>     should_process: True
>     requirements: set(['testing', 'chromium_deps', './'])
> 
>     name: third_party/libwebp
>     url: http://src.chromium.org/svn/trunk/src/third_party/libwebp@99393
>     should_process: True
>     requirements: set(['third_party', './'])
> 
>     name: googleurl
>     url: From('chromium_deps', 'src/googleurl')
>     should_process: True
>     requirements: set(['chromium_deps', './'])
> 
>     name: third_party/skia/include
>     url: From('chromium_deps', 'src/third_party/skia/include')
>     should_process: True
>     requirements: set(['third_party', 'chromium_deps', './'])
> 
>     name: third_party/ots
>     url: From('chromium_deps', 'src/third_party/ots')
>     should_process: True
>     requirements: set(['third_party', 'chromium_deps', './'])
> 
>     name: third_party/snappy/src
>     url: From('chromium_deps', 'src/third_party/snappy/src')
>     should_process: True
>     requirements: set(['third_party', 'chromium_deps', './'])
> 
> Died at Tools/Scripts/update-webkit-chromium line 80.
> No such file or directory at Tools/Scripts/update-webkit line 104.
> 
> 
> If any of these errors are false positives, please file a bug against check-webkit-style.

Obviously some problem. Though the style checker will complain about the two names for signal parameters but it's on purpose.
Comment 4 WebKit Review Bot 2011-09-08 10:01:23 PDT
Comment on attachment 106750 [details]
Patch

Attachment 106750 [details] did not pass cr-mac-ews (chromium):
Output: http://queues.webkit.org/results/9617905
Comment 5 Alexis Menard (darktears) 2011-09-08 10:05:28 PDT
Comment on attachment 106750 [details]
Patch

Clearing cq flags, the cr-mac is sick and the patch only touch Qt specific files.
Comment 6 Noam Rosenthal 2011-09-09 03:19:40 PDT
Comment on attachment 106750 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=106750&action=review

> Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp:147
> +    QWebError lastError(error);
> +    emit q->loadFailed(&lastError);

Hmmm... lifecycle problems coming. This is a classic by-value object; I wish it could be passed as a QVariantMap or as a heap-allocated QObject that is transferred to JS scope. Is there a way to do that in QML? Otherwise what I suggest something like:
loadFailed() and QWebError* lastError(), saving the last QWebError as a child object of the view - this way lifecycle is safe.

> Source/WebKit2/UIProcess/API/qt/qmlplugin/plugin.cpp:28
> +#include <QtNetwork/QNetworkReply>

Seems unrelated. Crumbs from a separate patch?

> Source/WebKit2/UIProcess/API/qt/qmlplugin/plugin.cpp:43
> +        qmlRegisterUncreatableType<QNetworkReply>(uri, 5, 0, "NetworkReply", QObject::tr("Cannot create separate instance of NetworkReply"));

Ditto.
Comment 7 Alexis Menard (darktears) 2011-09-09 10:10:40 PDT
(In reply to comment #6)
> (From update of attachment 106750 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=106750&action=review
> 
> > Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp:147
> > +    QWebError lastError(error);
> > +    emit q->loadFailed(&lastError);
> 
> Hmmm... lifecycle problems coming. This is a classic by-value object; I wish it could be passed as a QVariantMap or as a heap-allocated QObject that is transferred to JS scope. Is there a way to do that in QML? Otherwise what I suggest something like:
> loadFailed() and QWebError* lastError(), saving the last QWebError as a child object of the view - this way lifecycle is safe.
> 

I knew about the life cycle object as I put in the changelog. If you take a look at mouse area implementation you will see that they do the same for the event handler. It brings here an important topic : What do we want with those views : a nice C++ API or a nice primary QML API and by extension an okish C++ API. For example lastError is a suggestion I though about but this is a really awkward QML API. I think it is very convenient to have the error valid only in the handler :

onLoadFailed { if (error.errorCode() == NetworkReply.TimeOut) //do something }  

> > Source/WebKit2/UIProcess/API/qt/qmlplugin/plugin.cpp:28
> > +#include <QtNetwork/QNetworkReply>
> 
> Seems unrelated. Crumbs from a separate patch?
> 
> > Source/WebKit2/UIProcess/API/qt/qmlplugin/plugin.cpp:43
> > +        qmlRegisterUncreatableType<QNetworkReply>(uri, 5, 0, "NetworkReply", QObject::tr("Cannot create separate instance of NetworkReply"));
> 
> Ditto.

Could be done in a separate patch though I think it was related to that one. QWebError gives you an error code, if you don't export QNetworkReply you can't do anything with this error code as the enum NetworkError tells you what is the problem (Host not found, timeout,...).
Comment 8 Noam Rosenthal 2011-09-09 14:19:31 PDT
Comment on attachment 106750 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=106750&action=review

>>> Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp:147
>>> +    emit q->loadFailed(&lastError);
>> 
>> Hmmm... lifecycle problems coming. This is a classic by-value object; I wish it could be passed as a QVariantMap or as a heap-allocated QObject that is transferred to JS scope. Is there a way to do that in QML? Otherwise what I suggest something like:
>> loadFailed() and QWebError* lastError(), saving the last QWebError as a child object of the view - this way lifecycle is safe.
> 
> I knew about the life cycle object as I put in the changelog. If you take a look at mouse area implementation you will see that they do the same for the event handler. It brings here an important topic : What do we want with those views : a nice C++ API or a nice primary QML API and by extension an okish C++ API. For example lastError is a suggestion I though about but this is a really awkward QML API. I think it is very convenient to have the error valid only in the handler :
> 
> onLoadFailed { if (error.errorCode() == NetworkReply.TimeOut) //do something }

I don't think it's an awkward QML API.
onLoadFailed { doSomethingWith(webView.lastError.url); }

If you really want to, you can add it as a member AND send it in the signal; this way it at least doesn't die, but just replaced when a new error comes in.

>>> Source/WebKit2/UIProcess/API/qt/qmlplugin/plugin.cpp:28
>>> +#include <QtNetwork/QNetworkReply>
>> 
>> Seems unrelated. Crumbs from a separate patch?
> 
> Could be done in a separate patch though I think it was related to that one. QWebError gives you an error code, if you don't export QNetworkReply you can't do anything with this error code as the enum NetworkError tells you what is the problem (Host not found, timeout,...).

Fair enough; my oversight for missing parts in the Changelog.
Comment 9 Alexis Menard (darktears) 2011-09-12 09:56:26 PDT
Created attachment 107059 [details]
Patch
Comment 10 Alexis Menard (darktears) 2011-09-12 09:58:18 PDT
(In reply to comment #9)
> Created an attachment (id=107059) [details]
> Patch

Removed the network reply, let see if we can get it in Qt :
https://qt.gitorious.org/qt/qtdeclarative/merge_requests/7

Otherwise use a lastError member to have a valid object. For now it's on purpose that I didn't add the Q_PROPERTY for the last error as it brings more complexity on when I should reset this last error.
Comment 11 WebKit Review Bot 2011-09-12 10:00:47 PDT
Attachment 107059 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebKit2/ChangeLog', u'Source/WebKit..." exit_code: 1

Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h:68:  The parameter name "error" adds no information, so it should be removed.  [readability/parameter_name] [5]
Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h:84:  The parameter name "error" adds no information, so it should be removed.  [readability/parameter_name] [5]
Source/WebKit2/UIProcess/qt/QtWebPageProxy.h:30:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 3 in 11 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 12 Alexis Menard (darktears) 2011-09-12 10:03:12 PDT
(In reply to comment #11)
> Attachment 107059 [details] did not pass style-queue:
> 
> Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebKit2/ChangeLog', u'Source/WebKit..." exit_code: 1
> 
> Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h:68:  The parameter name "error" adds no information, so it should be removed.  [readability/parameter_name] [5]
> Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h:84:  The parameter name "error" adds no information, so it should be removed.  [readability/parameter_name] [5]

Explained why in the changelog.

> Source/WebKit2/UIProcess/qt/QtWebPageProxy.h:30:  Alphabetical sorting problem.  [build/include_order] [4]

Fixed in http://trac.webkit.org/changeset/94960 .

> Total errors found: 3 in 11 files
> 
> 
> If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 Alexis Menard (darktears) 2011-09-13 14:49:06 PDT
Created attachment 107233 [details]
Patch
Comment 14 Alexis Menard (darktears) 2011-09-15 06:59:12 PDT
Created attachment 107489 [details]
Patch
Comment 15 Alexis Menard (darktears) 2011-09-15 07:12:50 PDT
Created attachment 107491 [details]
Patch
Comment 16 WebKit Review Bot 2011-09-15 07:18:47 PDT
Comment on attachment 107491 [details]
Patch

Rejecting attachment 107491 [details] from commit-queue.

Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 2

Last 500 characters of output:
WebKit2/UIProcess/qt/TouchViewInterface.h
Hunk #2 succeeded at 77 with fuzz 2 (offset 2 lines).
patching file Source/WebKit2/UIProcess/qt/ViewInterface.h
Hunk #1 succeeded at 26 with fuzz 2 (offset 1 line).
Hunk #2 succeeded at 75 (offset 6 lines).
Hunk #3 FAILED at 77.
1 out of 3 hunks FAILED -- saving rejects to file Source/WebKit2/UIProcess/qt/ViewInterface.h.rej

Failed to run "[u'/mnt/git/webkit-commit-queue/Tools/Scripts/svn-apply', u'--reviewer', u'Simon Hausmann', u'--f..." exit_code: 1

Full output: http://queues.webkit.org/results/9686084
Comment 17 Alexis Menard (darktears) 2011-09-15 09:54:07 PDT
Committed r95197: <http://trac.webkit.org/changeset/95197>
Comment 18 Balazs Kelemen 2011-09-15 13:15:37 PDT
It broke the wk2 bot because it has a too old Qt5. Unfortunately this cannot be fixed with an update until #68181 would have been solved.