Bug 838343 - Convert HTMLFrameElement to WebIDL r=peterv
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 18 Feb 2013 12:29:43 +0100
changeset 132109 abba7ec43f009b480e8d57c6e71da246c3d85ea4
parent 132108 6b7b42fdfd57276b1fb0af6e6791289078f2ca36
child 132110 653bcba12dc600c31546ddeb278b7346e0847795
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs838343
milestone21.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 838343 - Convert HTMLFrameElement to WebIDL r=peterv
content/html/content/src/HTMLFrameElement.cpp
content/html/content/src/HTMLFrameElement.h
content/html/content/src/Makefile.in
dom/webidl/HTMLFrameElement.webidl
dom/webidl/WebIDL.mk
--- a/content/html/content/src/HTMLFrameElement.cpp
+++ b/content/html/content/src/HTMLFrameElement.cpp
@@ -1,27 +1,29 @@
 /* -*- Mode: C++; 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/. */
 
 #include "HTMLFrameElement.h"
+#include "mozilla/dom/HTMLFrameElementBinding.h"
 
 class nsIDOMDocument;
 
 NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Frame)
 DOMCI_NODE_DATA(HTMLFrameElement, mozilla::dom::HTMLFrameElement)
 
 namespace mozilla {
 namespace dom {
 
 HTMLFrameElement::HTMLFrameElement(already_AddRefed<nsINodeInfo> aNodeInfo,
                                    FromParser aFromParser)
   : nsGenericHTMLFrameElement(aNodeInfo, aFromParser)
 {
+  SetIsDOMBinding();
 }
 
 HTMLFrameElement::~HTMLFrameElement()
 {
 }
 
 
 NS_IMPL_ADDREF_INHERITED(HTMLFrameElement, Element)
@@ -109,10 +111,44 @@ HTMLFrameElement::IsAttributeMapped(cons
 }
 
 nsMapRuleToAttributesFunc
 HTMLFrameElement::GetAttributeMappingFunction() const
 {
   return &MapAttributesIntoRule;
 }
 
+already_AddRefed<nsIDocument>
+HTMLFrameElement::GetContentDocument(ErrorResult& aRv)
+{
+  nsCOMPtr<nsIDOMDocument> doc;
+  nsresult rv = nsGenericHTMLFrameElement::GetContentDocument(getter_AddRefs(doc));
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return nullptr;
+  }
+
+  nsCOMPtr<nsIDocument> ret = do_QueryInterface(doc);
+  return ret.forget();
+}
+
+already_AddRefed<nsIDOMWindow>
+HTMLFrameElement::GetContentWindow(ErrorResult& aRv)
+{
+  nsCOMPtr<nsIDOMWindow> win;
+  nsresult rv = nsGenericHTMLFrameElement::GetContentWindow(getter_AddRefs(win));
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return nullptr;
+  }
+
+  return win.forget();
+}
+
+JSObject*
+HTMLFrameElement::WrapNode(JSContext* aCx, JSObject* aScope,
+                           bool* aTriedToWrap)
+{
+  return HTMLFrameElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
+
 } // namespace mozilla
 } // namespace dom
--- a/content/html/content/src/HTMLFrameElement.h
+++ b/content/html/content/src/HTMLFrameElement.h
@@ -44,14 +44,74 @@ public:
                               nsIAtom* aAttribute,
                               const nsAString& aValue,
                               nsAttrValue& aResult);
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
   nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
   virtual nsXPCClassInfo* GetClassInfo();
   virtual nsIDOMNode* AsDOMNode() { return this; }
+
+  // WebIDL API
+  // The XPCOM GetFrameBorder is OK for us
+  void SetFrameBorder(const nsAString& aFrameBorder, ErrorResult& aError)
+  {
+    SetHTMLAttr(nsGkAtoms::frameborder, aFrameBorder, aError);
+  }
+
+  // The XPCOM GetLongDesc is OK for us
+  void SetLongDesc(const nsAString& aLongDesc, ErrorResult& aError)
+  {
+    SetAttrHelper(nsGkAtoms::longdesc, aLongDesc);
+  }
+
+  // The XPCOM GetMarginHeight is OK for us
+  void SetMarginHeight(const nsAString& aMarginHeight, ErrorResult& aError)
+  {
+    SetHTMLAttr(nsGkAtoms::marginheight, aMarginHeight, aError);
+  }
+
+  // The XPCOM GetMarginWidth is OK for us
+  void SetMarginWidth(const nsAString& aMarginWidth, ErrorResult& aError)
+  {
+    SetHTMLAttr(nsGkAtoms::marginwidth, aMarginWidth, aError);
+  }
+
+  // The XPCOM GetName is OK for us
+  void SetName(const nsAString& aName, ErrorResult& aError)
+  {
+    SetHTMLAttr(nsGkAtoms::name, aName, aError);
+  }
+
+  bool NoResize() const
+  {
+   return GetBoolAttr(nsGkAtoms::noresize);
+  }
+  void SetNoResize(bool& aNoResize, ErrorResult& aError)
+  {
+    SetHTMLBoolAttr(nsGkAtoms::noresize, aNoResize, aError);
+  }
+
+  // The XPCOM GetScrolling is OK for us
+  void SetScrolling(const nsAString& aScrolling, ErrorResult& aError)
+  {
+    SetHTMLAttr(nsGkAtoms::scrolling, aScrolling, aError);
+  }
+
+  // The XPCOM GetSrc is OK for us
+  void SetSrc(const nsAString& aSrc, ErrorResult& aError)
+  {
+    SetAttrHelper(nsGkAtoms::src, aSrc);
+  }
+
+  already_AddRefed<nsIDocument> GetContentDocument(ErrorResult& aRv);
+
+  already_AddRefed<nsIDOMWindow> GetContentWindow(ErrorResult& aRv);
+
+protected:
+  virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope,
+                             bool* aTriedToWrap) MOZ_OVERRIDE;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_HTMLFrameElement_h
--- a/content/html/content/src/Makefile.in
+++ b/content/html/content/src/Makefile.in
@@ -34,16 +34,17 @@ EXPORTS_mozilla/dom = \
 		HTMLAreaElement.h \
 		HTMLBodyElement.h \
 		HTMLBRElement.h \
 		HTMLButtonElement.h \
 		HTMLDataListElement.h \
 		HTMLDivElement.h \
 		HTMLFieldSetElement.h \
 		HTMLFontElement.h \
+		HTMLFrameElement.h \
 		HTMLFrameSetElement.h \
 		HTMLHeadingElement.h \
 		HTMLHRElement.h \
 		HTMLImageElement.h \
 		HTMLLabelElement.h \
 		HTMLLegendElement.h \
 		HTMLLIElement.h \
 		HTMLLinkElement.h \
new file mode 100644
--- /dev/null
+++ b/dom/webidl/HTMLFrameElement.webidl
@@ -0,0 +1,34 @@
+/* -*- 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/#htmlframeelement
+ * © 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/#htmlframeelement
+interface HTMLFrameElement : HTMLElement {
+           [SetterThrows]
+           attribute DOMString name;
+           [SetterThrows]
+           attribute DOMString scrolling;
+           [SetterThrows]
+           attribute DOMString src;
+           [SetterThrows]
+           attribute DOMString frameBorder;
+           [SetterThrows]
+           attribute DOMString longDesc;
+           [SetterThrows]
+           attribute boolean noResize;
+  [GetterThrows]
+  readonly attribute Document? contentDocument;
+  [GetterThrows]
+  readonly attribute WindowProxy? contentWindow;
+
+  [TreatNullAs=EmptyString, SetterThrows] attribute DOMString marginHeight;
+  [TreatNullAs=EmptyString, SetterThrows] attribute DOMString marginWidth;
+};
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -66,16 +66,17 @@ webidl_files = \
   HTMLDataListElement.webidl \
   HTMLDirectoryElement.webidl \
   HTMLDivElement.webidl \
   HTMLDListElement.webidl \
   HTMLDocument.webidl \
   HTMLElement.webidl \
   HTMLFieldSetElement.webidl \
   HTMLFontElement.webidl \
+  HTMLFrameElement.webidl \
   HTMLFrameSetElement.webidl \
   HTMLHeadElement.webidl \
   HTMLHeadingElement.webidl \
   HTMLHRElement.webidl \
   HTMLHtmlElement.webidl \
   HTMLImageElement.webidl \
   HTMLLabelElement.webidl \
   HTMLLegendElement.webidl \