mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 23:23:33 +00:00
Bug 1415747 - Remove nsIDOMHTMLScriptElement; r=bz
MozReview-Commit-ID: 3I7qVTsKFJC
This commit is contained in:
parent
ebd39f9ce0
commit
f25f505bc5
@ -48,7 +48,6 @@ HTMLScriptElement::~HTMLScriptElement()
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(HTMLScriptElement, nsGenericHTMLElement,
|
||||
nsIDOMHTMLScriptElement,
|
||||
nsIScriptLoaderObserver,
|
||||
nsIScriptElement,
|
||||
nsIMutationObserver)
|
||||
@ -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,
|
||||
@ -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
|
||||
|
||||
@ -281,7 +177,8 @@ HTMLScriptElement::GetScriptType(nsAString& type)
|
||||
void
|
||||
HTMLScriptElement::GetScriptText(nsAString& text)
|
||||
{
|
||||
GetText(text);
|
||||
IgnoredErrorResult rv;
|
||||
GetText(text, rv);
|
||||
}
|
||||
|
||||
void
|
||||
@ -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;
|
||||
|
@ -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"
|
||||
@ -16,7 +15,6 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class HTMLScriptElement final : public nsGenericHTMLElement,
|
||||
public nsIDOMHTMLScriptElement,
|
||||
public ScriptElement
|
||||
{
|
||||
public:
|
||||
@ -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;
|
||||
@ -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
|
||||
@ -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
|
||||
|
@ -16,7 +16,6 @@ XPIDL_SOURCES += [
|
||||
'nsIDOMHTMLHtmlElement.idl',
|
||||
'nsIDOMHTMLInputElement.idl',
|
||||
'nsIDOMHTMLMediaElement.idl',
|
||||
'nsIDOMHTMLScriptElement.idl',
|
||||
'nsIDOMMozBrowserFrame.idl',
|
||||
'nsIDOMTimeRanges.idl',
|
||||
'nsIDOMValidityState.idl',
|
||||
|
@ -1,31 +0,0 @@
|
||||
/* -*- 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;
|
||||
};
|
@ -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"
|
||||
|
@ -13,8 +13,8 @@
|
||||
#include "nsIScriptLoaderObserver.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsIDOMHTMLScriptElement.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
|
||||
#define NS_ISCRIPTELEMENT_IID \
|
||||
@ -152,12 +152,7 @@ public:
|
||||
mUri = nullptr;
|
||||
mCreatorParser = nullptr;
|
||||
mParserCreated = mozilla::dom::NOT_FROM_PARSER;
|
||||
bool async = false;
|
||||
nsCOMPtr<nsIDOMHTMLScriptElement> htmlScript = do_QueryInterface(this);
|
||||
if (htmlScript) {
|
||||
htmlScript->GetAsync(&async);
|
||||
}
|
||||
mForceAsync = !async;
|
||||
mForceAsync = !GetAsyncState();
|
||||
}
|
||||
|
||||
void SetCreatorParser(nsIParser* aParser)
|
||||
@ -270,6 +265,12 @@ protected:
|
||||
*/
|
||||
virtual bool MaybeProcessScript() = 0;
|
||||
|
||||
/**
|
||||
* Since we've removed the XPCOM interface to HTML elements, we need a way to
|
||||
* retreive async state from script elements without bringing the type in.
|
||||
*/
|
||||
virtual bool GetAsyncState() = 0;
|
||||
|
||||
/**
|
||||
* The start line number of the script.
|
||||
*/
|
||||
|
@ -79,6 +79,13 @@ protected:
|
||||
|
||||
virtual StringAttributesInfo GetStringInfo() override;
|
||||
|
||||
// SVG Script elements don't have the ability to set async properties on
|
||||
// themselves, so this will always return false.
|
||||
virtual bool GetAsyncState() override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
enum { HREF, XLINK_HREF };
|
||||
nsSVGString mStringAttributes[2];
|
||||
static StringInfo sStringInfo[2];
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMHTMLMediaElement.h"
|
||||
#include "nsIDOMHTMLScriptElement.h"
|
||||
#include "nsIDOMMozNamedAttrMap.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeFilter.h"
|
||||
@ -514,8 +513,7 @@ ResourceReader::OnWalkDOMNode(nsIDOMNode* aNode)
|
||||
return OnWalkAttribute(aNode, "background");
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLScriptElement> nodeAsScript = do_QueryInterface(aNode);
|
||||
if (nodeAsScript) {
|
||||
if (content->IsHTMLElement(nsGkAtoms::script)) {
|
||||
return OnWalkAttribute(aNode, "src");
|
||||
}
|
||||
|
||||
@ -1031,8 +1029,7 @@ PersistNodeFixup::FixupNode(nsIDOMNode *aNodeIn,
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLScriptElement> nodeAsScript = do_QueryInterface(aNodeIn);
|
||||
if (nodeAsScript) {
|
||||
if (content->IsHTMLElement(nsGkAtoms::script)) {
|
||||
rv = GetNodeToFixup(aNodeIn, aNodeOut);
|
||||
if (NS_SUCCEEDED(rv) && *aNodeOut) {
|
||||
FixupAttribute(*aNodeOut, "src");
|
||||
|
@ -24,7 +24,7 @@ interface HTMLScriptElement : HTMLElement {
|
||||
attribute boolean defer;
|
||||
[CEReactions, SetterThrows]
|
||||
attribute DOMString? crossOrigin;
|
||||
[CEReactions, SetterThrows]
|
||||
[CEReactions, Throws]
|
||||
attribute DOMString text;
|
||||
};
|
||||
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMHTMLScriptElement.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIEditRules.h"
|
||||
|
@ -53,7 +53,6 @@
|
||||
#include "nsIDOMHTMLHtmlElement.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMHTMLMediaElement.h"
|
||||
#include "nsIDOMHTMLScriptElement.h"
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIDOMMediaList.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
@ -152,7 +151,6 @@
|
||||
#include "mozilla/dom/HTMLHtmlElementBinding.h"
|
||||
#include "mozilla/dom/HTMLInputElementBinding.h"
|
||||
#include "mozilla/dom/HTMLMediaElementBinding.h"
|
||||
#include "mozilla/dom/HTMLScriptElementBinding.h"
|
||||
#include "mozilla/dom/KeyEventBinding.h"
|
||||
#include "mozilla/dom/ListBoxObjectBinding.h"
|
||||
#include "mozilla/dom/MediaListBinding.h"
|
||||
@ -303,7 +301,6 @@ const ComponentsInterfaceShimEntry kComponentsInterfaceShimMap[] =
|
||||
DEFINE_SHIM(HTMLHtmlElement),
|
||||
DEFINE_SHIM(HTMLInputElement),
|
||||
DEFINE_SHIM(HTMLMediaElement),
|
||||
DEFINE_SHIM(HTMLScriptElement),
|
||||
DEFINE_SHIM(KeyEvent),
|
||||
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIListBoxObject, ListBoxObject),
|
||||
DEFINE_SHIM(MediaList),
|
||||
|
Loading…
x
Reference in New Issue
Block a user