WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 69274
[Qt] [WK2] Support JS alert/confirm/prompt in QDesktopWebView
https://bugs.webkit.org/show_bug.cgi?id=69274
Summary
[Qt] [WK2] Support JS alert/confirm/prompt in QDesktopWebView
Caio Marcelo de Oliveira Filho
Reported
2011-10-03 11:40:05 PDT
[Qt] [WK2] Support JS alert/confirm/prompt in QDesktopWebView
Attachments
Patch
(13.16 KB, patch)
2011-10-03 11:44 PDT
,
Caio Marcelo de Oliveira Filho
kling
: review+
kling
: commit-queue-
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Caio Marcelo de Oliveira Filho
Comment 1
2011-10-03 11:44:31 PDT
Created
attachment 109503
[details]
Patch
Jocelyn Turcotte
Comment 2
2011-10-03 12:13:45 PDT
Comment on
attachment 109503
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=109503&action=review
> Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp:211 > +void QDesktopWebViewPrivate::runJavaScriptAlert(const QString& alertText) > +{ > +#ifndef QT_NO_MESSAGEBOX > + const QString title = tr("JavaScript Alert - %1").arg(q->url().host()); > + disableMouseEvents(); > + QMessageBox::information(0, title, escapeHtml(alertText), QMessageBox::Ok); > + enableMouseEvents(); > +#else
We're currently trying to get rid of dependencies of QtWebKit to QtGui to slim down memory uses. It would also be nice to give the the choice of using QMessageBox or a homemade/QtComponent dialog to the user code. Virtual method reimplementations aren't friendly to straight QML use cases, though I'm not sure if JS alerts should be considered a common use case for simple apps. In any case, emitting a signal instead might be better.
> Source/WebKit2/UIProcess/qt/ClientImpl.cpp:164 > +static inline WKStringRef createNullWKString() > +{ > + RefPtr<WebString> webString = WebString::createNull(); > + return toAPI(webString.release().leakRef()); > +}
I think that WKStringCreateWithQString should return a null WKString if given a null QString as input. Is it possible to use it instead?
Alexis Menard (darktears)
Comment 3
2011-10-03 12:22:44 PDT
Comment on
attachment 109503
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=109503&action=review
> Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp:-25 > -
Useless.
>> Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp:211
> > We're currently trying to get rid of dependencies of QtWebKit to QtGui to slim down memory uses. > It would also be nice to give the the choice of using QMessageBox or a homemade/QtComponent dialog to the user code. > > Virtual method reimplementations aren't friendly to straight QML use cases, though I'm not sure if JS alerts should be considered a common use case for simple apps. > > In any case, emitting a signal instead might be better.
But how you spin off an event loop from the QML side?
Alexis Menard (darktears)
Comment 4
2011-10-03 12:29:47 PDT
(In reply to
comment #3
)
> (From update of
attachment 109503
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=109503&action=review
> > > Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp:-25 > > - > > Useless. > > >> Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp:211 > > > > > We're currently trying to get rid of dependencies of QtWebKit to QtGui to slim down memory uses. > > It would also be nice to give the the choice of using QMessageBox or a homemade/QtComponent dialog to the user code. > > > > Virtual method reimplementations aren't friendly to straight QML use cases, though I'm not sure if JS alerts should be considered a common use case for simple apps. > > > > In any case, emitting a signal instead might be better. > > But how you spin off an event loop from the QML side?
We don't have yet such component and also the API call is sync from the WebProcess, so I'm not sure how a signal could work here. Also I'm wondering how this API could look like as the popup needs to be modal. But being optional yes. This entire QML styling thing should be properly studied for WebKit2. I mean, in theory we should have some kind of RenderThemeQML where youu could provide QML styling (but this is not exactly what we want here)
Jocelyn Turcotte
Comment 5
2011-10-03 13:23:01 PDT
(In reply to
comment #3
)
> But how you spin off an event loop from the QML side?
Humm that's a good point, there is nothing that prevents us from running an event loop beside the sync message system that is bound to the stack. Though since most web sites stopped using them I guess that we should keep it simple. Depending on how we manage our QtGui dependecies QT_NO_MESSAGEBOX might be enough. Adding Pierre on the loop.
Caio Marcelo de Oliveira Filho
Comment 6
2011-10-03 15:45:16 PDT
Hello Jocelyn, thanks for the promptly review. (In reply to
comment #2
)
> Virtual method reimplementations aren't friendly to straight QML use cases, though I'm not sure if JS alerts should be considered a common use case for simple apps.
Note that the virtual methods weren't exposed to the QDesktopWebView API. We can expose this in API in different ways. A constraint I had was to keep the message exchange from WebProcess to UIProcess synchronous. For the desktop case I wasn't expecting customization to be a major thing, and once we had QML dialogs we could replace them.
> In any case, emitting a signal instead might be better.
I don't think emitting signal will solve the problem. If we assume the responsibility of spawing a QML Component, maybe we can get a good enough API for QML. I'll give it a shot here and update you guys.
> I think that WKStringCreateWithQString should return a null WKString if given a null QString as input. Is it possible to use it instead?
Currently it doesn't. The current conversion from WTF::String -> WKStringRef turns Null strings into Empty strings, and QString conversion relies on that. Maybe would be better to treat this special case inside WKStringCreateWithQString()?
Caio Marcelo de Oliveira Filho
Comment 7
2011-10-04 09:17:31 PDT
(In reply to
comment #6
)
> I don't think emitting signal will solve the problem. If we assume the responsibility of spawing a QML Component, maybe we can get a good enough API for QML. I'll give it a shot here and update you guys.
For the record, I followed up this on the IRC, basically one working way to provide API for customization is to allow QML set an alertDialog component that is used in runJavaScriptAlert() to create a QML item. Like QMessageBox and QInputDialog static methods, we run our own QEventLoop waiting for a dismiss signal. Although I like this approach, this seems overkill for alert/confirm/prompt cases.
Andreas Kling
Comment 8
2011-10-04 11:06:29 PDT
Comment on
attachment 109503
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=109503&action=review
Looks generally good, but I gotta run, so here's some nitpicking and I'll be back tomorrow:
> Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp:207 > + const QString title = tr("JavaScript Alert - %1").arg(q->url().host());
QLatin1String?
> Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp:220 > + const QString title = tr("JavaScript Confirm - %1").arg(q->url().host());
QLatin1String?
> Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp:233 > + const QString title = tr("JavaScript Prompt - %1").arg(q->url().host());
QLatin1String?
Andreas Kling
Comment 9
2011-10-04 11:07:30 PDT
(In reply to
comment #8
)
> (From update of
attachment 109503
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=109503&action=review
> > Looks generally good, but I gotta run, so here's some nitpicking and I'll be back tomorrow: > > > Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp:207 > > + const QString title = tr("JavaScript Alert - %1").arg(q->url().host()); > > QLatin1String? > > > Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp:220 > > + const QString title = tr("JavaScript Confirm - %1").arg(q->url().host()); > > QLatin1String? > > > Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp:233 > > + const QString title = tr("JavaScript Prompt - %1").arg(q->url().host()); > > QLatin1String?
Dammit, I just realized that this nitpicking is completely wrong! Never mind this comment :)
Andreas Kling
Comment 10
2011-10-05 09:22:37 PDT
Comment on
attachment 109503
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=109503&action=review
LGTM!
> Source/WebKit2/ChangeLog:15 > + empty and null strings.
between* empty and null strings
> Source/WebKit2/UIProcess/qt/ClientImpl.cpp:148 > +void qt_wk_runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void *clientInfo)
Style, * placement.
> Source/WebKit2/UIProcess/qt/ClientImpl.cpp:154 > +bool qt_wk_runJavaScriptConfirm(WKPageRef, WKStringRef message, WKFrameRef, const void *clientInfo)
Ditto.
> Source/WebKit2/UIProcess/qt/ClientImpl.cpp:160 > +static inline WKStringRef createNullWKString()
C API candidate? Maybe not.
> Source/WebKit2/UIProcess/qt/ClientImpl.cpp:166 > +WKStringRef qt_wk_runJavaScriptPrompt(WKPageRef, WKStringRef message, WKStringRef defaultValue, WKFrameRef, const void *clientInfo)
Style, * placement.
> Source/WebKit2/UIProcess/qt/ClientImpl.h:44 > +void qt_wk_runJavaScriptAlert(WKPageRef, WKStringRef alertText, WKFrameRef, const void *clientInfo); > +bool qt_wk_runJavaScriptConfirm(WKPageRef, WKStringRef message, WKFrameRef, const void *clientInfo); > +WKStringRef qt_wk_runJavaScriptPrompt(WKPageRef, WKStringRef message, WKStringRef defaultValue, WKFrameRef, const void *clientInfo);
Ditto.
Caio Marcelo de Oliveira Filho
Comment 11
2011-10-05 13:27:26 PDT
Committed
r96743
: <
http://trac.webkit.org/changeset/96743
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug