Bug 140477

Summary: RenderLayerCompositor: Strange comparison of opacity to boolean.
Product: WebKit Reporter: Brent Fulgham <bfulgham>
Component: Layout and RenderingAssignee: Brent Fulgham <bfulgham>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, commit-queue, dino, esprehn+autocc, glenn, kondapallykalyan, simon.fraser, thorton
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on: 138448    
Bug Blocks:    
Attachments:
Description Flags
Patch simon.fraser: review+

Description Brent Fulgham 2015-01-14 16:23:47 PST
I receive the following warning when I build. Reviewing the line in question reveals that we are comparing a boolean (the return value of "ancestorBacking->graphicsLayer->drawsContents()") to the float returned by the style's opacity property.

This seems very strange. At the very least, we should do some casting here to make it clear that this is intentional (if it is).

            if (newStyle.opacity() != ancestorBacking->graphicsLayer()->drawsContent())
                return true;

Where:
opacity is a float
drawsContent is a boolean.
Comment 1 Brent Fulgham 2015-01-14 16:28:12 PST
Based on Bug 138448, it looks like this was an intentional comparison, but I think a cast would make it clear that this is desired behavior.
Comment 2 Simon Fraser (smfr) 2015-01-14 16:35:57 PST
Agreed it's odd. Would be fine to clarify.
Comment 3 Brent Fulgham 2015-01-14 16:40:54 PST
I neglected to include the compiler error:

18>c:\projects\webkit\opensource\source\webcore\rendering\RenderLayerCompositor.cpp(888): warning C4805: '!=' : unsafe mix of type 'float' and type 'bool' in operation (..\rendering\RenderingAllInOne.cpp)
Comment 4 Brent Fulgham 2015-01-15 08:40:08 PST
This code is checking for non-zero opacity.
Comment 5 Brent Fulgham 2015-01-15 14:56:37 PST
Created attachment 244716 [details]
Patch
Comment 6 Brent Fulgham 2015-01-15 18:18:37 PST
Committed r178568: <http://trac.webkit.org/changeset/178568>