Loading dom/html/HTMLScriptElement.cpp +18 −122 Original line number Diff line number Diff line Loading @@ -48,7 +48,6 @@ HTMLScriptElement::~HTMLScriptElement() } NS_IMPL_ISUPPORTS_INHERITED(HTMLScriptElement, nsGenericHTMLElement, nsIDOMHTMLScriptElement, nsIScriptLoaderObserver, nsIScriptElement, nsIMutationObserver) Loading Loading @@ -115,123 +114,6 @@ HTMLScriptElement::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult, return NS_OK; } NS_IMETHODIMP HTMLScriptElement::GetText(nsAString& aValue) { if (!nsContentUtils::GetNodeTextContent(this, false, aValue, fallible)) { return NS_ERROR_OUT_OF_MEMORY; } return NS_OK; } NS_IMETHODIMP HTMLScriptElement::SetText(const nsAString& aValue) { ErrorResult rv; SetText(aValue, rv); return rv.StealNSResult(); } void HTMLScriptElement::SetText(const nsAString& aValue, ErrorResult& rv) { rv = nsContentUtils::SetNodeTextContent(this, aValue, true); } NS_IMPL_STRING_ATTR(HTMLScriptElement, Charset, charset) NS_IMPL_BOOL_ATTR(HTMLScriptElement, Defer, defer) // If this ever gets changed to return "" if the attr value is "" (see // https://github.com/whatwg/html/issues/1739 for why it might not get changed), // it may be worth it to use GetSrc instead of GetAttr and manual // NewURIWithDocumentCharset in FreezeUriAsyncDefer. NS_IMPL_URI_ATTR(HTMLScriptElement, Src, src) NS_IMPL_STRING_ATTR(HTMLScriptElement, Type, type) NS_IMPL_STRING_ATTR(HTMLScriptElement, HtmlFor, _for) NS_IMPL_STRING_ATTR(HTMLScriptElement, Event, event) void HTMLScriptElement::SetCharset(const nsAString& aCharset, ErrorResult& rv) { SetHTMLAttr(nsGkAtoms::charset, aCharset, rv); } void HTMLScriptElement::SetDefer(bool aDefer, ErrorResult& rv) { SetHTMLBoolAttr(nsGkAtoms::defer, aDefer, rv); } bool HTMLScriptElement::Defer() { return GetBoolAttr(nsGkAtoms::defer); } void HTMLScriptElement::SetSrc(const nsAString& aSrc, nsIPrincipal& aTriggeringPrincipal, ErrorResult& rv) { SetHTMLAttr(nsGkAtoms::src, aSrc, aTriggeringPrincipal, rv); } void HTMLScriptElement::SetType(const nsAString& aType, ErrorResult& rv) { SetHTMLAttr(nsGkAtoms::type, aType, rv); } void HTMLScriptElement::SetHtmlFor(const nsAString& aHtmlFor, ErrorResult& rv) { SetHTMLAttr(nsGkAtoms::_for, aHtmlFor, rv); } void HTMLScriptElement::SetEvent(const nsAString& aEvent, ErrorResult& rv) { SetHTMLAttr(nsGkAtoms::event, aEvent, rv); } nsresult HTMLScriptElement::GetAsync(bool* aValue) { *aValue = Async(); return NS_OK; } bool HTMLScriptElement::Async() { return mForceAsync || GetBoolAttr(nsGkAtoms::async); } nsresult HTMLScriptElement::SetAsync(bool aValue) { ErrorResult rv; SetAsync(aValue, rv); return rv.StealNSResult(); } void HTMLScriptElement::SetAsync(bool aValue, ErrorResult& rv) { mForceAsync = false; SetHTMLBoolAttr(nsGkAtoms::async, aValue, rv); } bool HTMLScriptElement::NoModule() { return GetBoolAttr(nsGkAtoms::nomodule); } void HTMLScriptElement::SetNoModule(bool aValue, ErrorResult& aRv) { SetHTMLBoolAttr(nsGkAtoms::nomodule, aValue, aRv); } nsresult HTMLScriptElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, Loading Loading @@ -269,6 +151,20 @@ HTMLScriptElement::SetInnerHTML(const nsAString& aInnerHTML, aError = nsContentUtils::SetNodeTextContent(this, aInnerHTML, true); } void HTMLScriptElement::GetText(nsAString& aValue, ErrorResult& aRv) { if (!nsContentUtils::GetNodeTextContent(this, false, aValue, fallible)) { aRv.Throw(NS_ERROR_OUT_OF_MEMORY); } } void HTMLScriptElement::SetText(const nsAString& aValue, ErrorResult& aRv) { aRv = nsContentUtils::SetNodeTextContent(this, aValue, true); } // variation of this code in nsSVGScriptElement - check if changes // need to be transfered when modifying Loading @@ -281,7 +177,8 @@ HTMLScriptElement::GetScriptType(nsAString& type) void HTMLScriptElement::GetScriptText(nsAString& text) { GetText(text); IgnoredErrorResult rv; GetText(text, rv); } void Loading Loading @@ -330,9 +227,8 @@ HTMLScriptElement::FreezeUriAsyncDefer() // At this point mUri will be null for invalid URLs. mExternal = true; bool defer, async; GetAsync(&async); GetDefer(&defer); bool async = Async(); bool defer = Defer(); mDefer = !async && defer; mAsync = async; Loading dom/html/HTMLScriptElement.h +88 −21 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ #ifndef mozilla_dom_HTMLScriptElement_h #define mozilla_dom_HTMLScriptElement_h #include "nsIDOMHTMLScriptElement.h" #include "nsGenericHTMLElement.h" #include "mozilla/Attributes.h" #include "mozilla/dom/ScriptElement.h" Loading @@ -16,7 +15,6 @@ namespace mozilla { namespace dom { class HTMLScriptElement final : public nsGenericHTMLElement, public nsIDOMHTMLScriptElement, public ScriptElement { public: Loading @@ -33,9 +31,6 @@ public: virtual void SetInnerHTML(const nsAString& aInnerHTML, mozilla::ErrorResult& aError) override; // nsIDOMHTMLScriptElement NS_DECL_NSIDOMHTMLSCRIPTELEMENT // nsIScriptElement virtual bool GetScriptType(nsAString& type) override; virtual void GetScriptText(nsAString& text) override; Loading Loading @@ -63,18 +58,89 @@ public: bool aNotify) override; // WebIDL void SetText(const nsAString& aValue, ErrorResult& rv); void SetCharset(const nsAString& aCharset, ErrorResult& rv); void SetDefer(bool aDefer, ErrorResult& rv); bool Defer(); void SetSrc(const nsAString& aSrc, nsIPrincipal& aTriggeringPrincipal, ErrorResult& rv); void GetSrc(nsString& aSrc, nsIPrincipal&) void GetText(nsAString& aValue, ErrorResult& aRv); void SetText(const nsAString& aValue, ErrorResult& aRv); void GetCharset(nsAString& aCharset) { GetHTMLAttr(nsGkAtoms::charset, aCharset); } void SetCharset(const nsAString& aCharset, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::charset, aCharset, aRv); } bool Defer() { return GetBoolAttr(nsGkAtoms::defer); } void SetDefer(bool aDefer, ErrorResult& aRv) { SetHTMLBoolAttr(nsGkAtoms::defer, aDefer, aRv); } void GetSrc(nsAString& aSrc, nsIPrincipal&) { GetSrc(aSrc); }; void SetType(const nsAString& aType, ErrorResult& rv); void SetHtmlFor(const nsAString& aHtmlFor, ErrorResult& rv); void SetEvent(const nsAString& aEvent, ErrorResult& rv); } void GetSrc(nsAString& aSrc) { GetURIAttr(nsGkAtoms::src, nullptr, aSrc); } void SetSrc(const nsAString& aSrc, nsIPrincipal& aTriggeringPrincipal, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::src, aSrc, aTriggeringPrincipal, aRv); } void GetType(nsAString& aType) { GetHTMLAttr(nsGkAtoms::type, aType); } void SetType(const nsAString& aType, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::type, aType, aRv); } void GetHtmlFor(nsAString& aHtmlFor) { GetHTMLAttr(nsGkAtoms::_for, aHtmlFor); } void SetHtmlFor(const nsAString& aHtmlFor, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::_for, aHtmlFor, aRv); } void GetEvent(nsAString& aEvent) { GetHTMLAttr(nsGkAtoms::event, aEvent); } void SetEvent(const nsAString& aEvent, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::event, aEvent, aRv); } bool Async() { return mForceAsync || GetBoolAttr(nsGkAtoms::async); } void SetAsync(bool aValue, ErrorResult& aRv) { mForceAsync = false; SetHTMLBoolAttr(nsGkAtoms::async, aValue, aRv); } bool NoModule() { return GetBoolAttr(nsGkAtoms::nomodule); } void SetNoModule(bool aValue, ErrorResult& aRv) { SetHTMLBoolAttr(nsGkAtoms::nomodule, aValue, aRv); } void GetCrossOrigin(nsAString& aResult) { // Null for both missing and invalid defaults is ok, since we Loading @@ -90,18 +156,19 @@ public: { GetHTMLAttr(nsGkAtoms::integrity, aIntegrity); } void SetIntegrity(const nsAString& aIntegrity, ErrorResult& rv) void SetIntegrity(const nsAString& aIntegrity, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::integrity, aIntegrity, rv); SetHTMLAttr(nsGkAtoms::integrity, aIntegrity, aRv); } bool Async(); void SetAsync(bool aValue, ErrorResult& rv); bool NoModule(); void SetNoModule(bool aValue, ErrorResult& rv); protected: virtual ~HTMLScriptElement(); virtual bool GetAsyncState() override { return Async(); } virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override; // ScriptElement Loading dom/interfaces/html/moz.build +0 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ XPIDL_SOURCES += [ 'nsIDOMHTMLHtmlElement.idl', 'nsIDOMHTMLInputElement.idl', 'nsIDOMHTMLMediaElement.idl', 'nsIDOMHTMLScriptElement.idl', 'nsIDOMMozBrowserFrame.idl', 'nsIDOMTimeRanges.idl', 'nsIDOMValidityState.idl', Loading dom/interfaces/html/nsIDOMHTMLScriptElement.idldeleted 100644 → 0 +0 −31 Original line number Diff line number Diff line /* -*- 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/. */ #include "nsIDOMHTMLElement.idl" /** * The nsIDOMHTMLScriptElement interface is the interface to a [X]HTML * script element. * * This interface is trying to follow the DOM Level 2 HTML specification: * http://www.w3.org/TR/DOM-Level-2-HTML/ * * with changes from the work-in-progress WHATWG HTML specification: * http://www.whatwg.org/specs/web-apps/current-work/ */ [uuid(fe96dc1c-40e4-4974-9354-e3fce663c3d5)] interface nsIDOMHTMLScriptElement : nsISupports { attribute DOMString src; attribute boolean async; attribute boolean defer; attribute DOMString type; attribute DOMString charset; attribute DOMString text; attribute DOMString htmlFor; attribute DOMString event; }; dom/script/ScriptLoader.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ #include "nsICacheInfoChannel.h" #include "nsITimedChannel.h" #include "nsIScriptElement.h" #include "nsIDOMHTMLScriptElement.h" #include "nsIDocShell.h" #include "nsContentUtils.h" #include "nsUnicharUtils.h" Loading Loading
dom/html/HTMLScriptElement.cpp +18 −122 Original line number Diff line number Diff line Loading @@ -48,7 +48,6 @@ HTMLScriptElement::~HTMLScriptElement() } NS_IMPL_ISUPPORTS_INHERITED(HTMLScriptElement, nsGenericHTMLElement, nsIDOMHTMLScriptElement, nsIScriptLoaderObserver, nsIScriptElement, nsIMutationObserver) Loading Loading @@ -115,123 +114,6 @@ HTMLScriptElement::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult, return NS_OK; } NS_IMETHODIMP HTMLScriptElement::GetText(nsAString& aValue) { if (!nsContentUtils::GetNodeTextContent(this, false, aValue, fallible)) { return NS_ERROR_OUT_OF_MEMORY; } return NS_OK; } NS_IMETHODIMP HTMLScriptElement::SetText(const nsAString& aValue) { ErrorResult rv; SetText(aValue, rv); return rv.StealNSResult(); } void HTMLScriptElement::SetText(const nsAString& aValue, ErrorResult& rv) { rv = nsContentUtils::SetNodeTextContent(this, aValue, true); } NS_IMPL_STRING_ATTR(HTMLScriptElement, Charset, charset) NS_IMPL_BOOL_ATTR(HTMLScriptElement, Defer, defer) // If this ever gets changed to return "" if the attr value is "" (see // https://github.com/whatwg/html/issues/1739 for why it might not get changed), // it may be worth it to use GetSrc instead of GetAttr and manual // NewURIWithDocumentCharset in FreezeUriAsyncDefer. NS_IMPL_URI_ATTR(HTMLScriptElement, Src, src) NS_IMPL_STRING_ATTR(HTMLScriptElement, Type, type) NS_IMPL_STRING_ATTR(HTMLScriptElement, HtmlFor, _for) NS_IMPL_STRING_ATTR(HTMLScriptElement, Event, event) void HTMLScriptElement::SetCharset(const nsAString& aCharset, ErrorResult& rv) { SetHTMLAttr(nsGkAtoms::charset, aCharset, rv); } void HTMLScriptElement::SetDefer(bool aDefer, ErrorResult& rv) { SetHTMLBoolAttr(nsGkAtoms::defer, aDefer, rv); } bool HTMLScriptElement::Defer() { return GetBoolAttr(nsGkAtoms::defer); } void HTMLScriptElement::SetSrc(const nsAString& aSrc, nsIPrincipal& aTriggeringPrincipal, ErrorResult& rv) { SetHTMLAttr(nsGkAtoms::src, aSrc, aTriggeringPrincipal, rv); } void HTMLScriptElement::SetType(const nsAString& aType, ErrorResult& rv) { SetHTMLAttr(nsGkAtoms::type, aType, rv); } void HTMLScriptElement::SetHtmlFor(const nsAString& aHtmlFor, ErrorResult& rv) { SetHTMLAttr(nsGkAtoms::_for, aHtmlFor, rv); } void HTMLScriptElement::SetEvent(const nsAString& aEvent, ErrorResult& rv) { SetHTMLAttr(nsGkAtoms::event, aEvent, rv); } nsresult HTMLScriptElement::GetAsync(bool* aValue) { *aValue = Async(); return NS_OK; } bool HTMLScriptElement::Async() { return mForceAsync || GetBoolAttr(nsGkAtoms::async); } nsresult HTMLScriptElement::SetAsync(bool aValue) { ErrorResult rv; SetAsync(aValue, rv); return rv.StealNSResult(); } void HTMLScriptElement::SetAsync(bool aValue, ErrorResult& rv) { mForceAsync = false; SetHTMLBoolAttr(nsGkAtoms::async, aValue, rv); } bool HTMLScriptElement::NoModule() { return GetBoolAttr(nsGkAtoms::nomodule); } void HTMLScriptElement::SetNoModule(bool aValue, ErrorResult& aRv) { SetHTMLBoolAttr(nsGkAtoms::nomodule, aValue, aRv); } nsresult HTMLScriptElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, Loading Loading @@ -269,6 +151,20 @@ HTMLScriptElement::SetInnerHTML(const nsAString& aInnerHTML, aError = nsContentUtils::SetNodeTextContent(this, aInnerHTML, true); } void HTMLScriptElement::GetText(nsAString& aValue, ErrorResult& aRv) { if (!nsContentUtils::GetNodeTextContent(this, false, aValue, fallible)) { aRv.Throw(NS_ERROR_OUT_OF_MEMORY); } } void HTMLScriptElement::SetText(const nsAString& aValue, ErrorResult& aRv) { aRv = nsContentUtils::SetNodeTextContent(this, aValue, true); } // variation of this code in nsSVGScriptElement - check if changes // need to be transfered when modifying Loading @@ -281,7 +177,8 @@ HTMLScriptElement::GetScriptType(nsAString& type) void HTMLScriptElement::GetScriptText(nsAString& text) { GetText(text); IgnoredErrorResult rv; GetText(text, rv); } void Loading Loading @@ -330,9 +227,8 @@ HTMLScriptElement::FreezeUriAsyncDefer() // At this point mUri will be null for invalid URLs. mExternal = true; bool defer, async; GetAsync(&async); GetDefer(&defer); bool async = Async(); bool defer = Defer(); mDefer = !async && defer; mAsync = async; Loading
dom/html/HTMLScriptElement.h +88 −21 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ #ifndef mozilla_dom_HTMLScriptElement_h #define mozilla_dom_HTMLScriptElement_h #include "nsIDOMHTMLScriptElement.h" #include "nsGenericHTMLElement.h" #include "mozilla/Attributes.h" #include "mozilla/dom/ScriptElement.h" Loading @@ -16,7 +15,6 @@ namespace mozilla { namespace dom { class HTMLScriptElement final : public nsGenericHTMLElement, public nsIDOMHTMLScriptElement, public ScriptElement { public: Loading @@ -33,9 +31,6 @@ public: virtual void SetInnerHTML(const nsAString& aInnerHTML, mozilla::ErrorResult& aError) override; // nsIDOMHTMLScriptElement NS_DECL_NSIDOMHTMLSCRIPTELEMENT // nsIScriptElement virtual bool GetScriptType(nsAString& type) override; virtual void GetScriptText(nsAString& text) override; Loading Loading @@ -63,18 +58,89 @@ public: bool aNotify) override; // WebIDL void SetText(const nsAString& aValue, ErrorResult& rv); void SetCharset(const nsAString& aCharset, ErrorResult& rv); void SetDefer(bool aDefer, ErrorResult& rv); bool Defer(); void SetSrc(const nsAString& aSrc, nsIPrincipal& aTriggeringPrincipal, ErrorResult& rv); void GetSrc(nsString& aSrc, nsIPrincipal&) void GetText(nsAString& aValue, ErrorResult& aRv); void SetText(const nsAString& aValue, ErrorResult& aRv); void GetCharset(nsAString& aCharset) { GetHTMLAttr(nsGkAtoms::charset, aCharset); } void SetCharset(const nsAString& aCharset, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::charset, aCharset, aRv); } bool Defer() { return GetBoolAttr(nsGkAtoms::defer); } void SetDefer(bool aDefer, ErrorResult& aRv) { SetHTMLBoolAttr(nsGkAtoms::defer, aDefer, aRv); } void GetSrc(nsAString& aSrc, nsIPrincipal&) { GetSrc(aSrc); }; void SetType(const nsAString& aType, ErrorResult& rv); void SetHtmlFor(const nsAString& aHtmlFor, ErrorResult& rv); void SetEvent(const nsAString& aEvent, ErrorResult& rv); } void GetSrc(nsAString& aSrc) { GetURIAttr(nsGkAtoms::src, nullptr, aSrc); } void SetSrc(const nsAString& aSrc, nsIPrincipal& aTriggeringPrincipal, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::src, aSrc, aTriggeringPrincipal, aRv); } void GetType(nsAString& aType) { GetHTMLAttr(nsGkAtoms::type, aType); } void SetType(const nsAString& aType, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::type, aType, aRv); } void GetHtmlFor(nsAString& aHtmlFor) { GetHTMLAttr(nsGkAtoms::_for, aHtmlFor); } void SetHtmlFor(const nsAString& aHtmlFor, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::_for, aHtmlFor, aRv); } void GetEvent(nsAString& aEvent) { GetHTMLAttr(nsGkAtoms::event, aEvent); } void SetEvent(const nsAString& aEvent, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::event, aEvent, aRv); } bool Async() { return mForceAsync || GetBoolAttr(nsGkAtoms::async); } void SetAsync(bool aValue, ErrorResult& aRv) { mForceAsync = false; SetHTMLBoolAttr(nsGkAtoms::async, aValue, aRv); } bool NoModule() { return GetBoolAttr(nsGkAtoms::nomodule); } void SetNoModule(bool aValue, ErrorResult& aRv) { SetHTMLBoolAttr(nsGkAtoms::nomodule, aValue, aRv); } void GetCrossOrigin(nsAString& aResult) { // Null for both missing and invalid defaults is ok, since we Loading @@ -90,18 +156,19 @@ public: { GetHTMLAttr(nsGkAtoms::integrity, aIntegrity); } void SetIntegrity(const nsAString& aIntegrity, ErrorResult& rv) void SetIntegrity(const nsAString& aIntegrity, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::integrity, aIntegrity, rv); SetHTMLAttr(nsGkAtoms::integrity, aIntegrity, aRv); } bool Async(); void SetAsync(bool aValue, ErrorResult& rv); bool NoModule(); void SetNoModule(bool aValue, ErrorResult& rv); protected: virtual ~HTMLScriptElement(); virtual bool GetAsyncState() override { return Async(); } virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override; // ScriptElement Loading
dom/interfaces/html/moz.build +0 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ XPIDL_SOURCES += [ 'nsIDOMHTMLHtmlElement.idl', 'nsIDOMHTMLInputElement.idl', 'nsIDOMHTMLMediaElement.idl', 'nsIDOMHTMLScriptElement.idl', 'nsIDOMMozBrowserFrame.idl', 'nsIDOMTimeRanges.idl', 'nsIDOMValidityState.idl', Loading
dom/interfaces/html/nsIDOMHTMLScriptElement.idldeleted 100644 → 0 +0 −31 Original line number Diff line number Diff line /* -*- 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/. */ #include "nsIDOMHTMLElement.idl" /** * The nsIDOMHTMLScriptElement interface is the interface to a [X]HTML * script element. * * This interface is trying to follow the DOM Level 2 HTML specification: * http://www.w3.org/TR/DOM-Level-2-HTML/ * * with changes from the work-in-progress WHATWG HTML specification: * http://www.whatwg.org/specs/web-apps/current-work/ */ [uuid(fe96dc1c-40e4-4974-9354-e3fce663c3d5)] interface nsIDOMHTMLScriptElement : nsISupports { attribute DOMString src; attribute boolean async; attribute boolean defer; attribute DOMString type; attribute DOMString charset; attribute DOMString text; attribute DOMString htmlFor; attribute DOMString event; };
dom/script/ScriptLoader.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ #include "nsICacheInfoChannel.h" #include "nsITimedChannel.h" #include "nsIScriptElement.h" #include "nsIDOMHTMLScriptElement.h" #include "nsIDocShell.h" #include "nsContentUtils.h" #include "nsUnicharUtils.h" Loading