2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** 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 Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2011-06-23 01:30:48 -07:00
|
|
|
* Ms2ger <ms2ger@gmail.com>
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* 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 ***** */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Implementation of DOM Core's nsIDOMAttr node.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsDOMAttribute.h"
|
|
|
|
#include "nsGenericElement.h"
|
2010-08-24 00:05:56 -07:00
|
|
|
#include "mozilla/dom/Element.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsContentCreatorFunctions.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsDOMError.h"
|
|
|
|
#include "nsUnicharUtils.h"
|
|
|
|
#include "nsDOMString.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsIDOMUserDataHandler.h"
|
|
|
|
#include "nsEventDispatcher.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsNodeUtils.h"
|
2011-06-23 19:18:01 -07:00
|
|
|
#include "nsEventListenerManager.h"
|
2008-10-15 02:40:28 -07:00
|
|
|
#include "nsTextNode.h"
|
|
|
|
#include "mozAutoDocUpdate.h"
|
|
|
|
#include "nsMutationEvent.h"
|
2011-05-09 12:33:03 -07:00
|
|
|
#include "nsPLDOMEvent.h"
|
2011-05-26 12:58:35 -07:00
|
|
|
#include "nsWrapperCacheInlines.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-24 00:05:56 -07:00
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------------------------------------
|
2011-09-28 23:19:26 -07:00
|
|
|
bool nsDOMAttribute::sInitialized;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsDOMAttribute::nsDOMAttribute(nsDOMAttributeMap *aAttrMap,
|
2010-07-23 02:49:57 -07:00
|
|
|
already_AddRefed<nsINodeInfo> aNodeInfo,
|
2011-09-28 23:19:26 -07:00
|
|
|
const nsAString &aValue, bool aNsAware)
|
2010-10-14 07:07:20 -07:00
|
|
|
: nsIAttribute(aAttrMap, aNodeInfo, aNsAware), mValue(aValue), mChild(nsnull)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mNodeInfo, "We must get a nodeinfo here!");
|
2011-06-14 00:56:49 -07:00
|
|
|
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::ATTRIBUTE_NODE,
|
|
|
|
"Wrong nodeType");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// We don't add a reference to our content. It will tell us
|
|
|
|
// to drop our reference when it goes away.
|
2010-05-27 12:10:33 -07:00
|
|
|
|
|
|
|
EnsureChildState();
|
|
|
|
|
|
|
|
nsIContent* content = GetContentInternal();
|
|
|
|
if (content) {
|
|
|
|
content->AddMutationObserver(this);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-07-11 13:42:19 -07:00
|
|
|
nsDOMAttribute::~nsDOMAttribute()
|
|
|
|
{
|
2008-12-30 04:27:37 -08:00
|
|
|
if (mChild) {
|
|
|
|
static_cast<nsTextNode*>(mChild)->UnbindFromAttribute();
|
|
|
|
NS_RELEASE(mChild);
|
2010-05-27 12:10:33 -07:00
|
|
|
mFirstChild = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIContent* content = GetContentInternal();
|
|
|
|
if (content) {
|
|
|
|
content->RemoveMutationObserver(this);
|
2008-12-30 04:27:37 -08:00
|
|
|
}
|
2008-07-11 13:42:19 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMAttribute)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMAttribute)
|
2009-05-12 13:20:42 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
2011-08-28 07:07:24 -07:00
|
|
|
|
|
|
|
if (!nsINode::Traverse(tmp, cb)) {
|
|
|
|
return NS_SUCCESS_INTERRUPTED_TRAVERSE;
|
|
|
|
}
|
|
|
|
|
2008-07-11 13:42:19 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mChild)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2009-05-12 13:20:42 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsDOMAttribute)
|
2011-08-28 07:07:24 -07:00
|
|
|
nsINode::Trace(tmp, aCallback, aClosure);
|
2009-05-12 13:20:42 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMAttribute)
|
2011-08-28 07:07:24 -07:00
|
|
|
nsINode::Unlink(tmp);
|
2008-10-15 02:40:28 -07:00
|
|
|
if (tmp->mChild) {
|
|
|
|
static_cast<nsTextNode*>(tmp->mChild)->UnbindFromAttribute();
|
|
|
|
NS_RELEASE(tmp->mChild);
|
2010-05-27 12:10:33 -07:00
|
|
|
tmp->mFirstChild = nsnull;
|
2008-10-15 02:40:28 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
2010-01-12 05:08:43 -08:00
|
|
|
|
2010-07-23 02:49:57 -07:00
|
|
|
DOMCI_NODE_DATA(Attr, nsDOMAttribute)
|
2010-01-12 05:08:43 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// QueryInterface implementation for nsDOMAttribute
|
2008-11-03 02:31:47 -08:00
|
|
|
NS_INTERFACE_TABLE_HEAD(nsDOMAttribute)
|
2008-11-13 08:54:52 -08:00
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2011-06-25 00:33:32 -07:00
|
|
|
NS_NODE_INTERFACE_TABLE5(nsDOMAttribute, nsIDOMAttr, nsIAttribute, nsIDOMNode,
|
|
|
|
nsIDOMEventTarget, nsIMutationObserver)
|
2008-11-03 02:31:47 -08:00
|
|
|
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsDOMAttribute)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
|
|
|
|
new nsNodeSupportsWeakRefTearoff(this))
|
2010-04-19 08:41:37 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMXPathNSResolver,
|
|
|
|
new nsNode3Tearoff(this))
|
2010-03-17 08:09:05 -07:00
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Attr)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2011-03-06 03:11:31 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMAttribute)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_DESTROY(nsDOMAttribute,
|
|
|
|
nsNodeUtils::LastRelease(this))
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
nsDOMAttribute::SetMap(nsDOMAttributeMap *aMap)
|
|
|
|
{
|
|
|
|
if (mAttrMap && !aMap && sInitialized) {
|
|
|
|
// We're breaking a relationship with content and not getting a new one,
|
|
|
|
// need to locally cache value. GetValue() does that.
|
|
|
|
GetValue(mValue);
|
|
|
|
}
|
2010-05-27 12:10:33 -07:00
|
|
|
|
|
|
|
nsIContent* content = GetContentInternal();
|
|
|
|
if (content) {
|
|
|
|
content->RemoveMutationObserver(this);
|
|
|
|
}
|
2010-10-07 03:05:33 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
mAttrMap = aMap;
|
2010-10-07 03:05:33 -07:00
|
|
|
|
|
|
|
// If we have a new content, we sholud start listening to it.
|
|
|
|
content = GetContentInternal();
|
|
|
|
if (content) {
|
|
|
|
content->AddMutationObserver(this);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIContent*
|
|
|
|
nsDOMAttribute::GetContent() const
|
|
|
|
{
|
|
|
|
return GetContentInternal();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsDOMAttribute::SetOwnerDocument(nsIDocument* aDocument)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aDocument, "Missing document");
|
|
|
|
|
|
|
|
nsIDocument *doc = GetOwnerDoc();
|
|
|
|
NS_ASSERTION(doc != aDocument, "bad call to nsDOMAttribute::SetOwnerDocument");
|
|
|
|
if (doc) {
|
2010-04-22 19:41:38 -07:00
|
|
|
doc->DeleteAllPropertiesFor(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsINodeInfo> newNodeInfo;
|
2008-09-12 15:32:18 -07:00
|
|
|
newNodeInfo = aDocument->NodeInfoManager()->
|
2007-03-22 10:30:00 -07:00
|
|
|
GetNodeInfo(mNodeInfo->NameAtom(), mNodeInfo->GetPrefixAtom(),
|
2011-06-14 00:56:49 -07:00
|
|
|
mNodeInfo->NamespaceID(),
|
|
|
|
nsIDOMNode::ATTRIBUTE_NODE);
|
2008-09-25 15:46:52 -07:00
|
|
|
NS_ENSURE_TRUE(newNodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(newNodeInfo, "GetNodeInfo lies");
|
|
|
|
mNodeInfo.swap(newNodeInfo);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetName(nsAString& aName)
|
|
|
|
{
|
2011-06-14 00:56:49 -07:00
|
|
|
aName = NodeName();
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-12-28 06:35:06 -08:00
|
|
|
already_AddRefed<nsIAtom>
|
|
|
|
nsDOMAttribute::GetNameAtom(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
nsIAtom* result = nsnull;
|
2010-10-14 07:07:20 -07:00
|
|
|
if (!mNsAware &&
|
|
|
|
mNodeInfo->NamespaceID() == kNameSpaceID_None &&
|
2009-12-28 06:35:06 -08:00
|
|
|
aContent->IsInHTMLDocument() &&
|
|
|
|
aContent->IsHTML()) {
|
|
|
|
nsAutoString name;
|
|
|
|
mNodeInfo->NameAtom()->ToString(name);
|
|
|
|
nsAutoString lower;
|
|
|
|
ToLowerCase(name, lower);
|
|
|
|
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(lower);
|
|
|
|
nameAtom.swap(result);
|
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsIAtom> nameAtom = mNodeInfo->NameAtom();
|
|
|
|
nameAtom.swap(result);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetValue(nsAString& aValue)
|
|
|
|
{
|
|
|
|
nsIContent* content = GetContentInternal();
|
|
|
|
if (content) {
|
2009-12-28 06:35:06 -08:00
|
|
|
nsCOMPtr<nsIAtom> nameAtom = GetNameAtom(content);
|
|
|
|
content->GetAttr(mNodeInfo->NamespaceID(), nameAtom, aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
aValue = mValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::SetValue(const nsAString& aValue)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsIContent* content = GetContentInternal();
|
|
|
|
if (content) {
|
2009-12-28 06:35:06 -08:00
|
|
|
nsCOMPtr<nsIAtom> nameAtom = GetNameAtom(content);
|
2007-03-22 10:30:00 -07:00
|
|
|
rv = content->SetAttr(mNodeInfo->NamespaceID(),
|
2009-12-28 06:35:06 -08:00
|
|
|
nameAtom,
|
2007-03-22 10:30:00 -07:00
|
|
|
mNodeInfo->GetPrefixAtom(),
|
|
|
|
aValue,
|
2011-10-17 07:59:28 -07:00
|
|
|
true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
mValue = aValue;
|
2010-10-07 03:04:07 -07:00
|
|
|
|
|
|
|
if (mChild) {
|
2010-10-07 03:05:04 -07:00
|
|
|
if (mValue.IsEmpty()) {
|
2010-10-12 06:09:46 -07:00
|
|
|
doRemoveChild(true);
|
2010-10-07 03:05:04 -07:00
|
|
|
} else {
|
2011-10-17 07:59:28 -07:00
|
|
|
mChild->SetText(mValue, false);
|
2010-10-07 03:05:04 -07:00
|
|
|
}
|
2010-10-07 03:04:07 -07:00
|
|
|
} else {
|
|
|
|
EnsureChildState();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-06-23 01:30:48 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMAttribute::GetSpecified(bool* aSpecified)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aSpecified);
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eSpecified);
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
*aSpecified = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetOwnerElement(nsIDOMElement** aOwnerElement)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aOwnerElement);
|
|
|
|
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eOwnerElement);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIContent* content = GetContentInternal();
|
|
|
|
if (content) {
|
|
|
|
return CallQueryInterface(content, aOwnerElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
*aOwnerElement = nsnull;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetNodeName(nsAString& aNodeName)
|
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eNodeName);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return GetName(aNodeName);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetNodeValue(nsAString& aNodeValue)
|
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eNodeValue);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return GetValue(aNodeValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::SetNodeValue(const nsAString& aNodeValue)
|
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eNodeValue);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return SetValue(aNodeValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetNodeType(PRUint16* aNodeType)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aNodeType);
|
|
|
|
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eNodeType);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
*aNodeType = (PRUint16)nsIDOMNode::ATTRIBUTE_NODE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetParentNode(nsIDOMNode** aParentNode)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aParentNode);
|
|
|
|
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eParentNode);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
*aParentNode = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-11 15:45:39 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetParentElement(nsIDOMElement** aParentElement)
|
|
|
|
{
|
|
|
|
*aParentElement = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eChildNodes);
|
|
|
|
}
|
|
|
|
|
2009-01-02 09:00:18 -08:00
|
|
|
return nsINode::GetChildNodes(aChildNodes);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMAttribute::HasChildNodes(bool* aHasChildNodes)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eHasChildNodes);
|
|
|
|
}
|
|
|
|
|
2010-05-27 12:10:33 -07:00
|
|
|
*aHasChildNodes = mFirstChild != nsnull;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMAttribute::HasAttributes(bool* aHasAttributes)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aHasAttributes);
|
|
|
|
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eHasAttributes);
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
*aHasAttributes = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetFirstChild(nsIDOMNode** aFirstChild)
|
|
|
|
{
|
|
|
|
*aFirstChild = nsnull;
|
|
|
|
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eFirstChild);
|
|
|
|
}
|
|
|
|
|
2010-05-27 12:10:33 -07:00
|
|
|
if (mFirstChild) {
|
|
|
|
CallQueryInterface(mFirstChild, aFirstChild);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetLastChild(nsIDOMNode** aLastChild)
|
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eLastChild);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
return GetFirstChild(aLastChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPreviousSibling);
|
|
|
|
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::ePreviousSibling);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
*aPreviousSibling = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetNextSibling(nsIDOMNode** aNextSibling)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aNextSibling);
|
|
|
|
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eNextSibling);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
*aNextSibling = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aAttributes);
|
|
|
|
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eAttributes);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
*aAttributes = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn)
|
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eInsertBefore);
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return ReplaceOrInsertBefore(false, aNewChild, aRefChild, aReturn);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eReplaceChild);
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return ReplaceOrInsertBefore(true, aNewChild, aOldChild, aReturn);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eRemoveChild);
|
|
|
|
}
|
|
|
|
|
2010-03-17 08:06:19 -07:00
|
|
|
return nsINode::RemoveChild(aOldChild, aReturn);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eAppendChild);
|
|
|
|
}
|
|
|
|
|
2010-04-15 01:28:57 -07:00
|
|
|
return InsertBefore(aNewChild, nsnull, aReturn);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsDOMAttribute::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
|
|
|
|
{
|
|
|
|
nsAutoString value;
|
2007-07-08 00:08:04 -07:00
|
|
|
const_cast<nsDOMAttribute*>(this)->GetValue(value);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-23 02:49:57 -07:00
|
|
|
nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
|
2010-10-14 07:07:20 -07:00
|
|
|
*aResult = new nsDOMAttribute(nsnull, ni.forget(), value, mNsAware);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!*aResult) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ADDREF(*aResult);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMAttribute::CloneNode(bool aDeep, nsIDOMNode** aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eCloneNode);
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return nsNodeUtils::CloneNodeImpl(this, aDeep, true, aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eOwnerDocument);
|
|
|
|
}
|
|
|
|
|
2009-01-02 09:00:18 -08:00
|
|
|
return nsINode::GetOwnerDocument(aOwnerDocument);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetNamespaceURI(nsAString& aNamespaceURI)
|
|
|
|
{
|
|
|
|
return mNodeInfo->GetNamespaceURI(aNamespaceURI);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetPrefix(nsAString& aPrefix)
|
|
|
|
{
|
|
|
|
mNodeInfo->GetPrefix(aPrefix);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetLocalName(nsAString& aLocalName)
|
|
|
|
{
|
2011-05-05 09:26:33 -07:00
|
|
|
mNodeInfo->GetName(aLocalName);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::Normalize()
|
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eNormalize);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Nothing to do here
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::IsSupported(const nsAString& aFeature,
|
|
|
|
const nsAString& aVersion,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aReturn)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eIsSupported);
|
|
|
|
}
|
2007-07-08 00:08:04 -07:00
|
|
|
return nsGenericElement::InternalIsSupported(static_cast<nsIDOMAttr*>(this),
|
2007-03-22 10:30:00 -07:00
|
|
|
aFeature, aVersion, aReturn);
|
|
|
|
}
|
|
|
|
|
2010-04-19 08:40:15 -07:00
|
|
|
already_AddRefed<nsIURI>
|
|
|
|
nsDOMAttribute::GetBaseURI() const
|
|
|
|
{
|
|
|
|
nsINode *parent = GetContentInternal();
|
|
|
|
|
|
|
|
return parent ? parent->GetBaseURI() : nsnull;
|
|
|
|
}
|
|
|
|
|
2011-06-14 00:56:48 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetDOMBaseURI(nsAString &aURI)
|
|
|
|
{
|
|
|
|
return nsINode::GetDOMBaseURI(aURI);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::CompareDocumentPosition(nsIDOMNode *other,
|
|
|
|
PRUint16 *aResult)
|
|
|
|
{
|
|
|
|
return nsINode::CompareDocumentPosition(other, aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMAttribute::IsEqualNode(nsIDOMNode* aOther, bool* aResult)
|
2011-06-14 00:56:48 -07:00
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eIsEqualNode);
|
|
|
|
}
|
2011-06-14 00:56:48 -07:00
|
|
|
return nsINode::IsEqualNode(aOther, aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-06-14 00:56:48 -07:00
|
|
|
NS_IMETHODIMP
|
2007-03-22 10:30:00 -07:00
|
|
|
nsDOMAttribute::GetTextContent(nsAString &aTextContent)
|
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eTextContent);
|
|
|
|
}
|
2011-06-14 00:56:48 -07:00
|
|
|
return GetNodeValue(aTextContent);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-06-14 00:56:48 -07:00
|
|
|
NS_IMETHODIMP
|
2007-03-22 10:30:00 -07:00
|
|
|
nsDOMAttribute::SetTextContent(const nsAString& aTextContent)
|
|
|
|
{
|
2011-06-23 01:30:48 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eTextContent);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
return SetNodeValue(aTextContent);
|
|
|
|
}
|
|
|
|
|
2011-06-14 00:56:48 -07:00
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMAttribute::IsSameNode(nsIDOMNode *other, bool *aResult)
|
2011-06-14 00:56:48 -07:00
|
|
|
{
|
2011-09-27 03:07:11 -07:00
|
|
|
nsIDocument* document = GetOwnerDoc();
|
|
|
|
if (document) {
|
|
|
|
document->WarnOnceAbout(nsIDocument::eIsSameNode);
|
|
|
|
}
|
|
|
|
|
2011-06-14 00:56:48 -07:00
|
|
|
*aResult = other == this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-02 13:15:53 -07:00
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMAttribute::Contains(nsIDOMNode* aOther, bool* aReturn)
|
2011-09-02 13:15:53 -07:00
|
|
|
{
|
|
|
|
return nsINode::Contains(aOther, aReturn);
|
|
|
|
}
|
|
|
|
|
2011-06-14 00:56:48 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::LookupPrefix(const nsAString & namespaceURI,
|
|
|
|
nsAString & aResult)
|
|
|
|
{
|
|
|
|
SetDOMStringToNull(aResult);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::IsDefaultNamespace(const nsAString & namespaceURI,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool *aResult)
|
2011-06-14 00:56:48 -07:00
|
|
|
{
|
|
|
|
*aResult = namespaceURI.IsEmpty();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::LookupNamespaceURI(const nsAString & prefix,
|
|
|
|
nsAString & aResult)
|
|
|
|
{
|
|
|
|
SetDOMStringToNull(aResult);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::SetUserData(const nsAString & key,
|
|
|
|
nsIVariant *data, nsIDOMUserDataHandler *handler,
|
|
|
|
nsIVariant **aResult)
|
|
|
|
{
|
|
|
|
return nsINode::SetUserData(key, data, handler, aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAttribute::GetUserData(const nsAString & key, nsIVariant **aResult)
|
|
|
|
{
|
|
|
|
return nsINode::GetUserData(key, aResult);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMAttribute::GetIsId(bool* aReturn)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsIContent* content = GetContentInternal();
|
|
|
|
if (!content)
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
*aReturn = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-07-26 07:16:19 -07:00
|
|
|
nsIAtom* idAtom = content->GetIDAttributeName();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!idAtom)
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
*aReturn = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-07-26 07:16:19 -07:00
|
|
|
*aReturn = mNodeInfo->Equals(idAtom, kNameSpaceID_None);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsDOMAttribute::IsNodeOfType(PRUint32 aFlags) const
|
|
|
|
{
|
|
|
|
return !(aFlags & ~eATTRIBUTE);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32
|
|
|
|
nsDOMAttribute::GetChildCount() const
|
|
|
|
{
|
2010-05-27 12:10:33 -07:00
|
|
|
return mFirstChild ? 1 : 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIContent *
|
|
|
|
nsDOMAttribute::GetChildAt(PRUint32 aIndex) const
|
|
|
|
{
|
2010-05-27 12:10:33 -07:00
|
|
|
return aIndex == 0 ? mFirstChild : nsnull;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2008-07-11 13:42:19 -07:00
|
|
|
|
|
|
|
nsIContent * const *
|
2008-12-03 06:02:03 -08:00
|
|
|
nsDOMAttribute::GetChildArray(PRUint32* aChildCount) const
|
2008-07-11 13:42:19 -07:00
|
|
|
{
|
2010-05-27 12:10:33 -07:00
|
|
|
*aChildCount = GetChildCount();
|
|
|
|
return &mFirstChild;
|
2009-01-02 09:00:18 -08:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
PRInt32
|
|
|
|
nsDOMAttribute::IndexOf(nsINode* aPossibleChild) const
|
|
|
|
{
|
2010-05-27 12:10:33 -07:00
|
|
|
if (!aPossibleChild || aPossibleChild != mFirstChild) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-05-27 12:10:33 -07:00
|
|
|
return 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsDOMAttribute::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNotify)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMAttribute::AppendChildTo(nsIContent* aKid, bool aNotify)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMAttribute::RemoveChildAt(PRUint32 aIndex, bool aNotify)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-10-15 02:40:28 -07:00
|
|
|
if (aIndex != 0 || !mChild) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-09 03:10:29 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> child = mChild;
|
|
|
|
nsMutationGuard::DidMutate();
|
|
|
|
mozAutoDocUpdate updateBatch(GetOwnerDoc(), UPDATE_CONTENT_MODEL, aNotify);
|
2008-10-15 02:40:28 -07:00
|
|
|
|
2010-10-12 06:09:46 -07:00
|
|
|
doRemoveChild(aNotify);
|
2010-10-09 03:10:29 -07:00
|
|
|
}
|
2010-10-07 03:04:25 -07:00
|
|
|
|
2008-10-15 02:40:28 -07:00
|
|
|
nsString nullString;
|
|
|
|
SetDOMStringToNull(nullString);
|
|
|
|
SetValue(nullString);
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsDOMAttribute::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
aVisitor.mCanHandle = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-05-27 12:10:33 -07:00
|
|
|
void
|
|
|
|
nsDOMAttribute::EnsureChildState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-05-27 12:10:33 -07:00
|
|
|
NS_PRECONDITION(!mChild, "Someone screwed up");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsAutoString value;
|
2010-05-27 12:10:33 -07:00
|
|
|
GetValue(value);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-05-27 12:10:33 -07:00
|
|
|
if (!value.IsEmpty()) {
|
|
|
|
NS_NewTextNode(&mChild, mNodeInfo->NodeInfoManager());
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-05-27 12:10:33 -07:00
|
|
|
static_cast<nsTextNode*>(mChild)->BindToAttribute(this);
|
|
|
|
mFirstChild = mChild;
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
mChild->SetText(value, false);
|
2010-05-27 12:10:33 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsDOMAttribute::AttributeChanged(nsIDocument* aDocument,
|
2010-08-24 00:05:56 -07:00
|
|
|
Element* aElement,
|
2010-05-27 12:10:33 -07:00
|
|
|
PRInt32 aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aModType)
|
|
|
|
{
|
|
|
|
nsIContent* content = GetContentInternal();
|
2010-08-24 00:05:56 -07:00
|
|
|
if (aElement != content) {
|
2010-05-27 12:10:33 -07:00
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-05-27 12:10:33 -07:00
|
|
|
if (aNameSpaceID != mNodeInfo->NamespaceID()) {
|
|
|
|
return;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-05-27 12:10:33 -07:00
|
|
|
nsCOMPtr<nsIAtom> nameAtom = GetNameAtom(content);
|
|
|
|
if (nameAtom != aAttribute) {
|
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-21 08:33:32 -07:00
|
|
|
nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
|
|
|
|
|
2010-05-27 12:10:33 -07:00
|
|
|
// Just blow away our mChild and recreate it if needed
|
|
|
|
if (mChild) {
|
2010-10-12 06:09:46 -07:00
|
|
|
doRemoveChild(true);
|
2010-05-27 12:10:33 -07:00
|
|
|
}
|
|
|
|
EnsureChildState();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsDOMAttribute::Initialize()
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
sInitialized = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsDOMAttribute::Shutdown()
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
sInitialized = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-10-07 03:04:25 -07:00
|
|
|
|
|
|
|
void
|
2010-10-12 06:09:46 -07:00
|
|
|
nsDOMAttribute::doRemoveChild(bool aNotify)
|
2010-10-07 03:04:25 -07:00
|
|
|
{
|
2010-10-12 06:09:46 -07:00
|
|
|
if (aNotify) {
|
|
|
|
nsNodeUtils::AttributeChildRemoved(this, mChild);
|
|
|
|
}
|
|
|
|
|
2010-10-07 03:04:25 -07:00
|
|
|
static_cast<nsTextNode*>(mChild)->UnbindFromAttribute();
|
|
|
|
NS_RELEASE(mChild);
|
|
|
|
mFirstChild = nsnull;
|
|
|
|
}
|
|
|
|
|