Auto merge of #23711 - saschanaz:frompoint, r=Manishearth

Implement DOMPoint.fromPoint

<!-- Please describe your changes on the following line: -->

Implements DOMPoint.fromPoint and fixes codegen to use default value when an optional dictionary member got `undefined`.

PS: The codegen change is about:

```webidl
dictionary MyDictionary {
  optional short myMember = 0;
  short anotherMember;
}

[Exposed=Window, Constructor]
interface MyInterface {
  void myMethod(optional MyDictionary myDict);
};
```

```js
// The following two must behave same
new MyInterface().myMethod({ myMember: undefined, anotherMember = 0 });
new MyInterface().myMethod({ anotherMember = 0 });
```

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #23710

<!-- Either: -->
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23711)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-07-05 15:01:31 -04:00 committed by GitHub
commit aa752e4d45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 30 additions and 133 deletions

View file

@ -6414,7 +6414,8 @@ class CGDictionary(CGThing):
conversion = ( conversion = (
"{\n" "{\n"
" rooted!(in(cx) let mut rval = UndefinedValue());\n" " rooted!(in(cx) let mut rval = UndefinedValue());\n"
" if r#try!(get_dictionary_property(cx, object.handle(), \"%s\", rval.handle_mut())) {\n" " if r#try!(get_dictionary_property(cx, object.handle(), \"%s\", rval.handle_mut()))"
" && !rval.is_undefined() {\n"
"%s\n" "%s\n"
" } else {\n" " } else {\n"
"%s\n" "%s\n"

View file

@ -40,6 +40,11 @@ impl DOMPoint {
Ok(DOMPoint::new(global, x, y, z, w)) Ok(DOMPoint::new(global, x, y, z, w))
} }
// https://drafts.fxtf.org/geometry/#dom-dompoint-frompoint
pub fn FromPoint(global: &GlobalScope, init: &DOMPointInit) -> DomRoot<Self> {
Self::new_from_init(global, init)
}
pub fn new_from_init(global: &GlobalScope, p: &DOMPointInit) -> DomRoot<DOMPoint> { pub fn new_from_init(global: &GlobalScope, p: &DOMPointInit) -> DomRoot<DOMPoint> {
DOMPoint::new(global, p.x, p.y, p.z, p.w) DOMPoint::new(global, p.x, p.y, p.z, p.w)
} }

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
use crate::dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::{ use crate::dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::{
DOMPointReadOnlyMethods, Wrap, DOMPointReadOnlyMethods, Wrap,
}; };
@ -50,6 +51,11 @@ impl DOMPointReadOnly {
) -> Fallible<DomRoot<DOMPointReadOnly>> { ) -> Fallible<DomRoot<DOMPointReadOnly>> {
Ok(DOMPointReadOnly::new(global, x, y, z, w)) Ok(DOMPointReadOnly::new(global, x, y, z, w))
} }
// https://drafts.fxtf.org/geometry/#dom-dompointreadonly-frompoint
pub fn FromPoint(global: &GlobalScope, init: &DOMPointInit) -> DomRoot<Self> {
Self::new(global, init.x, init.y, init.z, init.w)
}
} }
impl DOMPointReadOnlyMethods for DOMPointReadOnly { impl DOMPointReadOnlyMethods for DOMPointReadOnly {

View file

@ -14,6 +14,8 @@
optional unrestricted double z = 0, optional unrestricted double w = 1), optional unrestricted double z = 0, optional unrestricted double w = 1),
Exposed=(Window,Worker)] Exposed=(Window,Worker)]
interface DOMPoint : DOMPointReadOnly { interface DOMPoint : DOMPointReadOnly {
[NewObject] static DOMPoint fromPoint(optional DOMPointInit other = null);
inherit attribute unrestricted double x; inherit attribute unrestricted double x;
inherit attribute unrestricted double y; inherit attribute unrestricted double y;
inherit attribute unrestricted double z; inherit attribute unrestricted double z;

View file

@ -14,6 +14,8 @@
optional unrestricted double z = 0, optional unrestricted double w = 1), optional unrestricted double z = 0, optional unrestricted double w = 1),
Exposed=(Window,Worker)] Exposed=(Window,Worker)]
interface DOMPointReadOnly { interface DOMPointReadOnly {
[NewObject] static DOMPointReadOnly fromPoint(optional DOMPointInit other = null);
readonly attribute unrestricted double x; readonly attribute unrestricted double x;
readonly attribute unrestricted double y; readonly attribute unrestricted double y;
readonly attribute unrestricted double z; readonly attribute unrestricted double z;

View file

@ -677585,7 +677585,7 @@
"testharness" "testharness"
], ],
"webaudio/the-audio-api/the-audioparam-interface/automation-rate-testing.js": [ "webaudio/the-audio-api/the-audioparam-interface/automation-rate-testing.js": [
"73892dd845887d731779b3794a14df3f6bd36cba", "43279f91d68d3c5e2d7a086c739c838b31dc7335",
"support" "support"
], ],
"webaudio/the-audio-api/the-audioparam-interface/automation-rate.html": [ "webaudio/the-audio-api/the-audioparam-interface/automation-rate.html": [
@ -677617,7 +677617,7 @@
"testharness" "testharness"
], ],
"webaudio/the-audio-api/the-audioparam-interface/k-rate-oscillator.html": [ "webaudio/the-audio-api/the-audioparam-interface/k-rate-oscillator.html": [
"1672f0d975f2b2e2fd0c127663b403745b669265", "6803f55eab00bbfb9766cc044a7240e6b4a0fda0",
"testharness" "testharness"
], ],
"webaudio/the-audio-api/the-audioparam-interface/k-rate-panner.html": [ "webaudio/the-audio-api/the-audioparam-interface/k-rate-panner.html": [

View file

@ -1,7 +0,0 @@
[transitionevent-interface.html]
[elapsedTime set to undefined]
expected: FAIL
[propertyName set to undefined]
expected: FAIL

View file

@ -1,10 +1,4 @@
[DOMMatrixInit-validate-fixup.html] [DOMMatrixInit-validate-fixup.html]
[{is2D: undefined} (2d)]
expected: FAIL
[{b: 0, m12: undefined} (2d)]
expected: FAIL
[{f: NaN, m42: NaN} (2d)] [{f: NaN, m42: NaN} (2d)]
expected: FAIL expected: FAIL

View file

@ -1,26 +0,0 @@
[DOMPoint-001.html]
type: testharness
[testConstructorDictionary2undefined]
expected: FAIL
[testConstructorDictionary3]
expected: FAIL
[testConstructorDictionary4]
expected: FAIL
[testConstructorDictionary5]
expected: FAIL
[testConstructorDictionary2irregular]
expected: FAIL
[testConstructorDOMPoint]
expected: FAIL
[testConstructorIllegal1]
expected: FAIL
[testConstructorIllegal2]
expected: FAIL

View file

@ -1,55 +1,7 @@
[DOMPoint-002.html] [DOMPoint-002.html]
[test DOMPoint fromPoint with empty object]
expected: FAIL
[test DOMPoint fromPoint with x]
expected: FAIL
[test DOMPoint fromPoint with x, y]
expected: FAIL
[test DOMPoint fromPoint with x, y, z]
expected: FAIL
[test DOMPoint fromPoint with x, y, z, w]
expected: FAIL
[test DOMPoint fromPoint with x, y, z, w, v]
expected: FAIL
[test DOMPoint fromPoint with x, z]
expected: FAIL
[test DOMPoint fromPoint with undefined value]
expected: FAIL
[test DOMPoint matrixTransform] [test DOMPoint matrixTransform]
expected: FAIL expected: FAIL
[test DOMPointReadOnly fromPoint with empty object]
expected: FAIL
[test DOMPointReadOnly fromPoint with x]
expected: FAIL
[test DOMPointReadOnly fromPoint with x, y]
expected: FAIL
[test DOMPointReadOnly fromPoint with x, y, z]
expected: FAIL
[test DOMPointReadOnly fromPoint with x, y, z, w]
expected: FAIL
[test DOMPointReadOnly fromPoint with x, y, z, w, v]
expected: FAIL
[test DOMPointReadOnly fromPoint with x, z]
expected: FAIL
[test DOMPointReadOnly fromPoint with undefined value]
expected: FAIL
[test DOMPointReadOnly matrixTransform] [test DOMPointReadOnly matrixTransform]
expected: FAIL expected: FAIL

View file

@ -213,15 +213,9 @@
[PseudoElement interface object name] [PseudoElement interface object name]
expected: FAIL expected: FAIL
[DOMPointReadOnly interface: operation fromPoint(DOMPointInit)]
expected: FAIL
[DOMPointReadOnly interface: operation matrixTransform(DOMMatrixInit)] [DOMPointReadOnly interface: operation matrixTransform(DOMMatrixInit)]
expected: FAIL expected: FAIL
[DOMPointReadOnly interface: calling fromPoint(DOMPointInit) on new DOMPointReadOnly() with too few arguments must throw TypeError]
expected: FAIL
[DOMPointReadOnly interface: new DOMPointReadOnly() must inherit property "matrixTransform(DOMMatrixInit)" with the proper type] [DOMPointReadOnly interface: new DOMPointReadOnly() must inherit property "matrixTransform(DOMMatrixInit)" with the proper type]
expected: FAIL expected: FAIL
@ -231,15 +225,6 @@
[DOMPoint interface: legacy window alias] [DOMPoint interface: legacy window alias]
expected: FAIL expected: FAIL
[DOMPoint interface: operation fromPoint(DOMPointInit)]
expected: FAIL
[DOMPoint interface: calling fromPoint(DOMPointInit) on new DOMPoint() with too few arguments must throw TypeError]
expected: FAIL
[DOMPointReadOnly interface: calling fromPoint(DOMPointInit) on new DOMPoint() with too few arguments must throw TypeError]
expected: FAIL
[DOMPointReadOnly interface: new DOMPoint() must inherit property "matrixTransform(DOMMatrixInit)" with the proper type] [DOMPointReadOnly interface: new DOMPoint() must inherit property "matrixTransform(DOMMatrixInit)" with the proper type]
expected: FAIL expected: FAIL

View file

@ -1,28 +1,13 @@
[interfaces.worker.html] [interfaces.worker.html]
[DOMPointReadOnly interface: operation fromPoint(DOMPointInit)]
expected: FAIL
[DOMPointReadOnly interface: operation matrixTransform(DOMMatrixInit)] [DOMPointReadOnly interface: operation matrixTransform(DOMMatrixInit)]
expected: FAIL expected: FAIL
[DOMPointReadOnly interface: calling fromPoint(DOMPointInit) on new DOMPointReadOnly() with too few arguments must throw TypeError]
expected: FAIL
[DOMPointReadOnly interface: new DOMPointReadOnly() must inherit property "matrixTransform(DOMMatrixInit)" with the proper type] [DOMPointReadOnly interface: new DOMPointReadOnly() must inherit property "matrixTransform(DOMMatrixInit)" with the proper type]
expected: FAIL expected: FAIL
[DOMPointReadOnly interface: calling matrixTransform(DOMMatrixInit) on new DOMPointReadOnly() with too few arguments must throw TypeError] [DOMPointReadOnly interface: calling matrixTransform(DOMMatrixInit) on new DOMPointReadOnly() with too few arguments must throw TypeError]
expected: FAIL expected: FAIL
[DOMPoint interface: operation fromPoint(DOMPointInit)]
expected: FAIL
[DOMPoint interface: calling fromPoint(DOMPointInit) on new DOMPoint() with too few arguments must throw TypeError]
expected: FAIL
[DOMPointReadOnly interface: calling fromPoint(DOMPointInit) on new DOMPoint() with too few arguments must throw TypeError]
expected: FAIL
[DOMPointReadOnly interface: new DOMPoint() must inherit property "matrixTransform(DOMMatrixInit)" with the proper type] [DOMPointReadOnly interface: new DOMPoint() must inherit property "matrixTransform(DOMMatrixInit)" with the proper type]
expected: FAIL expected: FAIL

View file

@ -1,2 +0,0 @@
[k-rate-biquad.html]
expected: ERROR

View file

@ -1,2 +0,0 @@
[k-rate-gain.html]
expected: ERROR

View file

@ -1,2 +1,10 @@
[k-rate-oscillator.html] [k-rate-oscillator.html]
expected: ERROR [X k-rate detune: Difference between a-rate and k-rate outputs should have contain at least one value different from 0.]
expected: FAIL
[< [Oscillator k-rate detune\] 1 out of 1 assertions were failed.]
expected: FAIL
[# AUDIT TASK RUNNER FINISHED: 1 out of 2 tasks were failed.]
expected: FAIL

View file

@ -1,2 +0,0 @@
[k-rate-stereo-panner.html]
expected: ERROR

View file

@ -1,4 +0,0 @@
[event_constructor.html]
[constructor with undefined type argument and members]
expected: FAIL

View file

@ -45,7 +45,7 @@
// The promise from |startRendering| is returned. // The promise from |startRendering| is returned.
function doTest(context, should, options) { function doTest(context, should, options) {
let merger = new ChannelMergerNode( let merger = new ChannelMergerNode(
context, {numberOfInputs: context.destination.numberOfChannels}); context, {numberOfInputs: context.destination.channelCount});
merger.connect(context.destination); merger.connect(context.destination);
let src = null; let src = null;

View file

@ -32,7 +32,7 @@
}); });
let merger = new ChannelMergerNode( let merger = new ChannelMergerNode(
context, {numberOfInputs: context.numberOfChannels}); context, {numberOfInputs: context.destination.channelCount});
merger.connect(context.destination); merger.connect(context.destination);
let inverter = new GainNode(context, {gain: -1}); let inverter = new GainNode(context, {gain: -1});
inverter.connect(merger, 0, 2); inverter.connect(merger, 0, 2);