diff --git a/content/html/content/src/HTMLSourceElement.cpp b/content/html/content/src/HTMLSourceElement.cpp index 640b6bfb714..520d81b911d 100644 --- a/content/html/content/src/HTMLSourceElement.cpp +++ b/content/html/content/src/HTMLSourceElement.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/HTMLSourceElement.h" +#include "mozilla/dom/HTMLSourceElementBinding.h" NS_IMPL_NS_NEW_HTML_ELEMENT(Source) DOMCI_NODE_DATA(HTMLSourceElement, mozilla::dom::HTMLSourceElement) @@ -15,6 +16,7 @@ namespace dom { HTMLSourceElement::HTMLSourceElement(already_AddRefed aNodeInfo) : nsGenericHTMLElement(aNodeInfo) { + SetIsDOMBinding(); } HTMLSourceElement::~HTMLSourceElement() @@ -75,5 +77,12 @@ HTMLSourceElement::BindToTree(nsIDocument *aDocument, return NS_OK; } +JSObject* +HTMLSourceElement::WrapNode(JSContext* aCx, JSObject* aScope, + bool* aTriedToWrap) +{ + return HTMLSourceElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + } // namespace dom } // namespace mozilla diff --git a/content/html/content/src/HTMLSourceElement.h b/content/html/content/src/HTMLSourceElement.h index bca6b7689a0..baeb180d5f9 100644 --- a/content/html/content/src/HTMLSourceElement.h +++ b/content/html/content/src/HTMLSourceElement.h @@ -36,18 +36,50 @@ public: // nsIDOMHTMLSourceElement NS_DECL_NSIDOMHTMLSOURCEELEMENT - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + virtual nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const; // Override BindToTree() so that we can trigger a load when we add a // child source element. - virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent, - nsIContent *aBindingParent, + virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, + nsIContent* aBindingParent, bool aCompileEventHandlers); virtual nsXPCClassInfo* GetClassInfo(); virtual nsIDOMNode* AsDOMNode() { return this; } + // WebIDL + void GetSrc(nsString& aSrc) + { + GetURIAttr(nsGkAtoms::src, nullptr, aSrc); + } + void SetSrc(const nsAString& aSrc, mozilla::ErrorResult& rv) + { + SetHTMLAttr(nsGkAtoms::src, aSrc, rv); + } + + void GetType(nsString& aType) + { + GetHTMLAttr(nsGkAtoms::type, aType); + } + void SetType(const nsAString& aType, ErrorResult& rv) + { + SetHTMLAttr(nsGkAtoms::type, aType, rv); + } + + void GetMedia(nsString& aMedia) + { + GetHTMLAttr(nsGkAtoms::media, aMedia); + } + void SetMedia(const nsAString& aMedia, mozilla::ErrorResult& rv) + { + SetHTMLAttr(nsGkAtoms::media, aMedia, rv); + } + +protected: + virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope, + bool* aTriedToWrap) MOZ_OVERRIDE; + protected: virtual void GetItemValueText(nsAString& text); virtual void SetItemValueText(const nsAString& text); diff --git a/content/html/content/test/reflect.js b/content/html/content/test/reflect.js index 5abbb754862..7af4ae4eb54 100644 --- a/content/html/content/test/reflect.js +++ b/content/html/content/test/reflect.js @@ -60,7 +60,6 @@ function reflectString(aParameters) form: [ "acceptCharset", "name", "target" ], input: [ "accept", "alt", "formTarget", "max", "min", "name", "pattern", "placeholder", "step", "defaultValue" ], link: [ "crossOrigin" ], - source: [ "media" ], textarea: [ "name", "placeholder" ] }; if (!(element.localName in todoAttrs) || todoAttrs[element.localName].indexOf(idlAttr) == -1) { diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 73e520be703..40124f7450b 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -470,6 +470,10 @@ DOMInterfaces = { 'hasInstanceInterface': 'nsIDOMHTMLScriptElement', }, +'HTMLSourceElement': { + 'hasInstanceInterface': 'nsIDOMHTMLSourceElement', +}, + 'HTMLTableCellElement': { 'hasInstanceInterface': 'nsIDOMHTMLTableCellElement' }, diff --git a/dom/webidl/HTMLSourceElement.webidl b/dom/webidl/HTMLSourceElement.webidl new file mode 100644 index 00000000000..8119a1e33cf --- /dev/null +++ b/dom/webidl/HTMLSourceElement.webidl @@ -0,0 +1,21 @@ +/* -*- 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-source-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. + */ + +interface HTMLSourceElement : HTMLElement { + [SetterThrows] + attribute DOMString src; + [SetterThrows] + attribute DOMString type; + [SetterThrows] + attribute DOMString media; +}; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index ea6355f20d9..70754bd7457 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -196,6 +196,12 @@ webidl_files = \ XULElement.webidl \ $(NULL) +ifdef MOZ_MEDIA +webidl_files += \ + HTMLSourceElement.webidl \ + $(NULL) +endif + ifdef MOZ_WEBGL webidl_files += \ WebGLRenderingContext.webidl \