Skip to content

Commit

Permalink
Use interface mixins
Browse files Browse the repository at this point in the history
Fixes #2596.
  • Loading branch information
TimothyGu authored and domenic committed May 27, 2019
1 parent c1b4591 commit 8533b57
Show file tree
Hide file tree
Showing 24 changed files with 92 additions and 91 deletions.
47 changes: 24 additions & 23 deletions lib/jsdom/living/navigator/Navigator.webidl
@@ -1,17 +1,18 @@
// https://html.spec.whatwg.org/#navigator
[Exposed=Window]
interface Navigator {
// objects implementing this interface also implement the interfaces given below
};
Navigator implements NavigatorID;
Navigator implements NavigatorLanguage;
Navigator implements NavigatorOnLine;
// Navigator implements NavigatorContentUtils;
Navigator implements NavigatorCookies;
Navigator implements NavigatorPlugins;
Navigator implements NavigatorConcurrentHardware;
Navigator includes NavigatorID;
Navigator includes NavigatorLanguage;
Navigator includes NavigatorOnLine;
// Navigator includes NavigatorContentUtils;
Navigator includes NavigatorCookies;
Navigator includes NavigatorPlugins;
Navigator includes NavigatorConcurrentHardware;

[NoInterfaceObject, Exposed=(Window,Worker)]
interface NavigatorID {
// https://html.spec.whatwg.org/#navigatorid
interface mixin NavigatorID {
readonly attribute DOMString appCodeName; // constant "Mozilla"
readonly attribute DOMString appName; // constant "Netscape"
readonly attribute DOMString appVersion;
Expand All @@ -21,35 +22,32 @@ interface NavigatorID {
readonly attribute DOMString userAgent;
[Exposed=Window] readonly attribute DOMString vendor;
[Exposed=Window] readonly attribute DOMString vendorSub; // constant ""

// also has additional members in a partial interface
};

[NoInterfaceObject, Exposed=(Window,Worker)]
interface NavigatorLanguage {
// https://html.spec.whatwg.org/#navigatorlanguage
interface mixin NavigatorLanguage {
readonly attribute DOMString language;
readonly attribute FrozenArray<DOMString> languages;
};

[NoInterfaceObject, Exposed=(Window,Worker)]
interface NavigatorOnLine {
// https://html.spec.whatwg.org/#navigatoronline
interface mixin NavigatorOnLine {
readonly attribute boolean onLine;
};

[Exposed=Window,
NoInterfaceObject]
interface NavigatorCookies {
// https://html.spec.whatwg.org/#navigatorcookies
interface mixin NavigatorCookies {
readonly attribute boolean cookieEnabled;
};

[Exposed=Window,
NoInterfaceObject]
interface NavigatorPlugins {
// https://html.spec.whatwg.org/#navigatorplugins
interface mixin NavigatorPlugins {
[SameObject] readonly attribute PluginArray plugins;
[SameObject] readonly attribute MimeTypeArray mimeTypes;
boolean javaEnabled();
};

// https://html.spec.whatwg.org/#pluginarray
[Exposed=Window,
LegacyUnenumerableNamedProperties]
interface PluginArray {
Expand All @@ -59,6 +57,7 @@ interface PluginArray {
[WebIDL2JSValueAsUnsupported=_null] getter Plugin? namedItem(DOMString name);
};

// https://html.spec.whatwg.org/#mimetypearray
[Exposed=Window,
LegacyUnenumerableNamedProperties]
interface MimeTypeArray {
Expand All @@ -67,6 +66,7 @@ interface MimeTypeArray {
[WebIDL2JSValueAsUnsupported=_null] getter MimeType? namedItem(DOMString name);
};

// https://html.spec.whatwg.org/#dom-plugin
[Exposed=Window,
LegacyUnenumerableNamedProperties]
interface Plugin {
Expand All @@ -78,6 +78,7 @@ interface Plugin {
[WebIDL2JSValueAsUnsupported=_null] getter MimeType? namedItem(DOMString name);
};

// https://html.spec.whatwg.org/#mimetype
[Exposed=Window]
interface MimeType {
readonly attribute DOMString type;
Expand All @@ -86,7 +87,7 @@ interface MimeType {
readonly attribute Plugin enabledPlugin;
};

[NoInterfaceObject, Exposed=(Window,Worker)]
interface NavigatorConcurrentHardware {
// https://html.spec.whatwg.org/#navigatorconcurrenthardware
interface mixin NavigatorConcurrentHardware {
readonly attribute unsigned long long hardwareConcurrency;
};
11 changes: 5 additions & 6 deletions lib/jsdom/living/nodes/ChildNode.webidl
@@ -1,11 +1,10 @@
[NoInterfaceObject,
Exposed=Window]
interface ChildNode {
// https://dom.spec.whatwg.org/#childnode
interface mixin ChildNode {
[CEReactions, Unscopable] void before((Node or DOMString)... nodes);
[CEReactions, Unscopable] void after((Node or DOMString)... nodes);
[CEReactions, Unscopable] void replaceWith((Node or DOMString)... nodes);
[CEReactions, Unscopable] void remove();
};
DocumentType implements ChildNode;
Element implements ChildNode;
CharacterData implements ChildNode;
DocumentType includes ChildNode;
Element includes ChildNode;
CharacterData includes ChildNode;
5 changes: 3 additions & 2 deletions lib/jsdom/living/nodes/Document.webidl
@@ -1,3 +1,4 @@
// https://dom.spec.whatwg.org/#document
[Constructor,
Exposed=Window]
interface Document : Node {
Expand Down Expand Up @@ -101,8 +102,8 @@ partial interface Document {
// special event handler IDL attributes that only apply to Document objects
[LenientThis] attribute EventHandler onreadystatechange;
};
Document implements GlobalEventHandlers;
// Document implements DocumentAndElementEventHandlers;
Document includes GlobalEventHandlers;
// Document includes DocumentAndElementEventHandlers;

// https://html.spec.whatwg.org/#Document-partial
partial interface Document {
Expand Down
3 changes: 1 addition & 2 deletions lib/jsdom/living/nodes/Element.webidl
@@ -1,3 +1,4 @@
// https://dom.spec.whatwg.org/#element
[Exposed=Window]
interface Element : Node {
readonly attribute DOMString? namespaceURI;
Expand Down Expand Up @@ -88,5 +89,3 @@ partial interface Element {
readonly attribute long clientWidth;
readonly attribute long clientHeight;
};

Element implements Slotable;
9 changes: 4 additions & 5 deletions lib/jsdom/living/nodes/ElementCSSInlineStyle.webidl
@@ -1,8 +1,7 @@
[Exposed=Window,
NoInterfaceObject]
interface ElementCSSInlineStyle {
// https://drafts.csswg.org/cssom/#elementcssinlinestyle
interface mixin ElementCSSInlineStyle {
[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
};

HTMLElement implements ElementCSSInlineStyle;
SVGElement implements ElementCSSInlineStyle;
HTMLElement includes ElementCSSInlineStyle;
SVGElement includes ElementCSSInlineStyle;
6 changes: 3 additions & 3 deletions lib/jsdom/living/nodes/ElementContentEditable.webidl
@@ -1,6 +1,6 @@
[Exposed=Window,
NoInterfaceObject]
interface ElementContentEditable {
interface mixin ElementContentEditable {
// [CEReactions] attribute DOMString contentEditable;
// [CEReactions] attribute DOMString enterKeyHint;
// readonly attribute boolean isContentEditable;
// [CEReactions] attribute DOMString inputMode;
};
5 changes: 2 additions & 3 deletions lib/jsdom/living/nodes/GlobalEventHandlers.webidl
@@ -1,6 +1,5 @@
[Exposed=Window,
NoInterfaceObject]
interface GlobalEventHandlers {
// https://html.spec.whatwg.org/#globaleventhandlers
interface mixin GlobalEventHandlers {
attribute EventHandler onabort;
attribute EventHandler onauxclick;
attribute EventHandler onblur;
Expand Down
3 changes: 2 additions & 1 deletion lib/jsdom/living/nodes/HTMLAnchorElement.webidl
@@ -1,3 +1,4 @@
// https://html.spec.whatwg.org/#htmlanchorelement
[Exposed=Window,
HTMLConstructor]
interface HTMLAnchorElement : HTMLElement {
Expand All @@ -15,7 +16,7 @@ interface HTMLAnchorElement : HTMLElement {

// also has obsolete members
};
HTMLAnchorElement implements HTMLHyperlinkElementUtils;
HTMLAnchorElement includes HTMLHyperlinkElementUtils;

partial interface HTMLAnchorElement {
[CEReactions, Reflect] attribute DOMString coords;
Expand Down
3 changes: 2 additions & 1 deletion lib/jsdom/living/nodes/HTMLAreaElement.webidl
@@ -1,3 +1,4 @@
// https://html.spec.whatwg.org/#htmlareaelement
[Exposed=Window,
HTMLConstructor]
interface HTMLAreaElement : HTMLElement {
Expand All @@ -13,7 +14,7 @@ interface HTMLAreaElement : HTMLElement {

// also has obsolete members
};
HTMLAreaElement implements HTMLHyperlinkElementUtils;
HTMLAreaElement includes HTMLHyperlinkElementUtils;

partial interface HTMLAreaElement {
[CEReactions, Reflect] attribute boolean noHref;
Expand Down
4 changes: 3 additions & 1 deletion lib/jsdom/living/nodes/HTMLBodyElement.webidl
@@ -1,11 +1,13 @@
// https://html.spec.whatwg.org/#htmlbodyelement
[Exposed=Window,
HTMLConstructor]
interface HTMLBodyElement : HTMLElement {
// also has obsolete members
};

HTMLBodyElement implements WindowEventHandlers;
HTMLBodyElement includes WindowEventHandlers;

// https://html.spec.whatwg.org/#HTMLBodyElement-partial
partial interface HTMLBodyElement {
[CEReactions, Reflect] attribute [TreatNullAs=EmptyString] DOMString text;
[CEReactions, Reflect] attribute [TreatNullAs=EmptyString] DOMString link;
Expand Down
8 changes: 5 additions & 3 deletions lib/jsdom/living/nodes/HTMLElement.webidl
@@ -1,3 +1,4 @@
// https://html.spec.whatwg.org/#htmlelement
[Exposed=Window,
HTMLConstructor]
interface HTMLElement : Element {
Expand All @@ -24,9 +25,10 @@ interface HTMLElement : Element {
// [CEReactions] attribute [TreatNullAs=EmptyString] DOMString innerText;
};

HTMLElement implements GlobalEventHandlers;
// HTMLElement implements DocumentAndElementEventHandlers;
HTMLElement implements ElementContentEditable;
HTMLElement includes GlobalEventHandlers;
// HTMLElement includes DocumentAndElementEventHandlers;
HTMLElement includes ElementContentEditable;
// HTMLElement includes HTMLOrSVGElement;

// https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
partial interface HTMLElement {
Expand Down
3 changes: 2 additions & 1 deletion lib/jsdom/living/nodes/HTMLFrameSetElement.webidl
@@ -1,7 +1,8 @@
// https://html.spec.whatwg.org/#htmlframesetelement
[Exposed=Window,
HTMLConstructor]
interface HTMLFrameSetElement : HTMLElement {
[CEReactions, Reflect] attribute DOMString cols;
[CEReactions, Reflect] attribute DOMString rows;
};
HTMLFrameSetElement implements WindowEventHandlers;
HTMLFrameSetElement includes WindowEventHandlers;
5 changes: 2 additions & 3 deletions lib/jsdom/living/nodes/HTMLHyperlinkElementUtils.webidl
@@ -1,6 +1,5 @@
[Exposed=Window,
NoInterfaceObject]
interface HTMLHyperlinkElementUtils {
// https://html.spec.whatwg.org/#htmlhyperlinkelementutils
interface mixin HTMLHyperlinkElementUtils {
[CEReactions] stringifier attribute USVString href;
readonly attribute USVString origin;
[CEReactions] attribute USVString protocol;
Expand Down
9 changes: 5 additions & 4 deletions lib/jsdom/living/nodes/HTMLLinkElement.webidl
@@ -1,3 +1,4 @@
// https://html.spec.whatwg.org/#htmllinkelement
[Exposed=Window,
HTMLConstructor]
interface HTMLLinkElement : HTMLElement {
Expand All @@ -12,15 +13,15 @@ interface HTMLLinkElement : HTMLElement {
[CEReactions, Reflect] attribute DOMString hreflang;
[CEReactions, Reflect] attribute DOMString type;
// [SameObject, PutForwards=value] readonly attribute DOMTokenList sizes;
// [CEReactions] attribute USVString imageSrcset;
// [CEReactions] attribute DOMString imageSizes;
// [CEReactions] attribute DOMString referrerPolicy;
// [CEReactions] attribute USVString scope;
// [CEReactions] attribute DOMString workerType;
// [CEReactions] attribute DOMString updateViaCache;

// also has obsolete members
};
HTMLLinkElement implements LinkStyle;
HTMLLinkElement includes LinkStyle;

// https://html.spec.whatwg.org/#HTMLLinkElement-partial
partial interface HTMLLinkElement {
[CEReactions, Reflect] attribute DOMString charset;
[CEReactions, Reflect] attribute DOMString rev;
Expand Down
4 changes: 3 additions & 1 deletion lib/jsdom/living/nodes/HTMLStyleElement.webidl
@@ -1,3 +1,4 @@
// https://html.spec.whatwg.org/#htmlstyleelement
[Exposed=Window,
HTMLConstructor]
interface HTMLStyleElement : HTMLElement {
Expand All @@ -6,8 +7,9 @@ interface HTMLStyleElement : HTMLElement {

// also has obsolete members
};
HTMLStyleElement implements LinkStyle;
HTMLStyleElement includes LinkStyle;

// https://html.spec.whatwg.org/#HTMLStyleElement-partial
partial interface HTMLStyleElement {
[CEReactions, Reflect] attribute DOMString type;
};
5 changes: 2 additions & 3 deletions lib/jsdom/living/nodes/LinkStyle.webidl
@@ -1,5 +1,4 @@
[Exposed=Window,
NoInterfaceObject]
interface LinkStyle {
// https://drafts.csswg.org/cssom/#linkstyle
interface mixin LinkStyle {
readonly attribute StyleSheet? sheet;
};
9 changes: 4 additions & 5 deletions lib/jsdom/living/nodes/NonDocumentTypeChildNode.webidl
@@ -1,8 +1,7 @@
[NoInterfaceObject,
Exposed=Window]
interface NonDocumentTypeChildNode {
// https://dom.spec.whatwg.org/#nondocumenttypechildnode
interface mixin NonDocumentTypeChildNode {
readonly attribute Element? previousElementSibling;
readonly attribute Element? nextElementSibling;
};
Element implements NonDocumentTypeChildNode;
CharacterData implements NonDocumentTypeChildNode;
Element includes NonDocumentTypeChildNode;
CharacterData includes NonDocumentTypeChildNode;
9 changes: 4 additions & 5 deletions lib/jsdom/living/nodes/NonElementParentNode.webidl
@@ -1,7 +1,6 @@
[NoInterfaceObject,
Exposed=Window]
interface NonElementParentNode {
// https://dom.spec.whatwg.org/#nonelementparentnode
interface mixin NonElementParentNode {
Element? getElementById(DOMString elementId);
};
Document implements NonElementParentNode;
DocumentFragment implements NonElementParentNode;
Document includes NonElementParentNode;
DocumentFragment includes NonElementParentNode;
11 changes: 5 additions & 6 deletions lib/jsdom/living/nodes/ParentNode.webidl
@@ -1,6 +1,5 @@
[NoInterfaceObject,
Exposed=Window]
interface ParentNode {
// https://dom.spec.whatwg.org/#parentnode
interface mixin ParentNode {
[SameObject] readonly attribute HTMLCollection children;
readonly attribute Element? firstElementChild;
readonly attribute Element? lastElementChild;
Expand All @@ -12,6 +11,6 @@ interface ParentNode {
Element? querySelector(DOMString selectors);
[NewObject] NodeList querySelectorAll(DOMString selectors);
};
Document implements ParentNode;
DocumentFragment implements ParentNode;
Element implements ParentNode;
Document includes ParentNode;
DocumentFragment includes ParentNode;
Element includes ParentNode;
4 changes: 2 additions & 2 deletions lib/jsdom/living/nodes/SVGElement.webidl
Expand Up @@ -14,5 +14,5 @@ interface SVGElement : Element {
void blur();
};

SVGElement implements GlobalEventHandlers;
// SVGElement implements SVGElementInstance;
SVGElement includes GlobalEventHandlers;
// SVGElement includes SVGElementInstance;
6 changes: 3 additions & 3 deletions lib/jsdom/living/nodes/SVGSVGElement.webidl
Expand Up @@ -35,6 +35,6 @@ interface SVGSVGElement : SVGGraphicsElement {
void forceRedraw();
};

// SVGSVGElement implements SVGFitToViewBox;
// SVGSVGElement implements SVGZoomAndPan;
SVGSVGElement implements WindowEventHandlers;
// SVGSVGElement includes SVGFitToViewBox;
// SVGSVGElement includes SVGZoomAndPan;
SVGSVGElement includes WindowEventHandlers;
7 changes: 4 additions & 3 deletions lib/jsdom/living/nodes/Slotable.webidl
@@ -1,5 +1,6 @@
// Slotable is a mixin rather than an interface
// Waiting for https://github.com/jsdom/webidl2js/commit/92598ce3ec39342e27a3ad090a373b20f3b99626
interface Slotable {
// https://dom.spec.whatwg.org/#slotable
interface mixin Slotable {
readonly attribute HTMLSlotElement? assignedSlot;
};
Element includes Slotable;
Text includes Slotable;
3 changes: 1 addition & 2 deletions lib/jsdom/living/nodes/Text.webidl
@@ -1,8 +1,7 @@
// https://dom.spec.whatwg.org/#text
[Constructor(optional DOMString data = ""),
Exposed=Window]
interface Text : CharacterData {
[NewObject] Text splitText(unsigned long offset);
readonly attribute DOMString wholeText;
};

Text implements Slotable;

0 comments on commit 8533b57

Please sign in to comment.