Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix our WebIDL for Safari #909

Merged
merged 1 commit into from
Oct 1, 2018
Merged

Conversation

alexcrichton
Copy link
Contributor

This commit employs the strategy described in #908 to apply a
non-breaking change to fix WebIDL to be compatible with all browsers,
including Safari.

The problem here is that BaseAudioContext and AudioScheduledSourceNode
are not types in Safari, but they are types in Firefox/Chrome. The fix
here was to move the contents of these two interfaces into mixins, and
then include the mixins in all classes which inherit from these two
classes. That should have the same effect as defining the methods
inherently on the original interface.

Additionally a special [RustDeprecated] attribute to WebIDL was added
to signify interfaces this has happened to. Currently it's directly
tailored towards this case of "this intermediate class doesn't exist in
all browsers", but we may want to refine and extend the deprecation
message over time.

Although it's possible we could do this as a breaking change to
web-sys I'm hoping that we can do this as a non-breaking change for
now and then eventually on the next breaking release batch all these
changes together, deleting the intermediate classes. This is also
hopefully a good trial run for how stable web-sys can be when it's
actually stable!

cc #897
cc #908

[Throws]
void start(optional double when = 0, optional double grainOffset = 0,
optional double grainDuration);

[Throws]
void stop (optional double when = 0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this class didn't switch to AudioBufferSourceNode includes rustAudioScheduledSourceNode; because the mixin's start method conflicts with the start method in this class, so it was just easier to inline the few properties here.

@@ -32,7 +32,12 @@ interface AudioBufferSourceNode : AudioScheduledSourceNode {
attribute double loopStart;
attribute double loopEnd;

attribute EventHandler onended;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the indentation of this line is wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh it is indeed wrong!

(a copy/paste error)

probably stop using this class and instead \
use the class that inherits from this, which \
should include all the same methods and work \
in all browsers in theory!");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we could tailor the deprecation message for the particular interfaces. Something like:

// BaseAudioContext.webidl

[Deprecated="reason why this is deprecated detailed here..."]
interface BaseAudioContext {
  // ...
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure yeah, I can upate this

@@ -16,8 +16,6 @@ features = [
'AudioDestinationNode',
'AudioNode',
'AudioParam',
'AudioScheduledSourceNode',
'BaseAudioContext',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't removing features a breaking change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh these aren't removed from web-sys itself, just here because the features are no longer needed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh I totally misread what file this was

let fm_osc;
let gain;
let fm_gain;
pub fn new() -> Result<FmOsc, JsValue> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

This commit employs the strategy described in rustwasm#908 to apply a
non-breaking change to fix WebIDL to be compatible with all browsers,
including Safari.

The problem here is that `BaseAudioContext` and `AudioScheduledSourceNode`
are not types in Safari, but they are types in Firefox/Chrome. The fix
here was to move the contents of these two interfaces into mixins, and
then include the mixins in all classes which inherit from these two
classes. That should have the same effect as defining the methods
inherently on the original interface.

Additionally a special `[RustDeprecated]` attribute to WebIDL was added
to signify interfaces this has happened to. Currently it's directly
tailored towards this case of "this intermediate class doesn't exist in
all browsers", but we may want to refine and extend the deprecation
message over time.

Although it's possible we could do this as a breaking change to
`web-sys` I'm hoping that we can do this as a non-breaking change for
now and then eventually on the next breaking release batch all these
changes together, deleting the intermediate classes. This is also
hopefully a good trial run for how stable web-sys can be when it's
actually stable!

cc rustwasm#897
cc rustwasm#908
@alexcrichton
Copy link
Contributor Author

Updated!

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@alexcrichton alexcrichton merged commit 3001d1e into rustwasm:master Oct 1, 2018
@alexcrichton alexcrichton deleted the fix-webidl branch October 1, 2018 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants