Bug 62295

Summary: Fix a ?: precedence error in ScrollbarThemeMac and ScrollbarThemeChromium
Product: WebKit Reporter: Nico Weber <thakis>
Component: Layout and RenderingAssignee: Nico Weber <thakis>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, hyatt, thakis, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Nico Weber 2011-06-08 10:01:22 PDT
Fix a ?: precedence error in ScrollbarThemeMac and ScrollbarThemeChromium
Comment 1 Nico Weber 2011-06-08 10:02:33 PDT
Created attachment 96438 [details]
Patch
Comment 2 Darin Adler 2011-06-08 10:18:31 PDT
Comment on attachment 96438 [details]
Patch

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

Please post a new patch that gets the ScrollbarThemeMac.mm part right.

Anyone got information on what the symptom of this was? Clearly the old code was incorrect. But we normally want regression testing too.

> Source/WebCore/platform/mac/ScrollbarThemeMac.mm:295
> -            result = IntRect(scrollbar->x(), scrollbar->y(), cOuterButtonLength[scrollbar->controlSize()] + painting ? cOuterButtonOverlap : 0, thickness);
> +            result = IntRect(scrollbar->x(), scrollbar->y(), cOuterButtonLength[scrollbar->controlSize()] + painting ? (cOuterButtonOverlap : 0), thickness);

This looks wrong. The parentheses are added in the wrong place here!
Comment 3 Nico Weber 2011-06-08 10:21:08 PDT
Comment on attachment 96438 [details]
Patch

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

>> Source/WebCore/platform/mac/ScrollbarThemeMac.mm:295
>> +            result = IntRect(scrollbar->x(), scrollbar->y(), cOuterButtonLength[scrollbar->controlSize()] + painting ? (cOuterButtonOverlap : 0), thickness);
> 
> This looks wrong. The parentheses are added in the wrong place here!

|painting| is a bool. What this code did before I added the parens was |(int + bool) ? overlap : 0|. I would have thought it's supposed to be |int + (bool ? overlap : 0)|, which is what this patch does.

Am I misunderstanding the code?
Comment 4 Nico Weber 2011-06-08 10:21:53 PDT
Thanks for your comment, Darin. I replied to it – I'm afraid I don't get it :-/
Comment 5 Darin Adler 2011-06-08 10:22:48 PDT
(In reply to comment #3)
> (From update of attachment 96438 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=96438&action=review
> 
> >> Source/WebCore/platform/mac/ScrollbarThemeMac.mm:295
> >> +            result = IntRect(scrollbar->x(), scrollbar->y(), cOuterButtonLength[scrollbar->controlSize()] + painting ? (cOuterButtonOverlap : 0), thickness);
> > 
> > This looks wrong. The parentheses are added in the wrong place here!
> 
> |painting| is a bool. What this code did before I added the parens was |(int + bool) ? overlap : 0|. I would have thought it's supposed to be |int + (bool ? overlap : 0)|, which is what this patch does.
> 
> Am I misunderstanding the code?

The above says:

    painting ? (cOuterButtonOverlap : 0)

But you need to say:

    (painting ? cOuterButtonOverlap : 0)

Maybe you just had trouble seeing it.
Comment 6 Nico Weber 2011-06-08 10:25:48 PDT
Created attachment 96439 [details]
Patch
Comment 7 Nico Weber 2011-06-08 10:26:06 PDT
9_9

Sorry.
Comment 8 Darin Adler 2011-06-08 10:27:35 PDT
Still would be good to find out what the symptom of this was.
Comment 9 Nico Weber 2011-06-08 10:33:40 PDT
This codepath was hit only when

    (buttonsPlacement() == ScrollbarButtonsDoubleStart || buttonsPlacement() == ScrollbarButtonsDoubleBoth

is true which I think isn't true for most people in practice. The only interesting called of this function is RenderScrollbarTheme::trackRect(), so from reading the code it looks like for doublestart / doubleboth scrollbars, the track would appear slightly too large.
Comment 10 WebKit Review Bot 2011-06-08 11:20:31 PDT
Comment on attachment 96439 [details]
Patch

Clearing flags on attachment: 96439

Committed r88364: <http://trac.webkit.org/changeset/88364>
Comment 11 WebKit Review Bot 2011-06-08 11:20:36 PDT
All reviewed patches have been landed.  Closing bug.