Bug 83895

Summary: [Qt] Clean up how the interaction engine is making use of ViewportAttributes
Product: WebKit Reporter: Kenneth Rohde Christiansen <kenneth>
Component: WebKit QtAssignee: Kenneth Rohde Christiansen <kenneth>
Status: RESOLVED FIXED    
Severity: Normal CC: hausmann, jturcotte, menard, webkit.review.bot, zalan, zoltan
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch hausmann: review+

Description Kenneth Rohde Christiansen 2012-04-13 08:12:59 PDT
SSIA
Comment 1 Kenneth Rohde Christiansen 2012-04-13 08:14:04 PDT
Created attachment 137087 [details]
Patch
Comment 2 zalan 2012-04-13 08:14:39 PDT
lgtm. discussed on irc.
Comment 3 Early Warning System Bot 2012-04-13 08:18:09 PDT
Comment on attachment 137087 [details]
Patch

Attachment 137087 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/12399333
Comment 4 Jocelyn Turcotte 2012-04-13 08:42:15 PDT
Comment on attachment 137087 [details]
Patch

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

> Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp:628
> +    // FIXME: Revise this.
> +    interactionEngine->reset();

Could you elaborate?

> Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp:96
> +void QWebViewportInfo::didUpdateViewportConstraints(const WebCore::ViewportAttributes& attr)

I don't think we should expose this in the public API

> Source/WebKit2/UIProcess/API/qt/qwebviewportinfo_p.h:70
> +    WebCore::ViewportAttributes attributes;

This should go in a new QWebViewportInfoPrivate
Comment 5 Kenneth Rohde Christiansen 2012-04-13 09:28:45 PDT
Comment on attachment 137087 [details]
Patch

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

>> Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp:628
>> +    interactionEngine->reset();
> 
> Could you elaborate?

It is the same reset you wanted to remove but left there. So we need to revise it at a later time.

>> Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp:96
>> +void QWebViewportInfo::didUpdateViewportConstraints(const WebCore::ViewportAttributes& attr)
> 
> I don't think we should expose this in the public API

This is not public API as it is not exposed to QML nor to a public header file.

>> Source/WebKit2/UIProcess/API/qt/qwebviewportinfo_p.h:70
>> +    WebCore::ViewportAttributes attributes;
> 
> This should go in a new QWebViewportInfoPrivate

If we are going to create a QWebViewportInfoPrivate I think that should be a separate patch.
Comment 6 Kenneth Rohde Christiansen 2012-04-13 09:29:50 PDT
I do not know why this doesnt build, maybe it needs a clean build. It compiles locally and I had this problem before I changed experimental.pri
Comment 7 Jocelyn Turcotte 2012-04-13 09:53:58 PDT
(In reply to comment #5)
> > Could you elaborate?
> 
> It is the same reset you wanted to remove but left there. So we need to revise it at a later time.

Sorry I meant in the comment.

> 
> >> Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp:96
> >> +void QWebViewportInfo::didUpdateViewportConstraints(const WebCore::ViewportAttributes& attr)
> > 
> > I don't think we should expose this in the public API
> 
> This is not public API as it is not exposed to QML nor to a public header file.
> 

Well it's private public API, so this would prevent anybody from doing "QT += webkit-private" in their project as they would also need all the referenced WebCore headers, which we won't distribute. All the other QML API headers already support this.

The private class is also just to make sure that no WebCore symbols are in those private public headers.


(In reply to comment #6)
> I do not know why this doesnt build, maybe it needs a clean build. It compiles locally and I had this problem before I changed experimental.pri

It doesn't build because moc doesn't include "config.h", so you need to "#include "moc_qwebviewportinfo.cpp" at the end of qwebviewportinfo.cpp. But I think you won't need it if you add the _p_p.h file.
Comment 8 Kenneth Rohde Christiansen 2012-04-16 05:14:38 PDT
Created attachment 137324 [details]
Patch
Comment 9 Rafael Brandao 2012-04-16 06:07:26 PDT
Comment on attachment 137324 [details]
Patch

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

> Source/WebKit2/ChangeLog:8
> +        Refactor now the interaction engine is using the ViewportAttributes

Wonder if you mean "how" instead of "now" here.

> Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp:635
> +    // This needs to be revised at some point.

I believe the "FIXME" already marks the following code as "should be revised at some point", so this paragragh may be omitted.

> Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp:640
> +    interactionEngine->setAllowsUserScaling(!!attr.userScalable);

Hm, what? !!attr.userScalable? Why not just "attr.userScalable"?

> Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp:97
> +    return itemScale / m_devicePixelRatio;

Is it possible that a division by zero occurs here?
Comment 10 Simon Hausmann 2012-04-16 06:07:51 PDT
Comment on attachment 137324 [details]
Patch

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

> Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h:54
> +    bool hadUserInteraction() { return m_hadUserInteraction; }

Missing const.

> Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h:130
> +    bool m_allowsUserScaling;
> +    qreal m_minimumScale;
> +    qreal m_maximumScale;
> +    qreal m_devicePixelRatio;

I see these variables being added, but it seems they're only "initialized" when the message about the updated viewport attributes arrives from the web process. Shouldn't they be initialized in the constructor?
Comment 11 Kenneth Rohde Christiansen 2012-04-16 06:21:20 PDT
> I see these variables being added, but it seems they're only "initialized" when the message about the updated viewport attributes arrives from the web process. Shouldn't they be initialized in the constructor?

Indeed, I will add them to the reset() method instead.
Comment 12 Kenneth Rohde Christiansen 2012-04-16 06:24:27 PDT
> Wonder if you mean "how" instead of "now" here.

OOps!

> > Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp:635
> > +    // This needs to be revised at some point.
> 
> I believe the "FIXME" already marks the following code as "should be revised at some point", so this paragragh may be omitted.

Im fine with that.

> 
> > Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp:640
> > +    interactionEngine->setAllowsUserScaling(!!attr.userScalable);
> 
> Hm, what? !!attr.userScalable? Why not just "attr.userScalable"?

It is a float. This is the common way to convert it.

> > Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp:97
> > +    return itemScale / m_devicePixelRatio;
> 
> Is it possible that a division by zero occurs here?

No, a ratio can never be zero.
Comment 13 Kenneth Rohde Christiansen 2012-04-16 06:27:58 PDT
Created attachment 137333 [details]
Patch
Comment 14 Kenneth Rohde Christiansen 2012-04-16 06:40:09 PDT
Landed in 114247.