Fix for bug 821606 (Turn on WebIDL bindings for Element and HTMLElement). r=bz.

--HG--
extra : rebase_source : f85002d801871a3a99c1b8bc121509ae87d2f665
This commit is contained in:
Peter Van der Beken 2012-11-22 12:09:57 +01:00
parent 28e38bbdf3
commit f931ddad9f
14 changed files with 76 additions and 27 deletions

View File

@ -9,6 +9,7 @@
#include "nsGenericHTMLElement.h"
#include "nsStyleConsts.h"
#include "nsMappedAttributes.h"
#include "mozilla/dom/HTMLDivElementBinding.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -19,6 +20,7 @@ NS_IMPL_NS_NEW_HTML_ELEMENT(Div)
nsHTMLDivElement::nsHTMLDivElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
{
SetIsDOMBinding();
}
nsHTMLDivElement::~nsHTMLDivElement()
@ -40,6 +42,11 @@ NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLDivElement)
NS_IMPL_ELEMENT_CLONE(nsHTMLDivElement)
JSObject*
nsHTMLDivElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return dom::HTMLDivElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
bool
nsHTMLDivElement::ParseAttribute(int32_t aNamespaceID,

View File

@ -8,8 +8,8 @@
#include "nsGenericHTMLElement.h"
#include "nsIDOMHTMLDivElement.h"
class nsHTMLDivElement : public nsGenericHTMLElement,
public nsIDOMHTMLDivElement
class nsHTMLDivElement MOZ_FINAL : public nsGenericHTMLElement,
public nsIDOMHTMLDivElement
{
public:
nsHTMLDivElement(already_AddRefed<nsINodeInfo> aNodeInfo);
@ -61,6 +61,10 @@ public:
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
protected:
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
bool *aTriedToWrap) MOZ_OVERRIDE;
};
#endif /* nsHTMLDivElement_h___ */

View File

@ -7,6 +7,7 @@
#include "nsIDOMHTMLElement.h"
#include "nsContentUtils.h"
#include "mozilla/dom/HTMLElementBinding.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -38,6 +39,10 @@ public:
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
protected:
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
bool *aTriedToWrap) MOZ_OVERRIDE;
};
// Here, we expand 'NS_IMPL_NS_NEW_HTML_ELEMENT()' by hand.
@ -52,6 +57,7 @@ NS_NewHTMLElement(already_AddRefed<nsINodeInfo> aNodeInfo,
nsHTMLElement::nsHTMLElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
{
SetIsDOMBinding();
}
nsHTMLElement::~nsHTMLElement()
@ -90,3 +96,8 @@ nsHTMLElement::GetInnerHTML(nsAString& aInnerHTML, ErrorResult& aError)
nsGenericHTMLElement::GetInnerHTML(aInnerHTML, aError);
}
JSObject*
nsHTMLElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return dom::HTMLElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}

View File

@ -4,12 +4,20 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsHTMLUnknownElement.h"
#include "mozilla/dom/HTMLElementBinding.h"
using namespace mozilla::dom;
NS_IMPL_ADDREF_INHERITED(nsHTMLUnknownElement, Element)
NS_IMPL_RELEASE_INHERITED(nsHTMLUnknownElement, Element)
JSObject*
nsHTMLUnknownElement::WrapNode(JSContext *aCx, JSObject *aScope,
bool *aTriedToWrap)
{
return HTMLUnknownElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
NS_IMPL_NS_NEW_HTML_ELEMENT(Unknown)
DOMCI_NODE_DATA(HTMLUnknownElement, nsHTMLUnknownElement)

View File

@ -8,13 +8,14 @@
#include "nsGenericHTMLElement.h"
#include "nsIDOMHTMLUnknownElement.h"
class nsHTMLUnknownElement : public nsGenericHTMLElement
, public nsIDOMHTMLUnknownElement
class nsHTMLUnknownElement MOZ_FINAL : public nsGenericHTMLElement
, public nsIDOMHTMLUnknownElement
{
public:
nsHTMLUnknownElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
{
SetIsDOMBinding();
if (NodeInfo()->Equals(nsGkAtoms::bdi)) {
SetHasDirAuto();
}
@ -37,6 +38,10 @@ public:
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
protected:
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
bool *aTriedToWrap) MOZ_OVERRIDE;
};
#endif /* nsHTMLUnknownElement_h___ */

View File

@ -41,8 +41,7 @@ function HTML_TAG(aTagName, aImplClass) {
// inherit from them do.
interfacesNonClassinfo[aTagName] =
[ "nsIDOMNode",
"nsIDOMElement",
"nsISupportsWeakReference" ];
"nsIDOMElement" ];
var interfaceName = "nsIDOM" + getClassName(aTagName);
if (interfaceName in SpecialPowers.Ci) { // no nsIDOMHTMLSpanElement

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsXMLElement.h"
#include "mozilla/dom/ElementBinding.h"
#include "nsContentUtils.h" // nsAutoScriptBlocker
using namespace mozilla::dom;
@ -31,6 +32,12 @@ NS_ELEMENT_INTERFACE_MAP_END
NS_IMPL_ADDREF_INHERITED(nsXMLElement, Element)
NS_IMPL_RELEASE_INHERITED(nsXMLElement, Element)
JSObject*
nsXMLElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return ElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
NS_IMPL_ELEMENT_CLONE(nsXMLElement)
nsresult

View File

@ -16,6 +16,7 @@ public:
nsXMLElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: mozilla::dom::Element(aNodeInfo)
{
SetIsDOMBinding();
}
// nsISupports
@ -51,7 +52,9 @@ public:
// Element overrides
virtual void NodeInfoChanged(nsINodeInfo* aOldNodeInfo);
protected:
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
bool *aTriedToWrap) MOZ_OVERRIDE;
};
#endif // nsXMLElement_h___

View File

@ -213,7 +213,6 @@ DOMInterfaces = {
'Element': {
'hasXPConnectImpls': True,
'register': False,
'hasInstanceInterface': 'nsIDOMElement',
'resultNotAddRefed': [
'classList', 'attributes', 'children', 'firstElementChild',
@ -277,9 +276,12 @@ DOMInterfaces = {
'resultNotAddRefed': [ 'item' ]
},
'HTMLDivElement': {
'nativeType': 'nsHTMLDivElement'
},
'HTMLElement': {
'nativeType': 'nsGenericHTMLElement',
'register': False,
'hasXPConnectImpls': True,
'hasInstanceInterface': 'nsIDOMHTMLElement',
'resultNotAddRefed': [
@ -303,9 +305,7 @@ DOMInterfaces = {
},
'HTMLUnknownElement': {
'nativeType': 'nsHTMLUnknownElement',
'register': False,
'hasXPConnectImpls': True
'nativeType': 'nsHTMLUnknownElement'
},
'IID': [

View File

@ -139,17 +139,14 @@
"EventTarget interface: calling addEventListener(DOMString,EventListener,boolean) on document.doctype with too few arguments must throw TypeError": true,
"EventTarget interface: calling removeEventListener(DOMString,EventListener,boolean) on document.doctype with too few arguments must throw TypeError": true,
"EventTarget interface: calling dispatchEvent(Event) on document.doctype with too few arguments must throw TypeError": true,
"Element interface: existence and properties of interface object": true,
"Element interface: existence and properties of interface prototype object": true,
"Element interface: existence and properties of interface prototype object's \"constructor\" property": true,
"Element interface: attribute namespaceURI": true,
"Element interface: attribute prefix": true,
"Element interface: attribute localName": true,
"Element interface: attribute attributes": true,
"Element interface: attribute className": true,
"Element interface: operation remove()": true,
"Stringification of element": "debug",
"Element interface: element must inherit property \"className\" with the proper type (5)": true,
"Element interface: element must inherit property \"remove\" with the proper type (25)": true,
"EventTarget interface: calling addEventListener(DOMString,EventListener,boolean) on element with too few arguments must throw TypeError": true,
"EventTarget interface: calling removeEventListener(DOMString,EventListener,boolean) on element with too few arguments must throw TypeError": true,
"EventTarget interface: calling dispatchEvent(Event) on element with too few arguments must throw TypeError": true,
"Attr interface: existence and properties of interface object": true,
"Attr interface: existence and properties of interface prototype object": true,
"Attr interface: existence and properties of interface prototype object's \"constructor\" property": true,

View File

@ -24,10 +24,9 @@ is(Object.getPrototypeOf(HTMLElement.prototype), Element.prototype,
is(Object.getPrototypeOf(document.createElementNS(null, "x")),
Element.prototype,
"Must have correct proto chain for random element");
// Todo because of HTMLUnknownElement
todo_is(Object.getPrototypeOf(document.createElement("noSuchElementName")),
HTMLElement.prototype,
"Must have correct proto chain for random HTML element");
is(Object.getPrototypeOf(document.createElement("noSuchElementName")),
HTMLUnknownElement.prototype,
"Must have correct proto chain for random HTML element");
// And check that it's really working as it should
function checkPropPresent(propName, objList, expected)

View File

@ -201,7 +201,6 @@ interface HTMLElement : Element {
// FIXME Bug 810677 Move className from HTMLElement to Element
attribute DOMString className;
/* Commented out for now because our quickstub setup doesn't handle calling PreEnabled() on our interface, which is what sets up the .expose pref here
[SetterThrows,Pref="dom.w3c_touch_events.expose"]
attribute EventHandler ontouchstart;
[SetterThrows,Pref="dom.w3c_touch_events.expose"]
@ -213,7 +212,7 @@ interface HTMLElement : Element {
[SetterThrows,Pref="dom.w3c_touch_events.expose"]
attribute EventHandler ontouchleave;
[SetterThrows,Pref="dom.w3c_touch_events.expose"]
attribute EventHandler ontouchcancel;*/
attribute EventHandler ontouchcancel;
[SetterThrows]
attribute EventHandler oncopy;

View File

@ -44,6 +44,7 @@ webidl_files = \
Function.webidl \
GainNode.webidl \
HTMLCollection.webidl \
HTMLDivElement.webidl \
HTMLElement.webidl \
HTMLOptionsCollection.webidl \
HTMLPropertiesCollection.webidl \

View File

@ -17,6 +17,10 @@
#include "nsHTMLDocument.h"
#include "nsICSSDeclaration.h"
#include "nsSVGStylableElement.h"
#include "mozilla/dom/EventTargetBinding.h"
#include "mozilla/dom/NodeBinding.h"
#include "mozilla/dom/ElementBinding.h"
#include "mozilla/dom/HTMLElementBinding.h"
template<class T>
struct ProtoIDAndDepth
@ -27,17 +31,22 @@ struct ProtoIDAndDepth
};
};
#define NEW_BINDING(_native) \
#define NEW_BINDING(_native, _id) \
template<> \
struct ProtoIDAndDepth<_native> \
{ \
enum { \
PrototypeID = mozilla::dom::PrototypeIDMap<_native>::PrototypeID, \
PrototypeID = mozilla::dom::prototypes::id::_id, \
Depth = mozilla::dom::PrototypeTraits< \
static_cast<mozilla::dom::prototypes::ID>(PrototypeID)>::Depth \
}; \
}
NEW_BINDING(mozilla::dom::EventTarget, EventTarget);
NEW_BINDING(nsINode, Node);
NEW_BINDING(mozilla::dom::Element, Element);
NEW_BINDING(nsGenericHTMLElement, HTMLElement);
#define DEFINE_UNWRAP_CAST(_interface, _base, _bit) \
template <> \
MOZ_ALWAYS_INLINE JSBool \