Bug 843627 part 2. Implement the WebIDL API for <embed> and <applet>. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Sun, 17 Mar 2013 10:42:03 -0400
changeset 125137 61099fdb7b2398302cf9a695e03169cd3ea00b0f
parent 125136 d31cfe6eeb240339619c6c360866ecdedf66709f
child 125138 4f79d9d9d818b6639987a190fe10f567d1d63b39
push id24449
push useremorley@mozilla.com
push dateMon, 18 Mar 2013 20:06:48 +0000
treeherdermozilla-central@e23e43a2c14e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs843627
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 843627 part 2. Implement the WebIDL API for <embed> and <applet>. r=peterv
content/html/content/src/HTMLSharedObjectElement.h
dom/bindings/Bindings.conf
dom/bindings/parser/WebIDL.py
dom/webidl/HTMLAppletElement.webidl
dom/webidl/HTMLEmbedElement.webidl
--- a/content/html/content/src/HTMLSharedObjectElement.h
+++ b/content/html/content/src/HTMLSharedObjectElement.h
@@ -99,16 +99,124 @@ public:
     return static_cast<nsXPCClassInfo*>(GetClassInfoInternal());
   }
   nsIClassInfo* GetClassInfoInternal();
 
   virtual nsIDOMNode* AsDOMNode()
   {
     return static_cast<nsIDOMHTMLAppletElement*>(this);
   }
+
+  // WebIDL API for <applet>
+  void GetAlign(DOMString& aValue)
+  {
+    GetHTMLAttr(nsGkAtoms::align, aValue);
+  }
+  void SetAlign(const nsAString& aValue, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::align, aValue, aRv);
+  }
+  void GetAlt(DOMString& aValue)
+  {
+    GetHTMLAttr(nsGkAtoms::alt, aValue);
+  }
+  void SetAlt(const nsAString& aValue, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::alt, aValue, aRv);
+  }
+  void GetArchive(DOMString& aValue)
+  {
+    GetHTMLAttr(nsGkAtoms::archive, aValue);
+  }
+  void SetArchive(const nsAString& aValue, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::archive, aValue, aRv);
+  }
+  void GetCode(DOMString& aValue)
+  {
+    GetHTMLAttr(nsGkAtoms::code, aValue);
+  }
+  void SetCode(const nsAString& aValue, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::code, aValue, aRv);
+  }
+  // XPCOM GetCodebase is ok; note that it's a URI attribute
+  void SetCodeBase(const nsAString& aValue, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::codebase, aValue, aRv);
+  }
+  void GetHeight(DOMString& aValue)
+  {
+    GetHTMLAttr(nsGkAtoms::height, aValue);
+  }
+  void SetHeight(const nsAString& aValue, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::height, aValue, aRv);
+  }
+  uint32_t Hspace()
+  {
+    return GetHTMLUnsignedIntAttr(nsGkAtoms::hspace, 0);
+  }
+  void SetHspace(uint32_t aValue, ErrorResult& aRv)
+  {
+    SetHTMLUnsignedIntAttr(nsGkAtoms::hspace, aValue, aRv);
+  }
+  void GetName(DOMString& aValue)
+  {
+    GetHTMLAttr(nsGkAtoms::name, aValue);
+  }
+  void SetName(const nsAString& aValue, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::name, aValue, aRv);
+  }
+  // XPCOM GetObject is ok; note that it's a URI attribute with a weird base URI
+  void SetObject(const nsAString& aValue, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::object, aValue, aRv);
+  }
+    uint32_t Vspace()
+  {
+    return GetHTMLUnsignedIntAttr(nsGkAtoms::vspace, 0);
+  }
+  void SetVspace(uint32_t aValue, ErrorResult& aRv)
+  {
+    SetHTMLUnsignedIntAttr(nsGkAtoms::vspace, aValue, aRv);
+  }
+  void GetWidth(DOMString& aValue)
+  {
+    GetHTMLAttr(nsGkAtoms::width, aValue);
+  }
+  void SetWidth(const nsAString& aValue, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::width, aValue, aRv);
+  }
+
+  // WebIDL <embed> api
+  // XPCOM GetSrc is ok; note that it's a URI attribute
+  void SetSrc(const nsAString& aValue, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::src, aValue, aRv);
+  }
+  void GetType(DOMString& aValue)
+  {
+    GetHTMLAttr(nsGkAtoms::type, aValue);
+  }
+  void SetType(const nsAString& aValue, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::type, aValue, aRv);
+  }
+  // width covered by <applet>
+  // height covered by <applet>
+  // align covered by <applet>
+  // name covered by <applet>
+  nsIDocument* GetSVGDocument()
+  {
+    return GetContentDocument();
+  }
+
 private:
   /**
    * Calls LoadObject with the correct arguments to start the plugin load.
    */
   NS_HIDDEN_(void) StartObjectLoad(bool aNotify);
 
   void GetTypeAttrValue(nsCString &aValue) const
   {
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -340,16 +340,20 @@ DOMInterfaces = {
     'nativeType': 'JSObject'
 }],
 
 'GainNode': {
     'resultNotAddRefed': [ 'gain' ],
     'wrapperCache': False
 },
 
+'HTMLAppletElement': {
+    'nativeType': 'mozilla::dom::HTMLSharedObjectElement'
+},
+
 'HTMLBaseElement': {
     'nativeType': 'mozilla::dom::HTMLSharedElement'
 },
 
 'HTMLCollection': {
     'nativeType': 'nsIHTMLCollection',
     'resultNotAddRefed': [ 'item' ]
 },
@@ -381,16 +385,20 @@ DOMInterfaces = {
     'nativeType': 'nsGenericHTMLElement',
     'hasXPConnectImpls': True,
     'resultNotAddRefed': [
         'itemType', 'itemRef', 'itemProp', 'properties', 'contextMenu', 'style',
         'offsetParent'
     ]
 },
 
+'HTMLEmbedElement': {
+    'nativeType': 'mozilla::dom::HTMLSharedObjectElement'
+},
+
 'HTMLHeadElement': {
     'nativeType': 'mozilla::dom::HTMLSharedElement'
 },
 
 'HTMLHtmlElement': {
     'nativeType': 'mozilla::dom::HTMLSharedElement'
 },
 
--- a/dom/bindings/parser/WebIDL.py
+++ b/dom/bindings/parser/WebIDL.py
@@ -314,17 +314,17 @@ class IDLUnresolvedIdentifier(IDLObject)
 
         assert len(name) > 0
 
         if name[:2] == "__" and not allowDoubleUnderscore:
             raise WebIDLError("Identifiers beginning with __ are reserved",
                               [location])
         if name[0] == '_' and not allowDoubleUnderscore:
             name = name[1:]
-        if name in ["constructor", "toString"] and not allowForbidden:
+        if name in ["constructor", "iterator", "toString", "toJSON"] and not allowForbidden:
             raise WebIDLError("Cannot use reserved identifier '%s'" % (name),
                               [location])
 
         self.name = name
 
     def __str__(self):
         return self.QName()
 
new file mode 100644
--- /dev/null
+++ b/dom/webidl/HTMLAppletElement.webidl
@@ -0,0 +1,43 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * The origin of this IDL file is
+ * http://www.whatwg.org/specs/web-apps/current-work/#the-applet-element
+ *
+ * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
+ * Opera Software ASA. You are granted a license to use, reproduce
+ * and create derivative works of this document.
+ */
+
+// http://www.whatwg.org/specs/web-apps/current-work/#the-applet-element
+[NeedNewResolve]
+interface HTMLAppletElement : HTMLElement {
+  [Pure, SetterThrows]
+           attribute DOMString align;
+  [Pure, SetterThrows]
+           attribute DOMString alt;
+  [Pure, SetterThrows]
+           attribute DOMString archive;
+  [Pure, SetterThrows]
+           attribute DOMString code;
+  [Pure, SetterThrows]
+           attribute DOMString codeBase;
+  [Pure, SetterThrows]
+           attribute DOMString height;
+  [Pure, SetterThrows]
+           attribute unsigned long hspace;
+  [Pure, SetterThrows]
+           attribute DOMString name;
+  [Pure, SetterThrows]
+           attribute DOMString _object;
+  [Pure, SetterThrows]
+           attribute unsigned long vspace;
+  [Pure, SetterThrows]
+           attribute DOMString width;
+};
+
+HTMLAppletElement implements MozImageLoadingContent;
+HTMLAppletElement implements MozFrameLoaderOwner;
+HTMLAppletElement implements MozObjectLoadingContent;
new file mode 100644
--- /dev/null
+++ b/dom/webidl/HTMLEmbedElement.webidl
@@ -0,0 +1,45 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * The origin of this IDL file is
+ * http://www.whatwg.org/specs/web-apps/current-work/#the-embed-element
+ * http://www.whatwg.org/specs/web-apps/current-work/#HTMLEmbedElement-partial
+ *
+ * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
+ * Opera Software ASA. You are granted a license to use, reproduce
+ * and create derivative works of this document.
+ */
+
+// http://www.whatwg.org/specs/web-apps/current-work/#the-embed-element
+[NeedNewResolve]
+interface HTMLEmbedElement : HTMLElement {
+  [Pure, SetterThrows]
+           attribute DOMString src;
+  [Pure, SetterThrows]
+           attribute DOMString type;
+  [Pure, SetterThrows]
+           attribute DOMString width;
+  [Pure, SetterThrows]
+           attribute DOMString height;
+  [Throws]
+  legacycaller any (any... arguments);
+};
+
+// http://www.whatwg.org/specs/web-apps/current-work/#HTMLEmbedElement-partial
+partial interface HTMLEmbedElement {
+  [Pure, SetterThrows]
+           attribute DOMString align;
+  [Pure, SetterThrows]
+           attribute DOMString name;
+};
+
+partial interface HTMLEmbedElement {
+  // nsIDOMGetSVGDocument
+  Document? getSVGDocument();
+};
+
+HTMLEmbedElement implements MozImageLoadingContent;
+HTMLEmbedElement implements MozFrameLoaderOwner;
+HTMLEmbedElement implements MozObjectLoadingContent;