Bug 102159 - [chromium] Clamp negative sizes to zero when converting to gfx:: types
Summary: [chromium] Clamp negative sizes to zero when converting to gfx:: types
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dana Jansens
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-13 17:49 PST by Dana Jansens
Modified: 2012-11-14 19:06 PST (History)
8 users (show)

See Also:


Attachments
Patch (1.95 KB, patch)
2012-11-13 17:50 PST, Dana Jansens
no flags Details | Formatted Diff | Diff
Patch (1.99 KB, patch)
2012-11-13 17:53 PST, Dana Jansens
no flags Details | Formatted Diff | Diff
Patch (3.14 KB, patch)
2012-11-14 18:18 PST, Dana Jansens
no flags Details | Formatted Diff | Diff
Patch for landing (3.14 KB, patch)
2012-11-14 18:40 PST, Dana Jansens
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dana Jansens 2012-11-13 17:49:06 PST
[chromium] Clamp contentsRect to not have negative sizes
Comment 1 Dana Jansens 2012-11-13 17:50:47 PST
Created attachment 174038 [details]
Patch
Comment 2 Dana Jansens 2012-11-13 17:53:13 PST
Created attachment 174040 [details]
Patch

Add bug to the changelog
Comment 3 Dana Jansens 2012-11-14 18:03:58 PST
Review ping
Comment 4 James Robinson 2012-11-14 18:06:32 PST
Comment on attachment 174040 [details]
Patch

Sorry, I thought I had already left feedback.  Would it make more sense to do this in the WebFoo -> gfx::Foo conversions in webkit/compositor_bindings?  I worry that trying to this here is going to be fragile to other rects/sizes that end up negative for who-knows-what reasons.
Comment 5 Dana Jansens 2012-11-14 18:07:57 PST
Sure, I'm good with that. I kind of like that new cases will come to attention easier. But then again it seems like negative sizes in WebCore aren't really a huge problem for us anyways and clamping seems reasonable.
Comment 6 Dana Jansens 2012-11-14 18:18:30 PST
Created attachment 174310 [details]
Patch
Comment 7 WebKit Review Bot 2012-11-14 18:21:21 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 8 James Robinson 2012-11-14 18:23:25 PST
(In reply to comment #4)
> (From update of attachment 174040 [details])
> in webkit/compositor_bindings

do other WebKit API users have this restriction?  If it's a compositor restriction we should do it ^^
Comment 9 Dana Jansens 2012-11-14 18:26:27 PST
Ohh. Well as soon as you try to make a gfx::Rect out of an IntRect with a negative size, it's going to assert.

Anyone else who uses these methods to convert will suffer the same assertions. So unless you want to leave them with asserts but protect w_c_bindings, I think we should do it here.
Comment 10 James Robinson 2012-11-14 18:30:47 PST
I see.  If it's a restriction of the gfx:: types then the only question is how loud we want to be when things other than the compositor pass negative values in to here.  How long have the gfx:: types asserted?  If it's been a while, then I think we can be pretty confident that nobody else depends on any particular behavior here.
Comment 11 Dana Jansens 2012-11-14 18:35:21 PST
They asserted before we came along and started the gtfo thing. Then we removed the assertions to try match webcore behaviour. Now I am putting them back, and there's a few places that we've found trigger them. We've been without them since Fri Sep 28 - chromium a25e25b907d387f0b76a2b8acd522193e777e793

One is contentsRect from GraphicsLayerChromium. One was the thumbLength for scrollbars. And the others were simple things that had cropped up in the meantime.
Comment 12 WebKit Review Bot 2012-11-14 18:37:03 PST
Comment on attachment 174310 [details]
Patch

Attachment 174310 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/14845244
Comment 13 James Robinson 2012-11-14 18:39:39 PST
Comment on attachment 174310 [details]
Patch

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

OK, thanks for the history.  Seems reasonable except for the build failure.

> Source/Platform/chromium/public/WebFloatRect.h:111
> +        return gfx::RectF(x, y, std::max(0, width), std::max(0, height));

gonna need to use floating point literals or invoke the ::max() override you want with max<float>, i think
Comment 14 Dana Jansens 2012-11-14 18:40:37 PST
Created attachment 174313 [details]
Patch for landing
Comment 15 Dana Jansens 2012-11-14 18:41:39 PST
Cool, thanks!
Comment 16 WebKit Review Bot 2012-11-14 19:06:28 PST
Comment on attachment 174313 [details]
Patch for landing

Clearing flags on attachment: 174313

Committed r134725: <http://trac.webkit.org/changeset/134725>
Comment 17 WebKit Review Bot 2012-11-14 19:06:34 PST
All reviewed patches have been landed.  Closing bug.