Changeset 68252 in webkit
- Timestamp:
- Sep 24, 2010, 7:38:10 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/dom/DeviceMotion/create-event-expected.txt (modified) (1 diff)
-
LayoutTests/fast/dom/DeviceMotion/optional-event-properties-expected.txt (modified) (1 diff)
-
LayoutTests/fast/dom/DeviceMotion/script-tests/create-event.js (modified) (2 diffs)
-
LayoutTests/fast/dom/DeviceMotion/script-tests/optional-event-properties.js (modified) (1 diff)
-
LayoutTests/fast/dom/script-tests/prototype-inheritance.js (modified) (1 diff)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/WebCore.exp.in (modified) (1 diff)
-
WebCore/bindings/js/JSDeviceMotionEventCustom.cpp (modified) (3 diffs)
-
WebCore/bindings/v8/custom/V8DeviceMotionEventCustom.cpp (modified) (2 diffs)
-
WebCore/dom/DeviceMotionData.cpp (modified) (2 diffs)
-
WebCore/dom/DeviceMotionData.h (modified) (2 diffs)
-
WebCore/dom/DeviceMotionEvent.idl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r68246 r68252 1 2010-09-24 Hans Wennborg <[email protected]> 2 3 Reviewed by Steve Block. 4 5 Update DeviceMotionEvent to spec 6 https://bugs.webkit.org/show_bug.cgi?id=46344 7 8 * fast/dom/DeviceMotion/script-tests/create-event.js: 9 * fast/dom/DeviceMotion/create-event-expected.txt: 10 Look for the new attributes. 11 12 * fast/dom/DeviceMotion/script-tests/optional-event-properties.js: 13 * fast/dom/DeviceMotion/optional-event-properties-expected.txt: 14 Test the new attributes. 15 16 * fast/dom/script-tests/prototype-inheritance.js: 17 DeviceMotionEvent is not implemented on all platforms, so it should be 18 skipped in this test. This is necessary for platforms that enable the 19 feature to pass the layout tests. 20 1 21 2010-09-24 Satish Sampath <[email protected]> 2 22 -
trunk/LayoutTests/fast/dom/DeviceMotion/create-event-expected.txt
r68241 r68252 8 8 PASS 'bubbles' in event is true 9 9 PASS 'cancelable' in event is true 10 PASS 'xAcceleration' in event is true 11 PASS 'yAcceleration' in event is true 12 PASS 'zAcceleration' in event is true 13 PASS 'xRotationRate' in event is true 14 PASS 'yRotationRate' in event is true 15 PASS 'zRotationRate' in event is true 10 PASS 'acceleration' in event is true 11 PASS 'accelerationIncludingGravity' in event is true 12 PASS 'rotationRate' in event is true 16 13 PASS 'interval' in event is true 17 14 PASS typeof event.type == 'string' is true 18 15 PASS typeof event.bubbles == 'boolean' is true 19 16 PASS typeof event.cancelable == 'boolean' is true 20 PASS typeof event.xAcceleration == 'object' is true 21 PASS typeof event.yAcceleration == 'object' is true 22 PASS typeof event.zAcceleration == 'object' is true 23 PASS typeof event.xRotationRate == 'object' is true 24 PASS typeof event.yRotationRate == 'object' is true 25 PASS typeof event.zRotationRate == 'object' is true 17 PASS typeof event.acceleration == 'object' is true 18 PASS typeof event.accelerationIncludingGravity == 'object' is true 19 PASS typeof event.rotationRate == 'object' is true 26 20 PASS typeof event.interval == 'object' is true 27 21 PASS successfullyParsed is true -
trunk/LayoutTests/fast/dom/DeviceMotion/optional-event-properties-expected.txt
r68241 r68252 5 5 6 6 event = document.createEvent('DeviceMotionEvent') 7 PASS event.xAcceleration == null is true 8 PASS event.yAcceleration == null is true 9 PASS event.zAcceleration == null is true 10 PASS event.xRotationRate == null is true 11 PASS event.yRotationRate == null is true 12 PASS event.zRotationRate == null is true 7 PASS event.acceleration == null is true 8 PASS event.accelerationIncludingGravity == null is true 9 PASS event.rotationRate == null is true 13 10 PASS event.interval == null is true 14 event.initDeviceMotionEvent('', false, false, 0, 1, 2, 3, 4, 5, 6) 15 PASS event.xAcceleration == 0 is true 16 PASS event.yAcceleration == 1 is true 17 PASS event.zAcceleration == 2 is true 18 PASS event.xRotationRate == 3 is true 19 PASS event.yRotationRate == 4 is true 20 PASS event.zRotationRate == 5 is true 21 PASS event.interval == 6 is true 11 event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, y: 4, z: 5}, {alpha: 6, beta: 7, gamma: 8}, 9) 12 PASS event.acceleration.x == 0 is true 13 PASS event.acceleration.y == 1 is true 14 PASS event.acceleration.z == 2 is true 15 PASS event.accelerationIncludingGravity.x == 3 is true 16 PASS event.accelerationIncludingGravity.y == 4 is true 17 PASS event.accelerationIncludingGravity.z == 5 is true 18 PASS event.rotationRate.alpha == 6 is true 19 PASS event.rotationRate.beta == 7 is true 20 PASS event.rotationRate.gamma == 8 is true 21 PASS event.interval == 9 is true 22 PASS event.initDeviceMotionEvent('', false, false, objectThrowingException, {x: 3, z: 5}, {gamma: 8, beta: 7}, 9) threw exception Error: x getter exception. 23 PASS event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, objectThrowingException, {gamma: 8, beta: 7}, 9) threw exception Error: x getter exception. 24 PASS event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, z: 5}, objectThrowingException, 9) threw exception Error: alpha getter exception. 25 PASS event.initDeviceMotionEvent('', false, false, {x: objectThrowingException, y: 1, z: 2}, {x: 3, y: 4, z: 5}, {alpha: 6, beta: 7, gamma: 8}, 9) threw exception Error: valueOf threw exception. 26 PASS event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, y: objectThrowingException, z: 5}, {alpha: 6, beta: 7, gamma: 8}, 9) threw exception Error: valueOf threw exception. 27 PASS event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, y: 4, z: 5}, {alpha: 6, beta: 7, gamma: objectThrowingException}, 9) threw exception Error: valueOf threw exception. 28 event.initDeviceMotionEvent('', false, false, {y: 1, x: 0}, {x: 3, z: 5}, {gamma: 8, beta: 7}, 9) 29 PASS event.acceleration.x == 0 is true 30 PASS event.acceleration.y == 1 is true 31 PASS event.acceleration.z == null is true 32 PASS event.accelerationIncludingGravity.x == 3 is true 33 PASS event.accelerationIncludingGravity.y == null is true 34 PASS event.accelerationIncludingGravity.z == 5 is true 35 PASS event.rotationRate.alpha == null is true 36 PASS event.rotationRate.beta == 7 is true 37 PASS event.rotationRate.gamma == 8 is true 38 PASS event.interval == 9 is true 22 39 event.initDeviceMotionEvent() 23 PASS event.xAcceleration == null is true 24 PASS event.yAcceleration == null is true 25 PASS event.zAcceleration == null is true 26 PASS event.xRotationRate == null is true 27 PASS event.yRotationRate == null is true 28 PASS event.zRotationRate == null is true 40 PASS event.acceleration == null is true 41 PASS event.accelerationIncludingGravity == null is true 42 PASS event.rotationRate == null is true 29 43 PASS event.interval == null is true 30 event.initDeviceMotionEvent('', false, false, [], [], [], [], [], [], []) 31 PASS event.xAcceleration == 0 is true 32 PASS event.yAcceleration == 0 is true 33 PASS event.zAcceleration == 0 is true 34 PASS event.xRotationRate == 0 is true 35 PASS event.yRotationRate == 0 is true 36 PASS event.zRotationRate == 0 is true 44 event.initDeviceMotionEvent('', false, false, [], [], [], []) 45 PASS event.acceleration == null is true 46 PASS event.accelerationIncludingGravity == null is true 47 PASS event.rotationRate == null is true 37 48 PASS event.interval == 0 is true 38 event.initDeviceMotionEvent('', false, false, undefined, undefined, undefined, undefined, undefined, undefined, undefined) 39 PASS event.xAcceleration == null is true 40 PASS event.yAcceleration == null is true 41 PASS event.zAcceleration == null is true 42 PASS event.xRotationRate == null is true 43 PASS event.yRotationRate == null is true 44 PASS event.zRotationRate == null is true 49 event.initDeviceMotionEvent('', false, false, undefined, undefined, undefined, undefined) 50 PASS event.acceleration == null is true 51 PASS event.accelerationIncludingGravity == null is true 52 PASS event.rotationRate == null is true 45 53 PASS event.interval == null is true 46 event.initDeviceMotionEvent('', false, false, '', '', '', '', '', '', '') 47 PASS event.xAcceleration == 0 is true 48 PASS event.yAcceleration == 0 is true 49 PASS event.zAcceleration == 0 is true 50 PASS event.xRotationRate == 0 is true 51 PASS event.yRotationRate == 0 is true 52 PASS event.zRotationRate == 0 is true 54 event.initDeviceMotionEvent('', false, false, '', '', '', '') 55 PASS event.acceleration == null is true 56 PASS event.accelerationIncludingGravity == null is true 57 PASS event.rotationRate == null is true 53 58 PASS event.interval == 0 is true 54 event.initDeviceMotionEvent('', false, false, null, null, null, null, null, null, null) 55 PASS event.xAcceleration == null is true 56 PASS event.yAcceleration == null is true 57 PASS event.zAcceleration == null is true 58 PASS event.xRotationRate == null is true 59 PASS event.yRotationRate == null is true 60 PASS event.zRotationRate == null is true 59 event.initDeviceMotionEvent('', false, false, null, null, null, null) 60 PASS event.acceleration == null is true 61 PASS event.accelerationIncludingGravity == null is true 62 PASS event.rotationRate == null is true 63 PASS event.interval == null is true 64 event.initDeviceMotionEvent('', false, false, {x: null, y: null, z: null}, {x: null, y: null, z: null}, {alpha: null, beta: null, gamma: null}, null) 65 PASS event.acceleration == null is true 66 PASS event.accelerationIncludingGravity == null is true 67 PASS event.rotationRate == null is true 68 PASS event.interval == null is true 69 event.initDeviceMotionEvent('', false, false, {x: null, y: null, z: 1}, {x: null, y: null, z: 2}, {alpha: null, beta: null, gamma: 3}, null) 70 PASS event.acceleration.x == null is true 71 PASS event.acceleration.y == null is true 72 PASS event.acceleration.z == 1 is true 73 PASS event.accelerationIncludingGravity.x == null is true 74 PASS event.accelerationIncludingGravity.y == null is true 75 PASS event.accelerationIncludingGravity.z == 2 is true 76 PASS event.rotationRate.alpha == null is true 77 PASS event.rotationRate.beta == null is true 78 PASS event.rotationRate.gamma == 3 is true 79 PASS event.interval == null is true 80 event.initDeviceMotionEvent('', false, false, {x: undefined, y: undefined, z: undefined}, {x: undefined, y: undefined, z: undefined}, {alpha: undefined, beta: undefined, gamma: undefined}, undefined) 81 PASS event.acceleration == null is true 82 PASS event.accelerationIncludingGravity == null is true 83 PASS event.rotationRate == null is true 84 PASS event.interval == null is true 85 event.initDeviceMotionEvent('', false, false, {x: undefined, y: undefined, z: 1}, {x: undefined, y: undefined, z: 2}, {alpha: undefined, beta: undefined, gamma: 3}, undefined) 86 PASS event.acceleration.x == null is true 87 PASS event.acceleration.y == null is true 88 PASS event.acceleration.z == 1 is true 89 PASS event.accelerationIncludingGravity.x == null is true 90 PASS event.accelerationIncludingGravity.y == null is true 91 PASS event.accelerationIncludingGravity.z == 2 is true 92 PASS event.rotationRate.alpha == null is true 93 PASS event.rotationRate.beta == null is true 94 PASS event.rotationRate.gamma == 3 is true 61 95 PASS event.interval == null is true 62 96 PASS successfullyParsed is true -
trunk/LayoutTests/fast/dom/DeviceMotion/script-tests/create-event.js
r68241 r68252 8 8 shouldBeTrue("'bubbles' in event"); 9 9 shouldBeTrue("'cancelable' in event"); 10 shouldBeTrue("'xAcceleration' in event"); 11 shouldBeTrue("'yAcceleration' in event"); 12 shouldBeTrue("'zAcceleration' in event"); 13 shouldBeTrue("'xRotationRate' in event"); 14 shouldBeTrue("'yRotationRate' in event"); 15 shouldBeTrue("'zRotationRate' in event"); 10 shouldBeTrue("'acceleration' in event"); 11 shouldBeTrue("'accelerationIncludingGravity' in event"); 12 shouldBeTrue("'rotationRate' in event"); 16 13 shouldBeTrue("'interval' in event"); 17 14 … … 19 16 shouldBeTrue("typeof event.bubbles == 'boolean'"); 20 17 shouldBeTrue("typeof event.cancelable == 'boolean'"); 21 shouldBeTrue("typeof event.xAcceleration == 'object'"); 22 shouldBeTrue("typeof event.yAcceleration == 'object'"); 23 shouldBeTrue("typeof event.zAcceleration == 'object'"); 24 shouldBeTrue("typeof event.xRotationRate == 'object'"); 25 shouldBeTrue("typeof event.yRotationRate == 'object'"); 26 shouldBeTrue("typeof event.zRotationRate == 'object'"); 18 shouldBeTrue("typeof event.acceleration == 'object'"); 19 shouldBeTrue("typeof event.accelerationIncludingGravity == 'object'"); 20 shouldBeTrue("typeof event.rotationRate == 'object'"); 27 21 shouldBeTrue("typeof event.interval == 'object'"); 28 22 -
trunk/LayoutTests/fast/dom/DeviceMotion/script-tests/optional-event-properties.js
r68241 r68252 1 1 description("Tests the optional properties of DeviceMotionEvent. Each property should be null if not set, or set to null or undefined."); 2 3 function ObjectThrowingException() {}; 4 ObjectThrowingException.prototype.valueOf = function() { throw new Error('valueOf threw exception'); } 5 ObjectThrowingException.prototype.__defineGetter__("x", function() { throw new Error('x getter exception'); }); 6 ObjectThrowingException.prototype.__defineGetter__("alpha", function() { throw new Error('alpha getter exception'); }); 7 var objectThrowingException = new ObjectThrowingException(); 8 9 function testException(expression, expectedException) 10 { 11 shouldThrow(expression, '(function() { return "' + expectedException + '"; })();'); 12 } 2 13 3 14 var event; 4 15 5 16 evalAndLog("event = document.createEvent('DeviceMotionEvent')"); 6 shouldBeTrue("event.xAcceleration == null"); 7 shouldBeTrue("event.yAcceleration == null"); 8 shouldBeTrue("event.zAcceleration == null"); 9 shouldBeTrue("event.xRotationRate == null"); 10 shouldBeTrue("event.yRotationRate == null"); 11 shouldBeTrue("event.zRotationRate == null"); 17 shouldBeTrue("event.acceleration == null"); 18 shouldBeTrue("event.accelerationIncludingGravity == null"); 19 shouldBeTrue("event.rotationRate == null"); 12 20 shouldBeTrue("event.interval == null"); 13 21 14 evalAndLog("event.initDeviceMotionEvent('', false, false, 0, 1, 2, 3, 4, 5, 6)"); 15 shouldBeTrue("event.xAcceleration == 0"); 16 shouldBeTrue("event.yAcceleration == 1"); 17 shouldBeTrue("event.zAcceleration == 2"); 18 shouldBeTrue("event.xRotationRate == 3"); 19 shouldBeTrue("event.yRotationRate == 4"); 20 shouldBeTrue("event.zRotationRate == 5"); 21 shouldBeTrue("event.interval == 6"); 22 evalAndLog("event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, y: 4, z: 5}, {alpha: 6, beta: 7, gamma: 8}, 9)"); 23 shouldBeTrue("event.acceleration.x == 0"); 24 shouldBeTrue("event.acceleration.y == 1"); 25 shouldBeTrue("event.acceleration.z == 2"); 26 shouldBeTrue("event.accelerationIncludingGravity.x == 3"); 27 shouldBeTrue("event.accelerationIncludingGravity.y == 4"); 28 shouldBeTrue("event.accelerationIncludingGravity.z == 5"); 29 shouldBeTrue("event.rotationRate.alpha == 6"); 30 shouldBeTrue("event.rotationRate.beta == 7"); 31 shouldBeTrue("event.rotationRate.gamma == 8"); 32 shouldBeTrue("event.interval == 9"); 33 34 testException("event.initDeviceMotionEvent('', false, false, objectThrowingException, {x: 3, z: 5}, {gamma: 8, beta: 7}, 9)", "Error: x getter exception"); 35 testException("event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, objectThrowingException, {gamma: 8, beta: 7}, 9)", "Error: x getter exception"); 36 testException("event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, z: 5}, objectThrowingException, 9)", "Error: alpha getter exception"); 37 38 testException("event.initDeviceMotionEvent('', false, false, {x: objectThrowingException, y: 1, z: 2}, {x: 3, y: 4, z: 5}, {alpha: 6, beta: 7, gamma: 8}, 9)", "Error: valueOf threw exception"); 39 testException("event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, y: objectThrowingException, z: 5}, {alpha: 6, beta: 7, gamma: 8}, 9)", "Error: valueOf threw exception"); 40 testException("event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, y: 4, z: 5}, {alpha: 6, beta: 7, gamma: objectThrowingException}, 9)", "Error: valueOf threw exception"); 41 42 evalAndLog("event.initDeviceMotionEvent('', false, false, {y: 1, x: 0}, {x: 3, z: 5}, {gamma: 8, beta: 7}, 9)"); 43 shouldBeTrue("event.acceleration.x == 0"); 44 shouldBeTrue("event.acceleration.y == 1"); 45 shouldBeTrue("event.acceleration.z == null"); 46 shouldBeTrue("event.accelerationIncludingGravity.x == 3"); 47 shouldBeTrue("event.accelerationIncludingGravity.y == null"); 48 shouldBeTrue("event.accelerationIncludingGravity.z == 5"); 49 shouldBeTrue("event.rotationRate.alpha == null"); 50 shouldBeTrue("event.rotationRate.beta == 7"); 51 shouldBeTrue("event.rotationRate.gamma == 8"); 52 shouldBeTrue("event.interval == 9"); 22 53 23 54 evalAndLog("event.initDeviceMotionEvent()"); 24 shouldBeTrue("event.xAcceleration == null"); 25 shouldBeTrue("event.yAcceleration == null"); 26 shouldBeTrue("event.zAcceleration == null"); 27 shouldBeTrue("event.xRotationRate == null"); 28 shouldBeTrue("event.yRotationRate == null"); 29 shouldBeTrue("event.zRotationRate == null"); 55 shouldBeTrue("event.acceleration == null"); 56 shouldBeTrue("event.accelerationIncludingGravity == null"); 57 shouldBeTrue("event.rotationRate == null"); 30 58 shouldBeTrue("event.interval == null"); 31 59 32 evalAndLog("event.initDeviceMotionEvent('', false, false, [], [], [], [], [], [], [])"); 33 shouldBeTrue("event.xAcceleration == 0"); 34 shouldBeTrue("event.yAcceleration == 0"); 35 shouldBeTrue("event.zAcceleration == 0"); 36 shouldBeTrue("event.xRotationRate == 0"); 37 shouldBeTrue("event.yRotationRate == 0"); 38 shouldBeTrue("event.zRotationRate == 0"); 60 evalAndLog("event.initDeviceMotionEvent('', false, false, [], [], [], [])"); 61 shouldBeTrue("event.acceleration == null"); 62 shouldBeTrue("event.accelerationIncludingGravity == null"); 63 shouldBeTrue("event.rotationRate == null"); 39 64 shouldBeTrue("event.interval == 0"); 40 65 41 evalAndLog("event.initDeviceMotionEvent('', false, false, undefined, undefined, undefined, undefined, undefined, undefined, undefined)"); 42 shouldBeTrue("event.xAcceleration == null"); 43 shouldBeTrue("event.yAcceleration == null"); 44 shouldBeTrue("event.zAcceleration == null"); 45 shouldBeTrue("event.xRotationRate == null"); 46 shouldBeTrue("event.yRotationRate == null"); 47 shouldBeTrue("event.zRotationRate == null"); 66 evalAndLog("event.initDeviceMotionEvent('', false, false, undefined, undefined, undefined, undefined)"); 67 shouldBeTrue("event.acceleration == null"); 68 shouldBeTrue("event.accelerationIncludingGravity == null"); 69 shouldBeTrue("event.rotationRate == null"); 48 70 shouldBeTrue("event.interval == null"); 49 71 50 evalAndLog("event.initDeviceMotionEvent('', false, false, '', '', '', '', '', '', '')"); 51 shouldBeTrue("event.xAcceleration == 0"); 52 shouldBeTrue("event.yAcceleration == 0"); 53 shouldBeTrue("event.zAcceleration == 0"); 54 shouldBeTrue("event.xRotationRate == 0"); 55 shouldBeTrue("event.yRotationRate == 0"); 56 shouldBeTrue("event.zRotationRate == 0"); 72 evalAndLog("event.initDeviceMotionEvent('', false, false, '', '', '', '')"); 73 shouldBeTrue("event.acceleration == null"); 74 shouldBeTrue("event.accelerationIncludingGravity == null"); 75 shouldBeTrue("event.rotationRate == null"); 57 76 shouldBeTrue("event.interval == 0"); 58 77 59 evalAndLog("event.initDeviceMotionEvent('', false, false, null, null, null, null, null, null, null)"); 60 shouldBeTrue("event.xAcceleration == null"); 61 shouldBeTrue("event.yAcceleration == null"); 62 shouldBeTrue("event.zAcceleration == null"); 63 shouldBeTrue("event.xRotationRate == null"); 64 shouldBeTrue("event.yRotationRate == null"); 65 shouldBeTrue("event.zRotationRate == null"); 78 evalAndLog("event.initDeviceMotionEvent('', false, false, null, null, null, null)"); 79 shouldBeTrue("event.acceleration == null"); 80 shouldBeTrue("event.accelerationIncludingGravity == null"); 81 shouldBeTrue("event.rotationRate == null"); 82 shouldBeTrue("event.interval == null"); 83 84 evalAndLog("event.initDeviceMotionEvent('', false, false, {x: null, y: null, z: null}, {x: null, y: null, z: null}, {alpha: null, beta: null, gamma: null}, null)"); 85 shouldBeTrue("event.acceleration == null"); 86 shouldBeTrue("event.accelerationIncludingGravity == null"); 87 shouldBeTrue("event.rotationRate == null"); 88 shouldBeTrue("event.interval == null"); 89 90 evalAndLog("event.initDeviceMotionEvent('', false, false, {x: null, y: null, z: 1}, {x: null, y: null, z: 2}, {alpha: null, beta: null, gamma: 3}, null)"); 91 shouldBeTrue("event.acceleration.x == null"); 92 shouldBeTrue("event.acceleration.y == null"); 93 shouldBeTrue("event.acceleration.z == 1"); 94 shouldBeTrue("event.accelerationIncludingGravity.x == null"); 95 shouldBeTrue("event.accelerationIncludingGravity.y == null"); 96 shouldBeTrue("event.accelerationIncludingGravity.z == 2"); 97 shouldBeTrue("event.rotationRate.alpha == null"); 98 shouldBeTrue("event.rotationRate.beta == null"); 99 shouldBeTrue("event.rotationRate.gamma == 3"); 100 shouldBeTrue("event.interval == null"); 101 102 evalAndLog("event.initDeviceMotionEvent('', false, false, {x: undefined, y: undefined, z: undefined}, {x: undefined, y: undefined, z: undefined}, {alpha: undefined, beta: undefined, gamma: undefined}, undefined)"); 103 shouldBeTrue("event.acceleration == null"); 104 shouldBeTrue("event.accelerationIncludingGravity == null"); 105 shouldBeTrue("event.rotationRate == null"); 106 shouldBeTrue("event.interval == null"); 107 108 evalAndLog("event.initDeviceMotionEvent('', false, false, {x: undefined, y: undefined, z: 1}, {x: undefined, y: undefined, z: 2}, {alpha: undefined, beta: undefined, gamma: 3}, undefined)"); 109 shouldBeTrue("event.acceleration.x == null"); 110 shouldBeTrue("event.acceleration.y == null"); 111 shouldBeTrue("event.acceleration.z == 1"); 112 shouldBeTrue("event.accelerationIncludingGravity.x == null"); 113 shouldBeTrue("event.accelerationIncludingGravity.y == null"); 114 shouldBeTrue("event.accelerationIncludingGravity.z == 2"); 115 shouldBeTrue("event.rotationRate.alpha == null"); 116 shouldBeTrue("event.rotationRate.beta == null"); 117 shouldBeTrue("event.rotationRate.gamma == 3"); 66 118 shouldBeTrue("event.interval == null"); 67 119 -
trunk/LayoutTests/fast/dom/script-tests/prototype-inheritance.js
r68241 r68252 24 24 "createBlobURL", "revokeBlobURL", 25 25 "DeviceOrientationEvent", 26 "DeviceMotionEvent", 26 27 "TEMPORARY", "PERSISTENT", 27 28 "Flags", -
trunk/WebCore/ChangeLog
r68251 r68252 1 2010-09-24 Hans Wennborg <[email protected]> 2 3 Reviewed by Steve Block. 4 5 Update DeviceMotionEvent to spec 6 https://bugs.webkit.org/show_bug.cgi?id=46344 7 8 The spec has changed: the DeviceMotionEvent attributes accelerationX, 9 accelerationY, etc. have been baked into an 'acceleration' attribute 10 which returns an object with x, y, and z values. Likewise for the 11 rotation rate. The 'accelerationIncludingGravity' attribute is new. 12 13 * WebCore.exp.in: 14 The DeviceMotionData::create member function has changed. Also export 15 create functions for DeviceMotionData::Acceleration and RotationRate. 16 17 * bindings/js/JSDeviceMotionEventCustom.cpp: 18 (WebCore::JSDeviceMotionEvent::acceleration): 19 (WebCore::JSDeviceMotionEvent::accelerationIncludingGravity): 20 (WebCore::JSDeviceMotionEvent::rotationRate): 21 (WebCore::JSDeviceMotionEvent::initDeviceMotionEvent): 22 Manually create and return objects with the right attributes for 23 acceleration, accelerationIncludingGravity, and rotationRate. 24 When creating the DeviceMotionData object in initDeviceMotionEvent, 25 accept any input objects that have the right attributes. 26 27 * bindings/v8/custom/V8DeviceMotionEventCustom.cpp: 28 (WebCore::V8DeviceMotionEvent::accelerationAccessorGetter): 29 (WebCore::V8DeviceMotionEvent::accelerationIncludingGravityAccessorGetter): 30 (WebCore::V8DeviceMotionEvent::rotationRateAccessorGetter): 31 (WebCore::V8DeviceMotionEvent::initDeviceMotionEventCallback): 32 V8 counterpart to the JSC code above. 33 34 * dom/DeviceMotionData.cpp: 35 (WebCore::DeviceMotionData::Acceleration::create): 36 (WebCore::DeviceMotionData::Acceleration::Acceleration): 37 (WebCore::DeviceMotionData::RotationRate::create): 38 (WebCore::DeviceMotionData::RotationRate::RotationRate): 39 (WebCore::DeviceMotionData::create): 40 (WebCore::DeviceMotionData::DeviceMotionData): 41 * dom/DeviceMotionData.h: 42 (WebCore::DeviceMotionData::Acceleration::canProvideX): 43 (WebCore::DeviceMotionData::Acceleration::canProvideY): 44 (WebCore::DeviceMotionData::Acceleration::canProvideZ): 45 (WebCore::DeviceMotionData::Acceleration::x): 46 (WebCore::DeviceMotionData::Acceleration::y): 47 (WebCore::DeviceMotionData::Acceleration::z): 48 (WebCore::DeviceMotionData::RotationRate::canProvideAlpha): 49 (WebCore::DeviceMotionData::RotationRate::canProvideBeta): 50 (WebCore::DeviceMotionData::RotationRate::canProvideGamma): 51 (WebCore::DeviceMotionData::RotationRate::alpha): 52 (WebCore::DeviceMotionData::RotationRate::beta): 53 (WebCore::DeviceMotionData::RotationRate::gamma): 54 (WebCore::DeviceMotionData::acceleration): 55 (WebCore::DeviceMotionData::accelerationIncludingGravity): 56 (WebCore::DeviceMotionData::rotationRate): 57 Add member classes Acceleration and RotationRate to DeviceMotionData. 58 59 * dom/DeviceMotionEvent.idl: 60 Update according to the spec. Acceleration and RotationRate need not 61 be backed by native classes. 62 1 63 2010-09-24 Romain Pokrzywka <[email protected]> 2 64 -
trunk/WebCore/WebCore.exp.in
r68241 r68252 361 361 __ZN7WebCore15visitedLinkHashEPKtj 362 362 __ZN7WebCore16AbstractDatabase14setIsAvailableEb 363 __ZN7WebCore16DeviceMotionData6createEbdbdbdbdbdbdbd 363 __ZN7WebCore16DeviceMotionData12Acceleration6createEbdbdbd 364 __ZN7WebCore16DeviceMotionData12RotationRate6createEbdbdbd 365 __ZN7WebCore16DeviceMotionData6createEN3WTF10PassRefPtrINS0_12AccelerationEEES4_NS2_INS0_12RotationRateEEEbd 364 366 __ZN7WebCore16FontFallbackList15releaseFontDataEv 365 367 __ZN7WebCore16FontPlatformDataC1EP6NSFontbb -
trunk/WebCore/bindings/js/JSDeviceMotionEventCustom.cpp
r68241 r68252 36 36 namespace WebCore { 37 37 38 JSValue JSDeviceMotionEvent::xAcceleration(ExecState* exec) const 38 static PassRefPtr<DeviceMotionData::Acceleration> readAccelerationArgument(JSValue value, ExecState* exec) 39 { 40 if (value.isUndefinedOrNull()) 41 return 0; 42 43 // Given the above test, this will always yield an object. 44 JSObject* object = value.toObject(exec); 45 46 JSValue xValue = object->get(exec, Identifier(exec, "x")); 47 if (exec->hadException()) 48 return 0; 49 bool canProvideX = !xValue.isUndefinedOrNull(); 50 double x = xValue.toNumber(exec); 51 if (exec->hadException()) 52 return 0; 53 54 JSValue yValue = object->get(exec, Identifier(exec, "y")); 55 if (exec->hadException()) 56 return 0; 57 bool canProvideY = !yValue.isUndefinedOrNull(); 58 double y = yValue.toNumber(exec); 59 if (exec->hadException()) 60 return 0; 61 62 JSValue zValue = object->get(exec, Identifier(exec, "z")); 63 if (exec->hadException()) 64 return 0; 65 bool canProvideZ = !zValue.isUndefinedOrNull(); 66 double z = zValue.toNumber(exec); 67 if (exec->hadException()) 68 return 0; 69 70 if (!canProvideX && !canProvideY && !canProvideZ) 71 return 0; 72 73 return DeviceMotionData::Acceleration::create(canProvideX, x, canProvideY, y, canProvideZ, z); 74 } 75 76 static PassRefPtr<DeviceMotionData::RotationRate> readRotationRateArgument(JSValue value, ExecState* exec) 77 { 78 if (value.isUndefinedOrNull()) 79 return 0; 80 81 // Given the above test, this will always yield an object. 82 JSObject* object = value.toObject(exec); 83 84 JSValue alphaValue = object->get(exec, Identifier(exec, "alpha")); 85 if (exec->hadException()) 86 return 0; 87 bool canProvideAlpha = !alphaValue.isUndefinedOrNull(); 88 double alpha = alphaValue.toNumber(exec); 89 if (exec->hadException()) 90 return 0; 91 92 JSValue betaValue = object->get(exec, Identifier(exec, "beta")); 93 if (exec->hadException()) 94 return 0; 95 bool canProvideBeta = !betaValue.isUndefinedOrNull(); 96 double beta = betaValue.toNumber(exec); 97 if (exec->hadException()) 98 return 0; 99 100 JSValue gammaValue = object->get(exec, Identifier(exec, "gamma")); 101 if (exec->hadException()) 102 return 0; 103 bool canProvideGamma = !gammaValue.isUndefinedOrNull(); 104 double gamma = gammaValue.toNumber(exec); 105 if (exec->hadException()) 106 return 0; 107 108 if (!canProvideAlpha && !canProvideBeta && !canProvideGamma) 109 return 0; 110 111 return DeviceMotionData::RotationRate::create(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma); 112 } 113 114 static JSObject* createAccelerationObject(const DeviceMotionData::Acceleration* acceleration, ExecState* exec) 115 { 116 JSObject* object = constructEmptyObject(exec); 117 object->putDirect(Identifier(exec, "x"), acceleration->canProvideX() ? jsNumber(exec, acceleration->x()) : jsNull()); 118 object->putDirect(Identifier(exec, "y"), acceleration->canProvideY() ? jsNumber(exec, acceleration->y()) : jsNull()); 119 object->putDirect(Identifier(exec, "z"), acceleration->canProvideZ() ? jsNumber(exec, acceleration->z()) : jsNull()); 120 return object; 121 } 122 123 static JSObject* createRotationRateObject(const DeviceMotionData::RotationRate* rotationRate, ExecState* exec) 124 { 125 JSObject* object = constructEmptyObject(exec); 126 object->putDirect(Identifier(exec, "alpha"), rotationRate->canProvideAlpha() ? jsNumber(exec, rotationRate->alpha()) : jsNull()); 127 object->putDirect(Identifier(exec, "beta"), rotationRate->canProvideBeta() ? jsNumber(exec, rotationRate->beta()) : jsNull()); 128 object->putDirect(Identifier(exec, "gamma"), rotationRate->canProvideGamma() ? jsNumber(exec, rotationRate->gamma()) : jsNull()); 129 return object; 130 } 131 132 JSValue JSDeviceMotionEvent::acceleration(ExecState* exec) const 39 133 { 40 134 DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl()); 41 if (!imp->deviceMotionData()-> canProvideXAcceleration())135 if (!imp->deviceMotionData()->acceleration()) 42 136 return jsNull(); 43 return jsNumber(exec, imp->deviceMotionData()->xAcceleration());137 return createAccelerationObject(imp->deviceMotionData()->acceleration(), exec); 44 138 } 45 139 46 JSValue JSDeviceMotionEvent:: yAcceleration(ExecState* exec) const140 JSValue JSDeviceMotionEvent::accelerationIncludingGravity(ExecState* exec) const 47 141 { 48 142 DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl()); 49 if (!imp->deviceMotionData()-> canProvideYAcceleration())143 if (!imp->deviceMotionData()->accelerationIncludingGravity()) 50 144 return jsNull(); 51 return jsNumber(exec, imp->deviceMotionData()->yAcceleration());145 return createAccelerationObject(imp->deviceMotionData()->accelerationIncludingGravity(), exec); 52 146 } 53 147 54 JSValue JSDeviceMotionEvent:: zAcceleration(ExecState* exec) const148 JSValue JSDeviceMotionEvent::rotationRate(ExecState* exec) const 55 149 { 56 150 DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl()); 57 if (!imp->deviceMotionData()-> canProvideZAcceleration())151 if (!imp->deviceMotionData()->rotationRate()) 58 152 return jsNull(); 59 return jsNumber(exec, imp->deviceMotionData()->zAcceleration());153 return createRotationRateObject(imp->deviceMotionData()->rotationRate(), exec); 60 154 } 61 155 62 JSValue JSDeviceMotionEvent::xRotationRate(ExecState* exec) const63 {64 DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());65 if (!imp->deviceMotionData()->canProvideXRotationRate())66 return jsNull();67 return jsNumber(exec, imp->deviceMotionData()->xRotationRate());68 }69 70 JSValue JSDeviceMotionEvent::yRotationRate(ExecState* exec) const71 {72 DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());73 if (!imp->deviceMotionData()->canProvideYRotationRate())74 return jsNull();75 return jsNumber(exec, imp->deviceMotionData()->yRotationRate());76 }77 78 JSValue JSDeviceMotionEvent::zRotationRate(ExecState* exec) const79 {80 DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());81 if (!imp->deviceMotionData()->canProvideZRotationRate())82 return jsNull();83 return jsNumber(exec, imp->deviceMotionData()->zRotationRate());84 }85 86 156 JSValue JSDeviceMotionEvent::interval(ExecState* exec) const 87 157 { … … 91 161 return jsNumber(exec, imp->deviceMotionData()->interval()); 92 162 } 93 163 94 164 JSValue JSDeviceMotionEvent::initDeviceMotionEvent(ExecState* exec) 95 165 { … … 97 167 bool bubbles = exec->argument(1).toBoolean(exec); 98 168 bool cancelable = exec->argument(2).toBoolean(exec); 169 99 170 // If any of the parameters are null or undefined, mark them as not provided. 100 171 // Otherwise, use the standard JavaScript conversion. 101 bool xAccelerationProvided = !exec->argument(3).isUndefinedOrNull(); 102 double xAcceleration = exec->argument(3).toNumber(exec); 103 bool yAccelerationProvided = !exec->argument(4).isUndefinedOrNull(); 104 double yAcceleration = exec->argument(4).toNumber(exec); 105 bool zAccelerationProvided = !exec->argument(5).isUndefinedOrNull(); 106 double zAcceleration = exec->argument(5).toNumber(exec); 107 bool xRotationRateProvided = !exec->argument(6).isUndefinedOrNull(); 108 double xRotationRate = exec->argument(6).toNumber(exec); 109 bool yRotationRateProvided = !exec->argument(7).isUndefinedOrNull(); 110 double yRotationRate = exec->argument(7).toNumber(exec); 111 bool zRotationRateProvided = !exec->argument(8).isUndefinedOrNull(); 112 double zRotationRate = exec->argument(8).toNumber(exec); 113 bool intervalProvided = !exec->argument(9).isUndefinedOrNull(); 114 double interval = exec->argument(9).toNumber(exec); 115 RefPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::create(xAccelerationProvided, xAcceleration, 116 yAccelerationProvided, yAcceleration, 117 zAccelerationProvided, zAcceleration, 118 xRotationRateProvided, xRotationRate, 119 yRotationRateProvided, yRotationRate, 120 zRotationRateProvided, zRotationRate, 121 intervalProvided, interval); 172 RefPtr<DeviceMotionData::Acceleration> acceleration = readAccelerationArgument(exec->argument(3), exec); 173 if (exec->hadException()) 174 return jsUndefined(); 175 176 RefPtr<DeviceMotionData::Acceleration> accelerationIncludingGravity = readAccelerationArgument(exec->argument(4), exec); 177 if (exec->hadException()) 178 return jsUndefined(); 179 180 RefPtr<DeviceMotionData::RotationRate> rotationRate = readRotationRateArgument(exec->argument(5), exec); 181 if (exec->hadException()) 182 return jsUndefined(); 183 184 bool intervalProvided = !exec->argument(6).isUndefinedOrNull(); 185 double interval = exec->argument(6).toNumber(exec); 186 RefPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, intervalProvided, interval); 122 187 DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl()); 123 188 imp->initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData.get()); -
trunk/WebCore/bindings/v8/custom/V8DeviceMotionEventCustom.cpp
r68241 r68252 38 38 namespace WebCore { 39 39 40 v8::Handle<v8::Value> V8DeviceMotionEvent::xAccelerationAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) 40 namespace { 41 42 v8::Handle<v8::Value> createAccelerationObject(const DeviceMotionData::Acceleration* acceleration) 41 43 { 42 INC_STATS("DOM.DeviceMotionEvent.xAcceleration._get"); 44 v8::Local<v8::Object> object = v8::Object::New(); 45 object->Set(v8::String::New("x"), acceleration->canProvideX() ? v8::Number::New(acceleration->x()) : v8::Null()); 46 object->Set(v8::String::New("y"), acceleration->canProvideY() ? v8::Number::New(acceleration->y()) : v8::Null()); 47 object->Set(v8::String::New("z"), acceleration->canProvideZ() ? v8::Number::New(acceleration->z()) : v8::Null()); 48 return object; 49 } 50 51 v8::Handle<v8::Value> createRotationRateObject(const DeviceMotionData::RotationRate* rotationRate) 52 { 53 v8::Local<v8::Object> object = v8::Object::New(); 54 object->Set(v8::String::New("alpha"), rotationRate->canProvideAlpha() ? v8::Number::New(rotationRate->alpha()) : v8::Null()); 55 object->Set(v8::String::New("beta"), rotationRate->canProvideBeta() ? v8::Number::New(rotationRate->beta()) : v8::Null()); 56 object->Set(v8::String::New("gamma"), rotationRate->canProvideGamma() ? v8::Number::New(rotationRate->gamma()) : v8::Null()); 57 return object; 58 } 59 60 RefPtr<DeviceMotionData::Acceleration> readAccelerationArgument(v8::Local<v8::Value> value) 61 { 62 if (isUndefinedOrNull(value)) 63 return 0; 64 65 // Given the test above, this will always yield an object. 66 v8::Local<v8::Object> object = value->ToObject(); 67 68 v8::Local<v8::Value> xValue = object->Get(v8::String::New("x")); 69 if (xValue.IsEmpty()) 70 return 0; 71 bool canProvideX = !isUndefinedOrNull(xValue); 72 double x = static_cast<double>(xValue->NumberValue()); 73 74 v8::Local<v8::Value> yValue = object->Get(v8::String::New("y")); 75 if (yValue.IsEmpty()) 76 return 0; 77 bool canProvideY = !isUndefinedOrNull(yValue); 78 double y = static_cast<double>(yValue->NumberValue()); 79 80 v8::Local<v8::Value> zValue = object->Get(v8::String::New("z")); 81 if (zValue.IsEmpty()) 82 return 0; 83 bool canProvideZ = !isUndefinedOrNull(zValue); 84 double z = static_cast<double>(zValue->NumberValue()); 85 86 if (!canProvideX && !canProvideY && !canProvideZ) 87 return 0; 88 89 return DeviceMotionData::Acceleration::create(canProvideX, x, canProvideY, y, canProvideZ, z); 90 } 91 92 RefPtr<DeviceMotionData::RotationRate> readRotationRateArgument(v8::Local<v8::Value> value) 93 { 94 if (isUndefinedOrNull(value)) 95 return 0; 96 97 // Given the test above, this will always yield an object. 98 v8::Local<v8::Object> object = value->ToObject(); 99 100 v8::Local<v8::Value> alphaValue = object->Get(v8::String::New("alpha")); 101 if (alphaValue.IsEmpty()) 102 return 0; 103 bool canProvideAlpha = !isUndefinedOrNull(alphaValue); 104 double alpha = static_cast<double>(alphaValue->NumberValue()); 105 106 v8::Local<v8::Value> betaValue = object->Get(v8::String::New("beta")); 107 if (betaValue.IsEmpty()) 108 return 0; 109 bool canProvideBeta = !isUndefinedOrNull(betaValue); 110 double beta = static_cast<double>(betaValue->NumberValue()); 111 112 v8::Local<v8::Value> gammaValue = object->Get(v8::String::New("gamma")); 113 if (gammaValue.IsEmpty()) 114 return 0; 115 bool canProvideGamma = !isUndefinedOrNull(gammaValue); 116 double gamma = static_cast<double>(gammaValue->NumberValue()); 117 118 if (!canProvideAlpha && !canProvideBeta && !canProvideGamma) 119 return 0; 120 121 return DeviceMotionData::RotationRate::create(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma); 122 } 123 124 } // namespace 125 126 v8::Handle<v8::Value> V8DeviceMotionEvent::accelerationAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) 127 { 128 INC_STATS("DOM.DeviceMotionEvent.acceleration._get"); 43 129 v8::Handle<v8::Object> holder = info.Holder(); 44 130 DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder); 45 if (!imp->deviceMotionData()-> canProvideXAcceleration())131 if (!imp->deviceMotionData()->acceleration()) 46 132 return v8::Null(); 47 return v8::Number::New(imp->deviceMotionData()->xAcceleration());133 return createAccelerationObject(imp->deviceMotionData()->acceleration()); 48 134 } 49 135 50 v8::Handle<v8::Value> V8DeviceMotionEvent:: yAccelerationAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)136 v8::Handle<v8::Value> V8DeviceMotionEvent::accelerationIncludingGravityAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) 51 137 { 52 INC_STATS("DOM.DeviceMotionEvent. yAcceleration._get");138 INC_STATS("DOM.DeviceMotionEvent.accelerationIncludingGravity._get"); 53 139 v8::Handle<v8::Object> holder = info.Holder(); 54 140 DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder); 55 if (!imp->deviceMotionData()-> canProvideYAcceleration())141 if (!imp->deviceMotionData()->accelerationIncludingGravity()) 56 142 return v8::Null(); 57 return v8::Number::New(imp->deviceMotionData()->yAcceleration());143 return createAccelerationObject(imp->deviceMotionData()->accelerationIncludingGravity()); 58 144 } 59 145 60 v8::Handle<v8::Value> V8DeviceMotionEvent:: zAccelerationAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)146 v8::Handle<v8::Value> V8DeviceMotionEvent::rotationRateAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) 61 147 { 62 INC_STATS("DOM.DeviceMotionEvent. zAcceleration._get");148 INC_STATS("DOM.DeviceMotionEvent.rotationRate._get"); 63 149 v8::Handle<v8::Object> holder = info.Holder(); 64 150 DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder); 65 if (!imp->deviceMotionData()-> canProvideZAcceleration())151 if (!imp->deviceMotionData()->rotationRate()) 66 152 return v8::Null(); 67 return v8::Number::New(imp->deviceMotionData()->zAcceleration());153 return createRotationRateObject(imp->deviceMotionData()->rotationRate()); 68 154 } 69 70 v8::Handle<v8::Value> V8DeviceMotionEvent::xRotationRateAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)71 {72 INC_STATS("DOM.DeviceMotionEvent.xRotationRate._get");73 v8::Handle<v8::Object> holder = info.Holder();74 DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder);75 if (!imp->deviceMotionData()->canProvideXRotationRate())76 return v8::Null();77 return v8::Number::New(imp->deviceMotionData()->xRotationRate());78 }79 80 v8::Handle<v8::Value> V8DeviceMotionEvent::yRotationRateAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)81 {82 INC_STATS("DOM.DeviceMotionEvent.yRotationRate._get");83 v8::Handle<v8::Object> holder = info.Holder();84 DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder);85 if (!imp->deviceMotionData()->canProvideYRotationRate())86 return v8::Null();87 return v8::Number::New(imp->deviceMotionData()->yRotationRate());88 }89 90 v8::Handle<v8::Value> V8DeviceMotionEvent::zRotationRateAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)91 {92 INC_STATS("DOM.DeviceMotionEvent.zRotationRate._get");93 v8::Handle<v8::Object> holder = info.Holder();94 DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder);95 if (!imp->deviceMotionData()->canProvideZRotationRate())96 return v8::Null();97 return v8::Number::New(imp->deviceMotionData()->zRotationRate());98 }99 100 155 101 156 v8::Handle<v8::Value> V8DeviceMotionEvent::intervalAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) … … 115 170 bool bubbles = args[1]->BooleanValue(); 116 171 bool cancelable = args[2]->BooleanValue(); 117 // If any of the parameters are null or undefined, mark them as not provided. 118 // Otherwise, use the standard JavaScript conversion. 119 bool xAccelerationProvided = !isUndefinedOrNull(args[3]); 120 double xAcceleration = static_cast<double>(args[3]->NumberValue()); 121 bool yAccelerationProvided = !isUndefinedOrNull(args[4]); 122 double yAcceleration = static_cast<double>(args[4]->NumberValue()); 123 bool zAccelerationProvided = !isUndefinedOrNull(args[5]); 124 double zAcceleration = static_cast<double>(args[5]->NumberValue()); 125 bool xRotationRateProvided = !isUndefinedOrNull(args[6]); 126 double xRotationRate = static_cast<double>(args[6]->NumberValue()); 127 bool yRotationRateProvided = !isUndefinedOrNull(args[7]); 128 double yRotationRate = static_cast<double>(args[7]->NumberValue()); 129 bool zRotationRateProvided = !isUndefinedOrNull(args[8]); 130 double zRotationRate = static_cast<double>(args[8]->NumberValue()); 131 bool intervalProvided = !isUndefinedOrNull(args[9]); 132 double interval = static_cast<double>(args[9]->NumberValue()); 133 RefPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::create(xAccelerationProvided, xAcceleration, yAccelerationProvided, yAcceleration, zAccelerationProvided, zAcceleration, xRotationRateProvided, xRotationRate, yRotationRateProvided, yRotationRate, zRotationRateProvided, zRotationRate, intervalProvided, interval); 172 RefPtr<DeviceMotionData::Acceleration> acceleration = readAccelerationArgument(args[3]); 173 RefPtr<DeviceMotionData::Acceleration> accelerationIncludingGravity = readAccelerationArgument(args[4]); 174 RefPtr<DeviceMotionData::RotationRate> rotationRate = readRotationRateArgument(args[5]); 175 bool intervalProvided = !isUndefinedOrNull(args[6]); 176 double interval = static_cast<double>(args[6]->NumberValue()); 177 RefPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, intervalProvided, interval); 134 178 imp->initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData.get()); 135 179 return v8::Handle<v8::Value>(); -
trunk/WebCore/dom/DeviceMotionData.cpp
r68241 r68252 29 29 namespace WebCore { 30 30 31 PassRefPtr<DeviceMotionData::Acceleration> DeviceMotionData::Acceleration::create(bool canProvideX, double x, 32 bool canProvideY, double y, 33 bool canProvideZ, double z) 34 { 35 return adoptRef(new DeviceMotionData::Acceleration(canProvideX, x, canProvideY, y, canProvideZ, z)); 36 } 37 38 DeviceMotionData::Acceleration::Acceleration(bool canProvideX, double x, bool canProvideY, double y, bool canProvideZ, double z) 39 : m_x(x) 40 , m_y(y) 41 , m_z(z) 42 , m_canProvideX(canProvideX) 43 , m_canProvideY(canProvideY) 44 , m_canProvideZ(canProvideZ) 45 46 { 47 } 48 49 PassRefPtr<DeviceMotionData::RotationRate> DeviceMotionData::RotationRate::create(bool canProvideAlpha, double alpha, 50 bool canProvideBeta, double beta, 51 bool canProvideGamma, double gamma) 52 { 53 return adoptRef(new DeviceMotionData::RotationRate(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma)); 54 } 55 56 DeviceMotionData::RotationRate::RotationRate(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma) 57 : m_alpha(alpha) 58 , m_beta(beta) 59 , m_gamma(gamma) 60 , m_canProvideAlpha(canProvideAlpha) 61 , m_canProvideBeta(canProvideBeta) 62 , m_canProvideGamma(canProvideGamma) 63 { 64 } 65 31 66 PassRefPtr<DeviceMotionData> DeviceMotionData::create() 32 67 { … … 34 69 } 35 70 36 PassRefPtr<DeviceMotionData> DeviceMotionData::create(bool canProvideXAcceleration, double xAcceleration, 37 bool canProvideYAcceleration, double yAcceleration, 38 bool canProvideZAcceleration, double zAcceleration, 39 bool canProvideXRotationRate, double xRotationRate, 40 bool canProvideYRotationRate, double yRotationRate, 41 bool canProvideZRotationRate, double zRotationRate, 42 bool canProvideInterval, double interval) 71 PassRefPtr<DeviceMotionData> DeviceMotionData::create(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity, 72 PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval) 43 73 { 44 return adoptRef(new DeviceMotionData(canProvideXAcceleration, xAcceleration, 45 canProvideYAcceleration, yAcceleration, 46 canProvideZAcceleration, zAcceleration, 47 canProvideXRotationRate, xRotationRate, 48 canProvideYRotationRate, yRotationRate, 49 canProvideZRotationRate, zRotationRate, 50 canProvideInterval, interval)); 74 return adoptRef(new DeviceMotionData(acceleration, accelerationIncludingGravity, rotationRate, canProvideInterval, interval)); 51 75 } 52 76 53 77 DeviceMotionData::DeviceMotionData() 54 : m_canProvideXAcceleration(false) 55 , m_canProvideYAcceleration(false) 56 , m_canProvideZAcceleration(false) 57 , m_canProvideXRotationRate(false) 58 , m_canProvideYRotationRate(false) 59 , m_canProvideZRotationRate(false) 60 , m_canProvideInterval(false) 78 : m_canProvideInterval(false) 61 79 { 62 80 } 63 81 64 DeviceMotionData::DeviceMotionData(bool canProvideXAcceleration, double xAcceleration, 65 bool canProvideYAcceleration, double yAcceleration, 66 bool canProvideZAcceleration, double zAcceleration, 67 bool canProvideXRotationRate, double xRotationRate, 68 bool canProvideYRotationRate, double yRotationRate, 69 bool canProvideZRotationRate, double zRotationRate, 70 bool canProvideInterval, double interval) 71 : m_canProvideXAcceleration(canProvideXAcceleration) 72 , m_canProvideYAcceleration(canProvideYAcceleration) 73 , m_canProvideZAcceleration(canProvideZAcceleration) 74 , m_canProvideXRotationRate(canProvideXRotationRate) 75 , m_canProvideYRotationRate(canProvideYRotationRate) 76 , m_canProvideZRotationRate(canProvideZRotationRate) 82 DeviceMotionData::DeviceMotionData(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity, 83 PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval) 84 : m_acceleration(acceleration) 85 , m_accelerationIncludingGravity(accelerationIncludingGravity) 86 , m_rotationRate(rotationRate) 77 87 , m_canProvideInterval(canProvideInterval) 78 , m_xAcceleration(xAcceleration)79 , m_yAcceleration(yAcceleration)80 , m_zAcceleration(zAcceleration)81 , m_xRotationRate(xRotationRate)82 , m_yRotationRate(yRotationRate)83 , m_zRotationRate(zRotationRate)84 88 , m_interval(interval) 85 89 { -
trunk/WebCore/dom/DeviceMotionData.h
r68241 r68252 29 29 #include <wtf/PassRefPtr.h> 30 30 #include <wtf/RefCounted.h> 31 #include <wtf/RefPtr.h> 31 32 32 33 namespace WebCore { … … 34 35 class DeviceMotionData : public RefCounted<DeviceMotionData> { 35 36 public: 37 class Acceleration : public RefCounted<DeviceMotionData::Acceleration> { 38 public: 39 static PassRefPtr<Acceleration> create(bool canProvideX, double x, bool canProvideY, double y, bool canProvideZ, double z); 40 41 bool canProvideX() const { return m_canProvideX; } 42 bool canProvideY() const { return m_canProvideY; } 43 bool canProvideZ() const { return m_canProvideZ; } 44 45 double x() const { return m_x; } 46 double y() const { return m_y; } 47 double z() const { return m_z; } 48 49 private: 50 Acceleration(bool canProvideX, double x, bool canProvideY, double y, bool canProvideZ, double z); 51 52 double m_x; 53 double m_y; 54 double m_z; 55 56 bool m_canProvideX; 57 bool m_canProvideY; 58 bool m_canProvideZ; 59 }; 60 61 class RotationRate : public RefCounted<DeviceMotionData::RotationRate> { 62 public: 63 static PassRefPtr<RotationRate> create(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma); 64 65 bool canProvideAlpha() const { return m_canProvideAlpha; } 66 bool canProvideBeta() const { return m_canProvideBeta; } 67 bool canProvideGamma() const { return m_canProvideGamma; } 68 69 double alpha() const { return m_alpha; } 70 double beta() const { return m_beta; } 71 double gamma() const { return m_gamma; } 72 73 private: 74 RotationRate(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma); 75 76 double m_alpha; 77 double m_beta; 78 double m_gamma; 79 80 bool m_canProvideAlpha; 81 bool m_canProvideBeta; 82 bool m_canProvideGamma; 83 }; 84 36 85 static PassRefPtr<DeviceMotionData> create(); 37 static PassRefPtr<DeviceMotionData> create(bool canProvideXAcceleration, double xAcceleration, 38 bool canProvideYAcceleration, double yAcceleration, 39 bool canProvideZAcceleration, double zAcceleration, 40 bool canProvideXRotationRate, double xRotationRate, 41 bool canProvideYRotationRate, double yRotationRate, 42 bool canProvideZRotationRate, double zRotationRate, 43 bool canProvideInterval, double interval); 86 static PassRefPtr<DeviceMotionData> create(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity, 87 PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval); 44 88 45 double xAcceleration() const { return m_xAcceleration; } 46 double yAcceleration() const { return m_yAcceleration; } 47 double zAcceleration() const { return m_zAcceleration; } 48 double xRotationRate() const { return m_xRotationRate; } 49 double yRotationRate() const { return m_yRotationRate; } 50 double zRotationRate() const { return m_zRotationRate; } 89 const Acceleration* acceleration() const { return m_acceleration.get(); } 90 const Acceleration* accelerationIncludingGravity() const { return m_accelerationIncludingGravity.get(); } 91 const RotationRate* rotationRate() const { return m_rotationRate.get(); } 51 92 double interval() const { return m_interval; } 52 53 bool canProvideXAcceleration() const { return m_canProvideXAcceleration; }54 bool canProvideYAcceleration() const { return m_canProvideYAcceleration; }55 bool canProvideZAcceleration() const { return m_canProvideZAcceleration; }56 bool canProvideXRotationRate() const { return m_canProvideXRotationRate; }57 bool canProvideYRotationRate() const { return m_canProvideYRotationRate; }58 bool canProvideZRotationRate() const { return m_canProvideZRotationRate; }59 93 bool canProvideInterval() const { return m_canProvideInterval; } 60 94 61 95 private: 62 96 DeviceMotionData(); 63 DeviceMotionData(bool canProvideXAcceleration, double xAcceleration, 64 bool canProvideYAcceleration, double yAcceleration, 65 bool canProvideZAcceleration, double zAcceleration, 66 bool canProvideXRotationRate, double xRotationRate, 67 bool canProvideYRotationRate, double yRotationRate, 68 bool canProvideZRotationRate, double zRotationRate, 69 bool canProvideInterval, double interval); 97 DeviceMotionData(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity, 98 PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval); 70 99 71 bool m_canProvideXAcceleration; 72 bool m_canProvideYAcceleration; 73 bool m_canProvideZAcceleration; 74 bool m_canProvideXRotationRate; 75 bool m_canProvideYRotationRate; 76 bool m_canProvideZRotationRate; 100 RefPtr<Acceleration> m_acceleration; 101 RefPtr<Acceleration> m_accelerationIncludingGravity; 102 RefPtr<RotationRate> m_rotationRate; 77 103 bool m_canProvideInterval; 78 79 double m_xAcceleration;80 double m_yAcceleration;81 double m_zAcceleration;82 double m_xRotationRate;83 double m_yRotationRate;84 double m_zRotationRate;85 104 double m_interval; 86 105 }; -
trunk/WebCore/dom/DeviceMotionEvent.idl
r68241 r68252 29 29 Conditional=DEVICE_ORIENTATION 30 30 ] DeviceMotionEvent : Event { 31 readonly attribute [Custom] double xAcceleration; 32 readonly attribute [Custom] double yAcceleration; 33 readonly attribute [Custom] double zAcceleration; 34 readonly attribute [Custom] double xRotationRate; 35 readonly attribute [Custom] double yRotationRate; 36 readonly attribute [Custom] double zRotationRate; 31 readonly attribute [Custom] Acceleration acceleration; 32 readonly attribute [Custom] Acceleration accelerationIncludingGravity; 33 readonly attribute [Custom] RotationRate rotationRate; 37 34 readonly attribute [Custom] double interval; 38 [Custom] void initDeviceMotionEvent(in DOMString type, in boolean bubbles, in boolean cancelable, in double xAcceleration, in double yAcceleration, in double zAcceleration, in double xRotationRate, in double yRotationRate, in double zRotationRate, in double interval);35 [Custom] void initDeviceMotionEvent(in DOMString type, in boolean bubbles, in boolean cancelable, in Acceleration acceleration, in Acceleration accelerationIncludingGravity, in RotationRate rotationRate, in double interval); 39 36 }; 40 37
Note:
See TracChangeset
for help on using the changeset viewer.