1998-11-11 22:06:16 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
1998-11-11 22:06:16 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* 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.
|
1998-11-11 22:06:16 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
1999-11-06 03:40:37 +00:00
|
|
|
* Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-11-11 22:06:16 +00:00
|
|
|
*/
|
|
|
|
#include "nsGenericElement.h"
|
|
|
|
|
1999-01-12 16:37:24 +00:00
|
|
|
#include "nsDOMAttribute.h"
|
|
|
|
#include "nsDOMAttributeMap.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsIAtom.h"
|
2000-05-10 13:13:39 +00:00
|
|
|
#include "nsINodeInfo.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDOMNodeList.h"
|
1998-11-30 07:59:11 +00:00
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsIDOMDocumentFragment.h"
|
1998-12-17 07:22:28 +00:00
|
|
|
#include "nsIDOMRange.h"
|
1999-01-25 22:17:15 +00:00
|
|
|
#include "nsIDOMText.h"
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:31:05 +00:00
|
|
|
#include "nsIDOMEventReceiver.h"
|
1998-12-30 08:28:16 +00:00
|
|
|
#include "nsRange.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsIEventListenerManager.h"
|
|
|
|
#include "nsILinkHandler.h"
|
|
|
|
#include "nsIScriptGlobalObject.h"
|
|
|
|
#include "nsIScriptObjectOwner.h"
|
|
|
|
#include "nsISizeOfHandler.h"
|
|
|
|
#include "nsISupportsArray.h"
|
|
|
|
#include "nsIURL.h"
|
1999-11-30 04:50:42 +00:00
|
|
|
#include "nsNetUtil.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsFrame.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsDOMEventsIIDs.h"
|
|
|
|
#include "nsIEventStateManager.h"
|
|
|
|
#include "nsDOMEvent.h"
|
|
|
|
#include "nsIPrivateDOMEvent.h"
|
|
|
|
#include "nsDOMCID.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMScriptObjectFactory.h"
|
|
|
|
#include "nsIDOMCSSStyleDeclaration.h"
|
|
|
|
#include "nsDOMCSSDeclaration.h"
|
1998-12-11 02:35:06 +00:00
|
|
|
#include "nsINameSpaceManager.h"
|
1999-01-18 03:43:43 +00:00
|
|
|
#include "nsContentList.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "prprf.h"
|
|
|
|
#include "prmem.h"
|
1999-09-08 23:18:27 +00:00
|
|
|
#include "nsDOMError.h"
|
2000-01-08 16:51:54 +00:00
|
|
|
#include "nsScriptSecurityManager.h"
|
2000-11-27 07:55:20 +00:00
|
|
|
#include "nsIDOMMutationEvent.h"
|
|
|
|
#include "nsMutationEvent.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2000-05-10 01:09:45 +00:00
|
|
|
#include "nsIBindingManager.h"
|
|
|
|
#include "nsIXBLBinding.h"
|
2000-06-14 08:19:07 +00:00
|
|
|
#include "nsIDOMCSSStyleDeclaration.h"
|
|
|
|
#include "nsIDOMViewCSS.h"
|
|
|
|
#include "nsIXBLService.h"
|
2000-11-27 07:55:20 +00:00
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
#include "nsEventListenerManager.h"
|
2000-05-10 01:09:45 +00:00
|
|
|
|
1999-01-25 22:17:15 +00:00
|
|
|
#include "nsLayoutAtoms.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsHTMLAtoms.h"
|
1999-12-18 20:29:29 +00:00
|
|
|
#include "nsLayoutUtils.h"
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:31:05 +00:00
|
|
|
#include "nsIJSContextStack.h"
|
2000-05-25 23:48:45 +00:00
|
|
|
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
|
|
|
NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
|
1999-01-25 22:17:15 +00:00
|
|
|
NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
|
1999-03-28 22:22:54 +00:00
|
|
|
NS_DEFINE_IID(kIDOMEventTargetIID, NS_IDOMEVENTTARGET_IID);
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:31:05 +00:00
|
|
|
NS_DEFINE_IID(kIDOMEventReceiverIID, NS_IDOMEVENTRECEIVER_IID);
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
|
|
|
NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
|
|
|
NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|
|
|
NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kIDOMAttrIID, NS_IDOMATTR_IID);
|
|
|
|
static NS_DEFINE_IID(kIDOMNamedNodeMapIID, NS_IDOMNAMEDNODEMAP_IID);
|
|
|
|
static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID);
|
|
|
|
static NS_DEFINE_IID(kIDOMNodeListIID, NS_IDOMNODELIST_IID);
|
|
|
|
static NS_DEFINE_IID(kIDOMCSSStyleDeclarationIID, NS_IDOMCSSSTYLEDECLARATION_IID);
|
1998-11-30 07:59:11 +00:00
|
|
|
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
|
|
|
|
static NS_DEFINE_IID(kIDOMDocumentFragmentIID, NS_IDOMDOCUMENTFRAGMENT_IID);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
nsChildContentList::nsChildContentList(nsIContent *aContent)
|
|
|
|
{
|
|
|
|
// This reference is not reference-counted. The content
|
|
|
|
// object tells us when its about to go away.
|
|
|
|
mContent = aContent;
|
|
|
|
}
|
|
|
|
|
1999-02-12 17:45:58 +00:00
|
|
|
nsChildContentList::~nsChildContentList()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsChildContentList::GetLength(PRUint32* aLength)
|
|
|
|
{
|
|
|
|
if (nsnull != mContent) {
|
|
|
|
PRInt32 length;
|
|
|
|
mContent->ChildCount(length);
|
|
|
|
*aLength = (PRUint32)length;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*aLength = 0;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsChildContentList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
|
|
|
{
|
|
|
|
nsIContent *content;
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
|
|
|
if (nsnull != mContent) {
|
|
|
|
mContent->ChildAt(aIndex, content);
|
|
|
|
if (nsnull != content) {
|
|
|
|
res = content->QueryInterface(kIDOMNodeIID, (void**)aReturn);
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*aReturn = nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*aReturn = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsChildContentList::DropReference()
|
|
|
|
{
|
|
|
|
mContent = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2000-02-08 01:12:59 +00:00
|
|
|
nsCheapVoidArray::nsCheapVoidArray()
|
|
|
|
{
|
|
|
|
mChildren = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCheapVoidArray::~nsCheapVoidArray()
|
|
|
|
{
|
|
|
|
if (!HasSingleChild()) {
|
|
|
|
nsVoidArray* vector = GetChildVector();
|
|
|
|
if (vector) {
|
|
|
|
delete vector;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32
|
|
|
|
nsCheapVoidArray::Count() const
|
|
|
|
{
|
|
|
|
if (HasSingleChild()) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsVoidArray* vector = GetChildVector();
|
|
|
|
if (vector) {
|
|
|
|
return vector->Count();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
|
|
|
nsCheapVoidArray::ElementAt(PRInt32 aIndex) const
|
|
|
|
{
|
|
|
|
if (HasSingleChild()) {
|
|
|
|
if (0 == aIndex) {
|
|
|
|
return (void*)GetSingleChild();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsVoidArray* vector = GetChildVector();
|
|
|
|
if (vector) {
|
|
|
|
return vector->ElementAt(aIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32
|
|
|
|
nsCheapVoidArray::IndexOf(void* aPossibleElement) const
|
|
|
|
{
|
|
|
|
if (HasSingleChild()) {
|
|
|
|
if (aPossibleElement == (void*)GetSingleChild()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsVoidArray* vector = GetChildVector();
|
|
|
|
if (vector) {
|
|
|
|
return vector->IndexOf(aPossibleElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsCheapVoidArray::InsertElementAt(void* aElement, PRInt32 aIndex)
|
|
|
|
{
|
|
|
|
nsVoidArray* vector;
|
|
|
|
if (HasSingleChild()) {
|
|
|
|
vector = SwitchToVector();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
vector = GetChildVector();
|
|
|
|
if (!vector) {
|
|
|
|
if (0 == aIndex) {
|
|
|
|
SetSingleChild(aElement);
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return vector->InsertElementAt(aElement, aIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsCheapVoidArray::ReplaceElementAt(void* aElement, PRInt32 aIndex)
|
|
|
|
{
|
|
|
|
if (HasSingleChild()) {
|
|
|
|
if (aIndex == 0) {
|
|
|
|
SetSingleChild(aElement);
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsVoidArray* vector = GetChildVector();
|
|
|
|
if (vector) {
|
|
|
|
return vector->ReplaceElementAt(aElement, aIndex);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsCheapVoidArray::AppendElement(void* aElement)
|
|
|
|
{
|
|
|
|
nsVoidArray* vector;
|
|
|
|
if (HasSingleChild()) {
|
|
|
|
vector = SwitchToVector();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
vector = GetChildVector();
|
|
|
|
if (!vector) {
|
|
|
|
SetSingleChild(aElement);
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return vector->AppendElement(aElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsCheapVoidArray::RemoveElement(void* aElement)
|
|
|
|
{
|
|
|
|
if (HasSingleChild()) {
|
|
|
|
if (aElement == GetSingleChild()) {
|
|
|
|
SetSingleChild(nsnull);
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsVoidArray* vector = GetChildVector();
|
|
|
|
if (vector) {
|
|
|
|
return vector->RemoveElement(aElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsCheapVoidArray::RemoveElementAt(PRInt32 aIndex)
|
|
|
|
{
|
|
|
|
if (HasSingleChild()) {
|
|
|
|
if (0 == aIndex) {
|
|
|
|
SetSingleChild(nsnull);
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsVoidArray* vector = GetChildVector();
|
|
|
|
if (vector) {
|
|
|
|
return vector->RemoveElementAt(aIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsCheapVoidArray::Compact()
|
|
|
|
{
|
|
|
|
if (!HasSingleChild()) {
|
|
|
|
nsVoidArray* vector = GetChildVector();
|
|
|
|
if (vector) {
|
|
|
|
vector->Compact();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsCheapVoidArray::SetSingleChild(void* aChild)
|
|
|
|
{
|
|
|
|
if (aChild)
|
|
|
|
mChildren = (void*)(PtrBits(aChild) | 0x1);
|
|
|
|
else
|
|
|
|
mChildren = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsVoidArray*
|
|
|
|
nsCheapVoidArray::SwitchToVector()
|
|
|
|
{
|
|
|
|
void* child = GetSingleChild();
|
|
|
|
|
|
|
|
mChildren = (void*)new nsVoidArray();
|
|
|
|
nsVoidArray* vector = GetChildVector();
|
|
|
|
if (vector && child) {
|
|
|
|
vector->AppendElement(child);
|
|
|
|
}
|
|
|
|
|
|
|
|
return vector;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
// XXX Currently, the script object factory is global. The way we
|
|
|
|
// obtain it should, at least, be made thread-safe later. Ideally,
|
|
|
|
// we'd find a better way.
|
|
|
|
nsIDOMScriptObjectFactory* nsGenericElement::gScriptObjectFactory = nsnull;
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kIDOMScriptObjectFactoryIID, NS_IDOM_SCRIPT_OBJECT_FACTORY_IID);
|
|
|
|
static NS_DEFINE_IID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::GetScriptObjectFactory(nsIDOMScriptObjectFactory **aResult)
|
|
|
|
{
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
|
|
|
|
if (nsnull == gScriptObjectFactory) {
|
|
|
|
result = nsServiceManager::GetService(kDOMScriptObjectFactoryCID,
|
|
|
|
kIDOMScriptObjectFactoryIID,
|
|
|
|
(nsISupports **)&gScriptObjectFactory);
|
|
|
|
if (result != NS_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = gScriptObjectFactory;
|
|
|
|
NS_ADDREF(gScriptObjectFactory);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-11-08 03:17:18 +00:00
|
|
|
/* static */ void
|
|
|
|
nsGenericElement::Shutdown()
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(gScriptObjectFactory); // assigns null
|
|
|
|
}
|
|
|
|
|
2000-05-10 13:13:39 +00:00
|
|
|
nsGenericElement::nsGenericElement() : mContent(nsnull), mDocument(nsnull),
|
2000-08-31 00:36:31 +00:00
|
|
|
mParent(nsnull), mNodeInfo(nsnull),
|
|
|
|
mDOMSlots(nsnull), mContentID(0)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGenericElement::~nsGenericElement()
|
|
|
|
{
|
1998-12-30 08:28:16 +00:00
|
|
|
// pop any enclosed ranges out
|
|
|
|
// nsRange::OwnerGone(mContent); not used for now
|
1998-11-11 22:06:16 +00:00
|
|
|
if (nsnull != mDOMSlots) {
|
|
|
|
if (nsnull != mDOMSlots->mChildNodes) {
|
|
|
|
mDOMSlots->mChildNodes->DropReference();
|
|
|
|
NS_RELEASE(mDOMSlots->mChildNodes);
|
1998-12-18 02:51:34 +00:00
|
|
|
delete mDOMSlots->mRangeList;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
if (nsnull != mDOMSlots->mStyle) {
|
|
|
|
mDOMSlots->mStyle->DropReference();
|
|
|
|
NS_RELEASE(mDOMSlots->mStyle);
|
|
|
|
}
|
1999-01-12 16:37:24 +00:00
|
|
|
if (nsnull != mDOMSlots->mAttributeMap) {
|
|
|
|
mDOMSlots->mAttributeMap->DropReference();
|
|
|
|
NS_RELEASE(mDOMSlots->mAttributeMap);
|
|
|
|
}
|
2000-05-16 11:35:12 +00:00
|
|
|
if (nsnull != mDOMSlots->mListenerManager) {
|
|
|
|
mDOMSlots->mListenerManager->SetListenerTarget(nsnull);
|
|
|
|
NS_RELEASE(mDOMSlots->mListenerManager);
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
// XXX Should really be arena managed
|
|
|
|
PR_DELETE(mDOMSlots);
|
|
|
|
}
|
2000-05-10 13:13:39 +00:00
|
|
|
NS_IF_RELEASE(mNodeInfo);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsDOMSlots *
|
|
|
|
nsGenericElement::GetDOMSlots()
|
|
|
|
{
|
|
|
|
if (nsnull == mDOMSlots) {
|
|
|
|
mDOMSlots = PR_NEW(nsDOMSlots);
|
|
|
|
mDOMSlots->mScriptObject = nsnull;
|
|
|
|
mDOMSlots->mChildNodes = nsnull;
|
|
|
|
mDOMSlots->mStyle = nsnull;
|
1999-01-12 16:37:24 +00:00
|
|
|
mDOMSlots->mAttributeMap = nsnull;
|
1998-12-18 02:51:34 +00:00
|
|
|
mDOMSlots->mRangeList = nsnull;
|
1999-03-28 22:22:54 +00:00
|
|
|
mDOMSlots->mCapturer = nsnull;
|
Landing changes Vidur made while the tree was closed for beta1 work, here's a list of the changes. r=me
[1] Cutting down the size of content. Made nsIJSScriptObject inherit from nsIScriptObjectOwner
[2] Cutting down the size of content. Made nsITextContent inherit from nsIContent.
[3] Cutting down the size of content. Moved implementation of nsIDOMReceiver to nsListenerManager. This is not true aggregation since it isn't transitive, but it's OK for now. It will be necessary for nsListenerManager to have a reference to its content in the future anyway, so the transitivity could be done.
dom/public/nsDOMPropEnums.h,v - bug 12559
dom/public/nsIJSScriptObject.h,v - [1]
dom/public/html/MANIFEST,v - bug 12559
dom/public/html/Makefile.in,v - bug 12559
dom/public/html/makefile.win,v - bug 12559
dom/public/html/nsIDOMHTMLInputElement.h,v - bug 17544
dom/public/idl/html/HTMLAnchorElement.idl,v - bug 12559
dom/public/idl/html/HTMLAreaElement.idl,v - bug 12559
dom/public/idl/html/HTMLInputElement.idl,v - bug 17544
dom/src/base/nsGlobalWindow.cpp,v - bug 30700
dom/src/base/nsGlobalWindow.h,v - [1]
dom/src/base/nsLocation.cpp,v - [1]
dom/src/html/nsJSHTMLAnchorElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLAreaElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLInputElement.cpp,v - bug 17544
layout/base/public/nsIDocument.h,v - bug 27953
layout/base/public/nsITextContent.h,v - [2]
layout/base/src/nsCommentNode.cpp,v - [2]
layout/base/src/nsDocument.cpp,v - bug 27953
layout/base/src/nsDocument.h,v - bug 27953
layout/base/src/nsDocumentViewer.cpp,v - bug 27953
layout/base/src/nsGenericDOMDataNode.cpp,v - [3]
layout/base/src/nsGenericDOMDataNode.h,v - [3]
layout/base/src/nsGenericElement.cpp,v - [3]
layout/base/src/nsGenericElement.h,v - [3]
layout/base/src/nsNameSpaceManager.cpp,v - bug 7834
layout/base/src/nsStyleContext.cpp,v - outline property shouldn't reflow
layout/base/src/nsTextNode.cpp,v - [2]
layout/events/src/nsEventListenerManager.cpp,v - [3]
layout/events/src/nsEventListenerManager.h,v - [3]
layout/html/base/src/nsGfxScrollFrame.cpp,v - nsString->nsAutoString
layout/html/content/src/nsAttributeContent.cpp,v - [2]
layout/html/content/src/nsHTMLAnchorElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAppletElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBodyElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLButtonElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDirectoryElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDivElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLEmbedElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFieldSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFormElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadingElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHtmlElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLImageElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInputElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInsElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIsIndexElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLIElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLabelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLayerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLegendElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLinkElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMapElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMenuElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMetaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLModElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLObjectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParagraphElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParamElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLPreElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLQuoteElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLScriptElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSelectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpacerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpanElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLStyleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCaptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCellElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableRowElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableSectionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTextAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTitleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLUListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLWBRElement.cpp,v - [1][3]
layout/html/document/src/nsHTMLDocument.cpp,v - bug 27953
layout/html/document/src/nsHTMLDocument.h,v - bug 27953
layout/xml/content/src/nsXMLCDATASection.cpp,v - [1][2]
layout/xml/content/src/nsXMLDocumentType.cpp,v - [1][2]
layout/xml/content/src/nsXMLElement.h,v - [1][2]
layout/xml/content/src/nsXMLEntity.cpp,v - [1][2]
layout/xml/content/src/nsXMLNotation.cpp,v - [1][2]
layout/xml/content/src/nsXMLProcessingInstruction.cpp,v - [1][2]
layout/xul/base/src/nsBoxFrame.cpp,v - nsString->nsAutoString
layout/xul/base/src/nsSliderFrame.cpp,v - nsString->nsAutoString
netwerk/protocol/http/src/nsHTTPRequest.cpp,v - nsString->nsAutoString
rdf/content/src/nsXULDocument.cpp,v - bug 27953
rdf/content/src/nsXULDocument.h,v - bug 27953
rdf/content/src/nsXULElement.h,v - [1]
xpcom/base/IIDS.h,v - bug 12559
2000-03-17 13:27:00 +00:00
|
|
|
mDOMSlots->mListenerManager = nsnull;
|
2000-08-12 06:28:02 +00:00
|
|
|
mDOMSlots->mBindingParent = nsnull;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return mDOMSlots;
|
|
|
|
}
|
|
|
|
|
Landing changes Vidur made while the tree was closed for beta1 work, here's a list of the changes. r=me
[1] Cutting down the size of content. Made nsIJSScriptObject inherit from nsIScriptObjectOwner
[2] Cutting down the size of content. Made nsITextContent inherit from nsIContent.
[3] Cutting down the size of content. Moved implementation of nsIDOMReceiver to nsListenerManager. This is not true aggregation since it isn't transitive, but it's OK for now. It will be necessary for nsListenerManager to have a reference to its content in the future anyway, so the transitivity could be done.
dom/public/nsDOMPropEnums.h,v - bug 12559
dom/public/nsIJSScriptObject.h,v - [1]
dom/public/html/MANIFEST,v - bug 12559
dom/public/html/Makefile.in,v - bug 12559
dom/public/html/makefile.win,v - bug 12559
dom/public/html/nsIDOMHTMLInputElement.h,v - bug 17544
dom/public/idl/html/HTMLAnchorElement.idl,v - bug 12559
dom/public/idl/html/HTMLAreaElement.idl,v - bug 12559
dom/public/idl/html/HTMLInputElement.idl,v - bug 17544
dom/src/base/nsGlobalWindow.cpp,v - bug 30700
dom/src/base/nsGlobalWindow.h,v - [1]
dom/src/base/nsLocation.cpp,v - [1]
dom/src/html/nsJSHTMLAnchorElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLAreaElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLInputElement.cpp,v - bug 17544
layout/base/public/nsIDocument.h,v - bug 27953
layout/base/public/nsITextContent.h,v - [2]
layout/base/src/nsCommentNode.cpp,v - [2]
layout/base/src/nsDocument.cpp,v - bug 27953
layout/base/src/nsDocument.h,v - bug 27953
layout/base/src/nsDocumentViewer.cpp,v - bug 27953
layout/base/src/nsGenericDOMDataNode.cpp,v - [3]
layout/base/src/nsGenericDOMDataNode.h,v - [3]
layout/base/src/nsGenericElement.cpp,v - [3]
layout/base/src/nsGenericElement.h,v - [3]
layout/base/src/nsNameSpaceManager.cpp,v - bug 7834
layout/base/src/nsStyleContext.cpp,v - outline property shouldn't reflow
layout/base/src/nsTextNode.cpp,v - [2]
layout/events/src/nsEventListenerManager.cpp,v - [3]
layout/events/src/nsEventListenerManager.h,v - [3]
layout/html/base/src/nsGfxScrollFrame.cpp,v - nsString->nsAutoString
layout/html/content/src/nsAttributeContent.cpp,v - [2]
layout/html/content/src/nsHTMLAnchorElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAppletElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBodyElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLButtonElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDirectoryElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDivElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLEmbedElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFieldSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFormElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadingElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHtmlElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLImageElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInputElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInsElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIsIndexElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLIElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLabelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLayerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLegendElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLinkElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMapElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMenuElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMetaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLModElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLObjectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParagraphElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParamElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLPreElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLQuoteElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLScriptElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSelectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpacerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpanElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLStyleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCaptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCellElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableRowElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableSectionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTextAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTitleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLUListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLWBRElement.cpp,v - [1][3]
layout/html/document/src/nsHTMLDocument.cpp,v - bug 27953
layout/html/document/src/nsHTMLDocument.h,v - bug 27953
layout/xml/content/src/nsXMLCDATASection.cpp,v - [1][2]
layout/xml/content/src/nsXMLDocumentType.cpp,v - [1][2]
layout/xml/content/src/nsXMLElement.h,v - [1][2]
layout/xml/content/src/nsXMLEntity.cpp,v - [1][2]
layout/xml/content/src/nsXMLNotation.cpp,v - [1][2]
layout/xml/content/src/nsXMLProcessingInstruction.cpp,v - [1][2]
layout/xul/base/src/nsBoxFrame.cpp,v - nsString->nsAutoString
layout/xul/base/src/nsSliderFrame.cpp,v - nsString->nsAutoString
netwerk/protocol/http/src/nsHTTPRequest.cpp,v - nsString->nsAutoString
rdf/content/src/nsXULDocument.cpp,v - bug 27953
rdf/content/src/nsXULDocument.h,v - bug 27953
rdf/content/src/nsXULElement.h,v - [1]
xpcom/base/IIDS.h,v - bug 12559
2000-03-17 13:27:00 +00:00
|
|
|
void
|
|
|
|
nsGenericElement::MaybeClearDOMSlots()
|
|
|
|
{
|
|
|
|
if (mDOMSlots &&
|
|
|
|
(nsnull == mDOMSlots->mScriptObject) &&
|
|
|
|
(nsnull == mDOMSlots->mChildNodes) &&
|
|
|
|
(nsnull == mDOMSlots->mStyle) &&
|
|
|
|
(nsnull == mDOMSlots->mAttributeMap) &&
|
|
|
|
(nsnull == mDOMSlots->mRangeList) &&
|
|
|
|
(nsnull == mDOMSlots->mCapturer) &&
|
2000-08-12 06:28:02 +00:00
|
|
|
(nsnull == mDOMSlots->mListenerManager) &&
|
|
|
|
(nsnull == mDOMSlots->mBindingParent)) {
|
Landing changes Vidur made while the tree was closed for beta1 work, here's a list of the changes. r=me
[1] Cutting down the size of content. Made nsIJSScriptObject inherit from nsIScriptObjectOwner
[2] Cutting down the size of content. Made nsITextContent inherit from nsIContent.
[3] Cutting down the size of content. Moved implementation of nsIDOMReceiver to nsListenerManager. This is not true aggregation since it isn't transitive, but it's OK for now. It will be necessary for nsListenerManager to have a reference to its content in the future anyway, so the transitivity could be done.
dom/public/nsDOMPropEnums.h,v - bug 12559
dom/public/nsIJSScriptObject.h,v - [1]
dom/public/html/MANIFEST,v - bug 12559
dom/public/html/Makefile.in,v - bug 12559
dom/public/html/makefile.win,v - bug 12559
dom/public/html/nsIDOMHTMLInputElement.h,v - bug 17544
dom/public/idl/html/HTMLAnchorElement.idl,v - bug 12559
dom/public/idl/html/HTMLAreaElement.idl,v - bug 12559
dom/public/idl/html/HTMLInputElement.idl,v - bug 17544
dom/src/base/nsGlobalWindow.cpp,v - bug 30700
dom/src/base/nsGlobalWindow.h,v - [1]
dom/src/base/nsLocation.cpp,v - [1]
dom/src/html/nsJSHTMLAnchorElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLAreaElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLInputElement.cpp,v - bug 17544
layout/base/public/nsIDocument.h,v - bug 27953
layout/base/public/nsITextContent.h,v - [2]
layout/base/src/nsCommentNode.cpp,v - [2]
layout/base/src/nsDocument.cpp,v - bug 27953
layout/base/src/nsDocument.h,v - bug 27953
layout/base/src/nsDocumentViewer.cpp,v - bug 27953
layout/base/src/nsGenericDOMDataNode.cpp,v - [3]
layout/base/src/nsGenericDOMDataNode.h,v - [3]
layout/base/src/nsGenericElement.cpp,v - [3]
layout/base/src/nsGenericElement.h,v - [3]
layout/base/src/nsNameSpaceManager.cpp,v - bug 7834
layout/base/src/nsStyleContext.cpp,v - outline property shouldn't reflow
layout/base/src/nsTextNode.cpp,v - [2]
layout/events/src/nsEventListenerManager.cpp,v - [3]
layout/events/src/nsEventListenerManager.h,v - [3]
layout/html/base/src/nsGfxScrollFrame.cpp,v - nsString->nsAutoString
layout/html/content/src/nsAttributeContent.cpp,v - [2]
layout/html/content/src/nsHTMLAnchorElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAppletElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBodyElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLButtonElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDirectoryElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDivElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLEmbedElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFieldSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFormElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadingElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHtmlElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLImageElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInputElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInsElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIsIndexElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLIElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLabelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLayerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLegendElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLinkElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMapElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMenuElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMetaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLModElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLObjectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParagraphElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParamElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLPreElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLQuoteElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLScriptElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSelectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpacerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpanElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLStyleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCaptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCellElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableRowElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableSectionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTextAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTitleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLUListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLWBRElement.cpp,v - [1][3]
layout/html/document/src/nsHTMLDocument.cpp,v - bug 27953
layout/html/document/src/nsHTMLDocument.h,v - bug 27953
layout/xml/content/src/nsXMLCDATASection.cpp,v - [1][2]
layout/xml/content/src/nsXMLDocumentType.cpp,v - [1][2]
layout/xml/content/src/nsXMLElement.h,v - [1][2]
layout/xml/content/src/nsXMLEntity.cpp,v - [1][2]
layout/xml/content/src/nsXMLNotation.cpp,v - [1][2]
layout/xml/content/src/nsXMLProcessingInstruction.cpp,v - [1][2]
layout/xul/base/src/nsBoxFrame.cpp,v - nsString->nsAutoString
layout/xul/base/src/nsSliderFrame.cpp,v - nsString->nsAutoString
netwerk/protocol/http/src/nsHTTPRequest.cpp,v - nsString->nsAutoString
rdf/content/src/nsXULDocument.cpp,v - bug 27953
rdf/content/src/nsXULDocument.h,v - bug 27953
rdf/content/src/nsXULElement.h,v - [1]
xpcom/base/IIDS.h,v - bug 12559
2000-03-17 13:27:00 +00:00
|
|
|
PR_DELETE(mDOMSlots);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
void
|
|
|
|
nsGenericElement::Init(nsIContent* aOuterContentObject,
|
2000-05-10 13:13:39 +00:00
|
|
|
nsINodeInfo *aNodeInfo)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
2000-05-10 13:13:39 +00:00
|
|
|
NS_ABORT_IF_FALSE(aOuterContentObject, "We need a outer content object!");
|
|
|
|
NS_ABORT_IF_FALSE(aNodeInfo, "This can't be used without node info!");
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_ASSERTION((nsnull == mContent) && (nsnull != aOuterContentObject),
|
|
|
|
"null ptr");
|
|
|
|
|
2000-05-10 13:13:39 +00:00
|
|
|
mContent = aOuterContentObject;
|
|
|
|
mNodeInfo = aNodeInfo;
|
|
|
|
NS_IF_ADDREF(mNodeInfo);
|
2000-04-01 13:31:23 +00:00
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::GetNodeValue(nsAWritableString& aNodeValue)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
aNodeValue.Truncate();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::SetNodeValue(const nsAReadableString& aNodeValue)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
1999-09-08 23:18:27 +00:00
|
|
|
// The node value can't be modified
|
|
|
|
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::GetNodeType(PRUint16* aNodeType)
|
|
|
|
{
|
|
|
|
*aNodeType = (PRUint16)nsIDOMNode::ELEMENT_NODE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::GetParentNode(nsIDOMNode** aParentNode)
|
|
|
|
{
|
1999-04-17 00:56:25 +00:00
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
if (nsnull != mParent) {
|
1999-04-17 00:56:25 +00:00
|
|
|
res = mParent->QueryInterface(kIDOMNodeIID, (void**)aParentNode);
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_ASSERTION(NS_OK == res, "Must be a DOM Node");
|
|
|
|
}
|
1999-01-19 03:54:26 +00:00
|
|
|
else if (nsnull == mDocument) {
|
1999-04-17 00:56:25 +00:00
|
|
|
*aParentNode = nsnull;
|
1999-01-19 03:54:26 +00:00
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
else {
|
1999-01-19 03:54:26 +00:00
|
|
|
// If we don't have a parent, but we're in the document, we must
|
|
|
|
// be the root node of the document. The DOM says that the root
|
|
|
|
// is the document.
|
1999-04-17 00:56:25 +00:00
|
|
|
res = mDocument->QueryInterface(kIDOMNodeIID, (void**)aParentNode);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1999-04-17 00:56:25 +00:00
|
|
|
|
|
|
|
return res;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1999-03-31 20:49:25 +00:00
|
|
|
nsGenericElement::GetPreviousSibling(nsIDOMNode** aPrevSibling)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
1999-03-31 20:49:25 +00:00
|
|
|
nsIContent* sibling = nsnull;
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
if (nsnull != mParent) {
|
|
|
|
PRInt32 pos;
|
|
|
|
mParent->IndexOf(mContent, pos);
|
1999-03-31 20:49:25 +00:00
|
|
|
if (pos > -1 ) {
|
|
|
|
mParent->ChildAt(--pos, sibling);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
1999-03-31 20:49:25 +00:00
|
|
|
else if (nsnull != mDocument) {
|
|
|
|
// Nodes that are just below the document (their parent is the
|
|
|
|
// document) need to go to the document to find their next sibling.
|
|
|
|
PRInt32 pos;
|
|
|
|
mDocument->IndexOf(mContent, pos);
|
|
|
|
if (pos > -1 ) {
|
|
|
|
mDocument->ChildAt(--pos, sibling);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull != sibling) {
|
|
|
|
result = sibling->QueryInterface(kIDOMNodeIID,(void**)aPrevSibling);
|
|
|
|
NS_ASSERTION(NS_OK == result, "Must be a DOM Node");
|
|
|
|
NS_RELEASE(sibling); // balance the AddRef in ChildAt()
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*aPrevSibling = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::GetNextSibling(nsIDOMNode** aNextSibling)
|
|
|
|
{
|
1999-03-31 20:49:25 +00:00
|
|
|
nsIContent* sibling = nsnull;
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
if (nsnull != mParent) {
|
|
|
|
PRInt32 pos;
|
|
|
|
mParent->IndexOf(mContent, pos);
|
|
|
|
if (pos > -1 ) {
|
1999-03-31 20:49:25 +00:00
|
|
|
mParent->ChildAt(++pos, sibling);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
1999-03-31 20:49:25 +00:00
|
|
|
else if (nsnull != mDocument) {
|
|
|
|
// Nodes that are just below the document (their parent is the
|
|
|
|
// document) need to go to the document to find their next sibling.
|
|
|
|
PRInt32 pos;
|
|
|
|
mDocument->IndexOf(mContent, pos);
|
|
|
|
if (pos > -1 ) {
|
|
|
|
mDocument->ChildAt(++pos, sibling);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull != sibling) {
|
|
|
|
result = sibling->QueryInterface(kIDOMNodeIID,(void**)aNextSibling);
|
|
|
|
NS_ASSERTION(NS_OK == result, "Must be a DOM Node");
|
|
|
|
NS_RELEASE(sibling); // balance the AddRef in ChildAt()
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*aNextSibling = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
|
|
|
{
|
|
|
|
// XXX Actually the owner document is the document in whose context
|
|
|
|
// the element has been created. We should be able to get at it
|
|
|
|
// whether or not we are attached to the document.
|
|
|
|
if (nsnull != mDocument) {
|
|
|
|
return mDocument->QueryInterface(kIDOMDocumentIID, (void **)aOwnerDocument);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*aOwnerDocument = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-10 13:13:39 +00:00
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::GetNamespaceURI(nsAWritableString& aNamespaceURI)
|
2000-05-10 13:13:39 +00:00
|
|
|
{
|
|
|
|
return mNodeInfo->GetNamespaceURI(aNamespaceURI);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::GetPrefix(nsAWritableString& aPrefix)
|
2000-05-10 13:13:39 +00:00
|
|
|
{
|
|
|
|
return mNodeInfo->GetPrefix(aPrefix);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::SetPrefix(const nsAReadableString& aPrefix)
|
2000-05-10 13:13:39 +00:00
|
|
|
{
|
|
|
|
// XXX: Validate the prefix string!
|
|
|
|
|
|
|
|
nsINodeInfo *newNodeInfo = nsnull;
|
|
|
|
nsCOMPtr<nsIAtom> prefix;
|
|
|
|
|
|
|
|
if (aPrefix.Length()) {
|
|
|
|
prefix = dont_AddRef(NS_NewAtom(aPrefix));
|
|
|
|
NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = mNodeInfo->PrefixChanged(prefix, newNodeInfo);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
NS_RELEASE(mNodeInfo);
|
|
|
|
|
|
|
|
mNodeInfo = newNodeInfo;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-14 13:08:00 +00:00
|
|
|
nsresult
|
2000-09-14 05:19:00 +00:00
|
|
|
nsGenericElement::InternalIsSupported(const nsAReadableString& aFeature,
|
|
|
|
const nsAReadableString& aVersion,
|
|
|
|
PRBool* aReturn)
|
2000-05-14 13:08:00 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aReturn);
|
|
|
|
*aReturn = PR_FALSE;
|
2000-08-23 17:27:06 +00:00
|
|
|
nsAutoString feature(aFeature);
|
2000-05-14 13:08:00 +00:00
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
if (feature.EqualsWithConversion("XML", PR_TRUE) ||
|
|
|
|
feature.EqualsWithConversion("HTML", PR_TRUE)) {
|
2000-05-14 13:08:00 +00:00
|
|
|
if (!aVersion.Length() ||
|
2000-08-23 17:27:06 +00:00
|
|
|
aVersion.Equals(NS_LITERAL_STRING("1.0")) ||
|
|
|
|
aVersion.Equals(NS_LITERAL_STRING("2.0"))) {
|
2000-05-14 13:08:00 +00:00
|
|
|
*aReturn = PR_TRUE;
|
|
|
|
}
|
2000-08-23 17:27:06 +00:00
|
|
|
} else if (feature.EqualsWithConversion("Views", PR_TRUE) ||
|
|
|
|
feature.EqualsWithConversion("StyleSheets", PR_TRUE) ||
|
|
|
|
feature.EqualsWithConversion("CSS", PR_TRUE) ||
|
|
|
|
// feature.EqualsWithConversion("CSS2", PR_TRUE) ||
|
|
|
|
feature.EqualsWithConversion("Events", PR_TRUE) ||
|
|
|
|
// feature.EqualsWithConversion("UIEvents", PR_TRUE) ||
|
|
|
|
feature.EqualsWithConversion("MouseEvents", PR_TRUE) ||
|
|
|
|
feature.EqualsWithConversion("HTMLEvents", PR_TRUE) ||
|
|
|
|
feature.EqualsWithConversion("Range", PR_TRUE)) {
|
|
|
|
if (!aVersion.Length() || aVersion.Equals(NS_LITERAL_STRING("2.0"))) {
|
2000-05-14 13:08:00 +00:00
|
|
|
*aReturn = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-10 13:13:39 +00:00
|
|
|
nsresult
|
2000-09-14 05:19:00 +00:00
|
|
|
nsGenericElement::IsSupported(const nsAReadableString& aFeature,
|
|
|
|
const nsAReadableString& aVersion,
|
|
|
|
PRBool* aReturn)
|
2000-05-10 13:13:39 +00:00
|
|
|
{
|
2000-09-14 05:19:00 +00:00
|
|
|
return InternalIsSupported(aFeature, aVersion, aReturn);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::HasAttributes(PRBool* aReturn)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aReturn);
|
|
|
|
PRInt32 attrCount = 0;
|
|
|
|
|
|
|
|
mContent->GetAttributeCount(attrCount);
|
|
|
|
|
|
|
|
*aReturn = !!attrCount;
|
|
|
|
|
|
|
|
return NS_OK;
|
2000-05-10 13:13:39 +00:00
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericElement::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aAttributes, "null pointer argument");
|
1999-01-12 16:37:24 +00:00
|
|
|
nsDOMSlots *slots = GetDOMSlots();
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1999-01-12 16:37:24 +00:00
|
|
|
if (nsnull == slots->mAttributeMap) {
|
|
|
|
slots->mAttributeMap = new nsDOMAttributeMap(mContent);
|
|
|
|
if (nsnull == slots->mAttributeMap) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
NS_ADDREF(slots->mAttributeMap);
|
|
|
|
}
|
|
|
|
|
|
|
|
return slots->mAttributeMap->QueryInterface(kIDOMNamedNodeMapIID,
|
|
|
|
(void **)aAttributes);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::GetTagName(nsAWritableString& aTagName)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
aTagName.Truncate();
|
2000-05-10 13:13:39 +00:00
|
|
|
if (mNodeInfo) {
|
|
|
|
mNodeInfo->GetName(aTagName);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::GetAttribute(const nsAReadableString& aName, nsAWritableString& aReturn)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
2000-08-31 00:36:31 +00:00
|
|
|
nsCOMPtr<nsINodeInfo> ni;
|
|
|
|
mContent->NormalizeAttributeString(aName, *getter_AddRefs(ni));
|
|
|
|
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
PRInt32 nsid;
|
|
|
|
nsCOMPtr<nsIAtom> nameAtom;
|
|
|
|
|
|
|
|
ni->GetNamespaceID(nsid);
|
|
|
|
ni->GetNameAtom(*getter_AddRefs(nameAtom));
|
1999-01-12 16:37:24 +00:00
|
|
|
|
2000-08-31 00:36:31 +00:00
|
|
|
mContent->GetAttribute(nsid, nameAtom, aReturn);
|
1999-01-12 16:37:24 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::SetAttribute(const nsAReadableString& aName,
|
|
|
|
const nsAReadableString& aValue)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
2000-08-31 00:36:31 +00:00
|
|
|
nsCOMPtr<nsINodeInfo> ni;
|
|
|
|
mContent->NormalizeAttributeString(aName, *getter_AddRefs(ni));
|
|
|
|
return mContent->SetAttribute(ni, aValue, PR_TRUE);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::RemoveAttribute(const nsAReadableString& aName)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
2000-08-31 00:36:31 +00:00
|
|
|
nsCOMPtr<nsINodeInfo> ni;
|
|
|
|
mContent->NormalizeAttributeString(aName, *getter_AddRefs(ni));
|
|
|
|
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
2000-05-25 23:48:45 +00:00
|
|
|
|
2000-08-31 00:36:31 +00:00
|
|
|
PRInt32 nsid;
|
|
|
|
nsCOMPtr<nsIAtom> tag;
|
1999-01-12 16:37:24 +00:00
|
|
|
|
2000-08-31 00:36:31 +00:00
|
|
|
ni->GetNamespaceID(nsid);
|
|
|
|
ni->GetNameAtom(*getter_AddRefs(tag));
|
1999-01-12 16:37:24 +00:00
|
|
|
|
2000-08-31 00:36:31 +00:00
|
|
|
return mContent->UnsetAttribute(nsid, tag, PR_TRUE);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::GetAttributeNode(const nsAReadableString& aName,
|
1998-12-20 01:21:23 +00:00
|
|
|
nsIDOMAttr** aReturn)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
1999-01-12 16:37:24 +00:00
|
|
|
if (nsnull == aReturn) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1999-01-12 16:37:24 +00:00
|
|
|
nsIDOMNamedNodeMap* map;
|
|
|
|
nsresult result = GetAttributes(&map);
|
|
|
|
|
|
|
|
*aReturn = nsnull;
|
|
|
|
if (NS_OK == result) {
|
|
|
|
nsIDOMNode* node;
|
|
|
|
result = map->GetNamedItem(aName, &node);
|
|
|
|
if ((NS_OK == result) && (nsnull != node)) {
|
|
|
|
result = node->QueryInterface(kIDOMAttrIID, (void **)aReturn);
|
|
|
|
NS_IF_RELEASE(node);
|
|
|
|
}
|
|
|
|
NS_RELEASE(map);
|
1998-12-20 01:21:23 +00:00
|
|
|
}
|
1999-01-12 16:37:24 +00:00
|
|
|
|
|
|
|
return result;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::SetAttributeNode(nsIDOMAttr* aAttribute,
|
1999-01-12 16:37:24 +00:00
|
|
|
nsIDOMAttr** aReturn)
|
|
|
|
{
|
|
|
|
if ((nsnull == aReturn) || (nsnull == aAttribute)) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
nsIDOMNamedNodeMap* map;
|
|
|
|
nsresult result = GetAttributes(&map);
|
|
|
|
|
|
|
|
*aReturn = nsnull;
|
|
|
|
if (NS_OK == result) {
|
|
|
|
nsIDOMNode *node, *returnNode;
|
|
|
|
result = aAttribute->QueryInterface(kIDOMNodeIID, (void **)&node);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
result = map->SetNamedItem(node, &returnNode);
|
|
|
|
if ((NS_OK == result) && (nsnull != returnNode)) {
|
|
|
|
result = returnNode->QueryInterface(kIDOMAttrIID, (void **)aReturn);
|
|
|
|
NS_IF_RELEASE(returnNode);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1999-01-12 16:37:24 +00:00
|
|
|
NS_RELEASE(node);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1999-01-12 16:37:24 +00:00
|
|
|
NS_RELEASE(map);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1999-01-12 16:37:24 +00:00
|
|
|
|
|
|
|
return result;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::RemoveAttributeNode(nsIDOMAttr* aAttribute,
|
1999-01-12 16:37:24 +00:00
|
|
|
nsIDOMAttr** aReturn)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
1999-01-12 16:37:24 +00:00
|
|
|
if ((nsnull == aReturn) || (nsnull == aAttribute)) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
nsIDOMNamedNodeMap* map;
|
|
|
|
nsresult result = GetAttributes(&map);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1999-01-12 16:37:24 +00:00
|
|
|
*aReturn = nsnull;
|
|
|
|
if (NS_OK == result) {
|
1998-11-11 22:06:16 +00:00
|
|
|
nsAutoString name;
|
1999-01-12 16:37:24 +00:00
|
|
|
|
|
|
|
result = aAttribute->GetName(name);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
nsIDOMNode* node;
|
|
|
|
result = map->RemoveNamedItem(name, &node);
|
|
|
|
if ((NS_OK == result) && (nsnull != node)) {
|
|
|
|
result = node->QueryInterface(kIDOMAttrIID, (void **)aReturn);
|
|
|
|
NS_RELEASE(node);
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1999-01-12 16:37:24 +00:00
|
|
|
NS_RELEASE(map);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
1999-01-12 16:37:24 +00:00
|
|
|
return result;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::GetElementsByTagName(const nsAReadableString& aTagname,
|
1999-01-15 19:18:30 +00:00
|
|
|
nsIDOMNodeList** aReturn)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
2000-08-31 00:36:31 +00:00
|
|
|
nsCOMPtr<nsIAtom> nameAtom;
|
2000-05-25 23:48:45 +00:00
|
|
|
|
2000-08-31 00:36:31 +00:00
|
|
|
nameAtom = dont_AddRef(NS_NewAtom(aTagname));
|
1999-01-18 03:43:43 +00:00
|
|
|
|
|
|
|
nsContentList* list = new nsContentList(mDocument,
|
|
|
|
nameAtom,
|
2000-08-31 00:36:31 +00:00
|
|
|
kNameSpaceID_Unknown,
|
1999-01-18 03:43:43 +00:00
|
|
|
mContent);
|
2000-08-31 00:36:31 +00:00
|
|
|
|
|
|
|
if (!list) {
|
1999-01-18 03:43:43 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
2000-09-14 04:53:03 +00:00
|
|
|
return list->QueryInterface(NS_GET_IID(nsIDOMNodeList), (void **)aReturn);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
2000-05-15 20:31:55 +00:00
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::GetAttributeNS(const nsAReadableString& aNamespaceURI,
|
2000-08-31 00:36:31 +00:00
|
|
|
const nsAReadableString& aLocalName,
|
|
|
|
nsAWritableString& aReturn)
|
2000-05-15 20:31:55 +00:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAtom> name(dont_AddRef(NS_NewAtom(aLocalName)));
|
|
|
|
PRInt32 nsid;
|
|
|
|
|
|
|
|
nsCOMPtr<nsINodeInfoManager> nimgr;
|
|
|
|
mNodeInfo->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
|
|
|
NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsINameSpaceManager> nsmgr;
|
|
|
|
nimgr->GetNamespaceManager(*getter_AddRefs(nsmgr));
|
|
|
|
NS_ENSURE_TRUE(nsmgr, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsmgr->GetNameSpaceID(aNamespaceURI, nsid);
|
|
|
|
|
|
|
|
if (nsid == kNameSpaceID_Unknown) {
|
|
|
|
// Unkonwn namespace means no attr...
|
|
|
|
|
|
|
|
aReturn.Truncate();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
mContent->GetAttribute(nsid, name, aReturn);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::SetAttributeNS(const nsAReadableString& aNamespaceURI,
|
|
|
|
const nsAReadableString& aQualifiedName,
|
|
|
|
const nsAReadableString& aValue)
|
2000-05-15 20:31:55 +00:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsINodeInfoManager> nimgr;
|
|
|
|
mNodeInfo->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
|
|
|
NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsINodeInfo> ni;
|
|
|
|
nsresult rv = nimgr->GetNodeInfo(aQualifiedName, aNamespaceURI,
|
|
|
|
*getter_AddRefs(ni));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2000-05-17 04:52:09 +00:00
|
|
|
return mContent->SetAttribute(ni, aValue, PR_TRUE);
|
2000-05-15 20:31:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::RemoveAttributeNS(const nsAReadableString& aNamespaceURI,
|
|
|
|
const nsAReadableString& aLocalName)
|
2000-05-15 20:31:55 +00:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAtom> name(dont_AddRef(NS_NewAtom(aLocalName)));
|
|
|
|
PRInt32 nsid;
|
|
|
|
|
|
|
|
nsCOMPtr<nsINodeInfoManager> nimgr;
|
|
|
|
mNodeInfo->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
|
|
|
NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsINameSpaceManager> nsmgr;
|
|
|
|
nimgr->GetNamespaceManager(*getter_AddRefs(nsmgr));
|
|
|
|
NS_ENSURE_TRUE(nsmgr, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsmgr->GetNameSpaceID(aNamespaceURI, nsid);
|
|
|
|
|
|
|
|
if (nsid == kNameSpaceID_Unknown) {
|
|
|
|
// Unkonwn namespace means no attr...
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString tmp;
|
|
|
|
mContent->UnsetAttribute(nsid, name, PR_TRUE);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::GetAttributeNodeNS(const nsAReadableString& aNamespaceURI,
|
|
|
|
const nsAReadableString& aLocalName,
|
2000-05-15 20:31:55 +00:00
|
|
|
nsIDOMAttr** aReturn)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aReturn);
|
|
|
|
|
|
|
|
nsIDOMNamedNodeMap* map;
|
|
|
|
nsresult result = GetAttributes(&map);
|
|
|
|
|
|
|
|
*aReturn = nsnull;
|
|
|
|
if (NS_OK == result) {
|
|
|
|
nsIDOMNode* node;
|
|
|
|
result = map->GetNamedItemNS(aNamespaceURI, aLocalName, &node);
|
|
|
|
if ((NS_OK == result) && (nsnull != node)) {
|
|
|
|
result = node->QueryInterface(kIDOMAttrIID, (void **)aReturn);
|
|
|
|
NS_IF_RELEASE(node);
|
|
|
|
}
|
|
|
|
NS_RELEASE(map);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::SetAttributeNodeNS(nsIDOMAttr* aNewAttr,
|
|
|
|
nsIDOMAttr** aReturn)
|
|
|
|
{
|
2000-05-25 23:48:45 +00:00
|
|
|
if ((nsnull == aReturn) || (nsnull == aNewAttr)) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
nsIDOMNamedNodeMap* map;
|
|
|
|
nsresult result = GetAttributes(&map);
|
|
|
|
|
|
|
|
*aReturn = nsnull;
|
|
|
|
if (NS_OK == result) {
|
|
|
|
nsIDOMNode *node, *returnNode;
|
|
|
|
result = aNewAttr->QueryInterface(kIDOMNodeIID, (void **)&node);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
result = map->SetNamedItemNS(node, &returnNode);
|
|
|
|
if ((NS_OK == result) && (nsnull != returnNode)) {
|
|
|
|
result = returnNode->QueryInterface(kIDOMAttrIID, (void **)aReturn);
|
|
|
|
NS_IF_RELEASE(returnNode);
|
|
|
|
}
|
|
|
|
NS_RELEASE(node);
|
|
|
|
}
|
|
|
|
NS_RELEASE(map);
|
|
|
|
}
|
|
|
|
|
2000-05-15 20:31:55 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::GetElementsByTagNameNS(const nsAReadableString& aNamespaceURI,
|
|
|
|
const nsAReadableString& aLocalName,
|
2000-05-15 20:31:55 +00:00
|
|
|
nsIDOMNodeList** aReturn)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAtom> nameAtom(dont_AddRef(NS_NewAtom(aLocalName)));
|
|
|
|
PRInt32 nameSpaceId = kNameSpaceID_Unknown;
|
|
|
|
|
|
|
|
nsContentList* list = nsnull;
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
if (!aNamespaceURI.Equals(NS_LITERAL_STRING("*"))) {
|
2000-05-15 20:31:55 +00:00
|
|
|
nsCOMPtr<nsINodeInfoManager> nimgr;
|
|
|
|
mNodeInfo->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
|
|
|
NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsINameSpaceManager> nsmgr;
|
|
|
|
nimgr->GetNamespaceManager(*getter_AddRefs(nsmgr));
|
|
|
|
NS_ENSURE_TRUE(nsmgr, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsmgr->GetNameSpaceID(aNamespaceURI, nameSpaceId);
|
|
|
|
|
|
|
|
if (nameSpaceId == kNameSpaceID_Unknown) {
|
|
|
|
// Unkonwn namespace means no matches, we create an empty list...
|
|
|
|
list = new nsContentList(mDocument, nsnull, kNameSpaceID_None);
|
|
|
|
NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!list) {
|
|
|
|
list = new nsContentList(mDocument, nameAtom, nameSpaceId, mContent);
|
|
|
|
NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
return list->QueryInterface(kIDOMNodeListIID, (void **)aReturn);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::HasAttribute(const nsAReadableString& aName, PRBool* aReturn)
|
2000-05-15 20:31:55 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aReturn);
|
|
|
|
|
2000-08-31 00:36:31 +00:00
|
|
|
nsCOMPtr<nsINodeInfo> ni;
|
|
|
|
mContent->NormalizeAttributeString(aName, *getter_AddRefs(ni));
|
|
|
|
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
PRInt32 nsid;
|
|
|
|
nsCOMPtr<nsIAtom> nameAtom;
|
|
|
|
|
|
|
|
ni->GetNamespaceID(nsid);
|
|
|
|
ni->GetNameAtom(*getter_AddRefs(nameAtom));
|
2000-05-15 20:31:55 +00:00
|
|
|
|
|
|
|
nsAutoString tmp;
|
2000-08-31 00:36:31 +00:00
|
|
|
nsresult rv = mContent->GetAttribute(nsid, nameAtom, tmp);
|
2000-05-15 20:31:55 +00:00
|
|
|
|
|
|
|
*aReturn = rv == NS_CONTENT_ATTR_NOT_THERE ? PR_FALSE : PR_TRUE;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericElement::HasAttributeNS(const nsAReadableString& aNamespaceURI,
|
|
|
|
const nsAReadableString& aLocalName, PRBool* aReturn)
|
2000-05-15 20:31:55 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aReturn);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAtom> name(dont_AddRef(NS_NewAtom(aLocalName)));
|
|
|
|
PRInt32 nsid;
|
|
|
|
|
|
|
|
nsCOMPtr<nsINodeInfoManager> nimgr;
|
|
|
|
mNodeInfo->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
|
|
|
NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsINameSpaceManager> nsmgr;
|
|
|
|
nimgr->GetNamespaceManager(*getter_AddRefs(nsmgr));
|
|
|
|
NS_ENSURE_TRUE(nsmgr, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsmgr->GetNameSpaceID(aNamespaceURI, nsid);
|
|
|
|
|
|
|
|
if (nsid == kNameSpaceID_Unknown) {
|
|
|
|
// Unkonwn namespace means no attr...
|
|
|
|
|
|
|
|
*aReturn = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString tmp;
|
|
|
|
nsresult rv = mContent->GetAttribute(nsid, name, tmp);
|
|
|
|
|
|
|
|
*aReturn = rv == NS_CONTENT_ATTR_NOT_THERE ? PR_FALSE : PR_TRUE;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-01-25 22:17:15 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericElement::JoinTextNodes(nsIContent* aFirst,
|
|
|
|
nsIContent* aSecond)
|
|
|
|
{
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
nsIDOMText *firstText, *secondText;
|
|
|
|
|
|
|
|
result = aFirst->QueryInterface(kIDOMTextIID, (void**)&firstText);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
result = aSecond->QueryInterface(kIDOMTextIID, (void**)&secondText);
|
|
|
|
|
|
|
|
if (NS_OK == result) {
|
|
|
|
nsAutoString str;
|
|
|
|
|
|
|
|
result = secondText->GetData(str);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
result = firstText->AppendData(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_RELEASE(secondText);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_RELEASE(firstText);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericElement::Normalize()
|
|
|
|
{
|
1999-01-25 22:17:15 +00:00
|
|
|
nsresult result = NS_OK;
|
|
|
|
PRInt32 index, count;
|
|
|
|
|
|
|
|
mContent->ChildCount(count);
|
|
|
|
for (index = 0; (index < count) && (NS_OK == result); index++) {
|
1999-12-22 01:54:04 +00:00
|
|
|
nsCOMPtr<nsIContent> child;
|
1999-01-25 22:17:15 +00:00
|
|
|
|
1999-12-22 01:54:04 +00:00
|
|
|
result = mContent->ChildAt(index, *getter_AddRefs(child));
|
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
return result;
|
|
|
|
}
|
1999-01-25 22:17:15 +00:00
|
|
|
|
1999-12-22 01:54:04 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(child);
|
|
|
|
if (node) {
|
|
|
|
PRUint16 nodeType;
|
|
|
|
node->GetNodeType(&nodeType);
|
|
|
|
|
|
|
|
switch (nodeType) {
|
|
|
|
case nsIDOMNode::TEXT_NODE:
|
1999-01-25 22:17:15 +00:00
|
|
|
|
1999-12-22 01:54:04 +00:00
|
|
|
if (index+1 < count) {
|
|
|
|
nsCOMPtr<nsIContent> sibling;
|
|
|
|
|
|
|
|
// Get the sibling. If it's also a text node, then
|
|
|
|
// remove it from the tree and join the two text
|
|
|
|
// nodes.
|
|
|
|
result = mContent->ChildAt(index+1, *getter_AddRefs(sibling));
|
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> siblingNode = do_QueryInterface(sibling);
|
|
|
|
|
|
|
|
if (sibling) {
|
|
|
|
PRUint16 siblingNodeType;
|
|
|
|
siblingNode->GetNodeType(&siblingNodeType);
|
|
|
|
|
|
|
|
if (siblingNodeType == nsIDOMNode::TEXT_NODE) {
|
|
|
|
result = mContent->RemoveChildAt(index+1, PR_TRUE);
|
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = JoinTextNodes(child, sibling);
|
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
count--;
|
|
|
|
index--;
|
|
|
|
}
|
1999-01-25 22:17:15 +00:00
|
|
|
}
|
|
|
|
}
|
1999-12-22 01:54:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIDOMNode::ELEMENT_NODE:
|
|
|
|
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(child);
|
1999-01-25 22:17:15 +00:00
|
|
|
|
1999-12-22 01:54:04 +00:00
|
|
|
if (element) {
|
|
|
|
result = element->Normalize();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1999-01-25 22:17:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::GetDocument(nsIDocument*& aResult) const
|
|
|
|
{
|
|
|
|
NS_IF_ADDREF(mDocument);
|
|
|
|
aResult = mDocument;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
nsGenericElement::SetDocumentInChildrenOf(nsIContent* aContent,
|
2000-05-19 04:48:43 +00:00
|
|
|
nsIDocument* aDocument,
|
|
|
|
PRBool aCompileEventHandlers)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
PRInt32 i, n;
|
|
|
|
aContent->ChildCount(n);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsIContent* child;
|
|
|
|
aContent->ChildAt(i, child);
|
|
|
|
if (nsnull != child) {
|
2000-05-19 04:48:43 +00:00
|
|
|
child->SetDocument(aDocument, PR_TRUE, aCompileEventHandlers);
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_RELEASE(child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-05-19 04:48:43 +00:00
|
|
|
nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
1999-12-22 01:54:04 +00:00
|
|
|
if (aDocument != mDocument) {
|
|
|
|
// If we were part of a document, make sure we get rid of the
|
|
|
|
// script context reference to our script object so that our
|
|
|
|
// script object can be freed (or collected).
|
|
|
|
if ((nsnull != mDocument) && (nsnull != mDOMSlots) &&
|
|
|
|
(nsnull != mDOMSlots->mScriptObject)) {
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
|
|
|
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
|
|
|
if (globalObject) {
|
|
|
|
nsCOMPtr<nsIScriptContext> context;
|
|
|
|
if (NS_OK == globalObject->GetContext(getter_AddRefs(context)) && context) {
|
|
|
|
context->RemoveReference((void *)&mDOMSlots->mScriptObject,
|
|
|
|
mDOMSlots->mScriptObject);
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
1999-12-22 01:54:04 +00:00
|
|
|
|
2000-08-09 12:51:05 +00:00
|
|
|
if (mDocument && aDeep) {
|
2000-09-20 00:14:04 +00:00
|
|
|
// Notify XBL- & nsIAnonymousContentCreator-generated
|
|
|
|
// anonymous content that the document is changing.
|
2000-05-10 01:09:45 +00:00
|
|
|
nsCOMPtr<nsIBindingManager> bindingManager;
|
|
|
|
mDocument->GetBindingManager(getter_AddRefs(bindingManager));
|
2000-08-09 12:51:05 +00:00
|
|
|
NS_ASSERTION(bindingManager, "No binding manager.");
|
|
|
|
if (bindingManager) {
|
2000-09-20 00:14:04 +00:00
|
|
|
bindingManager->ChangeDocumentFor(mContent, mDocument, aDocument);
|
2000-05-10 01:09:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-12-22 01:54:04 +00:00
|
|
|
mDocument = aDocument;
|
|
|
|
|
|
|
|
// If we already have a script object and now we're being added
|
|
|
|
// to a document, make sure that the script context adds a
|
|
|
|
// reference to our script object. This will ensure that it
|
|
|
|
// won't be freed (or collected) out from under us.
|
|
|
|
if ((nsnull != mDocument) && (nsnull != mDOMSlots) &&
|
|
|
|
(nsnull != mDOMSlots->mScriptObject)) {
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
|
|
|
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
|
|
|
if (globalObject) {
|
|
|
|
nsCOMPtr<nsIScriptContext> context;
|
|
|
|
if (NS_OK == globalObject->GetContext(getter_AddRefs(context)) && context) {
|
|
|
|
context->AddNamedReference((void *)&mDOMSlots->mScriptObject,
|
|
|
|
mDOMSlots->mScriptObject,
|
2000-05-03 23:34:10 +00:00
|
|
|
"nsGenericElement::mScriptObject");
|
1999-12-22 01:54:04 +00:00
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PR_TRUE == aDeep) {
|
2000-05-19 04:48:43 +00:00
|
|
|
SetDocumentInChildrenOf(mContent, aDocument, aCompileEventHandlers);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::GetParent(nsIContent*& aResult) const
|
|
|
|
{
|
|
|
|
aResult = mParent;
|
2000-08-12 15:03:24 +00:00
|
|
|
NS_IF_ADDREF(aResult);
|
1999-09-15 20:30:36 +00:00
|
|
|
return NS_OK;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::SetParent(nsIContent* aParent)
|
|
|
|
{
|
|
|
|
mParent = aParent;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-11 02:35:06 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericElement::GetNameSpaceID(PRInt32& aResult) const
|
|
|
|
{
|
|
|
|
aResult = kNameSpaceID_None;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericElement::GetTag(nsIAtom*& aResult) const
|
|
|
|
{
|
2000-05-10 13:13:39 +00:00
|
|
|
return mNodeInfo->GetNameAtom(aResult);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
2000-05-12 14:09:28 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericElement::GetNodeInfo(nsINodeInfo*& aResult) const
|
|
|
|
{
|
|
|
|
aResult = mNodeInfo;
|
|
|
|
NS_IF_ADDREF(aResult);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
nsresult
|
1999-11-24 06:03:41 +00:00
|
|
|
nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
1999-09-15 20:30:36 +00:00
|
|
|
nsEvent* aEvent,
|
|
|
|
nsIDOMEvent** aDOMEvent,
|
|
|
|
PRUint32 aFlags,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
nsresult ret = NS_OK;
|
2000-09-07 08:18:11 +00:00
|
|
|
PRBool retarget = PR_FALSE;
|
|
|
|
nsCOMPtr<nsIDOMEventTarget> oldTarget;
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
nsIDOMEvent* domEvent = nsnull;
|
2000-05-16 11:35:12 +00:00
|
|
|
if (NS_EVENT_FLAG_INIT & aFlags) {
|
2000-05-17 05:27:22 +00:00
|
|
|
if (!aDOMEvent) {
|
|
|
|
aDOMEvent = &domEvent;
|
|
|
|
}
|
2000-05-16 11:35:12 +00:00
|
|
|
aEvent->flags = aFlags;
|
|
|
|
aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
2000-09-07 08:18:11 +00:00
|
|
|
|
|
|
|
// Find out if we're anonymous.
|
|
|
|
nsCOMPtr<nsIContent> bindingParent;
|
|
|
|
GetBindingParent(getter_AddRefs(bindingParent));
|
|
|
|
if (bindingParent) {
|
|
|
|
// We're anonymous. We may potentially need to retarget
|
|
|
|
// our event if our parent is in a different scope.
|
|
|
|
if (mParent) {
|
|
|
|
nsCOMPtr<nsIContent> parentScope;
|
|
|
|
mParent->GetBindingParent(getter_AddRefs(parentScope));
|
|
|
|
if (parentScope != bindingParent)
|
|
|
|
retarget = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (retarget) {
|
|
|
|
if (!*aDOMEvent) {
|
|
|
|
// We haven't made a DOMEvent yet. Force making one now.
|
|
|
|
nsCOMPtr<nsIEventListenerManager> listenerManager;
|
|
|
|
if (NS_FAILED(ret = GetListenerManager(getter_AddRefs(listenerManager)))) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
nsAutoString empty;
|
|
|
|
if (NS_FAILED(ret = listenerManager->CreateEvent(aPresContext, aEvent, empty, aDOMEvent)))
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!*aDOMEvent) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(*aDOMEvent);
|
|
|
|
if (!privateEvent) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*aDOMEvent)->GetTarget(getter_AddRefs(oldTarget));
|
|
|
|
|
|
|
|
PRBool hasOriginal;
|
|
|
|
privateEvent->HasOriginalTarget(&hasOriginal);
|
|
|
|
|
|
|
|
if (!hasOriginal) {
|
|
|
|
privateEvent->SetOriginalTarget(oldTarget);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(mParent);
|
|
|
|
privateEvent->SetTarget(target);
|
|
|
|
}
|
|
|
|
|
1999-03-28 22:22:54 +00:00
|
|
|
//Capturing stage evaluation
|
|
|
|
//Always pass capturing up the tree before local evaulation
|
|
|
|
if (NS_EVENT_FLAG_BUBBLE != aFlags) {
|
1999-09-23 02:31:37 +00:00
|
|
|
// XXX: Bring on the more optimized version of capturing at some point
|
|
|
|
//if (nsnull != mDOMSlots && nsnull != mDOMSlots->mCapturer) {
|
|
|
|
//mDOMSlots->mCapturer->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_CAPTURE, aEventStatus);
|
|
|
|
//} else {
|
1999-09-23 01:55:41 +00:00
|
|
|
// Node capturing stage
|
|
|
|
if (mParent) {
|
|
|
|
// Pass off to our parent.
|
|
|
|
mParent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_CAPTURE, aEventStatus);
|
1999-09-23 02:31:37 +00:00
|
|
|
} else {
|
|
|
|
//Initiate capturing phase. Special case first call to document
|
|
|
|
if (nsnull != mDocument) {
|
|
|
|
mDocument->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_CAPTURE, aEventStatus);
|
|
|
|
}
|
1999-09-23 01:55:41 +00:00
|
|
|
}
|
1999-09-23 02:31:37 +00:00
|
|
|
//}
|
1999-03-28 22:22:54 +00:00
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2000-09-07 08:18:11 +00:00
|
|
|
if (retarget) {
|
|
|
|
// The event originated beneath us, and we performed a retargeting.
|
|
|
|
// We need to restore the original target of the event.
|
|
|
|
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(*aDOMEvent);
|
|
|
|
if (privateEvent)
|
|
|
|
privateEvent->SetTarget(oldTarget);
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
//Local handling stage
|
2000-05-16 11:35:12 +00:00
|
|
|
if (mDOMSlots && mDOMSlots->mListenerManager && !(aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) &&
|
|
|
|
!(NS_EVENT_FLAG_BUBBLE & aFlags && NS_EVENT_FLAG_CANT_BUBBLE & aEvent->flags)) {
|
2000-02-08 02:05:57 +00:00
|
|
|
aEvent->flags |= aFlags;
|
2000-05-16 11:35:12 +00:00
|
|
|
nsCOMPtr<nsIDOMEventTarget> curTarg(do_QueryInterface(mContent));
|
|
|
|
mDOMSlots->mListenerManager->HandleEvent(aPresContext, aEvent, aDOMEvent, curTarg, aFlags, aEventStatus);
|
2000-02-08 02:05:57 +00:00
|
|
|
aEvent->flags &= ~aFlags;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
2000-09-07 08:18:11 +00:00
|
|
|
if (retarget) {
|
|
|
|
// The event originated beneath us, and we need to perform a retargeting.
|
|
|
|
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(*aDOMEvent);
|
|
|
|
if (privateEvent) {
|
|
|
|
nsCOMPtr<nsIDOMEventTarget> parentTarget(do_QueryInterface(mParent));
|
|
|
|
privateEvent->SetTarget(parentTarget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
//Bubbling stage
|
2000-02-09 13:58:26 +00:00
|
|
|
if (NS_EVENT_FLAG_CAPTURE != aFlags && mDocument) {
|
|
|
|
if (mParent) {
|
|
|
|
/*
|
|
|
|
* If there's a parent we pass the event to the parent...
|
|
|
|
*/
|
|
|
|
ret = mParent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
|
|
|
NS_EVENT_FLAG_BUBBLE, aEventStatus);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* If there's no parent but there is a document (i.e. this is the
|
|
|
|
* root node) we pass the event to the document...
|
|
|
|
*/
|
|
|
|
ret = mDocument->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
|
|
|
NS_EVENT_FLAG_BUBBLE, aEventStatus);
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
2000-09-07 08:18:11 +00:00
|
|
|
if (retarget) {
|
|
|
|
// The event originated beneath us, and we performed a retargeting.
|
|
|
|
// We need to restore the original target of the event.
|
|
|
|
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(*aDOMEvent);
|
|
|
|
if (privateEvent)
|
|
|
|
privateEvent->SetTarget(oldTarget);
|
|
|
|
}
|
|
|
|
|
2000-05-16 11:35:12 +00:00
|
|
|
if (NS_EVENT_FLAG_INIT & aFlags) {
|
1998-11-11 22:06:16 +00:00
|
|
|
// We're leaving the DOM event loop so if we created a DOM event,
|
|
|
|
// release here.
|
|
|
|
if (nsnull != *aDOMEvent) {
|
|
|
|
nsrefcnt rc;
|
|
|
|
NS_RELEASE2(*aDOMEvent, rc);
|
|
|
|
if (0 != rc) {
|
|
|
|
// Okay, so someone in the DOM loop (a listener, JS object)
|
|
|
|
// still has a ref to the DOM Event but the internal data
|
|
|
|
// hasn't been malloc'd. Force a copy of the data here so the
|
|
|
|
// DOM Event is still valid.
|
|
|
|
nsIPrivateDOMEvent *privateEvent;
|
|
|
|
if (NS_OK == (*aDOMEvent)->QueryInterface(kIPrivateDOMEventIID, (void**)&privateEvent)) {
|
|
|
|
privateEvent->DuplicatePrivateData();
|
|
|
|
NS_RELEASE(privateEvent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aDOMEvent = nsnull;
|
|
|
|
}
|
2000-09-07 08:18:11 +00:00
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
return ret;
|
|
|
|
}
|
1998-12-17 07:22:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::RangeAdd(nsIDOMRange& aRange)
|
|
|
|
{
|
1998-12-18 02:51:34 +00:00
|
|
|
if (nsnull == mDOMSlots) GetDOMSlots();
|
1998-12-17 07:22:28 +00:00
|
|
|
// lazy allocation of range list
|
1998-12-18 02:51:34 +00:00
|
|
|
if (nsnull == mDOMSlots->mRangeList) {
|
|
|
|
mDOMSlots->mRangeList = new nsVoidArray();
|
1998-12-17 07:22:28 +00:00
|
|
|
}
|
1998-12-18 02:51:34 +00:00
|
|
|
if (nsnull == mDOMSlots->mRangeList) {
|
1998-12-17 07:22:28 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-08-04 18:36:19 +00:00
|
|
|
|
|
|
|
// Make sure we don't add a range that is already
|
|
|
|
// in the list!
|
|
|
|
PRInt32 i = mDOMSlots->mRangeList->IndexOf(&aRange);
|
|
|
|
if (i >= 0) {
|
|
|
|
// Range is already in the list, so there
|
|
|
|
// is nothing to do!
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-17 07:22:28 +00:00
|
|
|
// dont need to addref - this call is made by the range object itself
|
1998-12-18 02:51:34 +00:00
|
|
|
PRBool rv = mDOMSlots->mRangeList->AppendElement(&aRange);
|
1998-12-17 07:22:28 +00:00
|
|
|
if (rv) return NS_OK;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::RangeRemove(nsIDOMRange& aRange)
|
|
|
|
{
|
1998-12-18 02:51:34 +00:00
|
|
|
if (mDOMSlots && mDOMSlots->mRangeList) {
|
1998-12-17 07:22:28 +00:00
|
|
|
// dont need to release - this call is made by the range object itself
|
1998-12-18 02:51:34 +00:00
|
|
|
PRBool rv = mDOMSlots->mRangeList->RemoveElement(&aRange);
|
|
|
|
if (rv) {
|
|
|
|
if (mDOMSlots->mRangeList->Count() == 0) {
|
|
|
|
delete mDOMSlots->mRangeList;
|
1999-01-04 16:48:33 +00:00
|
|
|
mDOMSlots->mRangeList = nsnull;
|
Landing changes Vidur made while the tree was closed for beta1 work, here's a list of the changes. r=me
[1] Cutting down the size of content. Made nsIJSScriptObject inherit from nsIScriptObjectOwner
[2] Cutting down the size of content. Made nsITextContent inherit from nsIContent.
[3] Cutting down the size of content. Moved implementation of nsIDOMReceiver to nsListenerManager. This is not true aggregation since it isn't transitive, but it's OK for now. It will be necessary for nsListenerManager to have a reference to its content in the future anyway, so the transitivity could be done.
dom/public/nsDOMPropEnums.h,v - bug 12559
dom/public/nsIJSScriptObject.h,v - [1]
dom/public/html/MANIFEST,v - bug 12559
dom/public/html/Makefile.in,v - bug 12559
dom/public/html/makefile.win,v - bug 12559
dom/public/html/nsIDOMHTMLInputElement.h,v - bug 17544
dom/public/idl/html/HTMLAnchorElement.idl,v - bug 12559
dom/public/idl/html/HTMLAreaElement.idl,v - bug 12559
dom/public/idl/html/HTMLInputElement.idl,v - bug 17544
dom/src/base/nsGlobalWindow.cpp,v - bug 30700
dom/src/base/nsGlobalWindow.h,v - [1]
dom/src/base/nsLocation.cpp,v - [1]
dom/src/html/nsJSHTMLAnchorElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLAreaElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLInputElement.cpp,v - bug 17544
layout/base/public/nsIDocument.h,v - bug 27953
layout/base/public/nsITextContent.h,v - [2]
layout/base/src/nsCommentNode.cpp,v - [2]
layout/base/src/nsDocument.cpp,v - bug 27953
layout/base/src/nsDocument.h,v - bug 27953
layout/base/src/nsDocumentViewer.cpp,v - bug 27953
layout/base/src/nsGenericDOMDataNode.cpp,v - [3]
layout/base/src/nsGenericDOMDataNode.h,v - [3]
layout/base/src/nsGenericElement.cpp,v - [3]
layout/base/src/nsGenericElement.h,v - [3]
layout/base/src/nsNameSpaceManager.cpp,v - bug 7834
layout/base/src/nsStyleContext.cpp,v - outline property shouldn't reflow
layout/base/src/nsTextNode.cpp,v - [2]
layout/events/src/nsEventListenerManager.cpp,v - [3]
layout/events/src/nsEventListenerManager.h,v - [3]
layout/html/base/src/nsGfxScrollFrame.cpp,v - nsString->nsAutoString
layout/html/content/src/nsAttributeContent.cpp,v - [2]
layout/html/content/src/nsHTMLAnchorElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAppletElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBodyElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLButtonElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDirectoryElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDivElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLEmbedElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFieldSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFormElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadingElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHtmlElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLImageElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInputElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInsElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIsIndexElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLIElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLabelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLayerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLegendElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLinkElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMapElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMenuElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMetaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLModElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLObjectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParagraphElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParamElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLPreElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLQuoteElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLScriptElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSelectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpacerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpanElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLStyleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCaptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCellElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableRowElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableSectionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTextAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTitleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLUListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLWBRElement.cpp,v - [1][3]
layout/html/document/src/nsHTMLDocument.cpp,v - bug 27953
layout/html/document/src/nsHTMLDocument.h,v - bug 27953
layout/xml/content/src/nsXMLCDATASection.cpp,v - [1][2]
layout/xml/content/src/nsXMLDocumentType.cpp,v - [1][2]
layout/xml/content/src/nsXMLElement.h,v - [1][2]
layout/xml/content/src/nsXMLEntity.cpp,v - [1][2]
layout/xml/content/src/nsXMLNotation.cpp,v - [1][2]
layout/xml/content/src/nsXMLProcessingInstruction.cpp,v - [1][2]
layout/xul/base/src/nsBoxFrame.cpp,v - nsString->nsAutoString
layout/xul/base/src/nsSliderFrame.cpp,v - nsString->nsAutoString
netwerk/protocol/http/src/nsHTTPRequest.cpp,v - nsString->nsAutoString
rdf/content/src/nsXULDocument.cpp,v - bug 27953
rdf/content/src/nsXULDocument.h,v - bug 27953
rdf/content/src/nsXULElement.h,v - [1]
xpcom/base/IIDS.h,v - bug 12559
2000-03-17 13:27:00 +00:00
|
|
|
MaybeClearDOMSlots();
|
1998-12-18 02:51:34 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-12-17 07:22:28 +00:00
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1998-12-18 02:51:34 +00:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::GetRangeList(nsVoidArray*& aResult) const
|
|
|
|
{
|
|
|
|
if (mDOMSlots && mDOMSlots->mRangeList) {
|
|
|
|
aResult = mDOMSlots->mRangeList;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aResult = nsnull;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-04 23:55:31 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericElement::SetFocus(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::RemoveFocus(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-08-12 06:28:02 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericElement::GetBindingParent(nsIContent** aContent)
|
|
|
|
{
|
|
|
|
*aContent = mDOMSlots ? mDOMSlots->mBindingParent : nsnull;
|
|
|
|
NS_IF_ADDREF(*aContent);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::SetBindingParent(nsIContent* aParent)
|
|
|
|
{
|
|
|
|
if (!mDOMSlots)
|
|
|
|
GetDOMSlots();
|
|
|
|
|
|
|
|
mDOMSlots->mBindingParent = aParent; // Weak, so no addref happens.
|
2000-08-29 03:08:35 +00:00
|
|
|
|
|
|
|
if (aParent) {
|
|
|
|
PRInt32 count;
|
|
|
|
mContent->ChildCount(count);
|
|
|
|
for (PRInt32 i = 0; i < count; i++) {
|
|
|
|
nsCOMPtr<nsIContent> child;
|
|
|
|
mContent->ChildAt(i, *getter_AddRefs(child));
|
|
|
|
child->SetBindingParent(aParent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-12 06:28:02 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-10-05 23:47:46 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
|
|
|
size_t aInstanceSize) const
|
|
|
|
{
|
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
*aResult = (PRUint32) aInstanceSize;
|
|
|
|
#else
|
|
|
|
*aResult = 0;
|
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
nsresult
|
1999-10-26 04:44:41 +00:00
|
|
|
nsGenericElement::RenderFrame(nsIPresContext* aPresContext)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
nsPoint offset;
|
|
|
|
nsRect bounds;
|
|
|
|
|
|
|
|
// Trigger damage repairs for each frame that maps the given content
|
|
|
|
PRInt32 i, n;
|
|
|
|
n = mDocument->GetNumberOfShells();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsIPresShell* shell;
|
|
|
|
shell = mDocument->GetShellAt(i);
|
|
|
|
nsIFrame* frame;
|
1999-02-12 17:45:58 +00:00
|
|
|
shell->GetPrimaryFrameFor(mContent, &frame);
|
1998-11-11 22:06:16 +00:00
|
|
|
while (nsnull != frame) {
|
|
|
|
nsIViewManager* vm;
|
|
|
|
nsIView* view;
|
|
|
|
|
|
|
|
// Determine damaged area and tell view manager to redraw it
|
|
|
|
frame->GetRect(bounds);
|
|
|
|
bounds.x = bounds.y = 0;
|
|
|
|
|
|
|
|
// XXX We should tell the frame the damage area and let it invalidate
|
|
|
|
// itself. Add some API calls to nsIFrame to allow a caller to invalidate
|
|
|
|
// parts of the frame...
|
1999-10-26 04:44:41 +00:00
|
|
|
frame->GetOffsetFromView(aPresContext, offset, &view);
|
1998-11-11 22:06:16 +00:00
|
|
|
view->GetViewManager(vm);
|
|
|
|
bounds.x += offset.x;
|
|
|
|
bounds.y += offset.y;
|
|
|
|
|
|
|
|
vm->UpdateView(view, bounds, NS_VMREFRESH_IMMEDIATE);
|
|
|
|
NS_RELEASE(vm);
|
|
|
|
|
|
|
|
// If frame has a next-in-flow, repaint it too
|
1999-02-24 04:48:08 +00:00
|
|
|
frame->GetNextInFlow(&frame);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// nsIScriptObjectOwner implementation
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::GetScriptObject(nsIScriptContext* aContext,
|
|
|
|
void** aScriptObject)
|
|
|
|
{
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
nsDOMSlots *slots = GetDOMSlots();
|
|
|
|
|
|
|
|
if (nsnull == slots->mScriptObject) {
|
|
|
|
nsIDOMScriptObjectFactory *factory;
|
|
|
|
|
|
|
|
res = GetScriptObjectFactory(&factory);
|
|
|
|
if (NS_OK != res) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString tag;
|
2000-05-15 22:48:38 +00:00
|
|
|
mNodeInfo->GetName(tag);
|
1998-11-11 22:06:16 +00:00
|
|
|
res = factory->NewScriptElement(tag, aContext, mContent,
|
1999-11-25 00:05:21 +00:00
|
|
|
mParent ? (nsISupports*)mParent : (nsISupports*)mDocument,
|
|
|
|
(void**)&slots->mScriptObject);
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_RELEASE(factory);
|
|
|
|
|
|
|
|
if (nsnull != mDocument) {
|
|
|
|
aContext->AddNamedReference((void *)&slots->mScriptObject,
|
|
|
|
slots->mScriptObject,
|
2000-05-03 23:42:20 +00:00
|
|
|
"nsGenericElement::mScriptObject");
|
2000-06-14 08:19:07 +00:00
|
|
|
|
|
|
|
// See if we have a frame.
|
|
|
|
nsCOMPtr<nsIPresShell> shell = getter_AddRefs(mDocument->GetShellAt(0));
|
|
|
|
if (shell) {
|
|
|
|
nsIFrame* frame;
|
|
|
|
shell->GetPrimaryFrameFor(mContent, &frame);
|
|
|
|
if (!frame) {
|
|
|
|
// We must ensure that the XBL Binding is installed before we hand
|
|
|
|
// back this object.
|
|
|
|
nsCOMPtr<nsIBindingManager> bindingManager;
|
|
|
|
mDocument->GetBindingManager(getter_AddRefs(bindingManager));
|
|
|
|
nsCOMPtr<nsIXBLBinding> binding;
|
|
|
|
bindingManager->GetBinding(mContent, getter_AddRefs(binding));
|
|
|
|
if (!binding) {
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> global;
|
|
|
|
mDocument->GetScriptGlobalObject(getter_AddRefs(global));
|
|
|
|
nsCOMPtr<nsIDOMViewCSS> viewCSS(do_QueryInterface(global));
|
|
|
|
if (viewCSS) {
|
|
|
|
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
|
|
|
nsAutoString empty;
|
|
|
|
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mContent));
|
|
|
|
viewCSS->GetComputedStyle(elt, empty, getter_AddRefs(cssDecl));
|
|
|
|
if (cssDecl) {
|
2000-09-08 10:01:18 +00:00
|
|
|
nsAutoString behavior; behavior.Assign(NS_LITERAL_STRING("-moz-binding"));
|
2000-06-14 08:19:07 +00:00
|
|
|
nsAutoString value;
|
|
|
|
cssDecl->GetPropertyValue(behavior, value);
|
|
|
|
if (!value.IsEmpty()) {
|
|
|
|
// We have a binding that must be installed.
|
|
|
|
nsresult rv;
|
2000-09-08 10:01:18 +00:00
|
|
|
PRBool dummy;
|
2000-09-13 23:57:52 +00:00
|
|
|
NS_WITH_SERVICE(nsIXBLService, xblService, "@mozilla.org/xbl;1", &rv);
|
2000-09-08 10:01:18 +00:00
|
|
|
xblService->LoadBindings(mContent, value, PR_FALSE, getter_AddRefs(binding), &dummy);
|
2000-07-28 00:35:02 +00:00
|
|
|
if (binding) {
|
|
|
|
binding->ExecuteAttachedHandler();
|
|
|
|
}
|
2000-06-14 08:19:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
2000-05-24 08:19:10 +00:00
|
|
|
|
2000-05-27 08:20:04 +00:00
|
|
|
*aScriptObject = slots->mScriptObject;
|
1998-11-11 22:06:16 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::SetScriptObject(void *aScriptObject)
|
|
|
|
{
|
|
|
|
nsDOMSlots *slots = GetDOMSlots();
|
|
|
|
|
|
|
|
slots->mScriptObject = aScriptObject;
|
1999-11-05 23:37:40 +00:00
|
|
|
|
|
|
|
if (!aScriptObject) {
|
Landing changes Vidur made while the tree was closed for beta1 work, here's a list of the changes. r=me
[1] Cutting down the size of content. Made nsIJSScriptObject inherit from nsIScriptObjectOwner
[2] Cutting down the size of content. Made nsITextContent inherit from nsIContent.
[3] Cutting down the size of content. Moved implementation of nsIDOMReceiver to nsListenerManager. This is not true aggregation since it isn't transitive, but it's OK for now. It will be necessary for nsListenerManager to have a reference to its content in the future anyway, so the transitivity could be done.
dom/public/nsDOMPropEnums.h,v - bug 12559
dom/public/nsIJSScriptObject.h,v - [1]
dom/public/html/MANIFEST,v - bug 12559
dom/public/html/Makefile.in,v - bug 12559
dom/public/html/makefile.win,v - bug 12559
dom/public/html/nsIDOMHTMLInputElement.h,v - bug 17544
dom/public/idl/html/HTMLAnchorElement.idl,v - bug 12559
dom/public/idl/html/HTMLAreaElement.idl,v - bug 12559
dom/public/idl/html/HTMLInputElement.idl,v - bug 17544
dom/src/base/nsGlobalWindow.cpp,v - bug 30700
dom/src/base/nsGlobalWindow.h,v - [1]
dom/src/base/nsLocation.cpp,v - [1]
dom/src/html/nsJSHTMLAnchorElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLAreaElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLInputElement.cpp,v - bug 17544
layout/base/public/nsIDocument.h,v - bug 27953
layout/base/public/nsITextContent.h,v - [2]
layout/base/src/nsCommentNode.cpp,v - [2]
layout/base/src/nsDocument.cpp,v - bug 27953
layout/base/src/nsDocument.h,v - bug 27953
layout/base/src/nsDocumentViewer.cpp,v - bug 27953
layout/base/src/nsGenericDOMDataNode.cpp,v - [3]
layout/base/src/nsGenericDOMDataNode.h,v - [3]
layout/base/src/nsGenericElement.cpp,v - [3]
layout/base/src/nsGenericElement.h,v - [3]
layout/base/src/nsNameSpaceManager.cpp,v - bug 7834
layout/base/src/nsStyleContext.cpp,v - outline property shouldn't reflow
layout/base/src/nsTextNode.cpp,v - [2]
layout/events/src/nsEventListenerManager.cpp,v - [3]
layout/events/src/nsEventListenerManager.h,v - [3]
layout/html/base/src/nsGfxScrollFrame.cpp,v - nsString->nsAutoString
layout/html/content/src/nsAttributeContent.cpp,v - [2]
layout/html/content/src/nsHTMLAnchorElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAppletElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBodyElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLButtonElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDirectoryElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDivElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLEmbedElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFieldSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFormElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadingElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHtmlElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLImageElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInputElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInsElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIsIndexElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLIElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLabelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLayerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLegendElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLinkElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMapElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMenuElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMetaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLModElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLObjectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParagraphElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParamElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLPreElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLQuoteElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLScriptElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSelectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpacerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpanElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLStyleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCaptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCellElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableRowElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableSectionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTextAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTitleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLUListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLWBRElement.cpp,v - [1][3]
layout/html/document/src/nsHTMLDocument.cpp,v - bug 27953
layout/html/document/src/nsHTMLDocument.h,v - bug 27953
layout/xml/content/src/nsXMLCDATASection.cpp,v - [1][2]
layout/xml/content/src/nsXMLDocumentType.cpp,v - [1][2]
layout/xml/content/src/nsXMLElement.h,v - [1][2]
layout/xml/content/src/nsXMLEntity.cpp,v - [1][2]
layout/xml/content/src/nsXMLNotation.cpp,v - [1][2]
layout/xml/content/src/nsXMLProcessingInstruction.cpp,v - [1][2]
layout/xul/base/src/nsBoxFrame.cpp,v - nsString->nsAutoString
layout/xul/base/src/nsSliderFrame.cpp,v - nsString->nsAutoString
netwerk/protocol/http/src/nsHTTPRequest.cpp,v - nsString->nsAutoString
rdf/content/src/nsXULDocument.cpp,v - bug 27953
rdf/content/src/nsXULDocument.h,v - bug 27953
rdf/content/src/nsXULElement.h,v - [1]
xpcom/base/IIDS.h,v - bug 12559
2000-03-17 13:27:00 +00:00
|
|
|
if (slots->mListenerManager) {
|
|
|
|
slots->mListenerManager->RemoveAllListeners(PR_TRUE);
|
1999-11-05 23:37:40 +00:00
|
|
|
}
|
Landing changes Vidur made while the tree was closed for beta1 work, here's a list of the changes. r=me
[1] Cutting down the size of content. Made nsIJSScriptObject inherit from nsIScriptObjectOwner
[2] Cutting down the size of content. Made nsITextContent inherit from nsIContent.
[3] Cutting down the size of content. Moved implementation of nsIDOMReceiver to nsListenerManager. This is not true aggregation since it isn't transitive, but it's OK for now. It will be necessary for nsListenerManager to have a reference to its content in the future anyway, so the transitivity could be done.
dom/public/nsDOMPropEnums.h,v - bug 12559
dom/public/nsIJSScriptObject.h,v - [1]
dom/public/html/MANIFEST,v - bug 12559
dom/public/html/Makefile.in,v - bug 12559
dom/public/html/makefile.win,v - bug 12559
dom/public/html/nsIDOMHTMLInputElement.h,v - bug 17544
dom/public/idl/html/HTMLAnchorElement.idl,v - bug 12559
dom/public/idl/html/HTMLAreaElement.idl,v - bug 12559
dom/public/idl/html/HTMLInputElement.idl,v - bug 17544
dom/src/base/nsGlobalWindow.cpp,v - bug 30700
dom/src/base/nsGlobalWindow.h,v - [1]
dom/src/base/nsLocation.cpp,v - [1]
dom/src/html/nsJSHTMLAnchorElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLAreaElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLInputElement.cpp,v - bug 17544
layout/base/public/nsIDocument.h,v - bug 27953
layout/base/public/nsITextContent.h,v - [2]
layout/base/src/nsCommentNode.cpp,v - [2]
layout/base/src/nsDocument.cpp,v - bug 27953
layout/base/src/nsDocument.h,v - bug 27953
layout/base/src/nsDocumentViewer.cpp,v - bug 27953
layout/base/src/nsGenericDOMDataNode.cpp,v - [3]
layout/base/src/nsGenericDOMDataNode.h,v - [3]
layout/base/src/nsGenericElement.cpp,v - [3]
layout/base/src/nsGenericElement.h,v - [3]
layout/base/src/nsNameSpaceManager.cpp,v - bug 7834
layout/base/src/nsStyleContext.cpp,v - outline property shouldn't reflow
layout/base/src/nsTextNode.cpp,v - [2]
layout/events/src/nsEventListenerManager.cpp,v - [3]
layout/events/src/nsEventListenerManager.h,v - [3]
layout/html/base/src/nsGfxScrollFrame.cpp,v - nsString->nsAutoString
layout/html/content/src/nsAttributeContent.cpp,v - [2]
layout/html/content/src/nsHTMLAnchorElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAppletElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBodyElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLButtonElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDirectoryElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDivElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLEmbedElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFieldSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFormElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadingElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHtmlElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLImageElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInputElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInsElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIsIndexElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLIElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLabelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLayerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLegendElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLinkElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMapElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMenuElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMetaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLModElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLObjectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParagraphElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParamElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLPreElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLQuoteElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLScriptElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSelectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpacerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpanElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLStyleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCaptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCellElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableRowElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableSectionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTextAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTitleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLUListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLWBRElement.cpp,v - [1][3]
layout/html/document/src/nsHTMLDocument.cpp,v - bug 27953
layout/html/document/src/nsHTMLDocument.h,v - bug 27953
layout/xml/content/src/nsXMLCDATASection.cpp,v - [1][2]
layout/xml/content/src/nsXMLDocumentType.cpp,v - [1][2]
layout/xml/content/src/nsXMLElement.h,v - [1][2]
layout/xml/content/src/nsXMLEntity.cpp,v - [1][2]
layout/xml/content/src/nsXMLNotation.cpp,v - [1][2]
layout/xml/content/src/nsXMLProcessingInstruction.cpp,v - [1][2]
layout/xul/base/src/nsBoxFrame.cpp,v - nsString->nsAutoString
layout/xul/base/src/nsSliderFrame.cpp,v - nsString->nsAutoString
netwerk/protocol/http/src/nsHTTPRequest.cpp,v - nsString->nsAutoString
rdf/content/src/nsXULDocument.cpp,v - bug 27953
rdf/content/src/nsXULDocument.h,v - bug 27953
rdf/content/src/nsXULElement.h,v - [1]
xpcom/base/IIDS.h,v - bug 12559
2000-03-17 13:27:00 +00:00
|
|
|
MaybeClearDOMSlots();
|
1999-11-05 23:37:40 +00:00
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::GetListenerManager(nsIEventListenerManager** aResult)
|
|
|
|
{
|
Landing changes Vidur made while the tree was closed for beta1 work, here's a list of the changes. r=me
[1] Cutting down the size of content. Made nsIJSScriptObject inherit from nsIScriptObjectOwner
[2] Cutting down the size of content. Made nsITextContent inherit from nsIContent.
[3] Cutting down the size of content. Moved implementation of nsIDOMReceiver to nsListenerManager. This is not true aggregation since it isn't transitive, but it's OK for now. It will be necessary for nsListenerManager to have a reference to its content in the future anyway, so the transitivity could be done.
dom/public/nsDOMPropEnums.h,v - bug 12559
dom/public/nsIJSScriptObject.h,v - [1]
dom/public/html/MANIFEST,v - bug 12559
dom/public/html/Makefile.in,v - bug 12559
dom/public/html/makefile.win,v - bug 12559
dom/public/html/nsIDOMHTMLInputElement.h,v - bug 17544
dom/public/idl/html/HTMLAnchorElement.idl,v - bug 12559
dom/public/idl/html/HTMLAreaElement.idl,v - bug 12559
dom/public/idl/html/HTMLInputElement.idl,v - bug 17544
dom/src/base/nsGlobalWindow.cpp,v - bug 30700
dom/src/base/nsGlobalWindow.h,v - [1]
dom/src/base/nsLocation.cpp,v - [1]
dom/src/html/nsJSHTMLAnchorElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLAreaElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLInputElement.cpp,v - bug 17544
layout/base/public/nsIDocument.h,v - bug 27953
layout/base/public/nsITextContent.h,v - [2]
layout/base/src/nsCommentNode.cpp,v - [2]
layout/base/src/nsDocument.cpp,v - bug 27953
layout/base/src/nsDocument.h,v - bug 27953
layout/base/src/nsDocumentViewer.cpp,v - bug 27953
layout/base/src/nsGenericDOMDataNode.cpp,v - [3]
layout/base/src/nsGenericDOMDataNode.h,v - [3]
layout/base/src/nsGenericElement.cpp,v - [3]
layout/base/src/nsGenericElement.h,v - [3]
layout/base/src/nsNameSpaceManager.cpp,v - bug 7834
layout/base/src/nsStyleContext.cpp,v - outline property shouldn't reflow
layout/base/src/nsTextNode.cpp,v - [2]
layout/events/src/nsEventListenerManager.cpp,v - [3]
layout/events/src/nsEventListenerManager.h,v - [3]
layout/html/base/src/nsGfxScrollFrame.cpp,v - nsString->nsAutoString
layout/html/content/src/nsAttributeContent.cpp,v - [2]
layout/html/content/src/nsHTMLAnchorElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAppletElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBodyElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLButtonElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDirectoryElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDivElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLEmbedElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFieldSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFormElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadingElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHtmlElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLImageElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInputElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInsElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIsIndexElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLIElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLabelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLayerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLegendElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLinkElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMapElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMenuElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMetaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLModElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLObjectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParagraphElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParamElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLPreElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLQuoteElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLScriptElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSelectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpacerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpanElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLStyleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCaptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCellElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableRowElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableSectionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTextAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTitleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLUListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLWBRElement.cpp,v - [1][3]
layout/html/document/src/nsHTMLDocument.cpp,v - bug 27953
layout/html/document/src/nsHTMLDocument.h,v - bug 27953
layout/xml/content/src/nsXMLCDATASection.cpp,v - [1][2]
layout/xml/content/src/nsXMLDocumentType.cpp,v - [1][2]
layout/xml/content/src/nsXMLElement.h,v - [1][2]
layout/xml/content/src/nsXMLEntity.cpp,v - [1][2]
layout/xml/content/src/nsXMLNotation.cpp,v - [1][2]
layout/xml/content/src/nsXMLProcessingInstruction.cpp,v - [1][2]
layout/xul/base/src/nsBoxFrame.cpp,v - nsString->nsAutoString
layout/xul/base/src/nsSliderFrame.cpp,v - nsString->nsAutoString
netwerk/protocol/http/src/nsHTTPRequest.cpp,v - nsString->nsAutoString
rdf/content/src/nsXULDocument.cpp,v - bug 27953
rdf/content/src/nsXULDocument.h,v - bug 27953
rdf/content/src/nsXULElement.h,v - [1]
xpcom/base/IIDS.h,v - bug 12559
2000-03-17 13:27:00 +00:00
|
|
|
nsDOMSlots *slots = GetDOMSlots();
|
|
|
|
|
|
|
|
if (nsnull != slots->mListenerManager) {
|
|
|
|
NS_ADDREF(slots->mListenerManager);
|
|
|
|
*aResult = slots->mListenerManager;
|
1998-11-11 22:06:16 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
nsresult rv = NS_NewEventListenerManager(aResult);
|
|
|
|
if (NS_OK == rv) {
|
Landing changes Vidur made while the tree was closed for beta1 work, here's a list of the changes. r=me
[1] Cutting down the size of content. Made nsIJSScriptObject inherit from nsIScriptObjectOwner
[2] Cutting down the size of content. Made nsITextContent inherit from nsIContent.
[3] Cutting down the size of content. Moved implementation of nsIDOMReceiver to nsListenerManager. This is not true aggregation since it isn't transitive, but it's OK for now. It will be necessary for nsListenerManager to have a reference to its content in the future anyway, so the transitivity could be done.
dom/public/nsDOMPropEnums.h,v - bug 12559
dom/public/nsIJSScriptObject.h,v - [1]
dom/public/html/MANIFEST,v - bug 12559
dom/public/html/Makefile.in,v - bug 12559
dom/public/html/makefile.win,v - bug 12559
dom/public/html/nsIDOMHTMLInputElement.h,v - bug 17544
dom/public/idl/html/HTMLAnchorElement.idl,v - bug 12559
dom/public/idl/html/HTMLAreaElement.idl,v - bug 12559
dom/public/idl/html/HTMLInputElement.idl,v - bug 17544
dom/src/base/nsGlobalWindow.cpp,v - bug 30700
dom/src/base/nsGlobalWindow.h,v - [1]
dom/src/base/nsLocation.cpp,v - [1]
dom/src/html/nsJSHTMLAnchorElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLAreaElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLInputElement.cpp,v - bug 17544
layout/base/public/nsIDocument.h,v - bug 27953
layout/base/public/nsITextContent.h,v - [2]
layout/base/src/nsCommentNode.cpp,v - [2]
layout/base/src/nsDocument.cpp,v - bug 27953
layout/base/src/nsDocument.h,v - bug 27953
layout/base/src/nsDocumentViewer.cpp,v - bug 27953
layout/base/src/nsGenericDOMDataNode.cpp,v - [3]
layout/base/src/nsGenericDOMDataNode.h,v - [3]
layout/base/src/nsGenericElement.cpp,v - [3]
layout/base/src/nsGenericElement.h,v - [3]
layout/base/src/nsNameSpaceManager.cpp,v - bug 7834
layout/base/src/nsStyleContext.cpp,v - outline property shouldn't reflow
layout/base/src/nsTextNode.cpp,v - [2]
layout/events/src/nsEventListenerManager.cpp,v - [3]
layout/events/src/nsEventListenerManager.h,v - [3]
layout/html/base/src/nsGfxScrollFrame.cpp,v - nsString->nsAutoString
layout/html/content/src/nsAttributeContent.cpp,v - [2]
layout/html/content/src/nsHTMLAnchorElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAppletElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBodyElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLButtonElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDirectoryElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDivElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLEmbedElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFieldSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFormElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadingElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHtmlElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLImageElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInputElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInsElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIsIndexElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLIElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLabelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLayerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLegendElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLinkElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMapElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMenuElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMetaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLModElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLObjectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParagraphElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParamElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLPreElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLQuoteElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLScriptElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSelectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpacerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpanElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLStyleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCaptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCellElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableRowElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableSectionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTextAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTitleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLUListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLWBRElement.cpp,v - [1][3]
layout/html/document/src/nsHTMLDocument.cpp,v - bug 27953
layout/html/document/src/nsHTMLDocument.h,v - bug 27953
layout/xml/content/src/nsXMLCDATASection.cpp,v - [1][2]
layout/xml/content/src/nsXMLDocumentType.cpp,v - [1][2]
layout/xml/content/src/nsXMLElement.h,v - [1][2]
layout/xml/content/src/nsXMLEntity.cpp,v - [1][2]
layout/xml/content/src/nsXMLNotation.cpp,v - [1][2]
layout/xml/content/src/nsXMLProcessingInstruction.cpp,v - [1][2]
layout/xul/base/src/nsBoxFrame.cpp,v - nsString->nsAutoString
layout/xul/base/src/nsSliderFrame.cpp,v - nsString->nsAutoString
netwerk/protocol/http/src/nsHTTPRequest.cpp,v - nsString->nsAutoString
rdf/content/src/nsXULDocument.cpp,v - bug 27953
rdf/content/src/nsXULDocument.h,v - bug 27953
rdf/content/src/nsXULElement.h,v - [1]
xpcom/base/IIDS.h,v - bug 12559
2000-03-17 13:27:00 +00:00
|
|
|
slots->mListenerManager = *aResult;
|
|
|
|
NS_ADDREF(slots->mListenerManager);
|
2000-05-16 11:35:12 +00:00
|
|
|
slots->mListenerManager->SetListenerTarget(mContent);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// nsIJSScriptObject implementation
|
|
|
|
|
|
|
|
PRBool
|
1999-12-18 20:29:29 +00:00
|
|
|
nsGenericElement::AddProperty(JSContext *aContext, JSObject *aObj, jsval aID, jsval *aVp)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
1999-12-18 20:29:29 +00:00
|
|
|
nsGenericElement::DeleteProperty(JSContext *aContext, JSObject *aObj, jsval aID, jsval *aVp)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
1999-12-18 20:29:29 +00:00
|
|
|
nsGenericElement::GetProperty(JSContext *aContext, JSObject *aObj, jsval aID, jsval *aVp)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
1999-12-18 20:29:29 +00:00
|
|
|
nsGenericElement::SetProperty(JSContext *aContext, JSObject *aObj, jsval aID, jsval *aVp)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
nsIScriptObjectOwner *owner;
|
|
|
|
|
|
|
|
if (NS_OK != mContent->QueryInterface(kIScriptObjectOwnerIID, (void **)&owner)) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (JS_TypeOfValue(aContext, *aVp) == JSTYPE_FUNCTION && JSVAL_IS_STRING(aID)) {
|
|
|
|
nsAutoString propName, prefix;
|
2000-06-12 23:52:31 +00:00
|
|
|
propName.Assign(NS_REINTERPRET_CAST(const PRUnichar*, JS_GetStringChars(JS_ValueToString(aContext, aID))));
|
2000-01-23 04:23:14 +00:00
|
|
|
if (propName.Length() > 2)
|
2000-03-12 09:14:14 +00:00
|
|
|
prefix.Assign(propName.GetUnicode(), 2);
|
2000-08-23 17:27:06 +00:00
|
|
|
if (prefix.Equals(NS_LITERAL_STRING("on"))) {
|
1999-11-25 00:05:21 +00:00
|
|
|
nsCOMPtr<nsIAtom> atom = getter_AddRefs(NS_NewAtom(propName));
|
1998-11-11 22:06:16 +00:00
|
|
|
nsIEventListenerManager *manager = nsnull;
|
|
|
|
|
1999-11-25 01:02:52 +00:00
|
|
|
if (atom.get() == nsLayoutAtoms::onmousedown || atom.get() == nsLayoutAtoms::onmouseup || atom.get() == nsLayoutAtoms::onclick ||
|
|
|
|
atom.get() == nsLayoutAtoms::onmouseover || atom.get() == nsLayoutAtoms::onmouseout) {
|
1998-11-11 22:06:16 +00:00
|
|
|
if (NS_OK == GetListenerManager(&manager)) {
|
1999-12-18 20:29:29 +00:00
|
|
|
nsCOMPtr<nsIScriptContext> mScriptCX;
|
|
|
|
if (NS_FAILED(nsLayoutUtils::GetStaticScriptContext(aContext, (JSObject*)GetDOMSlots()->mScriptObject, getter_AddRefs(mScriptCX))) ||
|
|
|
|
NS_OK != manager->RegisterScriptEventListener(mScriptCX, owner, atom, kIDOMMouseListenerIID)) {
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_RELEASE(manager);
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-11-25 01:02:52 +00:00
|
|
|
else if (atom.get() == nsLayoutAtoms::onkeydown || atom.get() == nsLayoutAtoms::onkeyup || atom.get() == nsLayoutAtoms::onkeypress) {
|
1998-11-11 22:06:16 +00:00
|
|
|
if (NS_OK == GetListenerManager(&manager)) {
|
1999-12-18 20:29:29 +00:00
|
|
|
nsCOMPtr<nsIScriptContext> mScriptCX;
|
|
|
|
if (NS_FAILED(nsLayoutUtils::GetStaticScriptContext(aContext, (JSObject*)GetDOMSlots()->mScriptObject, getter_AddRefs(mScriptCX))) ||
|
|
|
|
NS_OK != manager->RegisterScriptEventListener(mScriptCX, owner, atom, kIDOMKeyListenerIID)) {
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_RELEASE(manager);
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-11-25 01:02:52 +00:00
|
|
|
else if (atom.get() == nsLayoutAtoms::onmousemove) {
|
1998-11-11 22:06:16 +00:00
|
|
|
if (NS_OK == GetListenerManager(&manager)) {
|
1999-12-18 20:29:29 +00:00
|
|
|
nsCOMPtr<nsIScriptContext> mScriptCX;
|
|
|
|
if (NS_FAILED(nsLayoutUtils::GetStaticScriptContext(aContext, (JSObject*)GetDOMSlots()->mScriptObject, getter_AddRefs(mScriptCX))) ||
|
|
|
|
NS_OK != manager->RegisterScriptEventListener(mScriptCX, owner, atom, kIDOMMouseMotionListenerIID)) {
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_RELEASE(manager);
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-11-25 01:02:52 +00:00
|
|
|
else if (atom.get() == nsLayoutAtoms::onfocus || atom.get() == nsLayoutAtoms::onblur) {
|
1998-11-11 22:06:16 +00:00
|
|
|
if (NS_OK == GetListenerManager(&manager)) {
|
1999-12-18 20:29:29 +00:00
|
|
|
nsCOMPtr<nsIScriptContext> mScriptCX;
|
|
|
|
if (NS_FAILED(nsLayoutUtils::GetStaticScriptContext(aContext, (JSObject*)GetDOMSlots()->mScriptObject, getter_AddRefs(mScriptCX))) ||
|
|
|
|
NS_OK != manager->RegisterScriptEventListener(mScriptCX, owner, atom, kIDOMFocusListenerIID)) {
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_RELEASE(manager);
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-11-25 01:02:52 +00:00
|
|
|
else if (atom.get() == nsLayoutAtoms::onsubmit || atom.get() == nsLayoutAtoms::onreset || atom.get() == nsLayoutAtoms::onchange ||
|
|
|
|
atom.get() == nsLayoutAtoms::onselect) {
|
1998-11-11 22:06:16 +00:00
|
|
|
if (NS_OK == GetListenerManager(&manager)) {
|
1999-12-18 20:29:29 +00:00
|
|
|
nsCOMPtr<nsIScriptContext> mScriptCX;
|
|
|
|
if (NS_FAILED(nsLayoutUtils::GetStaticScriptContext(aContext, (JSObject*)GetDOMSlots()->mScriptObject, getter_AddRefs(mScriptCX))) ||
|
|
|
|
NS_OK != manager->RegisterScriptEventListener(mScriptCX, owner, atom, kIDOMFormListenerIID)) {
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_RELEASE(manager);
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-11-25 01:02:52 +00:00
|
|
|
else if (atom.get() == nsLayoutAtoms::onload || atom.get() == nsLayoutAtoms::onunload || atom.get() == nsLayoutAtoms::onabort ||
|
|
|
|
atom.get() == nsLayoutAtoms::onerror) {
|
1998-11-11 22:06:16 +00:00
|
|
|
if (NS_OK == GetListenerManager(&manager)) {
|
1999-12-18 20:29:29 +00:00
|
|
|
nsCOMPtr<nsIScriptContext> mScriptCX;
|
|
|
|
if (NS_FAILED(nsLayoutUtils::GetStaticScriptContext(aContext, (JSObject*)GetDOMSlots()->mScriptObject, getter_AddRefs(mScriptCX))) ||
|
|
|
|
NS_OK != manager->RegisterScriptEventListener(mScriptCX, owner, atom, kIDOMLoadListenerIID)) {
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_RELEASE(manager);
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-05-17 06:53:58 +00:00
|
|
|
else if (atom.get() == nsLayoutAtoms::onpaint || atom.get() == nsLayoutAtoms::onresize ||
|
|
|
|
atom.get() == nsLayoutAtoms::onscroll) {
|
1998-11-11 22:06:16 +00:00
|
|
|
if (NS_OK == GetListenerManager(&manager)) {
|
1999-12-18 20:29:29 +00:00
|
|
|
nsCOMPtr<nsIScriptContext> mScriptCX;
|
|
|
|
if (NS_FAILED(nsLayoutUtils::GetStaticScriptContext(aContext, (JSObject*)GetDOMSlots()->mScriptObject, getter_AddRefs(mScriptCX))) ||
|
|
|
|
NS_OK != manager->RegisterScriptEventListener(mScriptCX, owner,
|
1999-11-25 00:05:21 +00:00
|
|
|
atom, kIDOMPaintListenerIID)) {
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_RELEASE(manager);
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(manager);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IF_RELEASE(owner);
|
|
|
|
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
1999-12-18 20:29:29 +00:00
|
|
|
nsGenericElement::EnumerateProperty(JSContext *aContext, JSObject *aObj)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
2000-09-22 10:18:07 +00:00
|
|
|
nsGenericElement::Resolve(JSContext *aContext, JSObject *aObj, jsval aID,
|
|
|
|
PRBool* aDidDefineProperty)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
2000-09-22 10:18:07 +00:00
|
|
|
*aDidDefineProperty = PR_FALSE;
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
1999-12-18 20:29:29 +00:00
|
|
|
nsGenericElement::Convert(JSContext *aContext, JSObject *aObj, jsval aID)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-12-18 20:29:29 +00:00
|
|
|
nsGenericElement::Finalize(JSContext *aContext, JSObject *aObj)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
}
|
2000-04-01 12:36:16 +00:00
|
|
|
|
|
|
|
// Generic DOMNode implementations
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This helper function checks if aChild is the same as aNode or if
|
|
|
|
* aChild is one of aNode's ancestors. -- jst@citec.fi
|
|
|
|
*/
|
|
|
|
|
|
|
|
static PRBool isSelfOrAncestor(nsIContent *aNode, nsIContent *aChild)
|
|
|
|
{
|
|
|
|
if (aNode == aChild)
|
|
|
|
return PR_TRUE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> parent, tmpNode;
|
|
|
|
PRInt32 childCount = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If aChild doesn't have children it can't be our ancestor
|
|
|
|
*/
|
|
|
|
aChild->ChildCount(childCount);
|
|
|
|
|
|
|
|
if (childCount <= 0) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
aNode->GetParent(*getter_AddRefs(parent));
|
|
|
|
|
|
|
|
while (parent) {
|
|
|
|
if (parent.get() == aChild) {
|
|
|
|
/*
|
|
|
|
* We found aChild as one of our ancestors
|
|
|
|
*/
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
parent->GetParent(*getter_AddRefs(tmpNode));
|
|
|
|
|
|
|
|
parent = tmpNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::doInsertBefore(nsIDOMNode* aNewChild,
|
|
|
|
nsIDOMNode* aRefChild,
|
|
|
|
nsIDOMNode** aReturn)
|
|
|
|
{
|
|
|
|
if (!aReturn) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aReturn = nsnull;
|
|
|
|
|
|
|
|
if (!aNewChild) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> refContent;
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
PRInt32 refPos = 0;
|
|
|
|
|
|
|
|
if (aRefChild) {
|
|
|
|
refContent = do_QueryInterface(aRefChild, &res);
|
|
|
|
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
/*
|
|
|
|
* If aRefChild doesn't support the nsIContent interface it can't be
|
|
|
|
* an existing child of this node.
|
|
|
|
*/
|
|
|
|
return NS_ERROR_DOM_NOT_FOUND_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
mContent->IndexOf(refContent, refPos);
|
|
|
|
|
|
|
|
if (refPos < 0) {
|
|
|
|
return NS_ERROR_DOM_NOT_FOUND_ERR;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mContent->ChildCount(refPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint16 nodeType = 0;
|
|
|
|
|
|
|
|
res = aNewChild->GetNodeType(&nodeType);
|
|
|
|
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (nodeType) {
|
|
|
|
case nsIDOMNode::ELEMENT_NODE :
|
|
|
|
case nsIDOMNode::TEXT_NODE :
|
|
|
|
case nsIDOMNode::CDATA_SECTION_NODE :
|
|
|
|
case nsIDOMNode::ENTITY_REFERENCE_NODE :
|
|
|
|
case nsIDOMNode::PROCESSING_INSTRUCTION_NODE :
|
|
|
|
case nsIDOMNode::COMMENT_NODE :
|
|
|
|
break;
|
|
|
|
case nsIDOMNode::DOCUMENT_FRAGMENT_NODE :
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* aNewChild is of invalid type.
|
|
|
|
*/
|
|
|
|
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> newContent(do_QueryInterface(aNewChild, &res));
|
|
|
|
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure the new child is not "this" node or one of this nodes
|
|
|
|
* ancestors. Doing this check here should be safe even if newContent
|
|
|
|
* is a document fragment.
|
|
|
|
*/
|
|
|
|
if (isSelfOrAncestor(mContent, newContent)) {
|
|
|
|
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if this is a document fragment. If it is, we need
|
|
|
|
* to remove the children of the document fragment and add them
|
|
|
|
* individually (i.e. we don't add the actual document fragment).
|
|
|
|
*/
|
|
|
|
if (nodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) {
|
|
|
|
nsCOMPtr<nsIContent> childContent;
|
|
|
|
PRInt32 count, i;
|
|
|
|
|
|
|
|
newContent->ChildCount(count);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Iterate through the fragments children, removing each from
|
|
|
|
* the fragment and inserting it into the child list of its
|
|
|
|
* new parent.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
// Always get and remove the first child, since the child indexes
|
|
|
|
// change as we go along.
|
|
|
|
res = newContent->ChildAt(0, *getter_AddRefs(childContent));
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = newContent->RemoveChildAt(0, PR_FALSE);
|
|
|
|
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2000-05-19 04:48:43 +00:00
|
|
|
childContent->SetDocument(mDocument, PR_TRUE, PR_TRUE);
|
2000-04-01 12:36:16 +00:00
|
|
|
|
|
|
|
// Insert the child and increment the insertion position
|
|
|
|
res = mContent->InsertChildAt(childContent, refPos++, PR_TRUE);
|
|
|
|
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsIDOMNode> oldParent;
|
|
|
|
res = aNewChild->GetParentNode(getter_AddRefs(oldParent));
|
|
|
|
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove the element from the old parent if one exists, since oldParent
|
|
|
|
* is a nsIDOMNode this will do the right thing even if the parent of
|
|
|
|
* aNewChild is a document. This code also handles the case where the
|
|
|
|
* new child is alleady a child of this node-- jst@citec.fi
|
|
|
|
*/
|
|
|
|
if (oldParent) {
|
|
|
|
nsCOMPtr<nsIDOMNode> tmpNode;
|
|
|
|
|
|
|
|
PRInt32 origChildCount, newChildCount;
|
|
|
|
|
|
|
|
mContent->ChildCount(origChildCount);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't care here if the return fails or not.
|
|
|
|
*/
|
|
|
|
oldParent->RemoveChild(aNewChild, getter_AddRefs(tmpNode));
|
|
|
|
|
|
|
|
mContent->ChildCount(newChildCount);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if our child count changed during the RemoveChild call, if
|
|
|
|
* it did then oldParent is most likely this node. In this case we
|
|
|
|
* must check if refPos is still correct (unless it's zero).
|
|
|
|
*/
|
|
|
|
if (refPos && origChildCount != newChildCount) {
|
|
|
|
if (refContent) {
|
|
|
|
/*
|
|
|
|
* If we did get aRefChild we check if that is now at refPos - 1,
|
|
|
|
* this will happend if the new child was one of aRefChilds'
|
|
|
|
* previous siblings.
|
|
|
|
*/
|
|
|
|
nsCOMPtr<nsIContent> tmpContent;
|
|
|
|
|
|
|
|
mContent->ChildAt(refPos - 1, *getter_AddRefs(tmpContent));
|
|
|
|
|
|
|
|
if (refContent == tmpContent) {
|
|
|
|
refPos--;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* If we didn't get aRefChild we simply decrement refPos.
|
|
|
|
*/
|
|
|
|
refPos--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-19 04:48:43 +00:00
|
|
|
newContent->SetDocument(mDocument, PR_TRUE, PR_TRUE);
|
2000-04-01 12:36:16 +00:00
|
|
|
|
|
|
|
res = mContent->InsertChildAt(newContent, refPos, PR_TRUE);
|
|
|
|
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*aReturn = aNewChild;
|
|
|
|
NS_ADDREF(*aReturn);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2000-04-01 12:36:16 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericElement::doReplaceChild(nsIDOMNode* aNewChild,
|
|
|
|
nsIDOMNode* aOldChild,
|
|
|
|
nsIDOMNode** aReturn)
|
|
|
|
{
|
|
|
|
if (!aReturn) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aReturn = nsnull;
|
|
|
|
|
|
|
|
if (!aNewChild || !aOldChild) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
PRInt32 oldPos = 0;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> oldContent(do_QueryInterface(aOldChild, &res));
|
|
|
|
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
/*
|
|
|
|
* If aOldChild doesn't support the nsIContent interface it can't be
|
|
|
|
* an existing child of this node.
|
|
|
|
*/
|
|
|
|
return NS_ERROR_DOM_NOT_FOUND_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
mContent->IndexOf(oldContent, oldPos);
|
|
|
|
|
|
|
|
if (oldPos < 0) {
|
|
|
|
return NS_ERROR_DOM_NOT_FOUND_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> replacedChild;
|
|
|
|
|
|
|
|
mContent->ChildAt(oldPos, *getter_AddRefs(replacedChild));
|
|
|
|
|
|
|
|
PRUint16 nodeType = 0;
|
|
|
|
|
|
|
|
res = aNewChild->GetNodeType(&nodeType);
|
|
|
|
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (nodeType) {
|
|
|
|
case nsIDOMNode::ELEMENT_NODE :
|
|
|
|
case nsIDOMNode::TEXT_NODE :
|
|
|
|
case nsIDOMNode::CDATA_SECTION_NODE :
|
|
|
|
case nsIDOMNode::ENTITY_REFERENCE_NODE :
|
|
|
|
case nsIDOMNode::PROCESSING_INSTRUCTION_NODE :
|
|
|
|
case nsIDOMNode::COMMENT_NODE :
|
|
|
|
case nsIDOMNode::DOCUMENT_FRAGMENT_NODE :
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* aNewChild is of invalid type.
|
|
|
|
*/
|
|
|
|
|
|
|
|
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> newContent(do_QueryInterface(aNewChild, &res));
|
|
|
|
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> document;
|
|
|
|
|
|
|
|
mContent->GetDocument(*getter_AddRefs(document));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure the new child is not "this" node or one of this nodes
|
|
|
|
* ancestors. Doing this check here should be safe even if newContent
|
|
|
|
* is a document fragment.
|
|
|
|
*/
|
|
|
|
if (isSelfOrAncestor(mContent, newContent)) {
|
|
|
|
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if this is a document fragment. If it is, we need
|
|
|
|
* to remove the children of the document fragment and add them
|
|
|
|
* individually (i.e. we don't add the actual document fragment).
|
|
|
|
*/
|
|
|
|
if (nodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) {
|
|
|
|
nsCOMPtr<nsIContent> childContent;
|
|
|
|
PRInt32 count, i;
|
|
|
|
|
|
|
|
newContent->ChildCount(count);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Iterate through the fragments children, removing each from
|
|
|
|
* the fragment and inserting it into the child list of its
|
|
|
|
* new parent.
|
|
|
|
*/
|
|
|
|
for (i =0; i < count; i++) {
|
|
|
|
// Always get and remove the first child, since the child indexes
|
|
|
|
// change as we go along.
|
|
|
|
res = newContent->ChildAt(0, *getter_AddRefs(childContent));
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = newContent->RemoveChildAt(0, PR_FALSE);
|
|
|
|
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2000-05-19 04:48:43 +00:00
|
|
|
childContent->SetDocument(document, PR_TRUE, PR_TRUE);
|
2000-04-01 12:36:16 +00:00
|
|
|
|
|
|
|
// Insert the child and increment the insertion position
|
|
|
|
if (i) {
|
|
|
|
res = mContent->InsertChildAt(childContent, oldPos++, PR_TRUE);
|
|
|
|
} else {
|
|
|
|
res = mContent->ReplaceChildAt(childContent, oldPos++, PR_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsIDOMNode> oldParent;
|
|
|
|
res = aNewChild->GetParentNode(getter_AddRefs(oldParent));
|
|
|
|
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove the element from the old parent if one exists, since oldParent
|
|
|
|
* is a nsIDOMNode this will do the right thing even if the parent of
|
|
|
|
* aNewChild is a document. This code also handles the case where the
|
|
|
|
* new child is alleady a child of this node-- jst@citec.fi
|
|
|
|
*/
|
|
|
|
if (oldParent) {
|
|
|
|
nsCOMPtr<nsIDOMNode> tmpNode;
|
|
|
|
|
|
|
|
PRInt32 origChildCount, newChildCount;
|
|
|
|
|
|
|
|
mContent->ChildCount(origChildCount);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't care here if the return fails or not.
|
|
|
|
*/
|
|
|
|
oldParent->RemoveChild(aNewChild, getter_AddRefs(tmpNode));
|
|
|
|
|
|
|
|
mContent->ChildCount(newChildCount);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if our child count changed during the RemoveChild call, if
|
|
|
|
* it did then oldParent is most likely this node. In this case we
|
|
|
|
* must check if oldPos is still correct (unless it's zero).
|
|
|
|
*/
|
|
|
|
if (oldPos && origChildCount != newChildCount) {
|
|
|
|
/*
|
|
|
|
* Check if aOldChild is now at oldPos - 1, this will happend if
|
|
|
|
* the new child was one of aOldChilds' previous siblings.
|
|
|
|
*/
|
|
|
|
nsCOMPtr<nsIContent> tmpContent;
|
|
|
|
|
|
|
|
mContent->ChildAt(oldPos - 1, *getter_AddRefs(tmpContent));
|
|
|
|
|
|
|
|
if (oldContent == tmpContent) {
|
|
|
|
oldPos--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-19 04:48:43 +00:00
|
|
|
newContent->SetDocument(document, PR_TRUE, PR_TRUE);
|
2000-04-01 12:36:16 +00:00
|
|
|
|
|
|
|
res = mContent->ReplaceChildAt(newContent, oldPos, PR_TRUE);
|
|
|
|
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return replacedChild->QueryInterface(NS_GET_IID(nsIDOMNode),
|
|
|
|
(void **)aReturn);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::doRemoveChild(nsIDOMNode* aOldChild,
|
|
|
|
nsIDOMNode** aReturn)
|
|
|
|
{
|
|
|
|
*aReturn = nsnull;
|
|
|
|
|
|
|
|
if (!aOldChild) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult res;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content(do_QueryInterface(aOldChild, &res));
|
|
|
|
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
/*
|
|
|
|
* If we're asked to remove something that doesn't support nsIContent
|
|
|
|
* it can not be one of our children, i.e. we return NOT_FOUND_ERR.
|
|
|
|
*/
|
|
|
|
return NS_ERROR_DOM_NOT_FOUND_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 pos;
|
|
|
|
mContent->IndexOf(content, pos);
|
|
|
|
|
|
|
|
if (pos < 0) {
|
|
|
|
/*
|
|
|
|
* aOldChild isn't one of our children.
|
|
|
|
*/
|
|
|
|
return NS_ERROR_DOM_NOT_FOUND_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = mContent->RemoveChildAt(pos, PR_TRUE);
|
|
|
|
|
|
|
|
*aReturn = aOldChild;
|
|
|
|
NS_ADDREF(aOldChild);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// nsISupports implementation
|
|
|
|
|
2000-03-21 01:29:01 +00:00
|
|
|
nsresult
|
1998-11-11 22:06:16 +00:00
|
|
|
nsGenericElement::QueryInterface(REFNSIID aIID,void** aInstancePtr)
|
|
|
|
{
|
|
|
|
return mContent->QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
|
2000-03-21 01:29:01 +00:00
|
|
|
nsrefcnt
|
1998-11-11 22:06:16 +00:00
|
|
|
nsGenericElement::AddRef()
|
|
|
|
{
|
|
|
|
return NS_ADDREF(mContent);
|
|
|
|
}
|
|
|
|
|
2000-03-21 01:29:01 +00:00
|
|
|
nsrefcnt
|
1998-11-11 22:06:16 +00:00
|
|
|
nsGenericElement::Release()
|
|
|
|
{
|
1999-09-17 05:15:00 +00:00
|
|
|
nsrefcnt rc=0;
|
|
|
|
NS_ASSERTION(mContent, "nsGenericElement: Nothing to release!");
|
|
|
|
if (mContent)
|
|
|
|
NS_RELEASE2(mContent, rc);
|
1998-12-08 16:08:44 +00:00
|
|
|
return rc;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2000-01-28 06:55:27 +00:00
|
|
|
nsresult
|
1999-11-24 06:03:41 +00:00
|
|
|
nsGenericElement::TriggerLink(nsIPresContext* aPresContext,
|
1998-11-14 00:21:19 +00:00
|
|
|
nsLinkVerb aVerb,
|
1999-06-23 03:29:44 +00:00
|
|
|
nsIURI* aBaseURL,
|
1998-11-14 00:21:19 +00:00
|
|
|
const nsString& aURLSpec,
|
|
|
|
const nsString& aTargetSpec,
|
|
|
|
PRBool aClick)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
2000-01-28 06:55:27 +00:00
|
|
|
nsCOMPtr<nsILinkHandler> handler;
|
|
|
|
nsresult rv = aPresContext->GetLinkHandler(getter_AddRefs(handler));
|
2000-02-02 23:40:22 +00:00
|
|
|
if (NS_FAILED(rv) || (nsnull == handler)) return rv;
|
|
|
|
|
2000-01-28 06:55:27 +00:00
|
|
|
// Resolve url to an absolute url
|
|
|
|
nsAutoString absURLSpec;
|
|
|
|
if (nsnull != aBaseURL) {
|
2000-03-29 03:58:50 +00:00
|
|
|
rv = NS_MakeAbsoluteURI(absURLSpec, aURLSpec, aBaseURL);
|
2000-01-28 06:55:27 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
}
|
|
|
|
else {
|
2000-04-15 21:18:29 +00:00
|
|
|
absURLSpec.Assign(aURLSpec);
|
2000-01-28 06:55:27 +00:00
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2000-01-28 06:55:27 +00:00
|
|
|
// Now pass on absolute url to the click handler
|
|
|
|
if (aClick) {
|
2000-02-02 23:02:59 +00:00
|
|
|
nsresult proceed = NS_OK;
|
2000-01-28 06:55:27 +00:00
|
|
|
// Check that this page is allowed to load this URI.
|
|
|
|
NS_WITH_SERVICE(nsIScriptSecurityManager, securityManager,
|
2000-09-13 23:57:52 +00:00
|
|
|
NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
2000-01-28 06:55:27 +00:00
|
|
|
nsCOMPtr<nsIURI> absURI;
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
rv = NS_NewURI(getter_AddRefs(absURI), absURLSpec, aBaseURL);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
2000-10-13 22:59:47 +00:00
|
|
|
proceed = securityManager->CheckLoadURI(aBaseURL, absURI, nsIScriptSecurityManager::STANDARD);
|
2000-02-02 23:02:59 +00:00
|
|
|
|
|
|
|
// Only pass off the click event if the script security manager
|
|
|
|
// says it's ok.
|
|
|
|
if (NS_SUCCEEDED(proceed))
|
2000-01-28 06:55:27 +00:00
|
|
|
handler->OnLinkClick(mContent, aVerb, absURLSpec.GetUnicode(), aTargetSpec.GetUnicode());
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
2000-01-28 06:55:27 +00:00
|
|
|
else {
|
|
|
|
handler->OnOverLink(mContent, absURLSpec.GetUnicode(), aTargetSpec.GetUnicode());
|
|
|
|
}
|
|
|
|
return rv;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericElement::AddScriptEventListener(nsIAtom* aAttribute,
|
2000-08-23 17:27:06 +00:00
|
|
|
const nsAReadableString& aValue,
|
1999-04-23 19:57:26 +00:00
|
|
|
REFNSIID aIID)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
nsresult ret = NS_OK;
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:31:05 +00:00
|
|
|
nsCOMPtr<nsIScriptContext> context = nsnull;
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> global = nsnull;
|
|
|
|
JSContext* cx = nsnull;
|
1998-11-11 22:06:16 +00:00
|
|
|
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:31:05 +00:00
|
|
|
//Try to get context from doc
|
|
|
|
if (mDocument) {
|
|
|
|
if (NS_SUCCEEDED(mDocument->GetScriptGlobalObject(getter_AddRefs(global))) && global) {
|
|
|
|
NS_ENSURE_SUCCESS(global->GetContext(getter_AddRefs(context)), NS_ERROR_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!context) {
|
|
|
|
// Get JSContext from stack.
|
2000-09-13 23:57:52 +00:00
|
|
|
nsCOMPtr<nsIThreadJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:31:05 +00:00
|
|
|
NS_ENSURE_TRUE(stack, NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_SUCCESS(stack->Peek(&cx), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
if(!cx) {
|
|
|
|
stack->GetSafeJSContext(&cx);
|
|
|
|
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLayoutUtils::GetDynamicScriptContext(cx, getter_AddRefs(context));
|
|
|
|
NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Attributes on the body and frameset tags get set on the global object
|
|
|
|
if (mNodeInfo->Equals(nsHTMLAtoms::body) ||
|
|
|
|
mNodeInfo->Equals(nsHTMLAtoms::frameset)) {
|
|
|
|
if (!global) {
|
|
|
|
if (cx) {
|
|
|
|
nsLayoutUtils::GetDynamicScriptGlobal(cx, getter_AddRefs(global));
|
|
|
|
}
|
|
|
|
NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDOMEventReceiver> receiver(do_QueryInterface(global));
|
|
|
|
nsCOMPtr<nsIEventListenerManager> manager;
|
|
|
|
if (receiver && NS_SUCCEEDED(receiver->GetListenerManager(getter_AddRefs(manager)))) {
|
|
|
|
nsCOMPtr<nsIScriptObjectOwner> objOwner(do_QueryInterface(global));
|
|
|
|
if (objOwner) {
|
|
|
|
ret = manager->AddScriptEventListener(context, objOwner, aAttribute, aValue, aIID, PR_FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsCOMPtr<nsIEventListenerManager> manager;
|
|
|
|
if (NS_SUCCEEDED(GetListenerManager(getter_AddRefs(manager)))) {
|
|
|
|
nsCOMPtr<nsIScriptObjectOwner> objOwner(do_QueryInterface(mContent));
|
|
|
|
if (objOwner) {
|
|
|
|
ret = manager->AddScriptEventListener(context, objOwner, aAttribute, aValue, aIID, PR_TRUE);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
1999-07-18 00:15:22 +00:00
|
|
|
static char kNameSpaceSeparator = ':';
|
1999-01-12 16:37:24 +00:00
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsGenericElement::CutNameSpacePrefix(nsString& aString)
|
|
|
|
{
|
|
|
|
nsAutoString prefix;
|
1999-07-18 00:15:22 +00:00
|
|
|
PRInt32 nsoffset = aString.FindChar(kNameSpaceSeparator);
|
1999-01-12 16:37:24 +00:00
|
|
|
if (-1 != nsoffset) {
|
|
|
|
aString.Left(prefix, nsoffset);
|
|
|
|
aString.Cut(0, nsoffset+1);
|
|
|
|
}
|
|
|
|
if (0 < prefix.Length()) {
|
|
|
|
return NS_NewAtom(prefix);
|
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1998-12-20 01:21:23 +00:00
|
|
|
struct nsGenericAttribute
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
2000-08-23 17:27:06 +00:00
|
|
|
nsGenericAttribute(nsINodeInfo *aNodeInfo, const nsAReadableString& aValue)
|
2000-05-17 04:52:09 +00:00
|
|
|
: mNodeInfo(aNodeInfo),
|
1998-12-20 01:21:23 +00:00
|
|
|
mValue(aValue)
|
|
|
|
{
|
2000-05-17 04:52:09 +00:00
|
|
|
NS_IF_ADDREF(mNodeInfo);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1998-12-20 01:21:23 +00:00
|
|
|
|
|
|
|
~nsGenericAttribute(void)
|
|
|
|
{
|
2000-05-17 04:52:09 +00:00
|
|
|
NS_IF_RELEASE(mNodeInfo);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
1999-10-05 23:47:46 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
PRUint32 sum = sizeof(*this) - sizeof(mValue);
|
|
|
|
PRUint32 ssize;
|
|
|
|
mValue.SizeOf(aSizer, &ssize);
|
|
|
|
sum += ssize;
|
|
|
|
*aResult = sum;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-05-17 04:52:09 +00:00
|
|
|
nsINodeInfo* mNodeInfo;
|
|
|
|
nsString mValue;
|
1998-12-20 01:21:23 +00:00
|
|
|
};
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
nsGenericContainerElement::nsGenericContainerElement()
|
|
|
|
{
|
|
|
|
mAttributes = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGenericContainerElement::~nsGenericContainerElement()
|
|
|
|
{
|
1998-12-20 01:21:23 +00:00
|
|
|
PRInt32 count = mChildren.Count();
|
|
|
|
PRInt32 index;
|
|
|
|
for (index = 0; index < count; index++) {
|
|
|
|
nsIContent* kid = (nsIContent *)mChildren.ElementAt(index);
|
1999-10-05 03:20:57 +00:00
|
|
|
kid->SetParent(nsnull);
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_RELEASE(kid);
|
|
|
|
}
|
|
|
|
if (nsnull != mAttributes) {
|
1998-12-20 01:21:23 +00:00
|
|
|
count = mAttributes->Count();
|
|
|
|
for (index = 0; index < count; index++) {
|
|
|
|
nsGenericAttribute* attr = (nsGenericAttribute*)mAttributes->ElementAt(index);
|
|
|
|
delete attr;
|
|
|
|
}
|
|
|
|
delete mAttributes;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-31 00:36:31 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::NormalizeAttributeString(const nsAReadableString& aStr, nsINodeInfo*& aNodeInfo)
|
|
|
|
{
|
|
|
|
if (mAttributes) {
|
|
|
|
PRInt32 indx, count = mAttributes->Count();
|
|
|
|
for (indx = 0; indx < count; indx++) {
|
|
|
|
nsGenericAttribute* attr = (nsGenericAttribute*)mAttributes->ElementAt(indx);
|
|
|
|
if (attr->mNodeInfo->QualifiedNameEquals(aStr)) {
|
|
|
|
aNodeInfo = attr->mNodeInfo;
|
|
|
|
NS_ADDREF(aNodeInfo);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsINodeInfoManager> nimgr;
|
|
|
|
mNodeInfo->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
|
|
|
NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
return nimgr->GetNodeInfo(aStr, nsnull, kNameSpaceID_None, aNodeInfo);
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::CopyInnerTo(nsIContent* aSrcContent,
|
1999-01-14 23:14:02 +00:00
|
|
|
nsGenericContainerElement* aDst,
|
|
|
|
PRBool aDeep)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
1999-01-14 23:14:02 +00:00
|
|
|
nsresult result = NS_OK;
|
|
|
|
|
|
|
|
if (nsnull != mAttributes) {
|
|
|
|
nsGenericAttribute* attr;
|
|
|
|
PRInt32 index;
|
|
|
|
PRInt32 count = mAttributes->Count();
|
|
|
|
for (index = 0; index < count; index++) {
|
|
|
|
attr = (nsGenericAttribute*)mAttributes->ElementAt(index);
|
|
|
|
// XXX Not very efficient, since SetAttribute does a linear search
|
|
|
|
// through its attributes before setting each attribute.
|
2000-05-17 04:52:09 +00:00
|
|
|
result = aDst->SetAttribute(attr->mNodeInfo, attr->mValue, PR_FALSE);
|
1999-01-14 23:14:02 +00:00
|
|
|
if (NS_OK != result) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aDeep) {
|
|
|
|
PRInt32 index;
|
|
|
|
PRInt32 count = mChildren.Count();
|
|
|
|
for (index = 0; index < count; index++) {
|
|
|
|
nsIContent* child = (nsIContent*)mChildren.ElementAt(index);
|
|
|
|
if (nsnull != child) {
|
|
|
|
nsIDOMNode* node;
|
|
|
|
result = child->QueryInterface(kIDOMNodeIID, (void**)&node);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
nsIDOMNode* newNode;
|
|
|
|
|
|
|
|
result = node->CloneNode(aDeep, &newNode);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
nsIContent* newContent;
|
|
|
|
|
|
|
|
result = newNode->QueryInterface(kIContentIID, (void**)&newContent);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
result = aDst->AppendChildTo(newContent, PR_FALSE);
|
|
|
|
NS_RELEASE(newContent);
|
|
|
|
}
|
|
|
|
NS_RELEASE(newNode);
|
|
|
|
}
|
|
|
|
NS_RELEASE(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_OK != result) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
|
|
|
{
|
|
|
|
nsDOMSlots *slots = GetDOMSlots();
|
|
|
|
|
|
|
|
if (nsnull == slots->mChildNodes) {
|
|
|
|
slots->mChildNodes = new nsChildContentList(mContent);
|
1998-12-17 07:22:28 +00:00
|
|
|
if (nsnull == slots->mChildNodes) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_ADDREF(slots->mChildNodes);
|
|
|
|
}
|
|
|
|
|
|
|
|
return slots->mChildNodes->QueryInterface(kIDOMNodeListIID, (void **)aChildNodes);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::HasChildNodes(PRBool* aReturn)
|
|
|
|
{
|
|
|
|
if (0 != mChildren.Count()) {
|
|
|
|
*aReturn = PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*aReturn = PR_FALSE;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::GetFirstChild(nsIDOMNode** aNode)
|
|
|
|
{
|
|
|
|
nsIContent *child = (nsIContent *)mChildren.ElementAt(0);
|
|
|
|
if (nsnull != child) {
|
|
|
|
nsresult res = child->QueryInterface(kIDOMNodeIID, (void**)aNode);
|
|
|
|
NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); // must be a DOM Node
|
|
|
|
return res;
|
|
|
|
}
|
1998-11-30 07:59:11 +00:00
|
|
|
*aNode = nsnull;
|
1998-11-11 22:06:16 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::GetLastChild(nsIDOMNode** aNode)
|
|
|
|
{
|
|
|
|
nsIContent *child = (nsIContent *)mChildren.ElementAt(mChildren.Count()-1);
|
|
|
|
if (nsnull != child) {
|
|
|
|
nsresult res = child->QueryInterface(kIDOMNodeIID, (void**)aNode);
|
|
|
|
NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); // must be a DOM Node
|
|
|
|
return res;
|
|
|
|
}
|
1998-11-30 07:59:11 +00:00
|
|
|
*aNode = nsnull;
|
1998-11-11 22:06:16 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1998-12-20 01:21:23 +00:00
|
|
|
nsGenericContainerElement::SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
|
2000-08-23 17:27:06 +00:00
|
|
|
const nsAReadableString& aValue,
|
1998-11-30 07:59:11 +00:00
|
|
|
PRBool aNotify)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
2000-06-23 00:21:32 +00:00
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsINodeInfoManager> nimgr;
|
|
|
|
rv = mNodeInfo->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsINodeInfo> ni;
|
|
|
|
rv = nimgr->GetNodeInfo(aName, nsnull, aNameSpaceID,
|
|
|
|
*getter_AddRefs(ni));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return SetAttribute(ni, aValue, aNotify);
|
|
|
|
}
|
|
|
|
|
2000-11-27 07:55:20 +00:00
|
|
|
static PRBool HasMutationListeners(nsIContent* aContent, PRUint32 aType)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
aContent->GetDocument(*getter_AddRefs(doc));
|
|
|
|
if (!doc)
|
|
|
|
return PR_FALSE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> global;
|
|
|
|
doc->GetScriptGlobalObject(getter_AddRefs(global));
|
|
|
|
if (!global)
|
|
|
|
return PR_FALSE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(global));
|
|
|
|
if (!window)
|
|
|
|
return PR_FALSE;
|
|
|
|
|
|
|
|
PRBool set;
|
|
|
|
window->HasMutationListeners(aType, &set);
|
|
|
|
if (!set)
|
|
|
|
return PR_FALSE;
|
|
|
|
|
|
|
|
// We know a mutation listener is registered, but it might not
|
|
|
|
// be in our chain. Check quickly to see.
|
|
|
|
nsCOMPtr<nsIContent> curr = aContent;
|
|
|
|
nsCOMPtr<nsIEventListenerManager> manager;
|
|
|
|
|
|
|
|
while (curr) {
|
|
|
|
nsCOMPtr<nsIDOMEventReceiver> rec(do_QueryInterface(curr));
|
|
|
|
if (rec) {
|
|
|
|
rec->GetListenerManager(getter_AddRefs(manager));
|
|
|
|
if (manager) {
|
|
|
|
PRBool hasMutationListeners = PR_FALSE;
|
|
|
|
manager->HasMutationListeners(&hasMutationListeners);
|
|
|
|
if (hasMutationListeners)
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> prev = curr;
|
|
|
|
prev->GetParent(*getter_AddRefs(curr));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMEventReceiver> rec(do_QueryInterface(doc));
|
|
|
|
if (rec) {
|
|
|
|
rec->GetListenerManager(getter_AddRefs(manager));
|
|
|
|
if (manager) {
|
|
|
|
PRBool hasMutationListeners = PR_FALSE;
|
|
|
|
manager->HasMutationListeners(&hasMutationListeners);
|
|
|
|
if (hasMutationListeners)
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rec = do_QueryInterface(window);
|
|
|
|
if (rec) {
|
|
|
|
rec->GetListenerManager(getter_AddRefs(manager));
|
|
|
|
if (manager) {
|
|
|
|
PRBool hasMutationListeners = PR_FALSE;
|
|
|
|
manager->HasMutationListeners(&hasMutationListeners);
|
|
|
|
if (hasMutationListeners)
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2000-06-23 00:21:32 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::SetAttribute(nsINodeInfo* aNodeInfo,
|
2000-08-23 17:27:06 +00:00
|
|
|
const nsAReadableString& aValue,
|
2000-06-23 00:21:32 +00:00
|
|
|
PRBool aNotify)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aNodeInfo);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2000-11-27 07:55:20 +00:00
|
|
|
PRBool modification = PR_FALSE;
|
|
|
|
nsAutoString oldValue;
|
|
|
|
|
1998-12-20 01:21:23 +00:00
|
|
|
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
2000-06-23 00:21:32 +00:00
|
|
|
if (!mAttributes) {
|
1998-12-20 01:21:23 +00:00
|
|
|
mAttributes = new nsVoidArray();
|
2000-06-23 00:21:32 +00:00
|
|
|
NS_ENSURE_TRUE(mAttributes, NS_ERROR_OUT_OF_MEMORY);
|
1998-12-20 01:21:23 +00:00
|
|
|
}
|
2000-01-28 23:43:12 +00:00
|
|
|
|
|
|
|
if (aNotify && (nsnull != mDocument)) {
|
|
|
|
mDocument->BeginUpdate();
|
|
|
|
}
|
|
|
|
|
2000-06-23 00:21:32 +00:00
|
|
|
nsGenericAttribute* attr;
|
|
|
|
PRInt32 index;
|
|
|
|
PRInt32 count = mAttributes->Count();
|
|
|
|
for (index = 0; index < count; index++) {
|
|
|
|
attr = (nsGenericAttribute*)mAttributes->ElementAt(index);
|
|
|
|
if (attr->mNodeInfo == aNodeInfo) {
|
2000-11-27 07:55:20 +00:00
|
|
|
oldValue = attr->mValue;
|
|
|
|
modification = PR_TRUE;
|
2000-06-23 00:21:32 +00:00
|
|
|
attr->mValue = aValue;
|
|
|
|
rv = NS_OK;
|
|
|
|
break;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
2000-06-23 00:21:32 +00:00
|
|
|
|
|
|
|
if (index >= count) { // didn't find it
|
|
|
|
attr = new nsGenericAttribute(aNodeInfo, aValue);
|
|
|
|
NS_ENSURE_TRUE(attr, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
mAttributes->AppendElement(attr);
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
1998-12-20 01:21:23 +00:00
|
|
|
|
2000-05-10 02:15:47 +00:00
|
|
|
if (mDocument && NS_SUCCEEDED(rv)) {
|
2000-06-23 00:21:32 +00:00
|
|
|
nsCOMPtr<nsIAtom> name;
|
|
|
|
PRInt32 nameSpaceID;
|
|
|
|
|
|
|
|
aNodeInfo->GetNameAtom(*getter_AddRefs(name));
|
|
|
|
aNodeInfo->GetNamespaceID(nameSpaceID);
|
|
|
|
|
2000-05-10 02:15:47 +00:00
|
|
|
nsCOMPtr<nsIBindingManager> bindingManager;
|
|
|
|
mDocument->GetBindingManager(getter_AddRefs(bindingManager));
|
|
|
|
nsCOMPtr<nsIXBLBinding> binding;
|
|
|
|
bindingManager->GetBinding(mContent, getter_AddRefs(binding));
|
|
|
|
if (binding)
|
2000-06-23 00:21:32 +00:00
|
|
|
binding->AttributeChanged(name, nameSpaceID, PR_FALSE);
|
2000-05-10 02:15:47 +00:00
|
|
|
|
2000-11-27 07:55:20 +00:00
|
|
|
if (HasMutationListeners(mContent, NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) {
|
|
|
|
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(mContent));
|
|
|
|
nsMutationEvent mutation;
|
|
|
|
mutation.eventStructType = NS_MUTATION_EVENT;
|
|
|
|
mutation.message = NS_MUTATION_ATTRMODIFIED;
|
|
|
|
mutation.mTarget = node;
|
|
|
|
|
|
|
|
nsAutoString attrName;
|
|
|
|
name->ToString(attrName);
|
|
|
|
nsCOMPtr<nsIDOMAttr> attrNode;
|
|
|
|
GetAttributeNode(attrName, getter_AddRefs(attrNode));
|
|
|
|
mutation.mRelatedNode = attrNode;
|
|
|
|
|
|
|
|
mutation.mAttrName = name;
|
|
|
|
if (!oldValue.IsEmpty())
|
|
|
|
mutation.mPrevAttrValue = getter_AddRefs(NS_NewAtom(oldValue));
|
|
|
|
if (!aValue.IsEmpty())
|
|
|
|
mutation.mNewAttrValue = getter_AddRefs(NS_NewAtom(aValue));
|
|
|
|
mutation.mAttrChange = modification ? nsIDOMMutationEvent::MODIFICATION :
|
|
|
|
nsIDOMMutationEvent::ADDITION;
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
|
|
nsCOMPtr<nsIDOMEvent> domEvent;
|
|
|
|
mContent->HandleDOMEvent(nsnull, &mutation, getter_AddRefs(domEvent), NS_EVENT_FLAG_INIT, &status);
|
|
|
|
}
|
|
|
|
|
2000-05-10 02:15:47 +00:00
|
|
|
if (aNotify) {
|
2000-06-23 00:21:32 +00:00
|
|
|
mDocument->AttributeChanged(mContent, nameSpaceID, name, NS_STYLE_HINT_UNKNOWN);
|
2000-05-10 02:15:47 +00:00
|
|
|
mDocument->EndUpdate();
|
2000-01-28 23:43:12 +00:00
|
|
|
}
|
1998-12-20 01:21:23 +00:00
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1998-12-20 01:21:23 +00:00
|
|
|
nsGenericContainerElement::GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
|
2000-08-23 17:27:06 +00:00
|
|
|
nsAWritableString& aResult) const
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
2000-05-17 00:21:53 +00:00
|
|
|
nsCOMPtr<nsIAtom> prefix;
|
|
|
|
return GetAttribute(aNameSpaceID, aName, *getter_AddRefs(prefix), aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
|
2000-05-17 04:52:09 +00:00
|
|
|
nsIAtom*& aPrefix,
|
2000-08-23 17:27:06 +00:00
|
|
|
nsAWritableString& aResult) const
|
2000-05-17 00:21:53 +00:00
|
|
|
{
|
1998-12-20 01:21:23 +00:00
|
|
|
NS_ASSERTION(nsnull != aName, "must have attribute name");
|
|
|
|
if (nsnull == aName) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1998-12-20 01:21:23 +00:00
|
|
|
nsresult rv = NS_CONTENT_ATTR_NOT_THERE;
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1998-12-20 01:21:23 +00:00
|
|
|
if (nsnull != mAttributes) {
|
|
|
|
PRInt32 count = mAttributes->Count();
|
|
|
|
PRInt32 index;
|
|
|
|
for (index = 0; index < count; index++) {
|
|
|
|
const nsGenericAttribute* attr = (const nsGenericAttribute*)mAttributes->ElementAt(index);
|
2000-06-23 00:21:32 +00:00
|
|
|
if ((aNameSpaceID == kNameSpaceID_Unknown ||
|
2000-05-17 04:52:09 +00:00
|
|
|
attr->mNodeInfo->NamespaceEquals(aNameSpaceID)) &&
|
|
|
|
(attr->mNodeInfo->Equals(aName))) {
|
|
|
|
attr->mNodeInfo->GetPrefixAtom(aPrefix);
|
2000-08-23 17:27:06 +00:00
|
|
|
aResult.Assign(attr->mValue);
|
1998-12-20 01:21:23 +00:00
|
|
|
if (0 < aResult.Length()) {
|
|
|
|
rv = NS_CONTENT_ATTR_HAS_VALUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rv = NS_CONTENT_ATTR_NO_VALUE;
|
|
|
|
}
|
|
|
|
break;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-12-20 01:21:23 +00:00
|
|
|
|
1999-05-04 20:51:42 +00:00
|
|
|
if (rv == NS_CONTENT_ATTR_NOT_THERE) {
|
|
|
|
// In other cases we already set the out param.
|
|
|
|
// Since we are returning a success code we'd better do
|
|
|
|
// something about the out parameters (someone may have
|
|
|
|
// given us a non-empty string).
|
|
|
|
aResult.Truncate();
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-08-31 00:36:31 +00:00
|
|
|
nsGenericContainerElement::UnsetAttribute(PRInt32 aNameSpaceID,
|
|
|
|
nsIAtom* aName, PRBool aNotify)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
1998-12-20 01:21:23 +00:00
|
|
|
NS_ASSERTION(nsnull != aName, "must have attribute name");
|
|
|
|
if (nsnull == aName) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
if (nsnull != mAttributes) {
|
1998-12-20 01:21:23 +00:00
|
|
|
PRInt32 count = mAttributes->Count();
|
|
|
|
PRInt32 index;
|
1999-01-15 01:56:18 +00:00
|
|
|
PRBool found = PR_FALSE;
|
1998-12-20 01:21:23 +00:00
|
|
|
for (index = 0; index < count; index++) {
|
|
|
|
nsGenericAttribute* attr = (nsGenericAttribute*)mAttributes->ElementAt(index);
|
2000-06-23 00:21:32 +00:00
|
|
|
if ((aNameSpaceID == kNameSpaceID_Unknown ||
|
2000-05-17 04:52:09 +00:00
|
|
|
attr->mNodeInfo->NamespaceEquals(aNameSpaceID)) &&
|
|
|
|
attr->mNodeInfo->Equals(aName)) {
|
2000-01-28 23:43:12 +00:00
|
|
|
if (aNotify && (nsnull != mDocument)) {
|
|
|
|
mDocument->BeginUpdate();
|
|
|
|
}
|
2000-11-27 07:55:20 +00:00
|
|
|
|
|
|
|
if (HasMutationListeners(mContent, NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) {
|
|
|
|
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(mContent));
|
|
|
|
nsMutationEvent mutation;
|
|
|
|
mutation.eventStructType = NS_MUTATION_EVENT;
|
|
|
|
mutation.message = NS_MUTATION_ATTRMODIFIED;
|
|
|
|
mutation.mTarget = node;
|
|
|
|
|
|
|
|
nsAutoString attrName;
|
|
|
|
aName->ToString(attrName);
|
|
|
|
nsCOMPtr<nsIDOMAttr> attrNode;
|
|
|
|
GetAttributeNode(attrName, getter_AddRefs(attrNode));
|
|
|
|
mutation.mRelatedNode = attrNode;
|
|
|
|
|
|
|
|
mutation.mAttrName = aName;
|
|
|
|
if (!attr->mValue.IsEmpty())
|
|
|
|
mutation.mPrevAttrValue = getter_AddRefs(NS_NewAtom(attr->mValue));
|
|
|
|
mutation.mAttrChange = nsIDOMMutationEvent::REMOVAL;
|
|
|
|
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
|
|
nsCOMPtr<nsIDOMEvent> domEvent;
|
|
|
|
mContent->HandleDOMEvent(nsnull, &mutation, getter_AddRefs(domEvent), NS_EVENT_FLAG_INIT, &status);
|
|
|
|
}
|
|
|
|
|
1998-12-20 01:21:23 +00:00
|
|
|
mAttributes->RemoveElementAt(index);
|
|
|
|
delete attr;
|
1999-01-15 01:56:18 +00:00
|
|
|
found = PR_TRUE;
|
1998-12-20 01:21:23 +00:00
|
|
|
break;
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
2000-05-10 02:15:47 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && found && mDocument) {
|
|
|
|
nsCOMPtr<nsIBindingManager> bindingManager;
|
|
|
|
mDocument->GetBindingManager(getter_AddRefs(bindingManager));
|
|
|
|
nsCOMPtr<nsIXBLBinding> binding;
|
|
|
|
bindingManager->GetBinding(mContent, getter_AddRefs(binding));
|
|
|
|
if (binding)
|
|
|
|
binding->AttributeChanged(aName, aNameSpaceID, PR_TRUE);
|
|
|
|
|
|
|
|
if (aNotify) {
|
|
|
|
mDocument->AttributeChanged(mContent, aNameSpaceID, aName, NS_STYLE_HINT_UNKNOWN);
|
|
|
|
mDocument->EndUpdate();
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-12-20 01:21:23 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::GetAttributeNameAt(PRInt32 aIndex,
|
|
|
|
PRInt32& aNameSpaceID,
|
2000-05-17 00:21:53 +00:00
|
|
|
nsIAtom*& aName,
|
|
|
|
nsIAtom*& aPrefix) const
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mAttributes) {
|
1998-12-20 01:21:23 +00:00
|
|
|
nsGenericAttribute* attr = (nsGenericAttribute*)mAttributes->ElementAt(aIndex);
|
|
|
|
if (nsnull != attr) {
|
2000-05-17 04:52:09 +00:00
|
|
|
attr->mNodeInfo->GetNamespaceID(aNameSpaceID);
|
|
|
|
attr->mNodeInfo->GetNameAtom(aName);
|
|
|
|
attr->mNodeInfo->GetPrefixAtom(aPrefix);
|
|
|
|
|
1998-12-20 01:21:23 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1998-12-20 01:21:23 +00:00
|
|
|
aNameSpaceID = kNameSpaceID_None;
|
|
|
|
aName = nsnull;
|
|
|
|
return NS_ERROR_ILLEGAL_VALUE;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::GetAttributeCount(PRInt32& aResult) const
|
|
|
|
{
|
|
|
|
if (nsnull != mAttributes) {
|
1998-12-20 01:21:23 +00:00
|
|
|
aResult = mAttributes->Count();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aResult = 0;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsGenericContainerElement::ListAttributes(FILE* out) const
|
|
|
|
{
|
1998-12-20 01:21:23 +00:00
|
|
|
PRInt32 index, count;
|
|
|
|
GetAttributeCount(count);
|
|
|
|
|
|
|
|
for (index = 0; index < count; index++) {
|
|
|
|
const nsGenericAttribute* attr = (const nsGenericAttribute*)mAttributes->ElementAt(index);
|
|
|
|
nsAutoString buffer;
|
|
|
|
|
|
|
|
// name
|
|
|
|
nsAutoString name;
|
2000-05-17 04:52:09 +00:00
|
|
|
attr->mNodeInfo->GetQualifiedName(name);
|
1998-12-20 01:21:23 +00:00
|
|
|
buffer.Append(name);
|
|
|
|
|
|
|
|
// value
|
2000-04-15 21:18:29 +00:00
|
|
|
buffer.AppendWithConversion("=");
|
1998-12-20 01:21:23 +00:00
|
|
|
buffer.Append(attr->mValue);
|
|
|
|
|
|
|
|
fputs(" ", out);
|
|
|
|
fputs(buffer, out);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::List(FILE* out, PRInt32 aIndent) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != mDocument, "bad content");
|
|
|
|
|
|
|
|
PRInt32 index;
|
|
|
|
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
|
|
|
|
2000-05-10 13:13:39 +00:00
|
|
|
nsAutoString buf;
|
|
|
|
mNodeInfo->GetQualifiedName(buf);
|
|
|
|
fputs(buf, out);
|
|
|
|
|
1999-11-01 15:23:06 +00:00
|
|
|
fprintf(out, "@%p", mContent);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
ListAttributes(out);
|
|
|
|
|
|
|
|
nsIContent* hc = mContent;
|
|
|
|
nsrefcnt r = NS_ADDREF(hc) - 1;
|
|
|
|
NS_RELEASE(hc);
|
|
|
|
fprintf(out, " refcount=%d<", r);
|
|
|
|
|
|
|
|
PRBool canHaveKids;
|
|
|
|
mContent->CanContainChildren(canHaveKids);
|
|
|
|
if (canHaveKids) {
|
|
|
|
fputs("\n", out);
|
|
|
|
PRInt32 kids;
|
|
|
|
mContent->ChildCount(kids);
|
|
|
|
for (index = 0; index < kids; index++) {
|
|
|
|
nsIContent* kid;
|
|
|
|
mContent->ChildAt(index, kid);
|
|
|
|
kid->List(out, aIndent + 1);
|
|
|
|
NS_RELEASE(kid);
|
|
|
|
}
|
|
|
|
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
|
|
|
}
|
|
|
|
fputs(">\n", out);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-26 19:45:37 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::CanContainChildren(PRBool& aResult) const
|
|
|
|
{
|
|
|
|
aResult = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::ChildCount(PRInt32& aCount) const
|
|
|
|
{
|
|
|
|
aCount = mChildren.Count();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::ChildAt(PRInt32 aIndex,
|
1998-11-30 07:59:11 +00:00
|
|
|
nsIContent*& aResult) const
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
nsIContent *child = (nsIContent *)mChildren.ElementAt(aIndex);
|
|
|
|
if (nsnull != child) {
|
|
|
|
NS_ADDREF(child);
|
|
|
|
}
|
|
|
|
aResult = child;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::IndexOf(nsIContent* aPossibleChild,
|
1998-11-30 07:59:11 +00:00
|
|
|
PRInt32& aIndex) const
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aPossibleChild, "null ptr");
|
|
|
|
aIndex = mChildren.IndexOf(aPossibleChild);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::InsertChildAt(nsIContent* aKid,
|
1998-11-30 07:59:11 +00:00
|
|
|
PRInt32 aIndex,
|
|
|
|
PRBool aNotify)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aKid, "null ptr");
|
2000-01-28 23:43:12 +00:00
|
|
|
nsIDocument* doc = mDocument;
|
|
|
|
if (aNotify && (nsnull != doc)) {
|
|
|
|
doc->BeginUpdate();
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
PRBool rv = mChildren.InsertElementAt(aKid, aIndex);/* XXX fix up void array api to use nsresult's*/
|
|
|
|
if (rv) {
|
|
|
|
NS_ADDREF(aKid);
|
|
|
|
aKid->SetParent(mContent);
|
1998-12-30 08:28:16 +00:00
|
|
|
nsRange::OwnerChildInserted(mContent, aIndex);
|
1998-11-11 22:06:16 +00:00
|
|
|
if (nsnull != doc) {
|
2000-05-19 04:48:43 +00:00
|
|
|
aKid->SetDocument(doc, PR_FALSE, PR_TRUE);
|
1998-11-11 22:06:16 +00:00
|
|
|
if (aNotify) {
|
|
|
|
doc->ContentInserted(mContent, aKid, aIndex);
|
|
|
|
}
|
2000-11-27 07:55:20 +00:00
|
|
|
|
|
|
|
if (HasMutationListeners(mContent, NS_EVENT_BITS_MUTATION_NODEINSERTED)) {
|
|
|
|
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(aKid));
|
|
|
|
nsMutationEvent mutation;
|
|
|
|
mutation.eventStructType = NS_MUTATION_EVENT;
|
|
|
|
mutation.message = NS_MUTATION_NODEINSERTED;
|
|
|
|
mutation.mTarget = node;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> relNode(do_QueryInterface(mContent));
|
|
|
|
mutation.mRelatedNode = relNode;
|
|
|
|
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
|
|
nsCOMPtr<nsIDOMEvent> domEvent;
|
|
|
|
aKid->HandleDOMEvent(nsnull, &mutation, getter_AddRefs(domEvent), NS_EVENT_FLAG_INIT, &status);
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
2000-01-28 23:43:12 +00:00
|
|
|
if (aNotify && (nsnull != doc)) {
|
|
|
|
doc->EndUpdate();
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::ReplaceChildAt(nsIContent* aKid,
|
1998-11-30 07:59:11 +00:00
|
|
|
PRInt32 aIndex,
|
|
|
|
PRBool aNotify)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aKid, "null ptr");
|
2000-01-28 23:43:12 +00:00
|
|
|
nsIDocument* doc = mDocument;
|
|
|
|
if (aNotify && (nsnull != mDocument)) {
|
|
|
|
doc->BeginUpdate();
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
nsIContent* oldKid = (nsIContent *)mChildren.ElementAt(aIndex);
|
1999-06-16 21:38:51 +00:00
|
|
|
nsRange::OwnerChildReplaced(mContent, aIndex, oldKid);
|
1998-11-11 22:06:16 +00:00
|
|
|
PRBool rv = mChildren.ReplaceElementAt(aKid, aIndex);
|
|
|
|
if (rv) {
|
|
|
|
NS_ADDREF(aKid);
|
|
|
|
aKid->SetParent(mContent);
|
|
|
|
if (nsnull != doc) {
|
2000-05-19 04:48:43 +00:00
|
|
|
aKid->SetDocument(doc, PR_FALSE, PR_TRUE);
|
1998-11-11 22:06:16 +00:00
|
|
|
if (aNotify) {
|
|
|
|
doc->ContentReplaced(mContent, oldKid, aKid, aIndex);
|
|
|
|
}
|
|
|
|
}
|
2000-05-19 04:48:43 +00:00
|
|
|
oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE);
|
1998-11-11 22:06:16 +00:00
|
|
|
oldKid->SetParent(nsnull);
|
|
|
|
NS_RELEASE(oldKid);
|
|
|
|
}
|
2000-01-28 23:43:12 +00:00
|
|
|
if (aNotify && (nsnull != mDocument)) {
|
|
|
|
doc->EndUpdate();
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION((nsnull != aKid) && (aKid != mContent), "null ptr");
|
2000-01-28 23:43:12 +00:00
|
|
|
nsIDocument* doc = mDocument;
|
|
|
|
if (aNotify && (nsnull != doc)) {
|
|
|
|
doc->BeginUpdate();
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
PRBool rv = mChildren.AppendElement(aKid);
|
|
|
|
if (rv) {
|
|
|
|
NS_ADDREF(aKid);
|
|
|
|
aKid->SetParent(mContent);
|
1998-12-30 08:28:16 +00:00
|
|
|
// ranges don't need adjustment since new child is at end of list
|
1998-11-11 22:06:16 +00:00
|
|
|
if (nsnull != doc) {
|
2000-05-19 04:48:43 +00:00
|
|
|
aKid->SetDocument(doc, PR_FALSE, PR_TRUE);
|
1998-11-11 22:06:16 +00:00
|
|
|
if (aNotify) {
|
|
|
|
doc->ContentAppended(mContent, mChildren.Count() - 1);
|
|
|
|
}
|
2000-11-27 07:55:20 +00:00
|
|
|
|
|
|
|
if (HasMutationListeners(mContent, NS_EVENT_BITS_MUTATION_NODEINSERTED)) {
|
|
|
|
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(aKid));
|
|
|
|
nsMutationEvent mutation;
|
|
|
|
mutation.eventStructType = NS_MUTATION_EVENT;
|
|
|
|
mutation.message = NS_MUTATION_NODEINSERTED;
|
|
|
|
mutation.mTarget = node;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> relNode(do_QueryInterface(mContent));
|
|
|
|
mutation.mRelatedNode = relNode;
|
|
|
|
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
|
|
nsCOMPtr<nsIDOMEvent> domEvent;
|
|
|
|
aKid->HandleDOMEvent(nsnull, &mutation, getter_AddRefs(domEvent), NS_EVENT_FLAG_INIT, &status);
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
2000-01-28 23:43:12 +00:00
|
|
|
if (aNotify && (nsnull != doc)) {
|
|
|
|
doc->EndUpdate();
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
|
|
|
{
|
|
|
|
nsIContent* oldKid = (nsIContent *)mChildren.ElementAt(aIndex);
|
|
|
|
if (nsnull != oldKid ) {
|
|
|
|
nsIDocument* doc = mDocument;
|
2000-01-28 23:43:12 +00:00
|
|
|
if (aNotify && (nsnull != doc)) {
|
|
|
|
doc->BeginUpdate();
|
|
|
|
}
|
2000-11-27 07:55:20 +00:00
|
|
|
|
|
|
|
if (HasMutationListeners(mContent, NS_EVENT_BITS_MUTATION_NODEREMOVED)) {
|
|
|
|
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(oldKid));
|
|
|
|
nsMutationEvent mutation;
|
|
|
|
mutation.eventStructType = NS_MUTATION_EVENT;
|
|
|
|
mutation.message = NS_MUTATION_NODEREMOVED;
|
|
|
|
mutation.mTarget = node;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> relNode(do_QueryInterface(mContent));
|
|
|
|
mutation.mRelatedNode = relNode;
|
|
|
|
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
|
|
nsCOMPtr<nsIDOMEvent> domEvent;
|
|
|
|
oldKid->HandleDOMEvent(nsnull, &mutation, getter_AddRefs(domEvent), NS_EVENT_FLAG_INIT, &status);
|
|
|
|
}
|
|
|
|
|
1998-12-30 08:28:16 +00:00
|
|
|
nsRange::OwnerChildRemoved(mContent, aIndex, oldKid);
|
1999-06-16 21:38:51 +00:00
|
|
|
mChildren.RemoveElementAt(aIndex);
|
1998-11-11 22:06:16 +00:00
|
|
|
if (aNotify) {
|
|
|
|
if (nsnull != doc) {
|
|
|
|
doc->ContentRemoved(mContent, oldKid, aIndex);
|
|
|
|
}
|
|
|
|
}
|
2000-05-19 04:48:43 +00:00
|
|
|
oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE);
|
1998-11-11 22:06:16 +00:00
|
|
|
oldKid->SetParent(nsnull);
|
|
|
|
NS_RELEASE(oldKid);
|
2000-01-28 23:43:12 +00:00
|
|
|
if (aNotify && (nsnull != doc)) {
|
|
|
|
doc->EndUpdate();
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-10-05 23:47:46 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericContainerElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
|
|
|
size_t aInstanceSize) const
|
|
|
|
{
|
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
PRUint32 sum = 0;
|
|
|
|
#ifdef DEBUG
|
|
|
|
sum += aInstanceSize;
|
|
|
|
if (mAttributes) {
|
|
|
|
// Add in array of attributes size
|
|
|
|
PRUint32 asize;
|
|
|
|
mAttributes->SizeOf(aSizer, &asize);
|
|
|
|
sum += asize;
|
|
|
|
|
|
|
|
// Add in each attributes size
|
|
|
|
PRInt32 i, n = mAttributes->Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
const nsGenericAttribute* attr = (const nsGenericAttribute*)
|
|
|
|
mAttributes->ElementAt(i);
|
|
|
|
if (attr) {
|
|
|
|
PRUint32 asum = 0;
|
|
|
|
attr->SizeOf(aSizer, &asum);
|
|
|
|
sum += asum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
*aResult = sum;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-12-18 20:29:29 +00:00
|
|
|
|