mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-22 10:27:03 +00:00
Bug 826947: Convert HTMLScriptElement to WebIDL r=bz
This commit is contained in:
parent
5a24a8b725
commit
4bbe6e8a41
@ -4,12 +4,10 @@
|
||||
* 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 "nsIDOMHTMLScriptElement.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsScriptElement.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsContentUtils.h"
|
||||
@ -24,6 +22,7 @@
|
||||
#include "nsTArray.h"
|
||||
#include "nsDOMJSUtils.h"
|
||||
#include "mozilla/dom/HTMLScriptElement.h"
|
||||
#include "mozilla/dom/HTMLScriptElementBinding.h"
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Script)
|
||||
|
||||
@ -32,11 +31,18 @@ DOMCI_NODE_DATA(HTMLScriptElement, mozilla::dom::HTMLScriptElement)
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
JSObject*
|
||||
HTMLScriptElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
|
||||
{
|
||||
return HTMLScriptElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
|
||||
}
|
||||
|
||||
HTMLScriptElement::HTMLScriptElement(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
FromParser aFromParser)
|
||||
: nsGenericHTMLElement(aNodeInfo)
|
||||
, nsScriptElement(aFromParser)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
AddMutationObserver(this);
|
||||
}
|
||||
|
||||
@ -127,7 +133,15 @@ HTMLScriptElement::GetText(nsAString& aValue)
|
||||
NS_IMETHODIMP
|
||||
HTMLScriptElement::SetText(const nsAString& aValue)
|
||||
{
|
||||
return nsContentUtils::SetNodeTextContent(this, aValue, true);
|
||||
ErrorResult rv;
|
||||
SetText(aValue, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
HTMLScriptElement::SetText(const nsAString& aValue, ErrorResult& rv)
|
||||
{
|
||||
rv = nsContentUtils::SetNodeTextContent(this, aValue, true);
|
||||
}
|
||||
|
||||
|
||||
@ -139,18 +153,80 @@ NS_IMPL_STRING_ATTR(HTMLScriptElement, HtmlFor, _for)
|
||||
NS_IMPL_STRING_ATTR(HTMLScriptElement, Event, event)
|
||||
NS_IMPL_STRING_ATTR(HTMLScriptElement, CrossOrigin, crossorigin)
|
||||
|
||||
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, ErrorResult& rv)
|
||||
{
|
||||
rv = SetAttrHelper(nsGkAtoms::src, aSrc);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
HTMLScriptElement::SetCrossOrigin(const nsAString& aCrossOrigin, ErrorResult& rv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::crossorigin, aCrossOrigin, rv);
|
||||
}
|
||||
|
||||
nsresult
|
||||
HTMLScriptElement::GetAsync(bool* aValue)
|
||||
{
|
||||
*aValue = mForceAsync || GetBoolAttr(nsGkAtoms::async);
|
||||
*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.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
HTMLScriptElement::SetAsync(bool aValue, ErrorResult& rv)
|
||||
{
|
||||
mForceAsync = false;
|
||||
return SetBoolAttr(nsGkAtoms::async, aValue);
|
||||
SetHTMLBoolAttr(nsGkAtoms::async, aValue, rv);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -7,6 +7,8 @@
|
||||
#ifndef mozilla_dom_HTMLScriptElement_h
|
||||
#define mozilla_dom_HTMLScriptElement_h
|
||||
|
||||
#include "nsIDOMHTMLScriptElement.h"
|
||||
#include "nsScriptElement.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
@ -70,7 +72,23 @@ public:
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() { return this; }
|
||||
|
||||
// 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, ErrorResult& rv);
|
||||
void SetType(const nsAString& aType, ErrorResult& rv);
|
||||
void SetHtmlFor(const nsAString& aHtmlFor, ErrorResult& rv);
|
||||
void SetEvent(const nsAString& aEvent, ErrorResult& rv);
|
||||
void SetCrossOrigin(const nsAString& aCrossOrigin, ErrorResult& rv);
|
||||
bool Async();
|
||||
void SetAsync(bool aValue, ErrorResult& rv);
|
||||
|
||||
protected:
|
||||
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
|
||||
bool *aTriedToWrap) MOZ_OVERRIDE;
|
||||
// nsScriptElement
|
||||
virtual bool HasScriptContent();
|
||||
};
|
||||
|
@ -63,7 +63,6 @@ function reflectString(aParameters)
|
||||
img: [ "align" ],
|
||||
input: [ "accept", "alt", "formTarget", "max", "min", "name", "pattern", "placeholder", "step", "defaultValue" ],
|
||||
link: [ "crossOrigin" ],
|
||||
script: [ "crossOrigin" ],
|
||||
source: [ "media" ],
|
||||
table: [ "border", "width" ],
|
||||
tbody: [ "align", "vAlign", "ch" ],
|
||||
|
@ -195,7 +195,7 @@ HTML_TAG("pre", "Pre");
|
||||
HTML_TAG("q", "Quote");
|
||||
HTML_TAG("s", "");
|
||||
HTML_TAG("samp", "");
|
||||
HTML_TAG("script", "Script", [], [ "nsIScriptLoaderObserver" ]);
|
||||
HTML_TAG("script", "Script", [ "nsIScriptLoaderObserver" ], []);
|
||||
HTML_TAG("section", "")
|
||||
HTML_TAG("select", "Select", ["nsIDOMHTMLSelectElement"]);
|
||||
HTML_TAG("small", "");
|
||||
|
@ -2750,6 +2750,7 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(HTMLScriptElement, nsIDOMHTMLScriptElement)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIScriptLoaderObserver)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLScriptElement)
|
||||
DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
@ -418,6 +418,10 @@ DOMInterfaces = {
|
||||
'resultNotAddRefed': [ 'item', 'namedItem', 'names' ]
|
||||
},
|
||||
|
||||
'HTMLScriptElement': {
|
||||
'hasInstanceInterface': 'nsIDOMHTMLScriptElement',
|
||||
},
|
||||
|
||||
'HTMLUListElement': {
|
||||
'headerFile' : 'mozilla/dom/HTMLSharedListElement.h'
|
||||
},
|
||||
|
37
dom/webidl/HTMLScriptElement.webidl
Normal file
37
dom/webidl/HTMLScriptElement.webidl
Normal file
@ -0,0 +1,37 @@
|
||||
/* -*- 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-script-element
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
|
||||
*/
|
||||
|
||||
interface HTMLScriptElement : HTMLElement {
|
||||
[SetterThrows]
|
||||
attribute DOMString src;
|
||||
[SetterThrows]
|
||||
attribute DOMString type;
|
||||
[SetterThrows]
|
||||
attribute DOMString charset;
|
||||
[SetterThrows]
|
||||
attribute boolean async;
|
||||
[SetterThrows]
|
||||
attribute boolean defer;
|
||||
[SetterThrows]
|
||||
attribute DOMString crossOrigin;
|
||||
[SetterThrows]
|
||||
attribute DOMString text;
|
||||
/*
|
||||
};
|
||||
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
|
||||
partial interface HTMLScriptElement {
|
||||
*/
|
||||
[SetterThrows]
|
||||
attribute DOMString event;
|
||||
[SetterThrows]
|
||||
attribute DOMString htmlFor;
|
||||
};
|
||||
|
@ -71,6 +71,7 @@ webidl_files = \
|
||||
HTMLParagraphElement.webidl \
|
||||
HTMLPreElement.webidl \
|
||||
HTMLPropertiesCollection.webidl \
|
||||
HTMLScriptElement.webidl \
|
||||
HTMLSpanElement.webidl \
|
||||
HTMLTitleElement.webidl \
|
||||
HTMLUListElement.webidl \
|
||||
|
Loading…
x
Reference in New Issue
Block a user