From 7353e0e472a60b99ff79f2d3eedd3c4dc22f4cc1 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Mon, 18 Feb 2013 12:29:43 +0100 Subject: [PATCH] Bug 838343 - Convert HTMLFrameElement to WebIDL r=peterv --HG-- rename : content/html/content/src/nsHTMLFrameElement.cpp => content/html/content/src/HTMLFrameElement.cpp rename : content/html/content/src/nsHTMLFrameElement.cpp => content/html/content/src/HTMLFrameElement.h extra : rebase_source : b22a6371050e987aeba86937b120584e7c5a1422 --- content/html/content/src/HTMLFrameElement.cpp | 36 +++++++++++ content/html/content/src/HTMLFrameElement.h | 60 +++++++++++++++++++ content/html/content/src/Makefile.in | 1 + dom/webidl/HTMLFrameElement.webidl | 34 +++++++++++ dom/webidl/WebIDL.mk | 1 + 5 files changed, 132 insertions(+) create mode 100644 dom/webidl/HTMLFrameElement.webidl diff --git a/content/html/content/src/HTMLFrameElement.cpp b/content/html/content/src/HTMLFrameElement.cpp index f2937042f771..24a36b74563c 100644 --- a/content/html/content/src/HTMLFrameElement.cpp +++ b/content/html/content/src/HTMLFrameElement.cpp @@ -4,6 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "HTMLFrameElement.h" +#include "mozilla/dom/HTMLFrameElementBinding.h" class nsIDOMDocument; @@ -17,6 +18,7 @@ HTMLFrameElement::HTMLFrameElement(already_AddRefed aNodeInfo, FromParser aFromParser) : nsGenericHTMLFrameElement(aNodeInfo, aFromParser) { + SetIsDOMBinding(); } HTMLFrameElement::~HTMLFrameElement() @@ -114,5 +116,39 @@ HTMLFrameElement::GetAttributeMappingFunction() const return &MapAttributesIntoRule; } +already_AddRefed +HTMLFrameElement::GetContentDocument(ErrorResult& aRv) +{ + nsCOMPtr doc; + nsresult rv = nsGenericHTMLFrameElement::GetContentDocument(getter_AddRefs(doc)); + if (NS_FAILED(rv)) { + aRv.Throw(rv); + return nullptr; + } + + nsCOMPtr ret = do_QueryInterface(doc); + return ret.forget(); +} + +already_AddRefed +HTMLFrameElement::GetContentWindow(ErrorResult& aRv) +{ + nsCOMPtr 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 diff --git a/content/html/content/src/HTMLFrameElement.h b/content/html/content/src/HTMLFrameElement.h index 4f7b9632c52e..ce8ddf5bfab8 100644 --- a/content/html/content/src/HTMLFrameElement.h +++ b/content/html/content/src/HTMLFrameElement.h @@ -49,6 +49,66 @@ public: 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 GetContentDocument(ErrorResult& aRv); + + already_AddRefed GetContentWindow(ErrorResult& aRv); + +protected: + virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope, + bool* aTriedToWrap) MOZ_OVERRIDE; }; } // namespace dom diff --git a/content/html/content/src/Makefile.in b/content/html/content/src/Makefile.in index 862447eb2405..08f4766e804e 100644 --- a/content/html/content/src/Makefile.in +++ b/content/html/content/src/Makefile.in @@ -39,6 +39,7 @@ EXPORTS_mozilla/dom = \ HTMLDivElement.h \ HTMLFieldSetElement.h \ HTMLFontElement.h \ + HTMLFrameElement.h \ HTMLFrameSetElement.h \ HTMLHeadingElement.h \ HTMLHRElement.h \ diff --git a/dom/webidl/HTMLFrameElement.webidl b/dom/webidl/HTMLFrameElement.webidl new file mode 100644 index 000000000000..3d30296eb0fa --- /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; +}; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 046ae5817861..76a7458133e2 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -71,6 +71,7 @@ webidl_files = \ HTMLElement.webidl \ HTMLFieldSetElement.webidl \ HTMLFontElement.webidl \ + HTMLFrameElement.webidl \ HTMLFrameSetElement.webidl \ HTMLHeadElement.webidl \ HTMLHeadingElement.webidl \