зеркало из https://github.com/mozilla/gecko-dev.git
Bug 851470 - Attr to WebIDL. r=Ms2ger
This commit is contained in:
Родитель
e509e0114b
Коммит
3d17116fda
|
@ -41,7 +41,7 @@
|
|||
#include "nsINodeList.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "mozilla/dom/Attr.h"
|
||||
#include "nsISMILAttr.h"
|
||||
#include "nsClientRect.h"
|
||||
#include "nsEvent.h"
|
||||
|
@ -644,16 +644,16 @@ public:
|
|||
{
|
||||
OwnerDoc()->RequestPointerLock(this);
|
||||
}
|
||||
nsIDOMAttr* GetAttributeNode(const nsAString& aName);
|
||||
already_AddRefed<nsIDOMAttr> SetAttributeNode(nsIDOMAttr* aNewAttr,
|
||||
ErrorResult& aError);
|
||||
already_AddRefed<nsIDOMAttr> RemoveAttributeNode(nsIDOMAttr* aOldAttr,
|
||||
ErrorResult& aError);
|
||||
nsIDOMAttr* GetAttributeNodeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
ErrorResult& aError);
|
||||
already_AddRefed<nsIDOMAttr> SetAttributeNodeNS(nsIDOMAttr* aNewAttr,
|
||||
ErrorResult& aError);
|
||||
Attr* GetAttributeNode(const nsAString& aName);
|
||||
already_AddRefed<Attr> SetAttributeNode(Attr& aNewAttr,
|
||||
ErrorResult& aError);
|
||||
already_AddRefed<Attr> RemoveAttributeNode(Attr& aOldAttr,
|
||||
ErrorResult& aError);
|
||||
Attr* GetAttributeNodeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
ErrorResult& aError);
|
||||
already_AddRefed<Attr> SetAttributeNodeNS(Attr& aNewAttr,
|
||||
ErrorResult& aError);
|
||||
|
||||
already_AddRefed<nsClientRectList> GetClientRects();
|
||||
already_AddRefed<nsClientRect> GetBoundingClientRect();
|
||||
|
@ -1064,9 +1064,9 @@ protected:
|
|||
return this;
|
||||
}
|
||||
|
||||
nsIDOMAttr* GetAttributeNodeNSInternal(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
ErrorResult& aError);
|
||||
Attr* GetAttributeNodeNSInternal(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
ErrorResult& aError);
|
||||
|
||||
void RegisterFreezableElement() {
|
||||
OwnerDoc()->RegisterFreezableElement(this);
|
||||
|
@ -1394,7 +1394,8 @@ NS_IMETHOD SetAttributeNode(nsIDOMAttr* newAttr, \
|
|||
return NS_ERROR_INVALID_POINTER; \
|
||||
} \
|
||||
mozilla::ErrorResult rv; \
|
||||
*_retval = Element::SetAttributeNode(newAttr, rv).get(); \
|
||||
mozilla::dom::Attr* attr = static_cast<mozilla::dom::Attr*>(newAttr); \
|
||||
*_retval = Element::SetAttributeNode(*attr, rv).get(); \
|
||||
return rv.ErrorCode(); \
|
||||
} \
|
||||
NS_IMETHOD RemoveAttributeNode(nsIDOMAttr* oldAttr, \
|
||||
|
@ -1404,7 +1405,8 @@ NS_IMETHOD RemoveAttributeNode(nsIDOMAttr* oldAttr, \
|
|||
return NS_ERROR_INVALID_POINTER; \
|
||||
} \
|
||||
mozilla::ErrorResult rv; \
|
||||
*_retval = Element::RemoveAttributeNode(oldAttr, rv).get(); \
|
||||
mozilla::dom::Attr* attr = static_cast<mozilla::dom::Attr*>(oldAttr); \
|
||||
*_retval = Element::RemoveAttributeNode(*attr, rv).get(); \
|
||||
return rv.ErrorCode(); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeNodeNS(const nsAString& namespaceURI, \
|
||||
|
@ -1421,7 +1423,8 @@ NS_IMETHOD SetAttributeNodeNS(nsIDOMAttr* newAttr, \
|
|||
nsIDOMAttr** _retval) MOZ_FINAL \
|
||||
{ \
|
||||
mozilla::ErrorResult rv; \
|
||||
*_retval = Element::SetAttributeNodeNS(newAttr, rv).get(); \
|
||||
mozilla::dom::Attr* attr = static_cast<mozilla::dom::Attr*>(newAttr); \
|
||||
*_retval = Element::SetAttributeNodeNS(*attr, rv).get(); \
|
||||
return rv.ErrorCode(); \
|
||||
} \
|
||||
NS_IMETHOD GetElementsByTagName(const nsAString& name, \
|
||||
|
|
|
@ -87,6 +87,7 @@ class ImageLoader;
|
|||
} // namespace css
|
||||
|
||||
namespace dom {
|
||||
class Attr;
|
||||
class CDATASection;
|
||||
class Comment;
|
||||
class DocumentFragment;
|
||||
|
@ -1983,9 +1984,9 @@ public:
|
|||
// Deprecated WebIDL bits
|
||||
already_AddRefed<mozilla::dom::CDATASection>
|
||||
CreateCDATASection(const nsAString& aData, mozilla::ErrorResult& rv);
|
||||
already_AddRefed<nsIDOMAttr>
|
||||
already_AddRefed<mozilla::dom::Attr>
|
||||
CreateAttribute(const nsAString& aName, mozilla::ErrorResult& rv);
|
||||
already_AddRefed<nsIDOMAttr>
|
||||
already_AddRefed<mozilla::dom::Attr>
|
||||
CreateAttributeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
mozilla::ErrorResult& rv);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
|
||||
#include "mozilla/dom/Attr.h"
|
||||
#include "mozilla/dom/AttrBinding.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
@ -47,6 +48,8 @@ Attr::Attr(nsDOMAttributeMap *aAttrMap,
|
|||
|
||||
// We don't add a reference to our content. It will tell us
|
||||
// to drop our reference when it goes away.
|
||||
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Attr)
|
||||
|
@ -164,34 +167,53 @@ Attr::GetValue(nsAString& aValue)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Attr::SetValue(const nsAString& aValue)
|
||||
void
|
||||
Attr::SetValue(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
nsIContent* content = GetContentInternal();
|
||||
if (!content) {
|
||||
mValue = aValue;
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> nameAtom = GetNameAtom(content);
|
||||
return content->SetAttr(mNodeInfo->NamespaceID(),
|
||||
nameAtom,
|
||||
mNodeInfo->GetPrefixAtom(),
|
||||
aValue,
|
||||
true);
|
||||
aRv = content->SetAttr(mNodeInfo->NamespaceID(),
|
||||
nameAtom,
|
||||
mNodeInfo->GetPrefixAtom(),
|
||||
aValue,
|
||||
true);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Attr::SetValue(const nsAString& aValue)
|
||||
{
|
||||
ErrorResult rv;
|
||||
SetValue(aValue, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
bool
|
||||
Attr::Specified() const
|
||||
{
|
||||
OwnerDoc()->WarnOnceAbout(nsIDocument::eSpecified);
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Attr::GetSpecified(bool* aSpecified)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSpecified);
|
||||
OwnerDoc()->WarnOnceAbout(nsIDocument::eSpecified);
|
||||
|
||||
*aSpecified = true;
|
||||
*aSpecified = Specified();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Element*
|
||||
Attr::GetOwnerElement(ErrorResult& aRv)
|
||||
{
|
||||
OwnerDoc()->WarnOnceAbout(nsIDocument::eOwnerElement);
|
||||
return GetContentInternal();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Attr::GetOwnerElement(nsIDOMElement** aOwnerElement)
|
||||
{
|
||||
|
@ -355,5 +377,11 @@ Attr::Shutdown()
|
|||
sInitialized = false;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
Attr::WrapObject(JSContext* aCx, JSObject* aScope)
|
||||
{
|
||||
return AttrBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -79,6 +79,23 @@ public:
|
|||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() { return this; }
|
||||
|
||||
// WebIDL
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
|
||||
|
||||
// XPCOM GetName() is OK
|
||||
// XPCOM GetValue() is OK
|
||||
|
||||
void SetValue(const nsAString& aValue, ErrorResult& aRv);
|
||||
|
||||
bool Specified() const;
|
||||
|
||||
// XPCOM GetNamespaceURI() is OK
|
||||
// XPCOM GetPrefix() is OK
|
||||
// XPCOM GetLocalName() is OK
|
||||
|
||||
Element* GetOwnerElement(ErrorResult& aRv);
|
||||
|
||||
protected:
|
||||
virtual mozilla::dom::Element* GetNameSpaceElement()
|
||||
{
|
||||
|
|
|
@ -769,46 +769,48 @@ Element::RemoveAttribute(const nsAString& aName, ErrorResult& aError)
|
|||
aError = UnsetAttr(name->NamespaceID(), name->LocalName(), true);
|
||||
}
|
||||
|
||||
nsIDOMAttr*
|
||||
Attr*
|
||||
Element::GetAttributeNode(const nsAString& aName)
|
||||
{
|
||||
OwnerDoc()->WarnOnceAbout(nsIDocument::eGetAttributeNode);
|
||||
return Attributes()->GetNamedItem(aName);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMAttr>
|
||||
Element::SetAttributeNode(nsIDOMAttr* aNewAttr, ErrorResult& aError)
|
||||
already_AddRefed<Attr>
|
||||
Element::SetAttributeNode(Attr& aNewAttr, ErrorResult& aError)
|
||||
{
|
||||
OwnerDoc()->WarnOnceAbout(nsIDocument::eSetAttributeNode);
|
||||
|
||||
nsCOMPtr<nsIDOMAttr> returnAttr;
|
||||
aError = Attributes()->SetNamedItem(aNewAttr, getter_AddRefs(returnAttr));
|
||||
nsCOMPtr<nsIDOMAttr> attr;
|
||||
aError = Attributes()->SetNamedItem(&aNewAttr, getter_AddRefs(attr));
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<Attr> returnAttr = static_cast<Attr*>(attr.get());
|
||||
return returnAttr.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMAttr>
|
||||
Element::RemoveAttributeNode(nsIDOMAttr* aAttribute,
|
||||
already_AddRefed<Attr>
|
||||
Element::RemoveAttributeNode(Attr& aAttribute,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
OwnerDoc()->WarnOnceAbout(nsIDocument::eRemoveAttributeNode);
|
||||
|
||||
nsAutoString name;
|
||||
|
||||
aError = aAttribute->GetName(name);
|
||||
aError = aAttribute.GetName(name);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMAttr> returnAttr;
|
||||
aError = Attributes()->RemoveNamedItem(name, getter_AddRefs(returnAttr));
|
||||
nsCOMPtr<nsIDOMAttr> attr;
|
||||
aError = Attributes()->RemoveNamedItem(name, getter_AddRefs(attr));
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<Attr> returnAttr = static_cast<Attr*>(attr.get());
|
||||
return returnAttr.forget();
|
||||
}
|
||||
|
||||
|
@ -872,7 +874,7 @@ Element::RemoveAttributeNS(const nsAString& aNamespaceURI,
|
|||
aError = UnsetAttr(nsid, name, true);
|
||||
}
|
||||
|
||||
nsIDOMAttr*
|
||||
Attr*
|
||||
Element::GetAttributeNodeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
ErrorResult& aError)
|
||||
|
@ -882,7 +884,7 @@ Element::GetAttributeNodeNS(const nsAString& aNamespaceURI,
|
|||
return GetAttributeNodeNSInternal(aNamespaceURI, aLocalName, aError);
|
||||
}
|
||||
|
||||
nsIDOMAttr*
|
||||
Attr*
|
||||
Element::GetAttributeNodeNSInternal(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
ErrorResult& aError)
|
||||
|
@ -890,12 +892,12 @@ Element::GetAttributeNodeNSInternal(const nsAString& aNamespaceURI,
|
|||
return Attributes()->GetNamedItemNS(aNamespaceURI, aLocalName, aError);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMAttr>
|
||||
Element::SetAttributeNodeNS(nsIDOMAttr* aNewAttr,
|
||||
already_AddRefed<Attr>
|
||||
Element::SetAttributeNodeNS(Attr& aNewAttr,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
OwnerDoc()->WarnOnceAbout(nsIDocument::eSetAttributeNodeNS);
|
||||
return Attributes()->SetNamedItemNS(aNewAttr, aError);
|
||||
return Attributes()->SetNamedItemNS(&aNewAttr, aError);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIHTMLCollection>
|
||||
|
@ -1863,7 +1865,7 @@ Element::SetAttrAndNotify(int32_t aNamespaceID,
|
|||
nsAutoString ns;
|
||||
nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNamespaceID, ns);
|
||||
ErrorResult rv;
|
||||
nsIDOMAttr* attrNode =
|
||||
Attr* attrNode =
|
||||
GetAttributeNodeNSInternal(ns, nsDependentAtomString(aName), rv);
|
||||
mutation.mRelatedNode = attrNode;
|
||||
|
||||
|
@ -1989,7 +1991,7 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|||
this);
|
||||
|
||||
// Grab the attr node if needed before we remove it from the attr map
|
||||
nsCOMPtr<nsIDOMAttr> attrNode;
|
||||
nsRefPtr<Attr> attrNode;
|
||||
if (hasMutationListeners) {
|
||||
nsAutoString ns;
|
||||
nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNameSpaceID, ns);
|
||||
|
|
|
@ -4930,7 +4930,7 @@ nsDocument::CreateAttribute(const nsAString& aName,
|
|||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMAttr>
|
||||
already_AddRefed<Attr>
|
||||
nsIDocument::CreateAttribute(const nsAString& aName, ErrorResult& rv)
|
||||
{
|
||||
WarnOnceAbout(eCreateAttribute);
|
||||
|
@ -4955,8 +4955,8 @@ nsIDocument::CreateAttribute(const nsAString& aName, ErrorResult& rv)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMAttr> attribute = new Attr(nullptr, nodeInfo.forget(),
|
||||
EmptyString(), false);
|
||||
nsRefPtr<Attr> attribute = new Attr(nullptr, nodeInfo.forget(),
|
||||
EmptyString(), false);
|
||||
return attribute.forget();
|
||||
}
|
||||
|
||||
|
@ -4971,7 +4971,7 @@ nsDocument::CreateAttributeNS(const nsAString & aNamespaceURI,
|
|||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMAttr>
|
||||
already_AddRefed<Attr>
|
||||
nsIDocument::CreateAttributeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
ErrorResult& rv)
|
||||
|
@ -4988,8 +4988,8 @@ nsIDocument::CreateAttributeNS(const nsAString& aNamespaceURI,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMAttr> attribute = new Attr(nullptr, nodeInfo.forget(),
|
||||
EmptyString(), true);
|
||||
nsRefPtr<Attr> attribute = new Attr(nullptr, nodeInfo.forget(),
|
||||
EmptyString(), true);
|
||||
return attribute.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -1425,7 +1425,6 @@ def addExternalHTMLElement(element):
|
|||
addExternalHTMLElement('HTMLFormElement')
|
||||
addExternalIface('ActivityOptions', nativeType='nsIDOMMozActivityOptions',
|
||||
headerFile='nsIDOMActivityOptions.h')
|
||||
addExternalIface('Attr')
|
||||
addExternalIface('CanvasGradient', headerFile='nsIDOMCanvasRenderingContext2D.h')
|
||||
addExternalIface('CanvasPattern', headerFile='nsIDOMCanvasRenderingContext2D.h')
|
||||
addExternalIface('Counter')
|
||||
|
|
|
@ -114,12 +114,7 @@
|
|||
"Element interface: element must inherit property \"replace\" with the proper type (29)": true,
|
||||
"Element interface: calling replace(union) on element with too few arguments must throw TypeError": true,
|
||||
"Element interface: element must inherit property \"remove\" with the proper type (30)": 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,
|
||||
"Attr interface: attribute value": true,
|
||||
"Attr interface: attribute name": true,
|
||||
"Stringification of document.querySelector(\"[id]\").attributes[0]": "debug",
|
||||
"CharacterData interface: attribute previousElementSibling": true,
|
||||
"CharacterData interface: attribute nextElementSibling": true,
|
||||
"CharacterData interface: operation before(union)": true,
|
||||
|
|
|
@ -10,11 +10,22 @@
|
|||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
interface Attr {
|
||||
readonly attribute DOMString name;
|
||||
interface Attr : Node {
|
||||
readonly attribute DOMString localName;
|
||||
[SetterThrows]
|
||||
attribute DOMString value;
|
||||
|
||||
readonly attribute DOMString name;
|
||||
readonly attribute DOMString? namespaceURI;
|
||||
readonly attribute DOMString? prefix;
|
||||
readonly attribute DOMString localName;
|
||||
};
|
||||
|
||||
// Mozilla extensions
|
||||
|
||||
partial interface Attr {
|
||||
readonly attribute boolean specified;
|
||||
|
||||
|
||||
[GetterThrows]
|
||||
readonly attribute Element? ownerElement;
|
||||
};
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
* http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/core/nsIDOMDocument.idl
|
||||
*/
|
||||
|
||||
interface Attr;
|
||||
interface Comment;
|
||||
interface StyleSheetList;
|
||||
interface Touch;
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
interface Attr;
|
||||
interface MozNamedAttrMap;
|
||||
|
||||
interface Element : Node {
|
||||
|
@ -137,15 +136,15 @@ interface Element : Node {
|
|||
void mozRequestPointerLock();
|
||||
|
||||
// Obsolete methods.
|
||||
Attr getAttributeNode(DOMString name);
|
||||
Attr? getAttributeNode(DOMString name);
|
||||
[Throws]
|
||||
Attr setAttributeNode(Attr newAttr);
|
||||
Attr? setAttributeNode(Attr newAttr);
|
||||
[Throws]
|
||||
Attr removeAttributeNode(Attr oldAttr);
|
||||
Attr? removeAttributeNode(Attr oldAttr);
|
||||
[Throws]
|
||||
Attr getAttributeNodeNS(DOMString? namespaceURI, DOMString localName);
|
||||
Attr? getAttributeNodeNS(DOMString? namespaceURI, DOMString localName);
|
||||
[Throws]
|
||||
Attr setAttributeNodeNS(Attr newAttr);
|
||||
Attr? setAttributeNodeNS(Attr newAttr);
|
||||
};
|
||||
|
||||
// http://dev.w3.org/csswg/cssom-view/#extensions-to-the-element-interface
|
||||
|
|
|
@ -20,6 +20,7 @@ webidl_files = \
|
|||
AudioListener.webidl \
|
||||
AudioNode.webidl \
|
||||
AudioParam.webidl \
|
||||
Attr.webidl \
|
||||
BatteryManager.webidl \
|
||||
BeforeUnloadEvent.webidl \
|
||||
BiquadFilterNode.webidl \
|
||||
|
|
Загрузка…
Ссылка в новой задаче