Bug 109222 - [Qt][WK2] Move Color picker on top of the C API
Summary: [Qt][WK2] Move Color picker on top of the C API
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Pierre Rossi
URL:
Keywords:
Depends on:
Blocks: 108471
  Show dependency treegraph
 
Reported: 2013-02-07 13:14 PST by Pierre Rossi
Modified: 2014-02-03 03:24 PST (History)
11 users (show)

See Also:


Attachments
Patch (28.20 KB, patch)
2013-02-07 13:56 PST, Pierre Rossi
no flags Details | Formatted Diff | Diff
Patch (40.53 KB, patch)
2013-02-28 08:02 PST, Pierre Rossi
no flags Details | Formatted Diff | Diff
Patch (50.30 KB, patch)
2013-02-28 09:35 PST, Pierre Rossi
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre Rossi 2013-02-07 13:14:38 PST
[Qt][WK2] Move Color picker on top of the C API
Comment 1 Pierre Rossi 2013-02-07 13:56:27 PST
Created attachment 187171 [details]
Patch
Comment 2 Simon Hausmann 2013-02-27 01:04:27 PST
Comment on attachment 187171 [details]
Patch

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

> Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp:200
> +void QtWebPageUIClient::showColorPicker(WKPageRef, WKStringRef initialColor, WKColorPickerResultListenerRef listener, const void *clientInfo)
> +{
> +    toQtWebPageUIClient(clientInfo)->showColorPicker(listener, QColor(toWTFString(initialColor)));
> +}
> +
> +void QtWebPageUIClient::hideColorPicker(WKPageRef, const void *clientInfo)
> +{
> +    toQtWebPageUIClient(clientInfo)->hideColorPicker();
> +}

Given the few lines of code I suggest to merge this with the non-static showColorPicker and then just wrote

d->m_colorPicker.reset(new QWebColorPicker(...));
Comment 3 Simon Hausmann 2013-02-27 01:05:05 PST
Patch looks good to me overall, modulo the small suggested change.

Pinging Benjamin for WK2 sign-off :)
Comment 4 Benjamin Poulain 2013-02-27 01:34:44 PST
Comment on attachment 187171 [details]
Patch

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

I'll have to look at this again. Simon, can you review then ping me?

> Source/WebKit2/Target.pri:829
> +# FIXME: move this along once the QQuickWebView is a bit less tangled.

I think this could be a little more descriptive. It is not clear what you mean.

> Source/WebKit2/UIProcess/API/qt/qwebcolorpicker.cpp:3
> + * Copyright (C) 2012 Intel Corporation. All rights reserved.
> + * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)

Hum, hum, no love for Digia in 2013? ;)

> Source/WebKit2/UIProcess/API/qt/qwebcolorpicker.cpp:33
> +#include <wtf/text/StringBuilder.h>

Do you use it somewhere?

> Source/WebKit2/UIProcess/API/qt/qwebcolorpicker.cpp:79
> +QWebColorPicker::~QWebColorPicker()
> +{
> +}

I don't think you will need this :)

> Source/WebKit2/UIProcess/API/qt/qwebcolorpicker.cpp:87
> +    if (!component) {
> +        delete contextObject;
> +        return;
> +    }

This looks so fragile :(

> Source/WebKit2/UIProcess/API/qt/qwebcolorpicker.cpp:102
> +    // Needs to be enqueue because it might trigger deletion.

I am not sure what is the "it" that can trigger deletion.
It could be useful to explain the cases where that would happen.

> Source/WebKit2/UIProcess/API/qt/qwebcolorpicker.cpp:130
> +    WKRetainPtr<WKStringRef> colorString(AdoptWK, WKStringCreateWithUTF8CString(coreColor.serialized().utf8().data()));

toApi(coreColor.serialized()) would be enough?

> Source/WebKit2/UIProcess/API/qt/qwebcolorpicker.cpp:131
> +    WKColorPickerResultListenerSetColor(m_listener, colorString.get());

I am such a huge fan of this API. Passing a color by string is brilliant :(

That's why we cannot have nice things I guess.
As far as I am concerned, you are free to break it or expend it for something better.

> Source/WebKit2/UIProcess/API/qt/qwebcolorpicker_p.h:2
> + * Copyright (C) 2012 Intel Corporation. All rights reserved.

... :)

> Source/WebKit2/UIProcess/API/qt/qwebcolorpicker_p.h:40
> +namespace WebCore {
> +class Color;
> +}

You need this in the header?
Comment 5 Pierre Rossi 2013-02-27 09:31:03 PST
Comment on attachment 187171 [details]
Patch

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

Thanks benjaminp, gonna try and clean that up a little... :)

>> Source/WebKit2/Target.pri:829
>> +# FIXME: move this along once the QQuickWebView is a bit less tangled.
> 
> I think this could be a little more descriptive. It is not clear what you mean.

yeah, I figured that was too cryptic. Hence the link below ;)
But I'll rephrase it.

>> Source/WebKit2/UIProcess/API/qt/qwebcolorpicker.cpp:3
>> + * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
> 
> Hum, hum, no love for Digia in 2013? ;)

Dude, this thing is way too complicated to memorize ! Actually this shows up as a rename from WebColorChooserProxyQt in git, but the review tool doesn't help much there...

>> Source/WebKit2/UIProcess/API/qt/qwebcolorpicker.cpp:33
>> +#include <wtf/text/StringBuilder.h>
> 
> Do you use it somewhere?

Stray stuff after I was puzzled with how to deal with the string representation of a color, nice catch !

>> Source/WebKit2/UIProcess/API/qt/qwebcolorpicker.cpp:79
>> +}
> 
> I don't think you will need this :)

Probably should clean that up indeed, did a dumb massive rename.

>> Source/WebKit2/UIProcess/API/qt/qwebcolorpicker.cpp:87
>> +    }
> 
> This looks so fragile :(

Just moving stuff around. It seemed to work before...
Indeed, that pattern might not be the most pleasing to the eye...

>> Source/WebKit2/UIProcess/API/qt/qwebcolorpicker.cpp:131
>> +    WKColorPickerResultListenerSetColor(m_listener, colorString.get());
> 
> I am such a huge fan of this API. Passing a color by string is brilliant :(
> 
> That's why we cannot have nice things I guess.
> As far as I am concerned, you are free to break it or expend it for something better.

Will do ! (break I mean) I actually wanted to add the element rect in there anyway ;)

>> Source/WebKit2/UIProcess/API/qt/qwebcolorpicker_p.h:2
>> + * Copyright (C) 2012 Intel Corporation. All rights reserved.
> 
> ... :)

Hey, this is originally a generous donation done by an Intel guy, I'm not gonna take away the credit ! But indeed, maybe Digia could get a bit of love...

>> Source/WebKit2/UIProcess/API/qt/qwebcolorpicker_p.h:40
>> +}
> 
> You need this in the header?

meh, probably not anymore... nice catch :)
Comment 6 Pierre Rossi 2013-02-28 08:02:39 PST
Created attachment 190730 [details]
Patch

Since the use of Color(const String&) is apparently only intended for use by the DOM, and not WebKit, let's revamp that API a bit.
Comment 7 Simon Hausmann 2013-02-28 08:12:05 PST
Comment on attachment 190730 [details]
Patch

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

LGTM overall. Two small nitpicks.

> Source/WebKit2/Shared/API/c/WKBase.h:96
> +typedef uint32_t WKARGB;

I suggest something a little more verbose (might be misread as "ARGH!" :)

How about WKColorARGB32? or WKARGB32Color?

> Source/WebKit2/UIProcess/qt/QtPageClient.cpp:226
> +    notImplemented();

I'd leave out the notImplemented() because it is implemented after all.

Alternative the pure virtual method could become one with an empty default impl like this, since we want to promote the C API then and ultimately it can be removed.
Comment 8 Pierre Rossi 2013-02-28 09:07:43 PST
Comment on attachment 190730 [details]
Patch

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

>> Source/WebKit2/Shared/API/c/WKBase.h:96
>> +typedef uint32_t WKARGB;
> 
> I suggest something a little more verbose (might be misread as "ARGH!" :)
> 
> How about WKColorARGB32? or WKARGB32Color?

Haha, agreed, people would ruin their keyboard trying to pronounce this. I'll go with your first proposition ;)

>> Source/WebKit2/UIProcess/qt/QtPageClient.cpp:226
>> +    notImplemented();
> 
> I'd leave out the notImplemented() because it is implemented after all.
> 
> Alternative the pure virtual method could become one with an empty default impl like this, since we want to promote the C API then and ultimately it can be removed.

true, that'd clean things up once and for all.
Comment 9 Pierre Rossi 2013-02-28 09:35:54 PST
Created attachment 190742 [details]
Patch
Comment 10 WebKit Review Bot 2013-02-28 09:42:28 PST
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 11 Anders Carlsson 2013-10-02 21:21:05 PDT
Comment on attachment 190742 [details]
Patch

Qt has been removed, clearing review flags.
Comment 12 Jocelyn Turcotte 2014-02-03 03:24:53 PST
=== Bulk closing of Qt bugs ===

If you believe that this bug report is still relevant for a non-Qt port of webkit.org, please re-open it and remove [Qt] from the summary.

If you believe that this is still an important QtWebKit bug, please fill a new report at https://bugreports.qt-project.org and add a link to this issue. See http://qt-project.org/wiki/ReportingBugsInQt for additional guidelines.