Bug 78728

Summary: Box shadow drawing takes an unnecessarily slow code path in some single-shadow, opaque-background cases
Product: WebKit Reporter: mitz
Component: Layout and RenderingAssignee: mitz
Status: RESOLVED FIXED    
Severity: Normal CC: simon.fraser, tony
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Let the background cast the shadow directly in some cases where this is possible hyatt: review+

Description mitz 2012-02-15 12:17:55 PST
Box shadow drawing takes an unnecessarily slow code path in some single-shadow, opaque-background cases
Comment 1 mitz 2012-02-15 12:18:23 PST
<rdar://problem/10870238>
Comment 2 mitz 2012-02-15 12:31:42 PST
Created attachment 127213 [details]
Let the background cast the shadow directly in some cases where this is possible
Comment 3 Dave Hyatt 2012-02-15 12:44:42 PST
Comment on attachment 127213 [details]
Let the background cast the shadow directly in some cases where this is possible

It's slightly slower, but you could simplify the patch considerably if you just moved:

if (!boxShadowShouldBeAppliedToBackground(determineBackgroundBleedAvoidance(paintInfo.context)))
    paintBoxShadow(paintInfo, rect, style(), Normal);

inside RenderBoxModelObject::paintBoxShadow.

Then you wouldn't have to patch a bunch of call sites, and you wouldn't even have to touch InlineFlowBox.

I'll leave it up to you, though, since your way is ever-so-slightly faster at the cost of complicating every call site.
Comment 4 mitz 2012-02-15 13:05:28 PST
I can't do this because InlineFlowBox doesn't use determineBackgroundBleedAvoidance(). Thanks for the review!
Comment 5 mitz 2012-02-15 13:58:06 PST
Fixed in <http://trac.webkit.org/r107836>.
Comment 7 mitz 2012-02-15 15:45:05 PST
Thanks. These differences do occur in OS X WebKit, but I failed to notice them.
Comment 8 mitz 2012-02-15 16:22:41 PST
Filed bug 78759.
Comment 9 Tony Chang 2012-02-15 19:21:45 PST
Comment on attachment 127213 [details]
Let the background cast the shadow directly in some cases where this is possible

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

> Source/WebCore/rendering/RenderBoxModelObject.cpp:2611
> +    for (const FillLayer* next = lastBackgroundLayer->next(); next; )
> +        lastBackgroundLayer = next;

This loop is bad.  We never iterate after the first iteration.  Did you mean to have next = lastBackgroundLayer->next() as the third part of the for statement?
Comment 10 mitz 2012-02-15 19:31:20 PST
(In reply to comment #9)
> (From update of attachment 127213 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=127213&action=review
> 
> > Source/WebCore/rendering/RenderBoxModelObject.cpp:2611
> > +    for (const FillLayer* next = lastBackgroundLayer->next(); next; )
> > +        lastBackgroundLayer = next;
> 
> This loop is bad.  We never iterate after the first iteration.  Did you mean to have next = lastBackgroundLayer->next() as the third part of the for statement?

Yes. Thanks for noticing it!