Fix for bug 814195 (Replace Element quickstubs with new binding methods). r=bz.

--HG--
extra : rebase_source : 349ceea8412f4133e1b9de4e2859d7663da27fa5
This commit is contained in:
Peter Van der Beken 2012-11-22 12:09:43 +01:00
Родитель bbe8e49a7f
Коммит c15e9ce14c
14 изменённых файлов: 49 добавлений и 282 удалений

Просмотреть файл

@ -530,7 +530,7 @@ public:
SetAttr(kNameSpaceID_None, nsGkAtoms::id, aId, true);
}
nsDOMTokenList* ClassList();
nsDOMTokenList* GetClassList();
nsDOMAttributeMap* GetAttributes()
{
nsDOMSlots *slots = DOMSlots();

Просмотреть файл

@ -447,12 +447,12 @@ Element::GetLastElementChild() const
}
nsDOMTokenList*
Element::ClassList()
Element::GetClassList()
{
Element::nsDOMSlots *slots = DOMSlots();
if (!slots->mClassList) {
nsCOMPtr<nsIAtom> classAttr = GetClassAttributeName();
nsIAtom* classAttr = GetClassAttributeName();
if (classAttr) {
slots->mClassList = new nsDOMTokenList(this, classAttr);
}
@ -464,7 +464,7 @@ Element::ClassList()
void
Element::GetClassList(nsIDOMDOMTokenList** aClassList)
{
NS_IF_ADDREF(*aClassList = ClassList());
NS_IF_ADDREF(*aClassList = GetClassList());
}
already_AddRefed<nsIHTMLCollection>

Просмотреть файл

@ -260,7 +260,7 @@ public:
virtual ~nsContentList();
// nsWrapperCache
using nsWrapperCache::GetWrapper;
using nsWrapperCache::GetWrapperPreserveColor;
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);

Просмотреть файл

@ -70,11 +70,11 @@ public:
virtual void GetSupportedNames(nsTArray<nsString>& aNames) = 0;
JSObject* GetWrapper()
JSObject* GetWrapperPreserveColor()
{
nsWrapperCache* cache;
CallQueryInterface(this, &cache);
return cache->GetWrapper();
return cache->GetWrapperPreserveColor();
}
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap) = 0;

Просмотреть файл

@ -58,7 +58,7 @@ public:
HTMLPropertiesCollection(nsGenericHTMLElement* aRoot);
virtual ~HTMLPropertiesCollection();
using nsWrapperCache::GetWrapper;
using nsWrapperCache::GetWrapperPreserveColor;
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);

Просмотреть файл

@ -48,9 +48,9 @@ function reflectString(aParameters)
* specifications, don't add it to the loop below and keep it here.
*/
element.setAttribute(contentAttr, null);
todo_is(element.getAttribute(contentAttr), "null",
is(element.getAttribute(contentAttr), "null",
"null should have been stringified to 'null'");
todo_is(element[idlAttr], "null",
is(element[idlAttr], "null",
"null should have been stringified to 'null'");
element.removeAttribute(contentAttr);
@ -423,14 +423,8 @@ function reflectBoolean(aParameters)
element.setAttribute(contentAttr, v.value);
is(element[idlAttr], true,
"IDL attribute should return always return 'true' if the content attribute has been set");
if (v.value === null) {
// bug 667856
todo(element.getAttribute(contentAttr), v.stringified,
"Content attribute should return the stringified value it has been set to.");
} else {
is(element.getAttribute(contentAttr), v.stringified,
"Content attribute should return the stringified value it has been set to.");
}
is(element.getAttribute(contentAttr), v.stringified,
"Content attribute should return the stringified value it has been set to.");
element.removeAttribute(contentAttr);
element[idlAttr] = v.value;
@ -465,7 +459,7 @@ function reflectInt(aParameters)
{
// Expected value returned by .getAttribute() when |value| has been previously passed to .setAttribute().
function expectedGetAttributeResult(value) {
return (value !== null) ? String(value) : "";
return String(value);
}
function stringToInteger(value, nonNegative, defaultValue) {

Просмотреть файл

@ -194,6 +194,20 @@ DOMInterfaces = {
}
}],
'Element': {
# 'prefable' is True because some nodes are not on new bindings yet, so the
# wrapping code for Element return values needs to fall back to XPConnect as
# needed.
'prefable': True,
'hasXPConnectImpls': True,
'hasInstanceInterface': 'nsIDOMElement',
'resultNotAddRefed': [
'classList', 'attributes', 'children', 'firstElementChild',
'lastElementChild', 'previousElementSibling', 'nextElementSibling',
'getAttributeNode', 'getAttributeNodeNS'
]
},
'Event': [
{
'workers': True,
@ -724,7 +738,6 @@ addExternalIface('CSSValue')
addExternalIface('DocumentType', nativeType='nsIDOMDocumentType')
addExternalIface('DOMStringList', nativeType='nsDOMStringList',
headerFile='nsDOMLists.h')
addExternalIface('Element', nativeType='mozilla::dom::Element')
addExternalIface('File')
addExternalIface('HitRegionOptions', nativeType='nsISupports')
addExternalIface('HTMLElement')

Просмотреть файл

@ -154,34 +154,15 @@
"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 tagName": true,
"Element interface: attribute id": true,
"Element interface: attribute namespaceURI": true,
"Element interface: attribute prefix": true,
"Element interface: attribute localName": true,
"Element interface: attribute className": true,
"Element interface: attribute classList": true,
"Element interface: attribute children": true,
"Element interface: attribute firstElementChild": true,
"Element interface: attribute lastElementChild": true,
"Element interface: attribute previousElementSibling": true,
"Element interface: attribute nextElementSibling": true,
"Element interface: attribute childElementCount": true,
"Element interface: attribute attributes": true,
"Element interface: operation remove()": true,
"Element must be primary interface of element": true,
"Stringification of element": "debug",
"Element interface: element must inherit property \"id\" with the proper type (4)": true,
"Element interface: element must inherit property \"className\" with the proper type (5)": true,
"Element interface: calling getAttribute(DOMString) on element with too few arguments must throw TypeError": true,
"Element interface: calling getAttributeNS(DOMString,DOMString) on element with too few arguments must throw TypeError": true,
"Element interface: calling setAttribute(DOMString,DOMString) on element with too few arguments must throw TypeError": true,
"Element interface: calling setAttributeNS(DOMString,DOMString,DOMString) on element with too few arguments must throw TypeError": true,
"Element interface: calling removeAttribute(DOMString) on element with too few arguments must throw TypeError": true,
"Element interface: calling removeAttributeNS(DOMString,DOMString) on element with too few arguments must throw TypeError": true,
"Element interface: calling hasAttribute(DOMString) on element with too few arguments must throw TypeError": true,
"Element interface: calling hasAttributeNS(DOMString,DOMString) on element with too few arguments must throw TypeError": true,
"Element interface: calling getElementsByTagName(DOMString) on element with too few arguments must throw TypeError": true,
"Element interface: calling getElementsByTagNameNS(DOMString,DOMString) on element with too few arguments must throw TypeError": true,
"Element interface: calling getElementsByClassName(DOMString) on element with too few arguments must throw TypeError": 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,

Просмотреть файл

@ -32,7 +32,7 @@ interface Element : Node {
FIXME Bug 810677 Move className from HTMLElement to Element
attribute DOMString className;
*/
readonly attribute DOMTokenList classList;
readonly attribute DOMTokenList? classList;
//readonly attribute Attr[] attributes;
DOMString? getAttribute(DOMString name);
@ -74,6 +74,13 @@ interface Element : Node {
// Mozilla specific stuff
[SetterThrows,LenientThis]
attribute EventHandler onmouseenter;
[SetterThrows,LenientThis]
attribute EventHandler onmouseleave;
[SetterThrows]
attribute EventHandler onwheel;
// Selectors API
/**
* Returns whether this element would be selected by the given selector
@ -125,7 +132,7 @@ interface Element : Node {
[Throws]
Attr removeAttributeNode(Attr oldAttr);
[Throws]
Attr getAttributeNodeNS(DOMString namespaceURI, DOMString localName);
Attr getAttributeNodeNS(DOMString? namespaceURI, DOMString localName);
[Throws]
Attr setAttributeNodeNS(Attr newAttr);
/*

Просмотреть файл

@ -200,13 +200,6 @@ interface HTMLElement : Element {
// FIXME Bug 810677 Move className from HTMLElement to Element
attribute DOMString className;
[SetterThrows,LenientThis]
attribute EventHandler onmouseenter;
[SetterThrows,LenientThis]
attribute EventHandler onmouseleave;
[SetterThrows]
attribute EventHandler onwheel;
[SetterThrows,Pref="dom.w3c_touch_events.enabled"]
attribute EventHandler ontouchstart;
[SetterThrows,Pref="dom.w3c_touch_events.enabled"]

Просмотреть файл

@ -28,6 +28,7 @@ webidl_files = \
DOMSettableTokenList.webidl \
DOMStringMap.webidl \
DynamicsCompressorNode.webidl \
Element.webidl \
EventHandler.webidl \
EventListener.webidl \
EventTarget.webidl \

Просмотреть файл

@ -95,40 +95,6 @@ members = [
'nsIDOMDocument.onmouseenter',
'nsIDOMDocument.onmouseleave',
'nsIDOMDocument.URL',
'nsIDOMElement.removeAttributeNS',
'nsIDOMElement.removeAttribute',
'nsIDOMElement.getAttribute',
'nsIDOMElement.getElementsByTagName',
'nsIDOMElement.setAttribute',
'nsIDOMElement.getElementsByTagNameNS',
'nsIDOMElement.hasAttributeNS',
'nsIDOMElement.tagName',
'nsIDOMElement.setAttributeNS',
'nsIDOMElement.hasAttribute',
'nsIDOMElement.getAttributeNS',
'nsIDOMElement.onmouseenter',
'nsIDOMElement.onmouseleave',
'nsIDOMElement.getElementsByClassName',
'nsIDOMElement.getClientRects',
'nsIDOMElement.getBoundingClientRect',
'nsIDOMElement.scrollTop',
'nsIDOMElement.scrollLeft',
'nsIDOMElement.scrollHeight',
'nsIDOMElement.scrollWidth',
'nsIDOMElement.clientTop',
'nsIDOMElement.clientLeft',
'nsIDOMElement.clientHeight',
'nsIDOMElement.clientWidth',
'nsIDOMElement.firstElementChild',
'nsIDOMElement.lastElementChild',
'nsIDOMElement.previousElementSibling',
'nsIDOMElement.nextElementSibling',
'nsIDOMElement.childElementCount',
'nsIDOMElement.children',
'nsIDOMElement.classList',
'nsIDOMElement.setCapture',
'nsIDOMElement.releaseCapture',
'nsIDOMElement.mozMatchesSelector',
'nsIDOMNamedNodeMap.item',
'nsIDOMNamedNodeMap.length',
'nsIDOMNodeSelector.querySelector',
@ -483,7 +449,8 @@ customIncludes = [
'HTMLPropertiesCollection.h',
'nsHTMLMenuElement.h',
'nsICSSDeclaration.h',
'mozilla/dom/NodeBinding.h'
'mozilla/dom/NodeBinding.h',
'mozilla/dom/ElementBinding.h'
]
customReturnInterfaces = [
@ -543,101 +510,6 @@ customMethodCalls = {
'nsIDOMStorage_Clear': {
'code': nsIDOMStorage_Clear_customMethodCallCode
},
'nsIDOMElement_GetScrollTop': {
'thisType': 'mozilla::dom::Element',
'code': ' int32_t result = self->ScrollTop();',
'canFail': False
},
'nsIDOMElement_SetScrollTop': {
'thisType': 'mozilla::dom::Element',
'canFail': False
},
'nsIDOMElement_GetScrollLeft': {
'thisType': 'mozilla::dom::Element',
'code': ' int32_t result = self->ScrollLeft();',
'canFail': False
},
'nsIDOMElement_SetScrollLeft': {
'thisType': 'mozilla::dom::Element',
'canFail': False
},
'nsIDOMElement_GetScrollHeight': {
'thisType': 'mozilla::dom::Element',
'code': ' int32_t result = self->ScrollHeight();',
'canFail': False
},
'nsIDOMElement_GetScrollWidth': {
'thisType': 'mozilla::dom::Element',
'code': ' int32_t result = self->ScrollWidth();',
'canFail': False
},
'nsIDOMElement_GetClientTop': {
'thisType': 'mozilla::dom::Element',
'code': ' int32_t result = self->ClientTop();',
'canFail': False
},
'nsIDOMElement_SetClientTop': {
'thisType': 'mozilla::dom::Element',
'canFail': False
},
'nsIDOMElement_GetClientLeft': {
'thisType': 'mozilla::dom::Element',
'code': ' int32_t result = self->ClientLeft();',
'canFail': False
},
'nsIDOMElement_SetClientLeft': {
'thisType': 'mozilla::dom::Element',
'canFail': False
},
'nsIDOMElement_GetClientHeight': {
'thisType': 'mozilla::dom::Element',
'code': ' int32_t result = self->ClientHeight();',
'canFail': False
},
'nsIDOMElement_GetClientWidth': {
'thisType': 'mozilla::dom::Element',
'code': ' int32_t result = self->ClientWidth();',
'canFail': False
},
'nsIDOMElement_GetFirstElementChild': {
'thisType': 'mozilla::dom::Element',
'code': ' nsIContent *result = self->GetFirstElementChild();',
'canFail': False
},
'nsIDOMElement_GetLastElementChild': {
'thisType': 'mozilla::dom::Element',
'code': ' nsIContent *result = self->GetLastElementChild();',
'canFail': False
},
'nsIDOMElement_GetPreviousElementSibling': {
'thisType': 'mozilla::dom::Element',
'code': ' nsIContent *result = self->GetPreviousElementSibling();',
'canFail': False
},
'nsIDOMElement_GetNextElementSibling': {
'thisType': 'mozilla::dom::Element',
'code': ' nsIContent *result = self->GetNextElementSibling();',
'canFail': False
},
'nsIDOMElement_GetClassList': {
'thisType': 'mozilla::dom::Element',
'code': ' nsDOMTokenList *result = self->ClassList();',
'canFail': False
},
'nsIDOMElement_SetCapture': {
'thisType': 'mozilla::dom::Element',
'canFail': False
},
'nsIDOMElement_ReleaseCapture': {
'thisType': 'mozilla::dom::Element',
'canFail': False
},
'nsIDOMElement_MozMatchesSelector': {
'thisType': 'mozilla::dom::Element',
'code': ' mozilla::ErrorResult error;\n'
' bool result = self->MozMatchesSelector(arg0, error);\n'
' rv = error.ErrorCode();'
},
'nsIDOMNodeSelector_QuerySelector': {
'thisType': 'nsINode',
'code': ' mozilla::ErrorResult error;\n'
@ -739,14 +611,6 @@ customMethodCalls = {
'self->GetElementsByTagNameNS(arg0, arg1);',
'canFail': False
},
'nsIDOMElement_': {
'thisType': 'mozilla::dom::Element'
},
'nsIDOMElement_GetTagName': {
'thisType': 'mozilla::dom::Element',
'code': 'nsString result = self->NodeName();',
'canFail': False
},
'nsIDOMDocument_CreateElement': {
'thisType': 'nsDocument',
'code': ' nsCOMPtr<nsIContent> result;\n'
@ -786,94 +650,6 @@ customMethodCalls = {
'thisType' : 'nsDocument',
'unwrapThisFailureFatal' : False
},
'nsIDOMElement_GetOnmouseenter' : {
'thisType' : 'mozilla::dom::Element',
'unwrapThisFailureFatal' : False
},
'nsIDOMElement_SetOnmouseenter' : {
'thisType' : 'mozilla::dom::Element',
'unwrapThisFailureFatal' : False
},
'nsIDOMElement_GetOnmouseleave' : {
'thisType' : 'mozilla::dom::Element',
'unwrapThisFailureFatal' : False
},
'nsIDOMElement_SetOnmouseleave' : {
'thisType' : 'mozilla::dom::Element',
'unwrapThisFailureFatal' : False
},
'nsIDOMElement_RemoveAttributeNS' : {
'thisType' : 'mozilla::dom::Element',
'code': ' mozilla::ErrorResult error;\n'
' self->RemoveAttributeNS(arg0, arg1, error);\n'
' rv = error.ErrorCode();'
},
'nsIDOMElement_RemoveAttribute' : {
'thisType' : 'mozilla::dom::Element',
'code': ' mozilla::ErrorResult error;\n'
' self->RemoveAttribute(arg0, error);\n'
' rv = error.ErrorCode();'
},
'nsIDOMElement_GetAttribute' : {
'thisType' : 'mozilla::dom::Element',
'code': ' nsString result;\n'
' self->GetAttribute(arg0, result);',
'canFail': False
},
'nsIDOMElement_GetAttributeNS' : {
'thisType' : 'mozilla::dom::Element',
'code': ' nsString result;\n'
' self->GetAttributeNS(arg0, arg1, result);',
'canFail': False
},
'nsIDOMElement_SetAttribute' : {
'thisType' : 'mozilla::dom::Element',
'code': ' mozilla::ErrorResult error;\n'
' self->SetAttribute(arg0, arg1, error);\n'
' rv = error.ErrorCode();'
},
'nsIDOMElement_SetAttributeNS' : {
'thisType' : 'mozilla::dom::Element',
'code': ' mozilla::ErrorResult error;\n'
' self->SetAttributeNS(arg0, arg1, arg2, error);\n'
' rv = error.ErrorCode();'
},
'nsIDOMElement_HasAttribute' : {
'thisType' : 'mozilla::dom::Element',
'code': ' bool result = self->HasAttribute(arg0);',
'canFail': False
},
'nsIDOMElement_HasAttributeNS' : {
'thisType' : 'mozilla::dom::Element',
'code': ' bool result = self->HasAttributeNS(arg0, arg1);',
'canFail': False
},
'nsIDOMElement_GetElementsByTagName' : {
'thisType' : 'mozilla::dom::Element',
'code': ' nsCOMPtr<nsIHTMLCollection> result = self->GetElementsByTagName(arg0);',
'canFail': False
},
'nsIDOMElement_GetClientRects' : {
'thisType' : 'mozilla::dom::Element',
'code': ' mozilla::ErrorResult error;\n'
' nsRefPtr<nsClientRectList> result = self->GetClientRects(error);\n'
' rv = error.ErrorCode();'
},
'nsIDOMElement_GetBoundingClientRect' : {
'thisType' : 'mozilla::dom::Element',
'code': ' nsRefPtr<nsClientRect> result = self->GetBoundingClientRect();',
'canFail': False
},
'nsIDOMElement_GetChildElementCount' : {
'thisType' : 'mozilla::dom::Element',
'code': ' uint32_t result = self->ChildElementCount();',
'canFail': False
},
'nsIDOMElement_GetChildElements' : {
'thisType' : 'mozilla::dom::Element',
'code': ' nsIHTMLCollection* result = self->Children();',
'canFail': False
},
'nsIDOMHTMLElement_GetTitle': {
'thisType' : 'nsGenericHTMLElement',
'canFail': False
@ -1055,5 +831,6 @@ customMethodCalls = {
}
newBindingProperties = {
'nsIDOMNode': 'mozilla::dom::NodeBinding::sNativePropertyHooks.mNativeProperties.regular'
'nsIDOMNode': 'mozilla::dom::NodeBinding::sNativePropertyHooks.mNativeProperties.regular',
'nsIDOMElement': 'mozilla::dom::ElementBinding::sNativePropertyHooks.mNativeProperties.regular'
}

Просмотреть файл

@ -219,7 +219,8 @@ CommonDialog.prototype = {
initTextbox : function (aName, aValue) {
this.ui[aName + "Container"].hidden = false;
this.ui[aName + "Textbox"].setAttribute("value", aValue);
this.ui[aName + "Textbox"].setAttribute("value",
aValue !== null ? aValue : "");
},
setButtonsEnabledState : function(enabled) {

Просмотреть файл

@ -2513,7 +2513,7 @@ var gDetailView = {
document.getElementById("detail-name").textContent = aAddon.name;
var icon = aAddon.icon64URL ? aAddon.icon64URL : aAddon.iconURL;
document.getElementById("detail-icon").src = icon ? icon : null;
document.getElementById("detail-icon").src = icon ? icon : "";
document.getElementById("detail-creator").setCreator(aAddon.creator, aAddon.homepageURL);
var version = document.getElementById("detail-version");