Bug 108311

Summary: [chromium] Add WebFrame::visibleContentRect()
Product: WebKit Reporter: Tien-Ren Chen <trchen>
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, dglazkov, fishd, jamesr, tkent+wkapi, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Tien-Ren Chen 2013-01-30 01:38:07 PST
[chromium] Add convenience functions for geometry query
Comment 1 Tien-Ren Chen 2013-01-30 01:40:14 PST
Created attachment 185435 [details]
Patch
Comment 2 WebKit Review Bot 2013-01-30 01:42:20 PST
Please wait for approval from abarth@webkit.org, dglazkov@chromium.org, fishd@chromium.org, jamesr@chromium.org or tkent@chromium.org before submitting, as this patch contains changes to the Chromium public API. See also https://trac.webkit.org/wiki/ChromiumWebKitAPI.
Comment 3 Adam Barth 2013-01-30 11:26:52 PST
@jamesr: Would you be willing to review this patch?
Comment 4 James Robinson 2013-01-30 13:40:23 PST
Comment on attachment 185435 [details]
Patch

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

> Source/WebKit/chromium/public/WebFrame.h:172
> +    // Returns the visible content rect (minus scrollbars, in absolute coordinate)

blank line before new functions

how does this interact with contentsSize() + scrollOffset() ?

> Source/WebKit/chromium/src/WebViewImpl.cpp:4378
> +    physicalWindowRect.scale(deviceScaleFactor() * pageScaleFactor());

I don't understand this function. device and page scale factors are exposed through the WebKit API, why do we need another WebKit API entry point just to multiply them together?
Comment 5 Tien-Ren Chen 2013-01-30 14:03:26 PST
(In reply to comment #4)
> (From update of attachment 185435 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=185435&action=review
> 
> > Source/WebKit/chromium/public/WebFrame.h:172
> > +    // Returns the visible content rect (minus scrollbars, in absolute coordinate)
> 
> blank line before new functions
> 
> how does this interact with contentsSize() + scrollOffset() ?

Nothing to do with contentsSize. It is the current visible area of the frame, in absolute coordinate. In current implementation it would be the same value as IntRect(scrollOffset, ceil(webView()->size() / pageScaleFactor))

> > Source/WebKit/chromium/src/WebViewImpl.cpp:4378
> > +    physicalWindowRect.scale(deviceScaleFactor() * pageScaleFactor());
> 
> I don't understand this function. device and page scale factors are exposed through the WebKit API, why do we need another WebKit API entry point just to multiply them together?

Because it is much less error-prone and easier to understand this way. Saying "foo = bar * deviceScaleFactor * pageScaleFactor;" can be understood by the compiler, but doesn't really translate well to English. While saying "foo = WebViewImpl->physicalWindowFromClient(bar);" even your grandmother can understand what are you trying to do here.

Consider the more complex case, what if we need to convert between absolute and client coordinates? Inner and outer viewport coordinates? Should we add or substract the offset? Translate before scale or after? Doing this all the times kills lots of brain cells.
Comment 6 Tien-Ren Chen 2013-01-30 16:01:31 PST
Created attachment 185607 [details]
Patch
Comment 7 Tien-Ren Chen 2013-01-30 16:03:00 PST
Per offline discussion, we decided not to over-grow WebView API with bunch of conversion functions, but there is probably no alternative for WebFrame::visibleContentRect().
Comment 8 WebKit Review Bot 2013-01-30 17:41:10 PST
Comment on attachment 185607 [details]
Patch

Clearing flags on attachment: 185607

Committed r141352: <http://trac.webkit.org/changeset/141352>
Comment 9 WebKit Review Bot 2013-01-30 17:41:14 PST
All reviewed patches have been landed.  Closing bug.