Bug 65006 - Draw rectangular box shadow for elements with border-radius if no corners are visible
Summary: Draw rectangular box shadow for elements with border-radius if no corners are...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.6
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-21 19:47 PDT by Ian Henderson
Modified: 2011-08-04 08:38 PDT (History)
5 users (show)

See Also:


Attachments
proposed patch (11.40 KB, patch)
2011-07-21 19:57 PDT, Ian Henderson
simon.fraser: review-
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff
test case (299 bytes, text/html)
2011-07-21 20:00 PDT, Ian Henderson
no flags Details
proposed patch (138.69 KB, patch)
2011-07-22 21:59 PDT, Ian Henderson
no flags Details | Formatted Diff | Diff
proposed patch (139.01 KB, patch)
2011-07-22 22:14 PDT, Ian Henderson
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff
proposed patch (260.47 KB, patch)
2011-07-25 15:26 PDT, Ian Henderson
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff
proposed patch (16.01 KB, patch)
2011-08-01 14:22 PDT, Ian Henderson
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff
proposed patch (139.23 KB, patch)
2011-08-02 14:57 PDT, Ian Henderson
simon.fraser: review-
simon.fraser: commit-queue-
Details | Formatted Diff | Diff
proposed patch (75.99 KB, patch)
2011-08-02 19:07 PDT, Ian Henderson
simon.fraser: review+
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff
illustration of the layout test (47.73 KB, image/png)
2011-08-03 01:10 PDT, Ian Henderson
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Henderson 2011-07-21 19:47:37 PDT
Drawing shadows of rectangular shapes is often much easier for the underlying graphics framework to optimize.  To this end, we can use the unroundClippedCorners function from 64584 to remove invisible corners before drawing an element's shadow.
Comment 1 Ian Henderson 2011-07-21 19:57:50 PDT
Created attachment 101692 [details]
proposed patch
Comment 2 Ian Henderson 2011-07-21 20:00:37 PDT
Created attachment 101693 [details]
test case

Attached a test case.
Comment 3 WebKit Review Bot 2011-07-21 20:10:40 PDT
Comment on attachment 101692 [details]
proposed patch

Attachment 101692 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/9209891
Comment 4 Simon Fraser (smfr) 2011-07-21 21:40:53 PDT
Comment on attachment 101692 [details]
proposed patch

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

> Source/WebCore/rendering/RenderBoxModelObject.cpp:2174
> +    unroundClippedCorners(border, info.rect);

I don't think this is right. The effect of the corner radius can propagate further for the shadow than the corner radius itself; you have to add the blur radius (or maybe twice the blur radius).
Comment 5 Simon Fraser (smfr) 2011-07-21 21:45:55 PDT
In ShadowBlur, computeSliceSizesFromRadii(), we use corner radius + 2 * blur radius as the "area of influence" of the corner in the shadow.
Comment 6 Ian Henderson 2011-07-22 21:59:39 PDT
Created attachment 101803 [details]
proposed patch
Comment 7 Ian Henderson 2011-07-22 22:14:54 PDT
Created attachment 101804 [details]
proposed patch

svn up!
Comment 8 WebKit Review Bot 2011-07-22 22:23:53 PDT
Comment on attachment 101804 [details]
proposed patch

Attachment 101804 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/9231328
Comment 9 Ian Henderson 2011-07-25 15:26:10 PDT
Created attachment 101925 [details]
proposed patch

Slightly updated patch -- add 2 * blur radius to the influence rect's corners, which moves them further towards the middle of the element's border.  Before, the influence rect only extended outwards by the blur radius, but the corners' presence can affect the shadows near the straight section of the border as well.
Comment 10 WebKit Review Bot 2011-07-25 17:13:07 PDT
Comment on attachment 101925 [details]
proposed patch

Attachment 101925 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/9244229
Comment 11 Ian Henderson 2011-07-25 18:40:59 PDT
I'm a bit confused about why cr-linux doesn't like these patches.  The error is:

/WebCore/rendering/RenderBoxModelObject.cpp: In member function 'void WebCore::RenderBoxModelObject::paintBoxShadow(const WebCore::PaintInfo&, const WebCore::LayoutRect&, const WebCore::RenderStyle*, WebCore::ShadowStyle, bool, bool)':
Source/WebCore/rendering/RenderBoxModelObject.cpp:2249: error: 'cornersIntersect' was not declared in this scope

but that function is defined in the patch, and the other ews bots don't seem to have any problem seeing it…
Comment 12 Ian Henderson 2011-08-01 14:22:04 PDT
Created attachment 102557 [details]
proposed patch

This is the same patch as the last one, but updated to ToT.  I'd like to make sure the cr-linux issue was not a transient one.
Comment 13 WebKit Review Bot 2011-08-01 15:01:24 PDT
Comment on attachment 102557 [details]
proposed patch

Attachment 102557 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/9288530
Comment 14 Ian Henderson 2011-08-02 14:57:38 PDT
Created attachment 102703 [details]
proposed patch

Move cornersIntersect() outside the #if HAVE(PATH_BASED_BORDER_RADIUS_DRAWING) block, since paintBoxShadow calls the function outside the #if block.
Comment 15 Simon Fraser (smfr) 2011-08-02 17:11:42 PDT
Comment on attachment 102703 [details]
proposed patch

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

> Source/WebCore/rendering/RenderBoxModelObject.cpp:1132
> +static bool cornersIntersect(const RoundedRect& border, const LayoutRect& clipRect)

I don't think the name of this function is quite right. It's asking whether any of the rounded corners fall inside the clipRect. You could call it isAnyCornerVisible() or something. Or you could flip the logic around and call it allCornersClippedOut().

> LayoutTests/platform/mac/fast/box-shadow/box-shadow-clipped-slices-expected.txt:4
> +layer at (0,0) size 800x600
> +  RenderView at (0,0) size 800x600
> +layer at (0,0) size 800x600
> +  RenderBlock {HTML} at (0,0) size 800x600

You should make this a dumpAsText(true). Where are the pixel results? If the pixel result includes a scrollbar, you should refactor the test to avoid this.
Comment 16 Ian Henderson 2011-08-02 19:07:23 PDT
Created attachment 102729 [details]
proposed patch

New patch to address Simon's comments.
Comment 17 WebKit Review Bot 2011-08-02 19:44:25 PDT
Comment on attachment 102729 [details]
proposed patch

Attachment 102729 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/9285916

New failing tests:
fast/box-shadow/box-shadow-clipped-slices.html
Comment 18 Simon Fraser (smfr) 2011-08-02 22:40:34 PDT
Comment on attachment 102729 [details]
proposed patch

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

> LayoutTests/fast/box-shadow/box-shadow-clipped-slices.html:9
> +</style></head><body>

No need to put all the properties on one line here.

I don't quite get the point of this test. If not all of the test divs are visible in the pixel result, there's no point having them all.
Comment 19 Ian Henderson 2011-08-03 01:10:10 PDT
Created attachment 102751 [details]
illustration of the layout test

(In reply to comment #18)
> (From update of attachment 102729 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=102729&action=review
> 
> > LayoutTests/fast/box-shadow/box-shadow-clipped-slices.html:9
> > +</style></head><body>
> 
> No need to put all the properties on one line here.
> 
> I don't quite get the point of this test. If not all of the test divs are visible in the pixel result, there's no point having them all.

All of the test divs are visible in the pixel result.  The idea is to clip the shadow to many small regions to ensure the drawing matches up correctly.  I attached an image of the test with a red border around each div to illustrate what's going on.
Comment 20 Joseph Pecoraro 2011-08-03 18:51:49 PDT
Landed in r92340 <http://trac.webkit.org/changeset/92340>
Comment 23 Adam Barth 2011-08-04 02:20:55 PDT
> I added that test in this commit with a mac baseline for the pixel results.  It looks like the diff is between the mac baseline and the Chromium pixel results.

Ok, so you're saying that the Chromium pixel result is ugly but not wrong.
Comment 24 Ian Henderson 2011-08-04 02:28:09 PDT
(In reply to comment #23)
> > I added that test in this commit with a mac baseline for the pixel results.  It looks like the diff is between the mac baseline and the Chromium pixel results.
> 
> Ok, so you're saying that the Chromium pixel result is ugly but not wrong.

I don't know if it's wrong or not -- I'm just saying it's not a regression.
Comment 25 Simon Fraser (smfr) 2011-08-04 08:38:36 PDT
Maybe it's a Skia bug.