Bug 94356 - Respect system setting for rubber-banding in ScrollAnimatorMac.
Summary: Respect system setting for rubber-banding in ScrollAnimatorMac.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: asvitkine
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-17 09:51 PDT by asvitkine
Modified: 2012-08-22 10:59 PDT (History)
6 users (show)

See Also:


Attachments
Patch (2.74 KB, patch)
2012-08-17 10:32 PDT, asvitkine
no flags Details | Formatted Diff | Diff
Patch (2.69 KB, patch)
2012-08-20 11:28 PDT, asvitkine
no flags Details | Formatted Diff | Diff
Patch (2.78 KB, patch)
2012-08-21 11:38 PDT, asvitkine
no flags Details | Formatted Diff | Diff
Patch (2.79 KB, patch)
2012-08-21 12:35 PDT, asvitkine
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description asvitkine 2012-08-17 09:51:06 PDT
[chromium/mac] Respect system setting for rubber-banding.
Comment 1 asvitkine 2012-08-17 10:32:12 PDT
Created attachment 159156 [details]
Patch
Comment 2 asvitkine 2012-08-17 10:32:49 PDT
Corresponds to http://crbug.com/133131
Comment 3 asvitkine 2012-08-17 10:33:31 PDT
Nico: Please review.
Comment 4 Nico Weber 2012-08-17 11:16:39 PDT
Comment on attachment 159156 [details]
Patch

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

> Source/WebCore/platform/mac/ScrollAnimatorMac.mm:661
> +#else

Does the apple port get this for free somehow?
Comment 5 asvitkine 2012-08-17 11:17:56 PDT
(In reply to comment #4)
> (From update of attachment 159156 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=159156&action=review
> 
> > Source/WebCore/platform/mac/ScrollAnimatorMac.mm:661
> > +#else
> 
> Does the apple port get this for free somehow?

No, they don't respect the setting, as far as I could tell.
Comment 6 Nico Weber 2012-08-17 13:00:42 PDT
Hi Beth,

it looks like the rest of OS X honors this setting. Is the apple port interested in honoring it too? If so, we can remove the ifdef.

Nico
Comment 7 Beth Dakin 2012-08-17 13:04:37 PDT
(In reply to comment #6)
> Hi Beth,
> 
> it looks like the rest of OS X honors this setting. Is the apple port interested in honoring it too? If so, we can remove the ifdef.
> 
> Nico

Hmm, maybe! Sam, what do you think?
Comment 8 Sam Weinig 2012-08-18 15:45:57 PDT
Seems reasonable to support.  If you are ever considering making something like this Chromium only in WebCore, don't!  

Please add a test.
Comment 9 asvitkine 2012-08-19 08:57:03 PDT
(In reply to comment #8)
> Please add a test.

Do you have a suggestion of how to go about writing a test for this?

This relies on both system settings and platform-specific wheel events and timings. I'm not sure what the convention is for testing such changes. Can you point me in the right direction?
Comment 10 Sam Weinig 2012-08-19 16:49:45 PDT
(In reply to comment #9)
> (In reply to comment #8)
> > Please add a test.
> 
> Do you have a suggestion of how to go about writing a test for this?
> 
> This relies on both system settings and platform-specific wheel events and timings. I'm not sure what the convention is for testing such changes. Can you point me in the right direction?

Beth, what is the current story with rubber-band testing?  Is it non-existent?
Comment 11 Beth Dakin 2012-08-20 11:03:47 PDT
(In reply to comment #10)
> (In reply to comment #9)
> > (In reply to comment #8)
> > > Please add a test.
> > 
> > Do you have a suggestion of how to go about writing a test for this?
> > 
> > This relies on both system settings and platform-specific wheel events and timings. I'm not sure what the convention is for testing such changes. Can you point me in the right direction?
> 
> Beth, what is the current story with rubber-band testing?  Is it non-existent?

Yeah, I don't think we ever devised a way to test this.
Comment 12 asvitkine 2012-08-20 11:28:11 PDT
Created attachment 159478 [details]
Patch
Comment 13 asvitkine 2012-08-20 11:28:53 PDT
(In reply to comment #12)
> Created an attachment (id=159478) [details]
> Patch

Updated patch removes the CHROMIUM ifdefs so that the behavior applies to the Mac port too.
Comment 14 Nico Weber 2012-08-20 14:10:04 PDT
Comment on attachment 159478 [details]
Patch

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

> Source/WebCore/platform/mac/ScrollAnimatorMac.mm:657
> +        initialized = true;

NSUserDefaults usually are supposed to be "live", you shouldn't have to restart your browser after you changed them.

Is this method hot? If so, maybe you could give WebScrollAnimationHelperDelegate a +initialize method and call registerDefaults: from there?
Comment 15 asvitkine 2012-08-20 14:17:26 PDT
Comment on attachment 159478 [details]
Patch

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

>> Source/WebCore/platform/mac/ScrollAnimatorMac.mm:657
>> +        initialized = true;
> 
> NSUserDefaults usually are supposed to be "live", you shouldn't have to restart your browser after you changed them.
> 
> Is this method hot? If so, maybe you could give WebScrollAnimationHelperDelegate a +initialize method and call registerDefaults: from there?

For this particular setting, other applications require a restart for the setting to take effect.

Regarding whether the method is hot: it's invoked for every mouse wheel event - so perhaps warm, but not hot?
Comment 16 Nico Weber 2012-08-20 14:20:24 PDT
Comment on attachment 159478 [details]
Patch

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

>>> Source/WebCore/platform/mac/ScrollAnimatorMac.mm:657
>>> +        initialized = true;
>> 
>> NSUserDefaults usually are supposed to be "live", you shouldn't have to restart your browser after you changed them.
>> 
>> Is this method hot? If so, maybe you could give WebScrollAnimationHelperDelegate a +initialize method and call registerDefaults: from there?
> 
> For this particular setting, other applications require a restart for the setting to take effect.
> 
> Regarding whether the method is hot: it's invoked for every mouse wheel event - so perhaps warm, but not hot?

If it's consistent with other apps, then I guess it's fine. "// Other apps like XXX require a restart after changing this default." makes a better comment than "// If the key hasn't been set, default to enabling rubber banding." which doesn't add much.

With that, LGTM. (I'm not a review though.)
Comment 17 Nico Weber 2012-08-20 15:27:23 PDT
> With that, LGTM. (I'm not a review though.)

*not a reviewer. Though I'm not a review either.
Comment 18 Beth Dakin 2012-08-20 17:51:24 PDT
Comment on attachment 159478 [details]
Patch

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

I think this patch is close, but I would like to see the things I commented on cleaned up.

> Source/WebCore/platform/mac/ScrollAnimatorMac.mm:651
> +        NSString* key = @"NSScrollViewRubberbanding";

For Objective-C objects, our style guide dictates that the * should go next to the variable name, not the type name. In other words, this should be: NSString *key…

> Source/WebCore/platform/mac/ScrollAnimatorMac.mm:652
> +        NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];

Same as above.

> Source/WebCore/platform/mac/ScrollAnimatorMac.mm:654
> +        id value = [defaults objectForKey:key];

Can you just use boolForKey here instead of objectForKey? And then avoid all of the conversions below?
Comment 19 Beth Dakin 2012-08-20 17:54:10 PDT
(In reply to comment #18)
> (From update of attachment 159478 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=159478&action=review
> 
> I think this patch is close, but I would like to see the things I commented on cleaned up.
> 
> > Source/WebCore/platform/mac/ScrollAnimatorMac.mm:651
> > +        NSString* key = @"NSScrollViewRubberbanding";
> 

Actually, there is no need to have a variable for the key here anyway. You can collapse these three lines of code into:

enabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"NSScrollViewRubberbanding"];
Comment 20 Nico Weber 2012-08-20 17:54:36 PDT
Comment on attachment 159478 [details]
Patch

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

>> Source/WebCore/platform/mac/ScrollAnimatorMac.mm:654
>> +        id value = [defaults objectForKey:key];
> 
> Can you just use boolForKey here instead of objectForKey? And then avoid all of the conversions below?

boolForKey defaults to NO for values that are not present. This wants to default to YES instead (see my suggestion about registerDefaults: above)
Comment 21 Beth Dakin 2012-08-20 17:56:48 PDT
(In reply to comment #20)
> (From update of attachment 159478 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=159478&action=review
> 
> >> Source/WebCore/platform/mac/ScrollAnimatorMac.mm:654
> >> +        id value = [defaults objectForKey:key];
> > 
> > Can you just use boolForKey here instead of objectForKey? And then avoid all of the conversions below?
> 
> boolForKey defaults to NO for values that are not present. This wants to default to YES instead (see my suggestion about registerDefaults: above)

Oh, that makes sense.
Comment 22 asvitkine 2012-08-21 11:38:45 PDT
Created attachment 159731 [details]
Patch
Comment 23 asvitkine 2012-08-21 11:40:54 PDT
(In reply to comment #22)
> Created an attachment (id=159731) [details]
> Patch

I've updated the patch to add a comment per Nico's suggestion and to inline some things per Beth's suggestion. I've kept (and clarified) the comment about the default value and why the code doesn't use -boolForKey:.

Please take another look.
Comment 24 Nico Weber 2012-08-21 12:20:31 PDT
Comment on attachment 159731 [details]
Patch

lgtm
Comment 25 Nico Weber 2012-08-21 12:20:53 PDT
Comment on attachment 159731 [details]
Patch

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

> Source/WebCore/ChangeLog:3
> +        [chromium/mac] Respect system setting for rubber-banding.

(nit: Remove [chromium/mac] here)
Comment 26 asvitkine 2012-08-21 12:35:07 PDT
Created attachment 159739 [details]
Patch
Comment 27 asvitkine 2012-08-21 12:35:49 PDT
(In reply to comment #25)
> (From update of attachment 159731 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=159731&action=review
> 
> > Source/WebCore/ChangeLog:3
> > +        [chromium/mac] Respect system setting for rubber-banding.
> 
> (nit: Remove [chromium/mac] here)

Done.
Comment 28 James Robinson 2012-08-22 10:43:02 PDT
Comment on attachment 159739 [details]
Patch

R=me
Comment 29 WebKit Review Bot 2012-08-22 10:59:04 PDT
Comment on attachment 159739 [details]
Patch

Clearing flags on attachment: 159739

Committed r126321: <http://trac.webkit.org/changeset/126321>
Comment 30 WebKit Review Bot 2012-08-22 10:59:08 PDT
All reviewed patches have been landed.  Closing bug.