1998-04-13 20:24:54 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
#ifndef nsIContent_h___
|
|
|
|
#define nsIContent_h___
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "nslayout.h"
|
|
|
|
#include "nsISupports.h"
|
1998-06-08 00:57:15 +00:00
|
|
|
#include "nsGUIEvent.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
class nsIAtom;
|
|
|
|
class nsIContentDelegate;
|
|
|
|
class nsIDocument;
|
|
|
|
class nsIPresContext;
|
1998-06-05 21:06:24 +00:00
|
|
|
class nsISizeOfHandler;
|
1998-04-13 20:24:54 +00:00
|
|
|
class nsString;
|
|
|
|
class nsString;
|
|
|
|
class nsVoidArray;
|
1998-07-14 22:34:27 +00:00
|
|
|
class nsXIFConverter;
|
1998-06-23 21:53:02 +00:00
|
|
|
class nsIDOMEvent;
|
1998-07-14 22:34:27 +00:00
|
|
|
class nsIContent;
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
// IID for the nsIContent interface
|
|
|
|
#define NS_ICONTENT_IID \
|
|
|
|
{ 0x78030220, 0x9447, 0x11d1, \
|
|
|
|
{0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Content attribute states
|
|
|
|
*/
|
|
|
|
enum nsContentAttr {
|
|
|
|
// Attribute does not exist on the piece of content
|
|
|
|
eContentAttr_NotThere,
|
|
|
|
|
|
|
|
// Attribute exists, but has no value, e.g. "BORDER" in <TABLE BORDER>
|
|
|
|
eContentAttr_NoValue,
|
|
|
|
|
|
|
|
// Attribute exists and has a value. However, value may be the
|
|
|
|
// empty string. e.g. <TABLE BORDER="1"> or <TABLE BORDER="">
|
1998-05-18 22:47:24 +00:00
|
|
|
eContentAttr_HasValue
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// A node of content in a documents content model. This interface
|
|
|
|
// is supported by all content objects.
|
|
|
|
class nsIContent : public nsISupports
|
|
|
|
{
|
|
|
|
public:
|
1998-06-03 15:39:32 +00:00
|
|
|
NS_IMETHOD GetDocument(nsIDocument*& aResult) const = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual void SetDocument(nsIDocument* aDocument) = 0;
|
|
|
|
|
|
|
|
virtual nsIContent* GetParent() const = 0;
|
|
|
|
virtual void SetParent(nsIContent* aParent) = 0;
|
|
|
|
|
|
|
|
virtual PRBool CanContainChildren() const = 0;
|
|
|
|
virtual PRInt32 ChildCount() const = 0;
|
|
|
|
virtual nsIContent* ChildAt(PRInt32 aIndex) const = 0;
|
|
|
|
virtual PRInt32 IndexOf(nsIContent* aPossibleChild) const = 0;
|
1998-06-03 15:39:32 +00:00
|
|
|
|
|
|
|
NS_IMETHOD InsertChildAt(nsIContent* aKid,
|
|
|
|
PRInt32 aIndex,
|
|
|
|
PRBool aNotify) = 0;
|
|
|
|
|
|
|
|
NS_IMETHOD ReplaceChildAt(nsIContent* aKid,
|
|
|
|
PRInt32 aIndex,
|
|
|
|
PRBool aNotify) = 0;
|
|
|
|
|
|
|
|
NS_IMETHOD AppendChild(nsIContent* aKid,
|
|
|
|
PRBool aNotify) = 0;
|
|
|
|
|
|
|
|
NS_IMETHOD RemoveChildAt(PRInt32 aIndex,
|
|
|
|
PRBool aNotify) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-05-29 02:09:38 +00:00
|
|
|
/**
|
|
|
|
* Test and see if this piece of content is synthetic. Synthetic content
|
|
|
|
* is content generated stylistically and should normally be ignored
|
|
|
|
* during content saving.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD IsSynthetic(PRBool& aResult) = 0;
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual nsIAtom* GetTag() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set attribute values. All attribute values are assumed to have a
|
|
|
|
* canonical String representation that can be used for these
|
|
|
|
* methods. The setAttribute method is assumed to perform a translation
|
|
|
|
* of the canonical form into the underlying content specific
|
|
|
|
* form.
|
|
|
|
*
|
|
|
|
* aValue may legitimately be the empty string.
|
|
|
|
*/
|
|
|
|
virtual void SetAttribute(const nsString& aName, const nsString& aValue) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the current value of the attribute. This returns a form that is
|
|
|
|
* suitable for passing back into setAttribute.
|
|
|
|
*
|
|
|
|
* <UL>
|
|
|
|
*
|
|
|
|
* <LI>If the attribute is not set and has no default value, return
|
|
|
|
* eContentAttr_NotThere.
|
|
|
|
*
|
|
|
|
* <LI>If the attribute exists, but has no value, return
|
|
|
|
* eContentAttr_NoValue.
|
|
|
|
*
|
|
|
|
* <LI>If the attribute has a value, empty or otherwise, set ret to
|
|
|
|
* be the value, and return eContentAttr_HasValue.
|
|
|
|
*
|
|
|
|
* </UL> */
|
|
|
|
virtual nsContentAttr GetAttribute(const nsString& aName,
|
|
|
|
nsString& aResult) const = 0;
|
|
|
|
|
|
|
|
virtual nsIContentDelegate* GetDelegate(nsIPresContext* aCX) = 0;
|
|
|
|
|
|
|
|
virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0;
|
|
|
|
|
1998-07-14 22:34:27 +00:00
|
|
|
/**
|
|
|
|
* Translate the content object into the (XIF) XML Interchange Format
|
|
|
|
* XIF is an intermediate form of the content model, the buffer
|
|
|
|
* will then be parsed into any number of formats including HTML, TXT, etc.
|
|
|
|
|
|
|
|
* Pattern for Containers
|
|
|
|
* BeginConvertToXIF -- opens a container
|
|
|
|
* DoConvertToXIF -- writes out element attribute information (if any exists)
|
|
|
|
* FinishConvertToXIF -- closes a container
|
|
|
|
|
|
|
|
* Pattern for Leafs
|
|
|
|
* BeginConvertToXIF -- does nothing
|
|
|
|
* DoConvertToXIF -- writes out the element and any attribute information (if any exists)
|
|
|
|
* FinishConvertToXIF -- does nothing
|
|
|
|
|
|
|
|
*/
|
|
|
|
virtual void BeginConvertToXIF(nsXIFConverter& aConverter) const = 0;
|
|
|
|
virtual void DoConvertToXIF(nsXIFConverter& aConverter) const = 0;
|
|
|
|
virtual void FinishConvertToXIF(nsXIFConverter& aConverter) const = 0;
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
/**
|
1998-06-05 21:06:24 +00:00
|
|
|
* Add this object's size information to the sizeof handler and
|
|
|
|
* any objects that it can reach.
|
1998-04-13 20:24:54 +00:00
|
|
|
*/
|
1998-06-05 21:06:24 +00:00
|
|
|
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const = 0;
|
1998-06-08 00:57:15 +00:00
|
|
|
|
|
|
|
NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext,
|
|
|
|
nsGUIEvent* aEvent,
|
1998-06-23 21:53:02 +00:00
|
|
|
nsIDOMEvent* aDOMEvent,
|
1998-06-08 00:57:15 +00:00
|
|
|
nsEventStatus& aEventStatus) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsIContent_h___ */
|