Bug 140477 - RenderLayerCompositor: Strange comparison of opacity to boolean.
Summary: RenderLayerCompositor: Strange comparison of opacity to boolean.
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Brent Fulgham
Depends on: 138448
  Show dependency treegraph
Reported: 2015-01-14 16:23 PST by Brent Fulgham
Modified: 2015-01-15 18:18 PST (History)
8 users (show)

See Also:

Patch (1.56 KB, patch)
2015-01-15 14:56 PST, Brent Fulgham
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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;

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]
Comment 6 Brent Fulgham 2015-01-15 18:18:37 PST
Committed r178568: <http://trac.webkit.org/changeset/178568>