Bug 41607

Summary: DeviceOrientationEvent should use optional properties
Product: WebKit Reporter: Steve Block <steveblock>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, eric, hans, japhet, jorlow, kling, steveblock, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on: 41608    
Bug Blocks: 39588    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch jorlow: review+

Description Steve Block 2010-07-05 05:11:12 PDT
The DeviceOrientation spec (http://dev.w3.org/geo/api/spec-source-orientation.html) requires the alpha, beta and gamma properties of DeviceOrientationEvent to all be optional.
Comment 1 Steve Block 2010-07-07 10:53:33 PDT
Created attachment 60754 [details]
Patch
Comment 2 Eric Seidel (no email) 2010-07-07 11:02:26 PDT
Attachment 60754 [details] did not build on mac:
Build output: http://webkit-commit-queue.appspot.com/results/3373471
Comment 3 Steve Block 2010-07-07 11:08:57 PDT
Created attachment 60756 [details]
Patch
Comment 4 Andreas Kling 2010-07-11 16:25:41 PDT
Comment on attachment 60756 [details]
Patch

>WebCore/dom/DeviceOrientation.h:66
> +      bool m_canProvideAlpha;
> +      double m_alpha;
> +      bool m_canProvideBeta;
> +      double m_beta;
> +      bool m_canProvideGamma;
> +      double m_gamma;
This member order will cause unnecessary padding. Better to group the doubles and bools.

Patch looks good otherwise.
Comment 5 Steve Block 2010-07-12 04:20:24 PDT
Created attachment 61208 [details]
Patch
Comment 6 Jeremy Orlow 2010-07-12 05:26:58 PDT
We should avoid adding new custom functions whenever practical.  It seems like it might be a bit better to add some new WebCore type that represents a double that could be null.  Or have some annotation in the IDL that says to pass a bool/enum ptr to the function and use that to pass back that the result should be null.

I'm not completely against the patch as is (hence no r-).  Adding japhet to see what he thinks.
Comment 7 Steve Block 2010-07-12 05:38:52 PDT
> We should avoid adding new custom functions whenever practical.  It seems like
> it might be a bit better to add some new WebCore type that represents a double
> that could be null.  Or have some annotation in the IDL that says to pass a
> bool/enum ptr to the function and use that to pass back that the result should
> be null.
Sounds reasonable. I'm totally happy to look into this for a future patch, but it sounds like it might take some time tor reach consensus for the new type/flag. It would be good to land this patch as-is now, as it's blocking progress on DeviceOrientation.
Comment 8 Jeremy Orlow 2010-07-12 06:17:31 PDT
Comment on attachment 61208 [details]
Patch


LayoutTests/fast/dom/DeviceOrientation/script-tests/optional-event-properties.js:39
 +  event.initDeviceOrientationEvent("", false, false, null, null, null);
if you used evalAndLog, then this would be printed to the console too, so it'd be easier to read without much additional effort.

WebCore/dom/DeviceOrientation.h:53
 +      DeviceOrientation()
There's enough code here I'd lean towards putting it in a .cpp file.

WebCore/bindings/js/JSDeviceOrientationEventCustom.cpp:2
 +   * Copyright 2010, The Android Open Source Project
Since these contributions are for sure from Google, should the copyright just read Google?
Comment 9 Steve Block 2010-07-12 07:01:47 PDT
> LayoutTests/fast/dom/DeviceOrientation/script-tests/optional-event-properties.js:39
>  +  event.initDeviceOrientationEvent("", false, false, null, null, null);
> if you used evalAndLog, then this would be printed to the console too, so it'd be easier to read without much additional effort.
OK, will do

> WebCore/dom/DeviceOrientation.h:53
>  +      DeviceOrientation()
> There's enough code here I'd lean towards putting it in a .cpp file.
OK

> WebCore/bindings/js/JSDeviceOrientationEventCustom.cpp:2
>  +   * Copyright 2010, The Android Open Source Project
> Since these contributions are for sure from Google, should the copyright just read Google?
All of the other DeviceOrientation patches are copyright Android, so I think it's best to stick with this.
Comment 10 Jeremy Orlow 2010-07-12 07:09:50 PDT
(In reply to comment #9)
> > LayoutTests/fast/dom/DeviceOrientation/script-tests/optional-event-properties.js:39
> >  +  event.initDeviceOrientationEvent("", false, false, null, null, null);
> > if you used evalAndLog, then this would be printed to the console too, so it'd be easier to read without much additional effort.
> OK, will do
> 
> > WebCore/dom/DeviceOrientation.h:53
> >  +      DeviceOrientation()
> > There's enough code here I'd lean towards putting it in a .cpp file.
> OK
> 
> > WebCore/bindings/js/JSDeviceOrientationEventCustom.cpp:2
> >  +   * Copyright 2010, The Android Open Source Project
> > Since these contributions are for sure from Google, should the copyright just read Google?
> All of the other DeviceOrientation patches are copyright Android, so I think it's best to stick with this.

Theres no reason the copyright needs to match.  There also is no strong reason why it needs to be Google rather than the android project beyond the former being closer to WebKit's conventions and the typical reasons for having the latter don't apply in this case (unless there's copied code...?).
Comment 11 Steve Block 2010-07-12 07:36:35 PDT
Created attachment 61226 [details]
Patch
Comment 12 Jeremy Orlow 2010-07-12 07:49:16 PDT
Comment on attachment 61226 [details]
Patch

r=me
Comment 13 Steve Block 2010-07-12 16:22:24 PDT
Created attachment 61283 [details]
Patch
Comment 14 Steve Block 2010-07-12 16:39:02 PDT
Created attachment 61287 [details]
Patch
Comment 15 Steve Block 2010-07-13 01:42:45 PDT
Created attachment 61345 [details]
Patch
Comment 16 Jeremy Orlow 2010-07-13 02:16:26 PDT
Comment on attachment 61345 [details]
Patch

rubber stamping because I already r+'ed and the diff hasn't changed much

in the future, no need to re-upload for minor changes
Comment 17 Steve Block 2010-07-13 02:26:06 PDT
> rubber stamping because I already r+'ed and the diff hasn't changed much
Thanks

> in the future, no need to re-upload for minor changes
I know. I was uploading to use the try-bot to make sure I get the correct incantations for the Windows build. Hopefully this one will work!
Comment 18 Steve Block 2010-07-13 03:37:52 PDT
The Windows EWS bot seems to have given up on my patch. It builds on my local machine, so will land manually and watch the bots.
Comment 19 Steve Block 2010-07-13 04:37:10 PDT
Committed r63193: <http://trac.webkit.org/changeset/63193>
Comment 20 WebKit Review Bot 2010-07-13 05:00:56 PDT
http://trac.webkit.org/changeset/63193 might have broken GTK Linux 64-bit Debug
Comment 21 Steve Block 2010-07-13 05:38:56 PDT
Fixed with http://trac.webkit.org/changeset/63195