Add nsIDOM3Attr; implement isId on Attr nodes. Bug 288513 starter, patch by

Alex Vincent <ajvincent@gmail.com>, r+sr=jst
This commit is contained in:
bzbarsky%mit.edu 2006-01-27 04:10:30 +00:00
Родитель 9fe48b0ebd
Коммит 02230a060a
6 изменённых файлов: 142 добавлений и 2 удалений

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

@ -46,6 +46,7 @@
#include "nsDOMString.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOM3Attr.h"
#include "nsIDOMUserDataHandler.h"
#include "nsITextContent.h"
@ -88,6 +89,7 @@ NS_INTERFACE_MAP_BEGIN(nsDOMAttribute)
NS_INTERFACE_MAP_ENTRY(nsIDOMGCParticipant)
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
NS_INTERFACE_MAP_ENTRY(nsIDOM3Node)
NS_INTERFACE_MAP_ENTRY(nsIDOM3Attr)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMAttr)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(Attr)
NS_INTERFACE_MAP_END
@ -683,6 +685,33 @@ nsDOMAttribute::GetUserData(const nsAString& aKey, nsIVariant** aResult)
aResult);
}
NS_IMETHODIMP
nsDOMAttribute::GetIsId(PRBool* aReturn)
{
nsIContent* content = GetContentInternal();
if (!content)
{
*aReturn = PR_FALSE;
return NS_OK;
}
nsIAtom* idAtom = content->GetIDAttributeName();
if (!idAtom)
{
*aReturn = PR_FALSE;
return NS_OK;
}
*aReturn = mNodeInfo->Equals(idAtom, kNameSpaceID_None);
return NS_OK;
}
NS_IMETHODIMP
nsDOMAttribute::GetSchemaTypeInfo(nsIDOM3TypeInfo** aReturn)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDOMAttribute::LookupPrefix(const nsAString& aNamespaceURI,
nsAString& aPrefix)

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

@ -46,6 +46,7 @@
#include "nsCOMPtr.h"
#include "nsINodeInfo.h"
#include "nsIDOM3Node.h"
#include "nsIDOM3Attr.h"
#include "nsDOMAttributeMap.h"
class nsDOMAttribute;
@ -69,9 +70,9 @@ protected:
};
// Attribute helper class used to wrap up an attribute with a dom
// object that implements nsIDOMAttr and nsIDOMNode
// object that implements nsIDOMAttr, nsIDOM3Attr, nsIDOMNode, nsIDOM3Node
class nsDOMAttribute : public nsIDOMAttr,
public nsIDOM3Node,
public nsIDOM3Attr,
public nsIAttribute
{
public:
@ -94,6 +95,9 @@ public:
// nsIDOMAttr interface
NS_DECL_NSIDOMATTR
// nsIDOM3Attr interface
NS_DECL_NSIDOM3ATTR
// nsIAttribute interface
void SetMap(nsDOMAttributeMap *aMap);
nsIContent *GetContent() const;

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

@ -69,6 +69,8 @@ SDK_XPIDLSRCS = \
XPIDLSRCS = \
nsIDOM3Document.idl \
nsIDOM3Node.idl \
nsIDOM3TypeInfo.idl \
nsIDOM3Attr.idl \
nsIDOMDOMStringList.idl \
nsIDOMNameList.idl \
nsIDOMNSDocument.idl \

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

@ -0,0 +1,48 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Alexander J. Vincent <ajvincent@gmail.com>.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "domstubs.idl"
#include "nsIDOM3Node.idl"
#include "nsIDOM3TypeInfo.idl"
[scriptable, uuid(a2216ddc-1bcd-4ec2-a292-371e09a6c377)]
interface nsIDOM3Attr : nsIDOM3Node
{
// Introduced in DOM Level 3:
readonly attribute nsIDOM3TypeInfo schemaTypeInfo;
// Introduced in DOM Level 3:
readonly attribute boolean isId;
};

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

@ -0,0 +1,55 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Alexander J. Vincent <ajvincent@gmail.com>.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "domstubs.idl"
// Introduced in DOM Level 3:
[scriptable, uuid(2a1088c7-499a-49a7-9d3b-1970d21532ab)]
interface nsIDOM3TypeInfo : nsISupports
{
readonly attribute DOMString typeName;
readonly attribute DOMString typeNamespace;
// DerivationMethods
const unsigned long DERIVATION_RESTRICTION = 0x00000001;
const unsigned long DERIVATION_EXTENSION = 0x00000002;
const unsigned long DERIVATION_UNION = 0x00000004;
const unsigned long DERIVATION_LIST = 0x00000008;
boolean isDerivedFrom(in DOMString typeNamespaceArg,
in DOMString typeNameArg,
in unsigned long derivationMethod);
};

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

@ -112,6 +112,7 @@
#include "nsIDOMDOMException.h"
#include "nsIDOMNode.h"
#include "nsIDOM3Node.h"
#include "nsIDOM3Attr.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMNamedNodeMap.h"
#include "nsIDOMDOMStringList.h"
@ -1806,6 +1807,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(Attr, nsIDOMAttr)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMAttr)
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Attr)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(Text, nsIDOMText)