Open Bug 1049788 Opened 10 years ago Updated 2 years ago

Support [Pref] on a mixin to mean "[Pref] on all the members of this mixin"

Categories

(Core :: DOM: Bindings (WebIDL), enhancement, P5)

enhancement

Tracking

()

REOPENED

People

(Reporter: keeler, Unassigned)

References

Details

See bug 1036546. What we would like to have done is this:

(in dom/webidl/Crypto.webidl)

#ifndef MOZ_DISABLE_CRYPTOLEGACY
[NoInterfaceObject,Pref="dom.unsafe_legacy_crypto.enabled"]
interface CryptoLegacy {
  readonly attribute DOMString version;

  attribute boolean enableSmartCardEvents;
...
};

Crypto implements CryptoLegacy;
#endif // !MOZ_DISABLE_CRYPTOLEGACY

That didn't seem to work (when the pref was false, the attributes/functions were still present on window.crypto). Instead, this worked:

#ifndef MOZ_DISABLE_CRYPTOLEGACY
[NoInterfaceObject]
interface CryptoLegacy {
  [Pref="dom.unsafe_legacy_crypto.enabled"
  readonly attribute DOMString version;

  [Pref="dom.unsafe_legacy_crypto.enabled"
  attribute boolean enableSmartCardEvents;
...
};

Crypto implements CryptoLegacy;
#endif // !MOZ_DISABLE_CRYPTOLEGACY

i.e. the pref had to be put on every attribute/function in CryptoLegacy, which is unfortunate.
> [NoInterfaceObject,Pref="dom.unsafe_legacy_crypto.enabled"]

That's pretty much nonsensical.  The Pref annotation on an interface controls visibility of the interface object in global scope (and this is clearly documented, last I checked), but in this case you're saying there is no interface object at all.  Arguably, we should fail codegen on this construct.

If you want to control the visibility of properties with a pref, you need to set [Pref] on those properties.
Ah, bug 921453 covers the codegen issue.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
And in particular, there are cases in which we want to hide the interface object but still have the interface properties available (e.g. Console), so we don't want to just blindly propagate conditions from the interface to properties.
It is very suboptimal if one needs to Pref all the properties on an [NoInterface] interface.
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
Another solution could be to support Pref with 'implements'.
Summary: setting a pref to enable/disable a webidl interface doesn't appear to work as expected → setting a pref to enable/disable a webidl [NoInterface] interface doesn't appear to work as expected
> Another solution could be to support Pref with 'implements'.

You can "implements" things that have interface objects, so it doesn't work to do that.

If we had explicit mixin syntax, then it would make sense to have [Pref] on a mixin propagate to all its members, just like [Exposed] behaves on a partial interface.  But we don't have that yet (though it's been suggested).

We _could_ have [Pref] on a partial interface propagate to members now, of course.
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046

Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5
Depends on: 1414372
Component: DOM → DOM: Core & HTML
Component: DOM: Core & HTML → DOM: Bindings (WebIDL)
Summary: setting a pref to enable/disable a webidl [NoInterface] interface doesn't appear to work as expected → Support [Pref] on a mixin to mean "[Pref] on all the members of this mixin"
Type: defect → enhancement
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.