Bug 98186 - [WK2] PageViewportController.cpp is supposed to be a generic WebKit2 file but only works with Qt port.
Summary: [WK2] PageViewportController.cpp is supposed to be a generic WebKit2 file but...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified All
: P2 Normal
Assignee: Hugo Parente Lima
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-02 12:14 PDT by Hugo Parente Lima
Modified: 2012-10-03 14:52 PDT (History)
8 users (show)

See Also:


Attachments
Patch (4.92 KB, patch)
2012-10-02 12:20 PDT, Hugo Parente Lima
no flags Details | Formatted Diff | Diff
Patch (7.10 KB, patch)
2012-10-03 11:23 PDT, Hugo Parente Lima
no flags Details | Formatted Diff | Diff
Patch (7.82 KB, patch)
2012-10-03 13:42 PDT, Hugo Parente Lima
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hugo Parente Lima 2012-10-02 12:14:26 PDT
The file is located at Source/WebKit2/UIProcess, it shouldn't depend on Qt but currently it only compiles based on a implicit conversion from WebCore::FloatSize to QSize (because QSize have operator/(float)).

The fix just add a operator/(float) to WebCore::FloatSize and remove the implicit conversion from WebCore::FloatSize to QSize.

I don't know if WebKit have some rule against operator overloads with operands of different types, so make me know about and if so, I can update the patch to fix PageViewportController.cpp, but IMO adding the operator/ on WebCore::FloatSize seems nicer.
Comment 1 Hugo Parente Lima 2012-10-02 12:20:02 PDT
Created attachment 166730 [details]
Patch
Comment 2 Noam Rosenthal 2012-10-02 14:39:46 PDT
Comment on attachment 166730 [details]
Patch

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

Better to use FloatSize::scale explicitly

> Source/WebCore/platform/graphics/FloatSize.h:188
> +inline FloatSize operator/(const FloatSize& a, const float& b)

const float& -> float
Comment 3 Hugo Parente Lima 2012-10-02 14:47:56 PDT
(In reply to comment #2)
> (From update of attachment 166730 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=166730&action=review
> 
> Better to use FloatSize::scale explicitly

Ok, I'll do that.
 
> > Source/WebCore/platform/graphics/FloatSize.h:188
> > +inline FloatSize operator/(const FloatSize& a, const float& b)
> 
> const float& -> float

So, if I'm goin to use FloatSize::scale, operator/ will disappear from this patch.
Comment 4 Hugo Parente Lima 2012-10-03 11:23:30 PDT
Created attachment 166927 [details]
Patch
Comment 5 Noam Rosenthal 2012-10-03 13:21:17 PDT
Comment on attachment 166927 [details]
Patch

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

> Source/WebCore/platform/graphics/FloatSize.h:100
> +    FloatSize scaledTo(float s) const

how about scaledSize

> Source/WebKit2/UIProcess/PageViewportController.cpp:148
> +        if (FloatRect(clampedPos, m_viewportSize.scaledTo(1 / m_effectiveScale)).intersects(coveredRect)) {

You're making the same calculation over and over... how about creating a function PageViewportController::viewportSizeInContentsCoordinates that would return that calculation? That way you also don't need a function...
Comment 6 Hugo Parente Lima 2012-10-03 13:26:29 PDT
(In reply to comment #5)
> (From update of attachment 166927 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=166927&action=review
> 
> > Source/WebCore/platform/graphics/FloatSize.h:100
> > +    FloatSize scaledTo(float s) const
> 
> how about scaledSize

I used scaledTo to follow the same convention used in this file, like "expandedTo" instead of "expandedSize"
 
> > Source/WebKit2/UIProcess/PageViewportController.cpp:148
> > +        if (FloatRect(clampedPos, m_viewportSize.scaledTo(1 / m_effectiveScale)).intersects(coveredRect)) {
> 
> You're making the same calculation over and over... how about creating a function PageViewportController::viewportSizeInContentsCoordinates that would return that calculation? That way you also don't need a function...

Could be, it's used 3 times, I'll update the patch.
Comment 7 Hugo Parente Lima 2012-10-03 13:42:07 PDT
Created attachment 166953 [details]
Patch
Comment 8 WebKit Review Bot 2012-10-03 14:52:09 PDT
Comment on attachment 166953 [details]
Patch

Clearing flags on attachment: 166953

Committed r130327: <http://trac.webkit.org/changeset/130327>
Comment 9 WebKit Review Bot 2012-10-03 14:52:13 PDT
All reviewed patches have been landed.  Closing bug.