Compare commits
2 Commits
Bugzilla_P
...
TABLE_REWO
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1afe654efd | ||
|
|
99eff8e223 |
46
mozilla/content/base/public/nsIAnonymousContent.h
Normal file
46
mozilla/content/base/public/nsIAnonymousContent.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
|
||||
#ifndef nsIAnonymousContent_h___
|
||||
#define nsIAnonymousContent_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsISupportsArray;
|
||||
class nsIAtom;
|
||||
|
||||
#define NS_IANONYMOUS_CONTENT_IID { 0x41a69e00, 0x2d6d, 0x12d3, { 0xb0, 0x33, 0xa1, 0x38, 0x71, 0x39, 0x78, 0x7c } }
|
||||
|
||||
|
||||
/**
|
||||
* If a node is anonymous. Then it should implement this interface.
|
||||
*/
|
||||
class nsIAnonymousContent : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IANONYMOUS_CONTENT_IID; return iid; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
276
mozilla/content/base/public/nsIContent.h
Normal file
276
mozilla/content/base/public/nsIContent.h
Normal file
@@ -0,0 +1,276 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsIContent_h___
|
||||
#define nsIContent_h___
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nslayout.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
// Forward declarations
|
||||
class nsIAtom;
|
||||
class nsIDocument;
|
||||
class nsIPresContext;
|
||||
class nsString;
|
||||
class nsString;
|
||||
class nsVoidArray;
|
||||
class nsXIFConverter;
|
||||
class nsIDOMEvent;
|
||||
class nsIContent;
|
||||
class nsISupportsArray;
|
||||
class nsIDOMRange;
|
||||
class nsISizeOfHandler;
|
||||
|
||||
// IID for the nsIContent interface
|
||||
#define NS_ICONTENT_IID \
|
||||
{ 0x78030220, 0x9447, 0x11d1, \
|
||||
{0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
|
||||
// A node of content in a documents content model. This interface
|
||||
// is supported by all content objects.
|
||||
class nsIContent : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ICONTENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) = 0;
|
||||
|
||||
NS_IMETHOD GetParent(nsIContent*& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD SetParent(nsIContent* aParent) = 0;
|
||||
|
||||
/**
|
||||
* Get the namespace that this tag is defined in
|
||||
*/
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const = 0;
|
||||
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) = 0;
|
||||
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) = 0;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Parses an attribute string into an atom that represents the
|
||||
* attribute name and an identifier that represents the namespace
|
||||
* of the attribute. The namespace identifier may be computed
|
||||
* from a namespace prefix that must be interpreted in the context
|
||||
* of the content itself.
|
||||
*
|
||||
* @param aStr the unparsed attribute string
|
||||
* @param aName out parameter representing the name of the attribute
|
||||
* @param aNameSpaceID out parameter reprsenting the namespace
|
||||
* of the attribute
|
||||
*/
|
||||
NS_IMETHOD ParseAttributeString(const nsString& aStr,
|
||||
nsIAtom*& aName,
|
||||
PRInt32& aNameSpaceID) = 0;
|
||||
|
||||
/**
|
||||
* Returns the prefix for the specified name space identifier in
|
||||
* the context of the content element itself.
|
||||
*
|
||||
* @param aNameSpaceID identifier of the namespace
|
||||
* @param aPrefix out parameter representing the prefix for the namespace
|
||||
*/
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) = 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.
|
||||
*
|
||||
* @param aName the name of the attribute
|
||||
|
||||
* @param aValue may legitimately be the empty string.
|
||||
*
|
||||
* @param aUpdateMask specifies how whether or not the document should be
|
||||
* notified of the attribute change.
|
||||
*/
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsString& aValue,
|
||||
PRBool aNotify) = 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
|
||||
* NS_CONTENT_ATTR_NOT_THERE.
|
||||
*
|
||||
* <LI>If the attribute exists, but has no value, return
|
||||
* NS_CONTENT_ATTR_NO_VALUE.
|
||||
*
|
||||
* <LI>If the attribute has a value, empty or otherwise, set ret to
|
||||
* be the value, and return NS_CONTENT_ATTR_HAS_VALUE (== NS_OK).
|
||||
*
|
||||
* </UL>
|
||||
*/
|
||||
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsString& aResult) const = 0;
|
||||
|
||||
/**
|
||||
* Remove an attribute so that it is no longer explicitly specified.
|
||||
*
|
||||
* @param aAttribute the name of the attribute to unset
|
||||
*
|
||||
* @param aNotify specifies whether or not the document should be
|
||||
* notified of the attribute change
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Get the namespace & name of a given attribute.
|
||||
*
|
||||
* @param aIndex the index of the attribute name
|
||||
* @param aNameSpace an out param of the name space ID of the attribute name
|
||||
* @param aName an out param if the attribute name
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex,
|
||||
PRInt32& aNameSpaceID,
|
||||
nsIAtom*& aName) const = 0;
|
||||
|
||||
/**
|
||||
* Get the number of all specified attributes.
|
||||
*
|
||||
* @param aCountResult an out parameter to be filled in with
|
||||
* the number of attributes
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aCountResult) const = 0;
|
||||
|
||||
/**
|
||||
* Get the size of the content object. The size value should include
|
||||
* all subordinate data referenced by the content that is not
|
||||
* accounted for by child content. However, this value should not
|
||||
* include the frame objects, style contexts, views or other data
|
||||
* that lies logically outside the content model.
|
||||
*
|
||||
* If the implementation so chooses, instead of returning the total
|
||||
* subordinate data it may instead use the sizeof handler to store
|
||||
* away subordinate data under its own key so that the subordinate
|
||||
* data may be tabulated independently of the frame itself.
|
||||
*
|
||||
* The caller is responsible for recursing over all children that
|
||||
* the content contains.
|
||||
*/
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const = 0;
|
||||
|
||||
/**
|
||||
* List the content (and anything it contains) out to the given
|
||||
* file stream. Use aIndent as the base indent during formatting.
|
||||
* Returns NS_OK unless a file error occurs.
|
||||
*/
|
||||
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
||||
* BeginConvertToXIF -- opens a container and writes out the attributes
|
||||
* ConvertContentToXIF -- typically does nothing unless there is text content
|
||||
* FinishConvertToXIF -- closes a container
|
||||
*/
|
||||
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const = 0;
|
||||
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const = 0;
|
||||
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const = 0;
|
||||
|
||||
/**
|
||||
* Inform content of range ownership changes. This allows content
|
||||
* to do the right thing to ranges in the face of changes to the content
|
||||
* model.
|
||||
|
||||
* RangeAdd -- informs content that it owns one or both range endpoints
|
||||
* RangeRemove -- informs content that it no longer owns a range endpoint
|
||||
* GetRangeList -- returns the list of ranges that have one or both endpoints
|
||||
* within this content item
|
||||
*/
|
||||
NS_IMETHOD RangeAdd(nsIDOMRange& aRange) = 0;
|
||||
NS_IMETHOD RangeRemove(nsIDOMRange& aRange) = 0;
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const = 0;
|
||||
|
||||
/**
|
||||
* Handle a DOM event for this piece of content.
|
||||
*/
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus) = 0;
|
||||
|
||||
/**
|
||||
* Get and set a unique ID for this piece of content.
|
||||
* This ID is used as a key to store state information
|
||||
* about this content object and its associated frame object.
|
||||
* The state information is stored in a dictionary that is
|
||||
* manipulated by the frame manager (nsIFrameManager) inside layout.
|
||||
* An opaque pointer to this dictionary is passed to the session
|
||||
* history as a handle associated with the current document's state
|
||||
*/
|
||||
NS_IMETHOD GetContentID(PRUint32* aID) = 0;
|
||||
NS_IMETHOD SetContentID(PRUint32 aID) = 0;
|
||||
|
||||
};
|
||||
|
||||
// nsresult codes for GetAttribute
|
||||
#define NS_CONTENT_ATTR_HAS_VALUE NS_OK
|
||||
|
||||
#define NS_CONTENT_ATTR_NO_VALUE \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT,0)
|
||||
|
||||
#define NS_CONTENT_ATTR_NOT_THERE \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT,1)
|
||||
|
||||
#endif /* nsIContent_h___ */
|
||||
91
mozilla/content/base/public/nsIContentIterator.h
Normal file
91
mozilla/content/base/public/nsIContentIterator.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* 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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef __nsIContentIterator_h___
|
||||
#define __nsIContentIterator_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIDOMRange;
|
||||
|
||||
#define NS_ICONTENTITERTOR_IID \
|
||||
{0xa6cf90e4, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
|
||||
class nsIContentIterator : public nsISupports {
|
||||
public:
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ICONTENTITERTOR_IID; return iid; }
|
||||
|
||||
/* Initializes an iterator for the subtree rooted by the node aRoot
|
||||
*/
|
||||
NS_IMETHOD Init(nsIContent* aRoot)=0;
|
||||
|
||||
/* Initializes an iterator for the subtree defined by the range aRange
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDOMRange* aRange)=0;
|
||||
|
||||
/** First will reset the list. will return NS_FAILED if no items
|
||||
*/
|
||||
NS_IMETHOD First()=0;
|
||||
|
||||
/** Last will reset the list to the end. will return NS_FAILED if no items
|
||||
*/
|
||||
NS_IMETHOD Last()=0;
|
||||
|
||||
/** Next will advance the list. will return failed if allready at end
|
||||
*/
|
||||
NS_IMETHOD Next()=0;
|
||||
|
||||
/** Prev will decrement the list. will return failed if allready at beginning
|
||||
*/
|
||||
NS_IMETHOD Prev()=0;
|
||||
|
||||
/** CurrentItem will return the CurrentItem item it will fail if the list is empty
|
||||
* @param aItem return value
|
||||
*/
|
||||
NS_IMETHOD CurrentNode(nsIContent **aNode)=0;
|
||||
|
||||
/** return if the collection is at the end. that is the beginning following a call to Prev
|
||||
* and it is the end of the list following a call to next
|
||||
* @param aItem return value
|
||||
*/
|
||||
NS_IMETHOD IsDone()=0;
|
||||
|
||||
/** PositionAt will position the iterator to the supplied node
|
||||
*/
|
||||
NS_IMETHOD PositionAt(nsIContent* aCurNode)=0;
|
||||
|
||||
/** MakePre will make the iterator a pre-order iterator
|
||||
*/
|
||||
NS_IMETHOD MakePre()=0;
|
||||
|
||||
/** MakePost will make the iterator a post-order iterator
|
||||
*/
|
||||
NS_IMETHOD MakePost()=0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __nsIContentIterator_h___
|
||||
|
||||
338
mozilla/content/base/public/nsIDocument.h
Normal file
338
mozilla/content/base/public/nsIDocument.h
Normal file
@@ -0,0 +1,338 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsIDocument_h___
|
||||
#define nsIDocument_h___
|
||||
|
||||
#include "nslayout.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIUnicharInputStream.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIArena;
|
||||
class nsIContent;
|
||||
class nsIDocumentContainer;
|
||||
class nsIDocumentObserver;
|
||||
class nsIPresContext;
|
||||
class nsIPresShell;
|
||||
|
||||
class nsIStreamListener;
|
||||
class nsIStreamObserver;
|
||||
class nsIStyleSet;
|
||||
class nsIStyleSheet;
|
||||
class nsIStyleRule;
|
||||
class nsIURI;
|
||||
class nsILoadGroup;
|
||||
class nsIViewManager;
|
||||
class nsString;
|
||||
class nsIScriptGlobalObject;
|
||||
class nsIDOMEvent;
|
||||
class nsIDeviceContext;
|
||||
class nsIParser;
|
||||
class nsIDOMNode;
|
||||
class nsXIFConverter;
|
||||
class nsINameSpaceManager;
|
||||
class nsIDOMDocumentFragment;
|
||||
class nsILineBreaker;
|
||||
class nsIWordBreaker;
|
||||
class nsIDOMSelection;
|
||||
class nsIChannel;
|
||||
class nsIPrincipal;
|
||||
|
||||
// IID for the nsIDocument interface
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0x94c6ceb0, 0x9447, 0x11d1, \
|
||||
{0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
|
||||
// specification for data to be sent via form "post"
|
||||
// IID for the nsIPostData interface - 152ab6e0-ff13-11d1-beb9-00805f8a66dc
|
||||
#define NS_IPOSTDATA_IID \
|
||||
{ 0x152ab6e0, 0xff13, 0x11d1, \
|
||||
{0xbe, 0xb9, 0x00, 0x80, 0x5f, 0x8a, 0x66, 0xdc} }
|
||||
|
||||
#if 0
|
||||
class nsIPostData : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IPOSTDATA_IID; return iid; }
|
||||
|
||||
virtual PRBool IsFile() = 0; // is the data a file (or raw data)
|
||||
virtual const char* GetData() = 0; // get the file name or raw data
|
||||
virtual PRInt32 GetDataLength() = 0;
|
||||
};
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Document interface
|
||||
class nsIDocument : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOCUMENT_IID; return iid; }
|
||||
|
||||
// All documents have a memory arena associated with them which is
|
||||
// used for memory allocation during document creation. This call
|
||||
// returns the arena associated with this document.
|
||||
virtual nsIArena* GetArena() = 0;
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener) = 0;
|
||||
|
||||
/**
|
||||
* Return the title of the document. May return null.
|
||||
*/
|
||||
virtual const nsString* GetDocumentTitle() const = 0;
|
||||
|
||||
/**
|
||||
* Return the URL for the document. May return null.
|
||||
*/
|
||||
virtual nsIURI* GetDocumentURL() const = 0;
|
||||
|
||||
/**
|
||||
* Return the principal responsible for this document.
|
||||
*/
|
||||
virtual nsIPrincipal* GetDocumentPrincipal() = 0;
|
||||
|
||||
/**
|
||||
* Return the LoadGroup for the document. May return null.
|
||||
*/
|
||||
NS_IMETHOD GetDocumentLoadGroup(nsILoadGroup** aGroup) const = 0;
|
||||
|
||||
/**
|
||||
* Return the base URL for realtive URLs in the document. May return null (or the document URL).
|
||||
*/
|
||||
NS_IMETHOD GetBaseURL(nsIURI*& aURL) const = 0;
|
||||
|
||||
/**
|
||||
* Return the content (mime) type of this document.
|
||||
*/
|
||||
NS_IMETHOD GetContentType(nsString& aContentType) const = 0;
|
||||
|
||||
/**
|
||||
* Return a standard name for the document's character set. This will
|
||||
* trigger a startDocumentLoad if necessary to answer the question.
|
||||
*/
|
||||
NS_IMETHOD GetDocumentCharacterSet(nsString& oCharSetID) = 0;
|
||||
NS_IMETHOD SetDocumentCharacterSet(const nsString& aCharSetID) = 0;
|
||||
|
||||
/**
|
||||
* Return the Line Breaker for the document
|
||||
*/
|
||||
NS_IMETHOD GetLineBreaker(nsILineBreaker** aResult) = 0;
|
||||
NS_IMETHOD SetLineBreaker(nsILineBreaker* aLineBreaker) = 0;
|
||||
NS_IMETHOD GetWordBreaker(nsIWordBreaker** aResult) = 0;
|
||||
NS_IMETHOD SetWordBreaker(nsIWordBreaker* aWordBreaker) = 0;
|
||||
|
||||
/**
|
||||
* Access HTTP header data (this may also get set from other sources, like
|
||||
* HTML META tags).
|
||||
*/
|
||||
NS_IMETHOD GetHeaderData(nsIAtom* aHeaderField, nsString& aData) const = 0;
|
||||
NS_IMETHOD SetHeaderData(nsIAtom* aheaderField, const nsString& aData) = 0;
|
||||
|
||||
/**
|
||||
* Create a new presentation shell that will use aContext for
|
||||
* it's presentation context (presentation context's <b>must not</b> be
|
||||
* shared among multiple presentation shell's).
|
||||
*/
|
||||
NS_IMETHOD CreateShell(nsIPresContext* aContext,
|
||||
nsIViewManager* aViewManager,
|
||||
nsIStyleSet* aStyleSet,
|
||||
nsIPresShell** aInstancePtrResult) = 0;
|
||||
virtual PRBool DeleteShell(nsIPresShell* aShell) = 0;
|
||||
virtual PRInt32 GetNumberOfShells() = 0;
|
||||
virtual nsIPresShell* GetShellAt(PRInt32 aIndex) = 0;
|
||||
|
||||
/**
|
||||
* Return the parent document of this document. Will return null
|
||||
* unless this document is within a compound document and has a parent.
|
||||
*/
|
||||
virtual nsIDocument* GetParentDocument() = 0;
|
||||
virtual void SetParentDocument(nsIDocument* aParent) = 0;
|
||||
virtual void AddSubDocument(nsIDocument* aSubDoc) = 0;
|
||||
virtual PRInt32 GetNumberOfSubDocuments() = 0;
|
||||
virtual nsIDocument* GetSubDocumentAt(PRInt32 aIndex) = 0;
|
||||
|
||||
/**
|
||||
* Return the root content object for this document.
|
||||
*/
|
||||
virtual nsIContent* GetRootContent() = 0;
|
||||
virtual void SetRootContent(nsIContent* aRoot) = 0;
|
||||
|
||||
/**
|
||||
* Methods to append to the prolog and epilog of
|
||||
* a document. The prolog is the content before the document
|
||||
* element, the epilog after.
|
||||
*/
|
||||
NS_IMETHOD AppendToProlog(nsIContent* aContent) = 0;
|
||||
NS_IMETHOD AppendToEpilog(nsIContent* aContent) = 0;
|
||||
|
||||
/**
|
||||
* Get the direct children of the document - content in
|
||||
* the prolog, the root content and content in the epilog.
|
||||
*/
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const = 0;
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const = 0;
|
||||
NS_IMETHOD GetChildCount(PRInt32& aCount) = 0;
|
||||
|
||||
/**
|
||||
* Get the style sheets owned by this document.
|
||||
* Style sheets are ordered, most significant last.
|
||||
*/
|
||||
virtual PRInt32 GetNumberOfStyleSheets() = 0;
|
||||
virtual nsIStyleSheet* GetStyleSheetAt(PRInt32 aIndex) = 0;
|
||||
virtual PRInt32 GetIndexOfStyleSheet(nsIStyleSheet* aSheet) = 0;
|
||||
virtual void AddStyleSheet(nsIStyleSheet* aSheet) = 0;
|
||||
virtual void RemoveStyleSheet(nsIStyleSheet* aSheet) = 0;
|
||||
NS_IMETHOD InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex, PRBool aNotify) = 0;
|
||||
virtual void SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
|
||||
PRBool mDisabled) = 0;
|
||||
|
||||
/**
|
||||
* Set the object from which a document can get a script context.
|
||||
* This is the context within which all scripts (during document
|
||||
* creation and during event handling) will run.
|
||||
*/
|
||||
NS_IMETHOD GetScriptGlobalObject(nsIScriptGlobalObject** aGlobalObject) = 0;
|
||||
NS_IMETHOD SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) = 0;
|
||||
|
||||
/**
|
||||
* Get the name space manager for this document
|
||||
*/
|
||||
NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager) = 0;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Document notification API's
|
||||
|
||||
/**
|
||||
* Add a new observer of document change notifications. Whenever
|
||||
* content is changed, appended, inserted or removed the observers are
|
||||
* informed.
|
||||
*/
|
||||
virtual void AddObserver(nsIDocumentObserver* aObserver) = 0;
|
||||
|
||||
/**
|
||||
* Remove an observer of document change notifications. This will
|
||||
* return false if the observer cannot be found.
|
||||
*/
|
||||
virtual PRBool RemoveObserver(nsIDocumentObserver* aObserver) = 0;
|
||||
|
||||
// Observation hooks used by content nodes to propagate
|
||||
// notifications to document observers.
|
||||
NS_IMETHOD BeginLoad() = 0;
|
||||
NS_IMETHOD EndLoad() = 0;
|
||||
NS_IMETHOD ContentChanged(nsIContent* aContent,
|
||||
nsISupports* aSubContent) = 0;
|
||||
// notify that one or two content nodes changed state
|
||||
// either may be nsnull, but not both
|
||||
NS_IMETHOD ContentStatesChanged(nsIContent* aContent1,
|
||||
nsIContent* aContent2) = 0;
|
||||
NS_IMETHOD AttributeChanged(nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint) = 0; // See nsStyleConsts fot hint values
|
||||
NS_IMETHOD ContentAppended(nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer) = 0;
|
||||
NS_IMETHOD ContentInserted(nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer) = 0;
|
||||
NS_IMETHOD ContentReplaced(nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
nsIContent* aNewChild,
|
||||
PRInt32 aIndexInContainer) = 0;
|
||||
NS_IMETHOD ContentRemoved(nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer) = 0;
|
||||
|
||||
// Observation hooks for style data to propogate notifications
|
||||
// to document observers
|
||||
NS_IMETHOD StyleRuleChanged(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule,
|
||||
PRInt32 aHint) = 0; // See nsStyleConsts fot hint values
|
||||
NS_IMETHOD StyleRuleAdded(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) = 0;
|
||||
NS_IMETHOD StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) = 0;
|
||||
|
||||
/**
|
||||
* Finds text in content
|
||||
*/
|
||||
NS_IMETHOD FindNext(const nsString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound) = 0;
|
||||
|
||||
/**
|
||||
* Converts the document or a selection of the
|
||||
* document to XIF (XML Interchange Format)
|
||||
* and places the result in aBuffer.
|
||||
|
||||
* NOTE: we may way to place the result in a stream,
|
||||
* but we will use a string for now -- gpk
|
||||
*/
|
||||
NS_IMETHOD CreateXIF(nsString & aBuffer, nsIDOMSelection* aSelection = nsnull) = 0;
|
||||
NS_IMETHOD ToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode) = 0;
|
||||
virtual void BeginConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode) = 0;
|
||||
virtual void ConvertChildrenToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode) = 0;
|
||||
virtual void FinishConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode) = 0;
|
||||
|
||||
/* Helper methods to help determine the logical positioning of content */
|
||||
virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const = 0;
|
||||
virtual nsIContent* GetPrevContent(const nsIContent *aContent) const = 0;
|
||||
virtual nsIContent* GetNextContent(const nsIContent *aContent) const = 0;
|
||||
virtual void SetDisplaySelection(PRBool aToggle) = 0;
|
||||
virtual PRBool GetDisplaySelection() const = 0;
|
||||
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
// XXX These belong somewhere else
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewImageDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
|
||||
nsIDocument* aOwnerDocument);
|
||||
|
||||
// Note: The buffer passed into NewPostData(...) becomes owned by the IPostData
|
||||
// instance and is freed when the instance is destroyed...
|
||||
//
|
||||
#if 0
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewPostData(PRBool aIsFile, char *aData, nsIPostData** aInstancePtrResult);
|
||||
#endif
|
||||
|
||||
#endif /* nsIDocument_h___ */
|
||||
75
mozilla/content/base/public/nsIDocumentContainer.h
Normal file
75
mozilla/content/base/public/nsIDocumentContainer.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsIDocumentContainer_h___
|
||||
#define nsIDocumentContainer_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsIScriptable;
|
||||
class nsIScriptEnvironment;
|
||||
class nsIURI;
|
||||
|
||||
#define NS_IDOCUMENT_CONTAINER_IID \
|
||||
{ 0x8efd4470, 0x944d, 0x11d1, \
|
||||
{0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
|
||||
class nIDocumentContainer : public nsISupports {
|
||||
public:
|
||||
/**
|
||||
* Display the specified URL with the given connection.
|
||||
*
|
||||
* @param url the URL to display
|
||||
* @param connection the connection to use.
|
||||
*/
|
||||
virtual void Display(nsIURI* aURL) = 0;
|
||||
|
||||
/**
|
||||
* Returns a script environment for the specified language and version.
|
||||
* The expectation is that the script environment already has been
|
||||
* set up with a container object. If a script environment has already
|
||||
* been requested for the given language, the same instance should
|
||||
* be returned.
|
||||
*
|
||||
* @param language the scripting language for the environment. If this
|
||||
* is null, returns the default scripting environment.
|
||||
* @param majorVersion the major version number of the language
|
||||
* @param minorVersion the minor version number of the language
|
||||
* @return the script environment for the language
|
||||
* @see mg.magellan.script.IScriptEnvrionment
|
||||
*/
|
||||
virtual nsIScriptEnvironment*
|
||||
GetScriptEnvironment(nsString* aLanguage,
|
||||
PRInt32 aMajorVersion,
|
||||
PRInt32 aMinorVersion) = 0;
|
||||
|
||||
/**
|
||||
* Returns the scriptable container object for the document container.
|
||||
* The scriptable object will be used as the scoping object in the
|
||||
* definition of scriptable classes used in the Document Object Model.
|
||||
*
|
||||
* @return the scriptable container for the application
|
||||
* @see mg.magellan.script.IScriptable
|
||||
* @see mg.magellan.script.IScriptEnvrionment
|
||||
*/
|
||||
virtual nsIScriptable* GetScriptableContainer() = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIDocumentContainer_h___ */
|
||||
155
mozilla/content/base/public/nsIDocumentEncoder.h
Normal file
155
mozilla/content/base/public/nsIDocumentEncoder.h
Normal file
@@ -0,0 +1,155 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIDocumentEncoder_h__
|
||||
#define nsIDocumentEncoder_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsIDocumentEncoder;
|
||||
class nsIDocument;
|
||||
class nsIDOMSelection;
|
||||
class nsIOutputStream;
|
||||
class nsISupportsArray;
|
||||
|
||||
|
||||
#define NS_IDOCUMENT_ENCODER_IID \
|
||||
{ /* a6cf9103-15b3-11d2-932e-00805f8add32 */ \
|
||||
0xa6cf9103, \
|
||||
0x15b3, \
|
||||
0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} \
|
||||
}
|
||||
|
||||
#define NS_TEXT_ENCODER_CID \
|
||||
{ /* e7ba1480-1dea-11d3-830f-00104bed045e */ \
|
||||
0xe7ba1480, \
|
||||
0x1dea, \
|
||||
0x11d3, \
|
||||
{0x83, 0x0f, 0x00, 0x10, 0x4b, 0xed, 0x04, 0x5e} \
|
||||
}
|
||||
|
||||
#define NS_DOC_ENCODER_PROGID_BASE "component://netscape/layout/documentEncoder?type="
|
||||
|
||||
class nsIDocumentEncoder : public nsISupports
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Output methods flag bits.
|
||||
*
|
||||
* There are a frightening number of these,
|
||||
* because everyone wants something a little bit different!
|
||||
*
|
||||
* These should move to an idl file so that Javascript can
|
||||
* have access to the symbols, not just the constants.
|
||||
*/
|
||||
enum {
|
||||
// Output only the selection.
|
||||
OutputSelectionOnly = 1,
|
||||
|
||||
// Convert html to plaintext that looks like the html.
|
||||
// Implies wrap (except inside <pre>), since html wraps.
|
||||
OutputFormatted = 2,
|
||||
|
||||
// Don't output the html doctype and gecko output system comment headers
|
||||
OutputNoDoctype = 4,
|
||||
|
||||
// No html head tags
|
||||
OutputBodyOnly = 8,
|
||||
|
||||
// Wrap even if we're not doing formatted output (e.g. for text fields)
|
||||
OutputPreformatted = 16,
|
||||
|
||||
// Output as though the content is preformatted
|
||||
// (e.g. maybe it's wrapped in a MOZ_PRE or MOZ_PRE_WRAP style tag)
|
||||
OutputWrap = 32,
|
||||
|
||||
// Output for format flowed (RFC 2646). This is used when converting
|
||||
// to text for mail sending. This differs just slightly
|
||||
// but in an important way from normal formatted, and that is that
|
||||
// lines are space stuffed. This can't (correctly) be done later.
|
||||
OutputFormatFlowed = 64
|
||||
};
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOCUMENT_ENCODER_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Initialize with a pointer to the document and the mime type.
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDocument* aDocument, const nsString& aMimeType, PRUint32 flags) = 0;
|
||||
|
||||
/**
|
||||
* If the selection is set to a non-null value, then the
|
||||
* selection is used for encoding, otherwise the entire
|
||||
* document is encoded.
|
||||
*/
|
||||
NS_IMETHOD SetSelection(nsIDOMSelection* aSelection) = 0;
|
||||
|
||||
/**
|
||||
* Documents typically have an intrinsic character set.
|
||||
* If no intrinsic value is found, the platform character set
|
||||
* is used.
|
||||
* aCharset overrides the both the intrinsic or platform
|
||||
* character set when encoding the document.
|
||||
*
|
||||
* Possible result codes: NS_ERROR_NO_CHARSET_CONVERTER
|
||||
*/
|
||||
NS_IMETHOD SetCharset(const nsString& aCharset) = 0;
|
||||
|
||||
/**
|
||||
* Set a wrap column. This may have no effect in some types of encoders.
|
||||
*/
|
||||
NS_IMETHOD SetWrapColumn(PRUint32 aWC) = 0;
|
||||
|
||||
/**
|
||||
* The document is encoded, the result is sent to the
|
||||
* to nsIOutputStream.
|
||||
*
|
||||
* Possible result codes are passing along whatever stream errors
|
||||
* might have been encountered.
|
||||
*/
|
||||
NS_IMETHOD EncodeToStream(nsIOutputStream* aStream) = 0;
|
||||
NS_IMETHOD EncodeToString(nsString& aOutputString) = 0;
|
||||
};
|
||||
|
||||
// XXXXXXXXXXXXXXXX nsITextEncoder is going away! XXXXXXXXXXXXXXXXXXXXXX
|
||||
#ifdef USE_OBSOLETE_TEXT_ENCODER
|
||||
// Example of a output service for a particular encoder.
|
||||
// The text encoder handles XIF, HTML, and plaintext.
|
||||
class nsITextEncoder : public nsIDocumentEncoder
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_TEXT_ENCODER_CID; return iid; }
|
||||
|
||||
// Get embedded objects -- images, links, etc.
|
||||
// NOTE: we may want to use an enumerator
|
||||
NS_IMETHOD PrettyPrint(PRBool aYes) = 0;
|
||||
NS_IMETHOD SetWrapColumn(PRUint32 aWC) = 0;
|
||||
NS_IMETHOD AddHeader(PRBool aYes) = 0;
|
||||
};
|
||||
#endif /* USE_OBSOLETE_TEXT_ENCODER */
|
||||
|
||||
|
||||
#endif /* nsIDocumentEncoder_h__ */
|
||||
|
||||
312
mozilla/content/base/public/nsIDocumentObserver.h
Normal file
312
mozilla/content/base/public/nsIDocumentObserver.h
Normal file
@@ -0,0 +1,312 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsIDocumentObserver_h___
|
||||
#define nsIDocumentObserver_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
class nsIPresShell;
|
||||
class nsIStyleSheet;
|
||||
class nsIStyleRule;
|
||||
class nsString;
|
||||
class nsIDocument;
|
||||
|
||||
#define NS_IDOCUMENT_OBSERVER_IID \
|
||||
{ 0xb3f92460, 0x944c, 0x11d1, {0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
// Document observer interface
|
||||
class nsIDocumentObserver : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOCUMENT_OBSERVER_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Notify that a content model update is beginning. This call can be
|
||||
* nested.
|
||||
*/
|
||||
NS_IMETHOD BeginUpdate(nsIDocument *aDocument) = 0;
|
||||
|
||||
/**
|
||||
* Notify that a content model update is finished. This call can be
|
||||
* nested.
|
||||
*/
|
||||
NS_IMETHOD EndUpdate(nsIDocument *aDocument) = 0;
|
||||
|
||||
/**
|
||||
* Notify the observer that a document load is beginning.
|
||||
*/
|
||||
NS_IMETHOD BeginLoad(nsIDocument *aDocument) = 0;
|
||||
|
||||
/**
|
||||
* Notify the observer that a document load has finished. Note that
|
||||
* the associated reflow of the document will be done <b>before</b>
|
||||
* EndLoad is invoked, not after.
|
||||
*/
|
||||
NS_IMETHOD EndLoad(nsIDocument *aDocument) = 0;
|
||||
|
||||
/**
|
||||
* Notify the observer that the document is being reflowed in
|
||||
* the given presentation shell.
|
||||
*/
|
||||
NS_IMETHOD BeginReflow(nsIDocument *aDocument, nsIPresShell* aShell) = 0;
|
||||
|
||||
/**
|
||||
* Notify the observer that the document is done being reflowed in
|
||||
* the given presentation shell.
|
||||
*/
|
||||
NS_IMETHOD EndReflow(nsIDocument *aDocument, nsIPresShell* aShell) = 0;
|
||||
|
||||
/**
|
||||
* Notification that the content model has changed. This method is
|
||||
* called automatically by content objects when their state is changed
|
||||
* (therefore there is normally no need to invoke this method
|
||||
* directly). The notification is passed to any
|
||||
* IDocumentObservers. The notification is passed on to all of the
|
||||
* document observers. <p>
|
||||
*
|
||||
* This notification is not sent when a piece of content is
|
||||
* added/removed from the document (the other notifications are used
|
||||
* for that).
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aContent the piece of content that changed
|
||||
* @param aSubContent subrange information about the piece of content
|
||||
* that changed
|
||||
*/
|
||||
NS_IMETHOD ContentChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
nsISupports* aSubContent) = 0;
|
||||
|
||||
/**
|
||||
* Notification that the state of a content node has changed.
|
||||
* (ie: gained or lost focus, became active or hovered over)
|
||||
* This method is called automatically by content objects
|
||||
* when their state is changed (therefore there is normally
|
||||
* no need to invoke this method directly). The notification
|
||||
* is passed to any IDocumentObservers. The notification is
|
||||
* passed on to all of the document observers. <p>
|
||||
*
|
||||
* This notification is not sent when a piece of content is
|
||||
* added/removed from the document or the content itself changed
|
||||
* (the other notifications are used for that).
|
||||
*
|
||||
* The optional second content node is to allow optimization
|
||||
* of the case where state moves from one node to another
|
||||
* (as is likely for :focus and :hover)
|
||||
*
|
||||
* Either content node may be nsnull, but not both
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aContent1 the piece of content that changed
|
||||
* @param aContent2 optional second piece of content that changed
|
||||
*/
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2) = 0;
|
||||
|
||||
/**
|
||||
* Notification that the content model has changed. This method is called
|
||||
* automatically by content objects when an attribute's value has changed
|
||||
* (therefore there is normally no need to invoke this method directly). The
|
||||
* notification is passed to any IDocumentObservers document observers. <p>
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aContent the piece of content whose attribute changed
|
||||
* @param aAttribute the atom name of the attribute
|
||||
*/
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint) = 0; // See nsStyleConsts fot hint values
|
||||
|
||||
/**
|
||||
* Notifcation that the content model has had data appended to the
|
||||
* given content object. This method is called automatically by the
|
||||
* content container objects when a new content object is appended to
|
||||
* the container (therefore there is normally no need to invoke this
|
||||
* method directly). The notification is passed on to all of the
|
||||
* document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aContainer the container that had a new child appended
|
||||
* @param aNewIndexInContainer the index in the container of the first
|
||||
* new child
|
||||
*/
|
||||
NS_IMETHOD ContentAppended(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer) = 0;
|
||||
|
||||
/**
|
||||
* Notification that content has been inserted. This method is called
|
||||
* automatically by the content container objects when a new content
|
||||
* object is inserted in the container (therefore there is normally no
|
||||
* need to invoke this method directly). The notification is passed on
|
||||
* to all of the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aContainer the container that now contains aChild
|
||||
* @param aChild the child that was inserted
|
||||
* @param aIndexInContainer the index of the child in the container
|
||||
*/
|
||||
NS_IMETHOD ContentInserted(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer) = 0;
|
||||
|
||||
/**
|
||||
* Notification that content has been replaced. This method is called
|
||||
* automatically by the content container objects when a content object
|
||||
* is replaced in the container (therefore there is normally no need to
|
||||
* invoke this method directly). The notification is passed on to all
|
||||
* of the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aContainer the container that now contains aChild
|
||||
* @param aOldChild the child that was replaced
|
||||
* @param aNewChild the child that replaced aOldChild
|
||||
* @param aIndexInContainer the index of the old and new child in the
|
||||
* container
|
||||
*/
|
||||
NS_IMETHOD ContentReplaced(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
nsIContent* aNewChild,
|
||||
PRInt32 aIndexInContainer) = 0;
|
||||
|
||||
/**
|
||||
* Content has just been removed. This method is called automatically
|
||||
* by content container objects when a content object has just been
|
||||
* removed from the container (therefore there is normally no need to
|
||||
* invoke this method directly). The notification is passed on to all
|
||||
* of the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aContainer the container that had a child removed
|
||||
* @param aChild the child that was just removed
|
||||
* @param aIndexInContainer the index of the child in the container
|
||||
* before it was removed
|
||||
*/
|
||||
NS_IMETHOD ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer) = 0;
|
||||
|
||||
/**
|
||||
* A StyleSheet has just been added to the document.
|
||||
* This method is called automatically when a StyleSheet gets added
|
||||
* to the document. The notification is passed on to all of the
|
||||
* document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aStyleSheet the StyleSheet that has been added
|
||||
*/
|
||||
NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* A StyleSheet has just been removed from the document.
|
||||
* This method is called automatically when a StyleSheet gets removed
|
||||
* from the document. The notification is passed on to all of the
|
||||
* document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aStyleSheet the StyleSheet that has been removed
|
||||
*/
|
||||
NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* A StyleSheet has just disabled or enabled.
|
||||
* This method is called automatically when the disabled state
|
||||
* of a StyleSheet gets changed. The style sheet passes this
|
||||
* notification to the document. The notification is passed on
|
||||
* to all of the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aStyleSheet the StyleSheet that has been added
|
||||
* @param aDisabled PR_TRUE if the sheet is disabled, PR_FALSE if
|
||||
* it is enabled
|
||||
*/
|
||||
NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDisabled) = 0;
|
||||
|
||||
/**
|
||||
* A StyleRule has just been modified within a style sheet.
|
||||
* This method is called automatically when the rule gets
|
||||
* modified. The style sheet passes this notification to
|
||||
* the document. The notification is passed on to all of
|
||||
* the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aStyleSheet the StyleSheet that contians the rule
|
||||
* @param aStyleRule the rule that was modified
|
||||
* @param aHint some possible info about the nature of the change
|
||||
*/
|
||||
NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule,
|
||||
PRInt32 aHint) = 0; // See nsStyleConsts fot hint values
|
||||
|
||||
/**
|
||||
* A StyleRule has just been added to a style sheet.
|
||||
* This method is called automatically when the rule gets
|
||||
* added to the sheet. The style sheet passes this
|
||||
* notification to the document. The notification is passed on
|
||||
* to all of the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aStyleSheet the StyleSheet that has been modified
|
||||
* @param aStyleRule the rule that was added
|
||||
*/
|
||||
NS_IMETHOD StyleRuleAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) = 0;
|
||||
|
||||
/**
|
||||
* A StyleRule has just been removed from a style sheet.
|
||||
* This method is called automatically when the rule gets
|
||||
* removed from the sheet. The style sheet passes this
|
||||
* notification to the document. The notification is passed on
|
||||
* to all of the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aStyleSheet the StyleSheet that has been modified
|
||||
* @param aStyleRule the rule that was removed
|
||||
*/
|
||||
NS_IMETHOD StyleRuleRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) = 0;
|
||||
|
||||
/**
|
||||
* The document is in the process of being destroyed.
|
||||
* This method is called automatically during document
|
||||
* destruction.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
*/
|
||||
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIDocumentObserver_h___ */
|
||||
56
mozilla/content/base/public/nsIDocumentViewer.h
Normal file
56
mozilla/content/base/public/nsIDocumentViewer.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsIDocumentViewer_h___
|
||||
#define nsIDocumentViewer_h___
|
||||
|
||||
#include "nsIContentViewer.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsIPresContext;
|
||||
class nsIPresShell;
|
||||
class nsIStyleSheet;
|
||||
|
||||
#define NS_IDOCUMENT_VIEWER_IID \
|
||||
{ 0xa6cf9057, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
/**
|
||||
* A document viewer is a kind of content viewer that uses NGLayout
|
||||
* to manage the presentation of the content.
|
||||
*/
|
||||
class nsIDocumentViewer : public nsIContentViewer
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_VIEWER_IID)
|
||||
|
||||
NS_IMETHOD SetUAStyleSheet(nsIStyleSheet* aUAStyleSheet) = 0;
|
||||
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) = 0;
|
||||
|
||||
NS_IMETHOD GetPresShell(nsIPresShell*& aResult) = 0;
|
||||
|
||||
NS_IMETHOD GetPresContext(nsIPresContext*& aResult) = 0;
|
||||
|
||||
NS_IMETHOD CreateDocumentViewerUsing(nsIPresContext* aPresContext,
|
||||
nsIDocumentViewer*& aResult) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIDocumentViewer_h___ */
|
||||
75
mozilla/content/base/public/nsINameSpace.h
Normal file
75
mozilla/content/base/public/nsINameSpace.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsINameSpace_h___
|
||||
#define nsINameSpace_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nslayout.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsString;
|
||||
class nsINameSpaceManager;
|
||||
|
||||
#define NS_INAMESPACE_IID \
|
||||
{ 0xa6cf90d4, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
|
||||
/**
|
||||
* A nsINameSpace registers the NameSpace URI with the NameSpaceManager
|
||||
* (creating or finding an ID), and manages the relationship between
|
||||
* the NameSpace ID and the (optional) Prefix.
|
||||
*
|
||||
* New NameSpaces are created as a child of an existing NameSpace. Searches
|
||||
* for NameSpaces based on prefix search up the chain of nested NameSpaces
|
||||
*
|
||||
* Each NameSpace keeps a live reference on its parent and its Manager.
|
||||
*
|
||||
*/
|
||||
class nsINameSpace : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_INAMESPACE_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager) const = 0;
|
||||
|
||||
// Get data of this name space
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32& aID) const = 0;
|
||||
NS_IMETHOD GetNameSpaceURI(nsString& aURI) const = 0;
|
||||
NS_IMETHOD GetNameSpacePrefix(nsIAtom*& aPrefix) const = 0;
|
||||
|
||||
NS_IMETHOD GetParentNameSpace(nsINameSpace*& aParent) const = 0;
|
||||
|
||||
// find name space within self and parents (not children)
|
||||
NS_IMETHOD FindNameSpace(nsIAtom* aPrefix, nsINameSpace*& aNameSpace) const = 0;
|
||||
NS_IMETHOD FindNameSpaceID(nsIAtom* aPrefix, PRInt32& aNameSpaceID) const = 0;
|
||||
NS_IMETHOD FindNameSpacePrefix(PRInt32 aNameSpaceID, nsIAtom*& aPrefix) const = 0;
|
||||
|
||||
// create new child name space
|
||||
NS_IMETHOD CreateChildNameSpace(nsIAtom* aPrefix, const nsString& aURI,
|
||||
nsINameSpace*& aChildNameSpace) = 0;
|
||||
|
||||
NS_IMETHOD CreateChildNameSpace(nsIAtom* aPrefix, PRInt32 aNameSpaceID,
|
||||
nsINameSpace*& aChildNameSpace) = 0;
|
||||
};
|
||||
|
||||
#endif // nsINameSpace_h___
|
||||
83
mozilla/content/base/public/nsINameSpaceManager.h
Normal file
83
mozilla/content/base/public/nsINameSpaceManager.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsINameSpaceManager_h___
|
||||
#define nsINameSpaceManager_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nslayout.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsString;
|
||||
class nsINameSpace;
|
||||
|
||||
#define kNameSpaceID_Unknown -1
|
||||
#define kNameSpaceID_None 0
|
||||
#define kNameSpaceID_XMLNS 1 // not really a namespace, but it needs to play the game
|
||||
#define kNameSpaceID_XML 2
|
||||
#define kNameSpaceID_HTML 3
|
||||
|
||||
// 'html' is by definition bound to the namespace name "urn:w3-org-ns:HTML" XXX ???
|
||||
// 'xml' is by definition bound to the namespace name "urn:Connolly:input:required" XXX
|
||||
|
||||
#define NS_INAMESPACEMANAGER_IID \
|
||||
{ 0xa6cf90d5, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
/**
|
||||
* The Name Space Manager tracks the associtation between a NameSpace
|
||||
* URI and the PRInt32 runtime id. Mappings between NameSpaces and
|
||||
* NameSpace prefixes are managed by nsINameSpaces
|
||||
*
|
||||
* All NameSpace URIs are stored in a global table so that IDs are
|
||||
* consistent accross the app. NameSpace IDs are only consistent at runtime
|
||||
* ie: they are not guaranteed to be consistent accross app sessions.
|
||||
*
|
||||
* The nsINameSpaceManager needs to have a live reference for as long as
|
||||
* the NameSpace IDs are needed. Generally, a document keeps a reference to
|
||||
* a nsINameSpaceManager. Also, each nsINameSpace that comes from the manager
|
||||
* keeps a reference to it.
|
||||
*
|
||||
* To create a stack of NameSpaces, call CreateRootNameSpace, and then create
|
||||
* child NameSpaces from the root.
|
||||
*
|
||||
* The "html" and "xml" namespaces come "pre-canned" from the root.
|
||||
*
|
||||
*/
|
||||
class nsINameSpaceManager : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_INAMESPACEMANAGER_IID; return iid; }
|
||||
|
||||
NS_IMETHOD CreateRootNameSpace(nsINameSpace*& aRootNameSpace) = 0;
|
||||
|
||||
NS_IMETHOD RegisterNameSpace(const nsString& aURI,
|
||||
PRInt32& aNameSpaceID) = 0;
|
||||
|
||||
NS_IMETHOD GetNameSpaceURI(PRInt32 aNameSpaceID, nsString& aURI) = 0;
|
||||
NS_IMETHOD GetNameSpaceID(const nsString& aURI, PRInt32& aNameSpaceID) = 0;
|
||||
};
|
||||
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewNameSpaceManager(nsINameSpaceManager** aInstancePtrResult);
|
||||
|
||||
|
||||
#endif // nsINameSpaceManager_h___
|
||||
104
mozilla/content/base/public/nsISelectionControler.h
Normal file
104
mozilla/content/base/public/nsISelectionControler.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/*
|
||||
* !!Note this is for a javascriptable pres shell currently for accessing selection
|
||||
* the selection refers only to that which listens to keybindings which is the "NORMAL"
|
||||
* selection this will be IDLIZED LATER
|
||||
*/
|
||||
|
||||
#ifndef nsISelectionControler_h___
|
||||
#define nsISelectionControler_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
|
||||
#define NS_ISELECTIONCONTROLER_IID_STR "D2D1D179-85A7-11d3-9932-00108301233C"
|
||||
|
||||
#define NS_ISELECTIONCONTROLER_IID \
|
||||
{ 0xd2d1d179, 0x85a7, 0x11d3, \
|
||||
{ 0x99, 0x32, 0x0, 0x10, 0x83, 0x1, 0x23, 0x3c }}
|
||||
|
||||
|
||||
class nsISelectionControler : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ISELECTIONCONTROLER_IID; return iid; }
|
||||
|
||||
/** CharacterMove will move the selection one character forward/backward in the document.
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
NS_IMETHOD CharacterMove(PRBool aForward, PRBool aExtend) = 0;
|
||||
|
||||
/** WordMove will move the selection one word forward/backward in the document.
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
NS_IMETHOD WordMove(PRBool aForward, PRBool aExtend) = 0;
|
||||
|
||||
/** LineMove will move the selection one line forward/backward in the document.
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
NS_IMETHOD LineMove(PRBool aForward, PRBool aExtend) = 0;
|
||||
|
||||
/** IntraLineMove will move the selection to the front of the line or end of the line
|
||||
* in the document.
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
NS_IMETHOD IntraLineMove(PRBool aForward, PRBool aExtend) = 0;
|
||||
|
||||
/** PageMove will move the selection one page forward/backward in the document.
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
NS_IMETHOD PageMove(PRBool aForward, PRBool aExtend) = 0;
|
||||
|
||||
/** ScrollPage will scroll the page without affecting the selection.
|
||||
* @param aForward scroll forward or backwards in selection
|
||||
*/
|
||||
NS_IMETHOD ScrollPage(PRBool aForward) = 0;
|
||||
|
||||
/** SelectAll will select the whole page
|
||||
*/
|
||||
NS_IMETHOD SelectAll() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* nsISelectionControler_h___ */
|
||||
114
mozilla/content/base/public/nsISelectionController.idl
Normal file
114
mozilla/content/base/public/nsISelectionController.idl
Normal file
@@ -0,0 +1,114 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sammy Ford
|
||||
*/
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(D2D1D179-85A7-11d3-9932-00108301233C)]
|
||||
interface nsISelectionController : nsISupports
|
||||
{
|
||||
/** CharacterMove will move the selection one character forward/backward in the document.
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
void characterMove(in boolean aForward, in boolean aExtend);
|
||||
|
||||
/** WordMove will move the selection one word forward/backward in the document.
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
|
||||
void wordMove(in boolean aForward, in boolean aExtend);
|
||||
|
||||
/** LineMove will move the selection one line forward/backward in the document.
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
void lineMove(in boolean aForward, in boolean aExtend);
|
||||
|
||||
/** IntraLineMove will move the selection to the front of the line or end of the line
|
||||
* in the document.
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
void intraLineMove(in boolean aForward, in boolean aExtend);
|
||||
|
||||
/** PageMove will move the selection one page forward/backward in the document.
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
void pageMove(in boolean aForward, in boolean aExtend);
|
||||
|
||||
/** CompleteScroll will move page view to the top or bottom of the document
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
*/
|
||||
void completeScroll(in boolean aForward);
|
||||
|
||||
/** CompleteMove will move page view to the top or bottom of the document
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
void completeMove(in boolean aForward, in boolean aExtend);
|
||||
|
||||
|
||||
/** ScrollPage will scroll the page without affecting the selection.
|
||||
* @param aForward scroll forward or backwards in selection
|
||||
*/
|
||||
void scrollPage(in boolean aForward);
|
||||
|
||||
/** ScrolLine will scroll line up or down dependent on the boolean
|
||||
* @param aForward scroll forward or backwards in selection
|
||||
*/
|
||||
void scrollLine(in boolean aForward);
|
||||
|
||||
/** ScrolHorizontal will scroll left or right dependent on the boolean
|
||||
* @param aLeft if true will scroll left. if not will scroll right.
|
||||
*/
|
||||
void scrollHorizontal(in boolean aLeft);
|
||||
/** SelectAll will select the whole page
|
||||
*/
|
||||
void selectAll();
|
||||
};
|
||||
%{ C++
|
||||
#define NS_ISELECTIONCONTROLLER_CID \
|
||||
{ 0xd2d1d179, 0x85a7, 0x11d3, \
|
||||
{ 0x99, 0x32, 0x0, 0x10, 0x83, 0x1, 0x23, 0x3c }}
|
||||
%}
|
||||
56
mozilla/content/base/public/nsIStyleRule.h
Normal file
56
mozilla/content/base/public/nsIStyleRule.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsIStyleRule_h___
|
||||
#define nsIStyleRule_h___
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "nslayout.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIStyleSheet;
|
||||
class nsIMutableStyleContext;
|
||||
class nsIPresContext;
|
||||
class nsIContent;
|
||||
|
||||
// IID for the nsIStyleRule interface {40ae5c90-ad6a-11d1-8031-006008159b5a}
|
||||
#define NS_ISTYLE_RULE_IID \
|
||||
{0x40ae5c90, 0xad6a, 0x11d1, {0x80, 0x31, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}}
|
||||
|
||||
class nsIStyleRule : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ISTYLE_RULE_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const = 0;
|
||||
|
||||
// Strength is an out-of-band weighting, useful for mapping CSS ! important
|
||||
NS_IMETHOD GetStrength(PRInt32& aStrength) const = 0;
|
||||
|
||||
// Map only font data into style context
|
||||
NS_IMETHOD MapFontStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aPresContext) = 0;
|
||||
// Map all non-font info into style context
|
||||
NS_IMETHOD MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aPresContext) = 0;
|
||||
|
||||
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIStyleRule_h___ */
|
||||
72
mozilla/content/base/public/nsIStyleRuleProcessor.h
Normal file
72
mozilla/content/base/public/nsIStyleRuleProcessor.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsIStyleRuleProcessor_h___
|
||||
#define nsIStyleRuleProcessor_h___
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "nslayout.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIStyleSheet;
|
||||
class nsIStyleContext;
|
||||
class nsIPresContext;
|
||||
class nsIContent;
|
||||
class nsISupportsArray;
|
||||
class nsIAtom;
|
||||
|
||||
// IID for the nsIStyleRuleProcessor interface {015575fe-7b6c-11d3-ba05-001083023c2b}
|
||||
#define NS_ISTYLE_RULE_PROCESSOR_IID \
|
||||
{0x015575fe, 0x7b6c, 0x11d3, {0xba, 0x05, 0x00, 0x10, 0x83, 0x02, 0x3c, 0x2b}}
|
||||
|
||||
/* The style rule processor interface is a mechanism to seperate the matching
|
||||
* of style rules from style sheet instances.
|
||||
* Simple style sheets can and will act as their own processor.
|
||||
* Sheets where rule ordering interlaces between multiple sheets, will need to
|
||||
* share a single rule processor between them (CSS sheets do this for cascading order)
|
||||
*/
|
||||
class nsIStyleRuleProcessor : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ISTYLE_RULE_PROCESSOR_IID; return iid; }
|
||||
|
||||
// populate supports array with nsIStyleRule*
|
||||
// rules are ordered, those with higher precedence come last
|
||||
NS_IMETHOD RulesMatching(nsIPresContext* aPresContext,
|
||||
nsIAtom* aMedium,
|
||||
nsIContent* aContent,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsISupportsArray* aResults) = 0;
|
||||
|
||||
NS_IMETHOD RulesMatching(nsIPresContext* aPresContext,
|
||||
nsIAtom* aMedium,
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsISupportsArray* aResults) = 0;
|
||||
|
||||
// Test if style is dependent on content state
|
||||
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
|
||||
nsIAtom* aMedium,
|
||||
nsIContent* aContent) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIStyleRuleProcessor_h___ */
|
||||
71
mozilla/content/base/public/nsIStyleSheet.h
Normal file
71
mozilla/content/base/public/nsIStyleSheet.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsIStyleSheet_h___
|
||||
#define nsIStyleSheet_h___
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsISupports.h"
|
||||
class nsIAtom;
|
||||
class nsString;
|
||||
class nsIURI;
|
||||
class nsIStyleRule;
|
||||
class nsISupportsArray;
|
||||
class nsIPresContext;
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIStyleContext;
|
||||
class nsIStyleRuleProcessor;
|
||||
|
||||
// IID for the nsIStyleSheet interface {8c4a80a0-ad6a-11d1-8031-006008159b5a}
|
||||
#define NS_ISTYLE_SHEET_IID \
|
||||
{0x8c4a80a0, 0xad6a, 0x11d1, {0x80, 0x31, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}}
|
||||
|
||||
class nsIStyleSheet : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ISTYLE_SHEET_IID; return iid; }
|
||||
|
||||
// basic style sheet data
|
||||
NS_IMETHOD GetURL(nsIURI*& aURL) const = 0;
|
||||
NS_IMETHOD GetTitle(nsString& aTitle) const = 0;
|
||||
NS_IMETHOD GetType(nsString& aType) const = 0;
|
||||
NS_IMETHOD GetMediumCount(PRInt32& aCount) const = 0;
|
||||
NS_IMETHOD GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const = 0;
|
||||
NS_IMETHOD UseForMedium(nsIAtom* aMedium) const = 0;
|
||||
|
||||
NS_IMETHOD GetEnabled(PRBool& aEnabled) const = 0;
|
||||
NS_IMETHOD SetEnabled(PRBool aEnabled) = 0;
|
||||
|
||||
// style sheet owner info
|
||||
NS_IMETHOD GetParentSheet(nsIStyleSheet*& aParent) const = 0; // may be null
|
||||
NS_IMETHOD GetOwningDocument(nsIDocument*& aDocument) const = 0; // may be null
|
||||
NS_IMETHOD SetOwningDocument(nsIDocument* aDocument) = 0;
|
||||
|
||||
// style rule processor access
|
||||
NS_IMETHOD GetStyleRuleProcessor(nsIStyleRuleProcessor*& aProcessor,
|
||||
nsIStyleRuleProcessor* aPrevProcessor) = 0;
|
||||
|
||||
// XXX style rule enumerations
|
||||
|
||||
virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIStyleSheet_h___ */
|
||||
54
mozilla/content/base/public/nsIStyleSheetLinkingElement.h
Normal file
54
mozilla/content/base/public/nsIStyleSheetLinkingElement.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsIStyleSheetLinkingElement_h__
|
||||
#define nsIStyleSheetLinkingElement_h__
|
||||
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
#define NS_ISTYLESHEETLINKINGELEMENT_IID \
|
||||
{0xa6cf90e9, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
class nsIStyleSheet;
|
||||
|
||||
class nsIStyleSheetLinkingElement : public nsISupports {
|
||||
public:
|
||||
/**
|
||||
* Used to make the association between a style sheet and
|
||||
* the element that linked it to the document.
|
||||
*
|
||||
* @param aStyleSheet the style sheet associated with this
|
||||
* element.
|
||||
*/
|
||||
NS_IMETHOD SetStyleSheet(nsIStyleSheet* aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* Used to obtain the style sheet linked in by this element.
|
||||
*
|
||||
* @param aStyleSheet out parameter that returns the style
|
||||
* sheet associated with this element.
|
||||
*/
|
||||
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aStyleSheet) = 0;
|
||||
};
|
||||
|
||||
#endif // nsILinkingElement_h__
|
||||
62
mozilla/content/base/public/nsIStyledContent.h
Normal file
62
mozilla/content/base/public/nsIStyledContent.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsIStyledContent_h___
|
||||
#define nsIStyledContent_h___
|
||||
|
||||
#include "nsIContent.h"
|
||||
|
||||
class nsString;
|
||||
class nsIStyleRule;
|
||||
class nsIStyleContext;
|
||||
class nsISupportsArray;
|
||||
|
||||
// IID for the nsIStyledContent class
|
||||
#define NS_ISTYLEDCONTENT_IID \
|
||||
{ 0xc1e84e01, 0xcd15, 0x11d2, { 0x96, 0xed, 0x0, 0x10, 0x4b, 0x7b, 0x7d, 0xeb } }
|
||||
|
||||
// Abstract interface for all styled content (that supports ID, CLASS, STYLE, and
|
||||
// the ability to specify style hints on an attribute change).
|
||||
class nsIStyledContent : public nsIContent {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ISTYLEDCONTENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetID(nsIAtom*& aResult) const = 0;
|
||||
NS_IMETHOD GetClasses(nsVoidArray& aArray) const = 0;
|
||||
NS_IMETHOD HasClass(nsIAtom* aClass) const = 0;
|
||||
|
||||
NS_IMETHOD GetContentStyleRules(nsISupportsArray* aRules) = 0;
|
||||
NS_IMETHOD GetInlineStyleRules(nsISupportsArray* aRules) = 0;
|
||||
|
||||
/** NRA ***
|
||||
* Get a hint that tells the style system what to do when
|
||||
* an attribute on this node changes.
|
||||
* This only applies to attributes that map their value
|
||||
* DIRECTLY into style contexts via NON-CSS style rules
|
||||
* Only HTML currently does this.
|
||||
* All other attributes return NS_STYLE_HINT_CONTENT
|
||||
*/
|
||||
NS_IMETHOD GetMappedAttributeImpact(const nsIAtom* aAttribute,
|
||||
PRInt32& aHint) const = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsIStyledContent_h___ */
|
||||
122
mozilla/content/base/public/nsITextContent.h
Normal file
122
mozilla/content/base/public/nsITextContent.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsITextContent_h___
|
||||
#define nsITextContent_h___
|
||||
|
||||
#include "nslayout.h"
|
||||
class nsString;
|
||||
class nsTextFragment;
|
||||
class nsIContent;
|
||||
|
||||
// IID for the nsITextContent interface
|
||||
#define NS_ITEXT_CONTENT_IID \
|
||||
{0xa6cf9065, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
/**
|
||||
* Interface for textual content. This interface is used to provide
|
||||
* an efficient access to text content.
|
||||
*/
|
||||
class nsITextContent : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ITEXT_CONTENT_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Get direct access (but read only) to the text in the text content.
|
||||
*/
|
||||
NS_IMETHOD GetText(const nsTextFragment** aFragmentsResult) = 0;
|
||||
|
||||
/**
|
||||
* Get the length of the text content.
|
||||
*/
|
||||
NS_IMETHOD GetTextLength(PRInt32* aLengthResult) = 0;
|
||||
|
||||
/**
|
||||
* Make a copy of the text content in aResult.
|
||||
*/
|
||||
NS_IMETHOD CopyText(nsString& aResult) = 0;
|
||||
|
||||
/**
|
||||
* Set the text to the given value. If aNotify is PR_TRUE then
|
||||
* the document is notified of the content change.
|
||||
*/
|
||||
NS_IMETHOD SetText(const PRUnichar* aBuffer,
|
||||
PRInt32 aLength,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
/**
|
||||
* Set the text to the given value. If aNotify is PR_TRUE then
|
||||
* the document is notified of the content change.
|
||||
*/
|
||||
NS_IMETHOD SetText(const char* aBuffer,
|
||||
PRInt32 aLength,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
/**
|
||||
* Query method to see if the frame is nothing but whitespace
|
||||
*/
|
||||
NS_IMETHOD IsOnlyWhitespace(PRBool* aResult) = 0;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/* a6cf905e-15b3-11d2-932e-00805f8add32 */
|
||||
#define NS_ITEXT_CONTENT_CHANGE_DATA_IID \
|
||||
{0xa6cf905e, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
// Simple interface for encapsulating change data for a ContentChanged
|
||||
// notification.
|
||||
class nsITextContentChangeData : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITEXT_CONTENT_CHANGE_DATA_IID);
|
||||
|
||||
enum ChangeType {
|
||||
Insert,
|
||||
Append,
|
||||
Replace
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the type of change associated with the ContentChanged
|
||||
* notification.
|
||||
*/
|
||||
NS_IMETHOD GetChangeType(ChangeType* aResult) = 0;
|
||||
|
||||
NS_IMETHOD GetInsertData(PRInt32* aOffset,
|
||||
PRInt32* aInsertLength) = 0;
|
||||
|
||||
NS_IMETHOD GetAppendData(PRInt32* aOffset,
|
||||
PRInt32* aAppendLength) = 0;
|
||||
|
||||
NS_IMETHOD GetReplaceData(PRInt32* aOffset,
|
||||
PRInt32* aSourceLength,
|
||||
PRInt32* aReplaceLength) = 0;
|
||||
};
|
||||
|
||||
// XXX These belong elsewhere
|
||||
extern nsresult
|
||||
NS_NewTextNode(nsIContent** aResult);
|
||||
|
||||
extern nsresult
|
||||
NS_NewCommentNode(nsIContent** aResult);
|
||||
|
||||
|
||||
#endif /* nsITextContent_h___ */
|
||||
241
mozilla/content/base/public/nsTextFragment.h
Normal file
241
mozilla/content/base/public/nsTextFragment.h
Normal file
@@ -0,0 +1,241 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsTextFragment_h___
|
||||
#define nsTextFragment_h___
|
||||
|
||||
#include "nslayout.h"
|
||||
class nsString;
|
||||
|
||||
// XXX should this normalize the code to keep a \u0000 at the end?
|
||||
|
||||
// XXX nsTextFragmentPool?
|
||||
|
||||
// XXX these need I18N spankage
|
||||
#define XP_IS_SPACE(_ch) \
|
||||
(((_ch) == ' ') || ((_ch) == '\t') || ((_ch) == '\n'))
|
||||
|
||||
#define XP_IS_UPPERCASE(_ch) \
|
||||
(((_ch) >= 'A') && ((_ch) <= 'Z'))
|
||||
|
||||
#define XP_IS_LOWERCASE(_ch) \
|
||||
(((_ch) >= 'a') && ((_ch) <= 'z'))
|
||||
|
||||
#define XP_TO_LOWER(_ch) ((_ch) | 32)
|
||||
|
||||
#define XP_TO_UPPER(_ch) ((_ch) & ~32)
|
||||
|
||||
#define XP_IS_SPACE_W XP_IS_SPACE
|
||||
|
||||
/**
|
||||
* A fragment of text. If mIs2b is 1 then the m2b pointer is valid
|
||||
* otherwise the m1b pointer is valid. If m1b is used then each byte
|
||||
* of data represents a single ucs2 character with the high byte being
|
||||
* zero.
|
||||
*
|
||||
* This class does not have a virtual destructor therefore it is not
|
||||
* meant to be subclassed.
|
||||
*/
|
||||
class NS_LAYOUT nsTextFragment {
|
||||
public:
|
||||
/**
|
||||
* Default constructor. Initialize the fragment to be empty.
|
||||
*/
|
||||
nsTextFragment() {
|
||||
m1b = nsnull;
|
||||
mAllBits = 0;
|
||||
}
|
||||
|
||||
~nsTextFragment();
|
||||
|
||||
/**
|
||||
* Initialize the contents of this fragment to be a copy of
|
||||
* the argument fragment.
|
||||
*/
|
||||
nsTextFragment(const nsTextFragment& aOther);
|
||||
|
||||
/**
|
||||
* Initialize the contents of this fragment to be a copy of
|
||||
* the argument 7bit ascii string.
|
||||
*/
|
||||
nsTextFragment(const char* aString);
|
||||
|
||||
/**
|
||||
* Initialize the contents of this fragment to be a copy of
|
||||
* the argument ucs2 string.
|
||||
*/
|
||||
nsTextFragment(const PRUnichar* aString);
|
||||
|
||||
/**
|
||||
* Initialize the contents of this fragment to be a copy of
|
||||
* the argument string.
|
||||
*/
|
||||
nsTextFragment(const nsString& aString);
|
||||
|
||||
/**
|
||||
* Change the contents of this fragment to be a copy of the
|
||||
* the argument fragment.
|
||||
*/
|
||||
nsTextFragment& operator=(const nsTextFragment& aOther);
|
||||
|
||||
/**
|
||||
* Change the contents of this fragment to be a copy of the
|
||||
* the argument 7bit ascii string.
|
||||
*/
|
||||
nsTextFragment& operator=(const char* aString);
|
||||
|
||||
/**
|
||||
* Change the contents of this fragment to be a copy of the
|
||||
* the argument ucs2 string.
|
||||
*/
|
||||
nsTextFragment& operator=(const PRUnichar* aString);
|
||||
|
||||
/**
|
||||
* Change the contents of this fragment to be a copy of the
|
||||
* the argument string.
|
||||
*/
|
||||
nsTextFragment& operator=(const nsString& aString);
|
||||
|
||||
/**
|
||||
* Return PR_TRUE if this fragment is represented by PRUnichar data
|
||||
*/
|
||||
PRBool Is2b() const {
|
||||
return mState.mIs2b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pointer to constant PRUnichar data.
|
||||
*/
|
||||
const PRUnichar* Get2b() const {
|
||||
NS_ASSERTION(Is2b(), "not 2b text");
|
||||
return m2b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pointer to constant char data.
|
||||
*/
|
||||
const char* Get1b() const {
|
||||
NS_ASSERTION(!Is2b(), "not 1b text");
|
||||
return (const char*) m1b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of the fragment. The length is the number of logical
|
||||
* characters, not the number of bytes to store the characters.
|
||||
*/
|
||||
PRInt32 GetLength() const {
|
||||
return PRInt32(mState.mLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutable version of Get2b. Only works for a non-const object.
|
||||
* Returns a pointer to the PRUnichar data.
|
||||
*/
|
||||
PRUnichar* Get2b() {
|
||||
NS_ASSERTION(Is2b(), "not 2b text");
|
||||
return m2b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutable version of Get1b. Only works for a non-const object.
|
||||
* Returns a pointer to the char data.
|
||||
*/
|
||||
char* Get1b() {
|
||||
NS_ASSERTION(!Is2b(), "not 1b text");
|
||||
return (char*) m1b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the contents of this fragment to be the given buffer and
|
||||
* length. The memory becomes owned by the fragment. In addition,
|
||||
* the memory for aBuffer must have been allocated using the "new[]"
|
||||
* because it will be released with "delete []".
|
||||
*/
|
||||
void SetTo(PRUnichar* aBuffer, PRInt32 aLength, PRBool aRelease);
|
||||
|
||||
/**
|
||||
* Change the contents of this fragment to be a copy of the given
|
||||
* buffer. Like operator= except a length is specified instead of
|
||||
* assuming 0 termination.
|
||||
*/
|
||||
void SetTo(const PRUnichar* aBuffer, PRInt32 aLength);
|
||||
|
||||
/**
|
||||
* Change the contents of this fragment to be a copy of the given
|
||||
* buffer. Like operator= except a length is specified instead of
|
||||
* assuming 0 termination.
|
||||
*/
|
||||
void SetTo(const char* aBuffer, PRInt32 aLength);
|
||||
|
||||
/**
|
||||
* Append the contents of this string fragment to aString
|
||||
*/
|
||||
void AppendTo(nsString& aString) const;
|
||||
|
||||
/**
|
||||
* Make a copy of the fragments contents starting at offset for
|
||||
* count characters. The offset and count will be adjusted to
|
||||
* lie within the fragments data. The fragments data is converted if
|
||||
* necessary.
|
||||
*/
|
||||
void CopyTo(PRUnichar* aDest, PRInt32 aOffset, PRInt32 aCount);
|
||||
|
||||
/**
|
||||
* Make a copy of the fragments contents starting at offset for
|
||||
* count characters. The offset and count will be adjusted to
|
||||
* lie within the fragments data. The fragments data is converted if
|
||||
* necessary.
|
||||
*/
|
||||
void CopyTo(char* aDest, PRInt32 aOffset, PRInt32 aCount);
|
||||
|
||||
/**
|
||||
* Return the character in the text-fragment at the given
|
||||
* index. This always returns a PRUnichar.
|
||||
*/
|
||||
PRUnichar CharAt(PRInt32 aIndex) const {
|
||||
NS_ASSERTION(PRUint32(aIndex) < mState.mLength, "bad index");
|
||||
return mState.mIs2b ? m2b[aIndex] : PRUnichar(m1b[aIndex]);
|
||||
}
|
||||
|
||||
protected:
|
||||
union {
|
||||
PRUnichar* m2b;
|
||||
unsigned char* m1b;
|
||||
};
|
||||
|
||||
public:
|
||||
struct FragmentBits {
|
||||
PRUint32 mInHeap : 1;
|
||||
PRUint32 mIs2b : 1;
|
||||
PRUint32 mLength : 30;
|
||||
};
|
||||
|
||||
protected:
|
||||
union {
|
||||
PRUint32 mAllBits;
|
||||
FragmentBits mState;
|
||||
};
|
||||
|
||||
void ReleaseText();
|
||||
};
|
||||
|
||||
#endif /* nsTextFragment_h___ */
|
||||
|
||||
505
mozilla/content/base/src/nsCommentNode.cpp
Normal file
505
mozilla/content/base/src/nsCommentNode.cpp
Normal file
@@ -0,0 +1,505 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsFrame.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsXIFConverter.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMRange.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
|
||||
static NS_DEFINE_IID(kIEnumeratorIID, NS_IENUMERATOR_IID);
|
||||
static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID);
|
||||
|
||||
class nsCommentNode : public nsIDOMComment,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIContent,
|
||||
public nsITextContent
|
||||
{
|
||||
public:
|
||||
nsCommentNode();
|
||||
virtual ~nsCommentNode();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_IDOMNODE_USING_GENERIC_DOM_DATA(mInner)
|
||||
|
||||
// nsIDOMCharacterData
|
||||
NS_IMPL_IDOMCHARACTERDATA_USING_GENERIC_DOM_DATA(mInner)
|
||||
|
||||
// nsIDOMComment
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC_DOM_DATA(mInner)
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC_DOM_DATA(mInner)
|
||||
|
||||
// nsIContent
|
||||
//NS_IMPL_ICONTENT_USING_GENERIC_DOM_DATA(mInner)
|
||||
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const {
|
||||
return mInner.GetDocument(aResult);
|
||||
}
|
||||
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) {
|
||||
return mInner.SetDocument(aDocument, aDeep);
|
||||
}
|
||||
NS_IMETHOD GetParent(nsIContent*& aResult) const {
|
||||
return mInner.GetParent(aResult);
|
||||
}
|
||||
NS_IMETHOD SetParent(nsIContent* aParent) {
|
||||
return mInner.SetParent(aParent);
|
||||
}
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const {
|
||||
return mInner.CanContainChildren(aResult);
|
||||
}
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const {
|
||||
return mInner.ChildCount(aResult);
|
||||
}
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const {
|
||||
return mInner.ChildAt(aIndex, aResult);
|
||||
}
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const {
|
||||
return mInner.IndexOf(aPossibleChild, aResult);
|
||||
}
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
PRBool aNotify) {
|
||||
return mInner.InsertChildAt(aKid, aIndex, aNotify);
|
||||
}
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
PRBool aNotify) {
|
||||
return mInner.ReplaceChildAt(aKid, aIndex, aNotify);
|
||||
}
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) {
|
||||
return mInner.AppendChildTo(aKid, aNotify);
|
||||
}
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) {
|
||||
return mInner.RemoveChildAt(aIndex, aNotify);
|
||||
}
|
||||
NS_IMETHOD IsSynthetic(PRBool& aResult) {
|
||||
return mInner.IsSynthetic(aResult);
|
||||
}
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32& aID) const {
|
||||
return mInner.GetNameSpaceID(aID);
|
||||
}
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const;
|
||||
NS_IMETHOD ParseAttributeString(const nsString& aStr,
|
||||
nsIAtom*& aName,
|
||||
PRInt32& aNameSpaceID) {
|
||||
return mInner.ParseAttributeString(aStr, aName, aNameSpaceID);
|
||||
}
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) {
|
||||
return mInner.GetNameSpacePrefixFromId(aNameSpaceID, aPrefix);
|
||||
}
|
||||
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom *aAttribute,
|
||||
nsString &aResult) const {
|
||||
return mInner.GetAttribute(aNameSpaceID, aAttribute, aResult);
|
||||
}
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
const nsString& aValue, PRBool aNotify) {
|
||||
return mInner.SetAttribute(aNameSpaceID, aAttribute, aValue, aNotify);
|
||||
}
|
||||
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
PRBool aNotify) {
|
||||
return mInner.UnsetAttribute(aNameSpaceID, aAttribute, aNotify);
|
||||
}
|
||||
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex,
|
||||
PRInt32& aNameSpaceID,
|
||||
nsIAtom*& aName) const {
|
||||
return mInner.GetAttributeNameAt(aIndex, aNameSpaceID, aName);
|
||||
}
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const {
|
||||
return mInner.GetAttributeCount(aResult);
|
||||
}
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
||||
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const {
|
||||
return mInner.BeginConvertToXIF(aConverter);
|
||||
}
|
||||
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const;
|
||||
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const {
|
||||
return mInner.FinishConvertToXIF(aConverter);
|
||||
}
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus);
|
||||
|
||||
NS_IMETHOD GetContentID(PRUint32* aID) {
|
||||
*aID = mContentID;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD SetContentID(PRUint32 aID) {
|
||||
mContentID = aID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD RangeAdd(nsIDOMRange& aRange){
|
||||
return mInner.RangeAdd(aRange);
|
||||
}
|
||||
NS_IMETHOD RangeRemove(nsIDOMRange& aRange){
|
||||
return mInner.RangeRemove(aRange);
|
||||
}
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const {
|
||||
return mInner.GetRangeList(aResult);
|
||||
}
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
*aResult = sizeof(*this);
|
||||
#else
|
||||
*aResult = 0;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetText(const nsTextFragment** aFragmentsResult)
|
||||
{ return mInner.GetText(aFragmentsResult); }
|
||||
NS_IMETHOD GetTextLength(PRInt32* aLengthResult) {
|
||||
return mInner.GetTextLength(aLengthResult);
|
||||
}
|
||||
NS_IMETHOD CopyText(nsString& aResult) {
|
||||
return mInner.CopyText(aResult);
|
||||
}
|
||||
NS_IMETHOD SetText(const PRUnichar* aBuffer,
|
||||
PRInt32 aLength,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD SetText(const char* aBuffer,
|
||||
PRInt32 aLength,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD IsOnlyWhitespace(PRBool* aResult)
|
||||
{ return mInner.IsOnlyWhitespace(aResult); }
|
||||
|
||||
protected:
|
||||
nsGenericDOMDataNode mInner;
|
||||
PRUint32 mContentID;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewCommentNode(nsIContent** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsIContent* it = new nsCommentNode();
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIContentIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
|
||||
nsCommentNode::nsCommentNode()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInner.Init(this);
|
||||
mContentID = 0;
|
||||
}
|
||||
|
||||
nsCommentNode::~nsCommentNode()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsCommentNode)
|
||||
|
||||
NS_IMPL_RELEASE(nsCommentNode)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_IMPL_DOM_DATA_QUERY_INTERFACE(aIID, aInstancePtr, this)
|
||||
if (aIID.Equals(kIDOMCommentIID)) {
|
||||
nsIDOMComment* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kITextContentIID)) {
|
||||
nsITextContent* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::GetTag(nsIAtom*& aResult) const
|
||||
{
|
||||
aResult = nsLayoutAtoms::commentTagName;
|
||||
NS_ADDREF(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::GetNodeName(nsString& aNodeName)
|
||||
{
|
||||
aNodeName.SetString("#comment");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = (PRUint16)nsIDOMNode::COMMENT_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
nsCommentNode* it = new nsCommentNode();
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
// XXX Increment the ref count before calling any
|
||||
// methods. If they do a QI and then a Release()
|
||||
// the instance will be deleted.
|
||||
result = it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
nsAutoString data;
|
||||
result = GetData(data);
|
||||
if (NS_FAILED(result)) {
|
||||
NS_RELEASE(*aReturn);
|
||||
return result;
|
||||
}
|
||||
result = it->SetData(data);
|
||||
if (NS_FAILED(result)) {
|
||||
NS_RELEASE(*aReturn);
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
NS_PRECONDITION(nsnull != mInner.mDocument, "bad content");
|
||||
|
||||
PRInt32 indx;
|
||||
for (indx = aIndent; --indx >= 0; ) fputs(" ", out);
|
||||
|
||||
fprintf(out, "Comment@%p refcount=%d<!--", this, mRefCnt);
|
||||
|
||||
nsAutoString tmp;
|
||||
mInner.ToCString(tmp, 0, mInner.mText.GetLength());
|
||||
fputs(tmp, out);
|
||||
|
||||
fputs("-->\n", out);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
||||
nsresult NS_NewCommentFrame(nsIPresShell* aPresShell, nsIFrame*& aResult);
|
||||
nsresult
|
||||
NS_NewCommentFrame(nsIPresShell* aPresShell, nsIFrame*& aResult)
|
||||
{
|
||||
nsIFrame* frame;
|
||||
NS_NewEmptyFrame(aPresShell, &frame);
|
||||
if (nsnull == frame) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
aResult = frame;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
nsresult
|
||||
nsCommentNode::ConvertContentToXIF(nsXIFConverter& aConverter) const
|
||||
{
|
||||
const nsIContent* content = this;
|
||||
nsIDOMSelection* sel = aConverter.GetSelection();
|
||||
|
||||
nsIDocument* document;
|
||||
nsresult res;
|
||||
res = GetDocument(document);
|
||||
if (!NS_SUCCEEDED(res))
|
||||
return res;
|
||||
|
||||
const nsTextFragment* textFrag;
|
||||
|
||||
// XXX This method is const, but GetText() isn't,
|
||||
// XXX so cast away the constness of mInner:
|
||||
nsGenericDOMDataNode* inner = (nsGenericDOMDataNode*)&mInner;
|
||||
res = inner->GetText(&textFrag);
|
||||
if (!NS_SUCCEEDED(res))
|
||||
return res;
|
||||
|
||||
if (sel != nsnull && document->IsInSelection(sel,content))
|
||||
{
|
||||
nsIEnumerator *enumerator;
|
||||
if (NS_SUCCEEDED(sel->QueryInterface(kIEnumeratorIID, (void **)&enumerator))) {
|
||||
for (enumerator->First();NS_OK != enumerator->IsDone(); enumerator->Next()) {
|
||||
nsIDOMRange* range = nsnull;
|
||||
if (NS_SUCCEEDED(enumerator->CurrentItem((nsISupports**)&range))) {
|
||||
|
||||
nsCOMPtr<nsIDOMNode> startNode;
|
||||
nsCOMPtr<nsIDOMNode> endNode;
|
||||
PRInt32 startOffset = 0;
|
||||
PRInt32 endOffset = 0;
|
||||
|
||||
range->GetStartParent(getter_AddRefs(startNode));
|
||||
range->GetEndParent(getter_AddRefs(endNode));
|
||||
|
||||
range->GetStartOffset(&startOffset);
|
||||
range->GetEndOffset(&endOffset);
|
||||
|
||||
nsCOMPtr<nsIContent> startContent;
|
||||
nsCOMPtr<nsIContent> endContent;
|
||||
startContent = do_QueryInterface(startNode);
|
||||
endContent = do_QueryInterface(endNode);
|
||||
|
||||
|
||||
nsString buffer;
|
||||
textFrag->AppendTo(buffer);
|
||||
if (startContent.get() == content || endContent.get() == content)
|
||||
{
|
||||
// NOTE: ORDER MATTERS!
|
||||
// This must go before the Cut
|
||||
if (endContent.get() == content)
|
||||
buffer.Truncate(endOffset);
|
||||
|
||||
// This must go after the Trunctate
|
||||
if (startContent.get() == content)
|
||||
buffer.Cut(0,startOffset);
|
||||
}
|
||||
aConverter.AddContentComment(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nsString buffer;
|
||||
textFrag->AppendTo(buffer);
|
||||
aConverter.AddContentComment(buffer);
|
||||
}
|
||||
NS_IF_RELEASE(document);
|
||||
// XXX Possible mem leak: Do we need to delete textFrag?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
nsresult
|
||||
nsCommentNode::BeginConvertToXIF(nsXIFConverter& aConverter) const
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCommentNode::FinishConvertToXIF(nsXIFConverter& aConverter) const
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
// This would ideally be done by the parser, but for the sake
|
||||
// of "genericity" it's being done in the comment content code
|
||||
static void
|
||||
StripCommentDelimiters(nsString& aCommentString)
|
||||
{
|
||||
PRInt32 offset;
|
||||
static char* kCommentStart = "<!";
|
||||
static char* kCommentEnd = "->";
|
||||
static char* kCommentAlternateEnd = "--!>";
|
||||
static char kMinus = '-';
|
||||
|
||||
offset = aCommentString.Find(kCommentStart);
|
||||
if (-1 != offset) {
|
||||
// Take up to 2 '-' characters
|
||||
offset += strlen(kCommentStart);
|
||||
if (kMinus == aCommentString.CharAt(offset)) {
|
||||
offset++;
|
||||
if (kMinus == aCommentString.CharAt(offset)) {
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
aCommentString.Cut(0, offset);
|
||||
}
|
||||
|
||||
offset = aCommentString.RFind(kCommentEnd);
|
||||
if (-1 != offset) {
|
||||
// Take up to 1 more '-'
|
||||
if (kMinus == aCommentString.CharAt(offset-1)) {
|
||||
offset--;
|
||||
}
|
||||
aCommentString.Cut(offset, aCommentString.Length()-offset);
|
||||
}
|
||||
else {
|
||||
offset = aCommentString.RFind(kCommentAlternateEnd);
|
||||
if (-1 != offset) {
|
||||
aCommentString.Cut(offset, aCommentString.Length()-offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::SetText(const PRUnichar* aBuffer,
|
||||
PRInt32 aLength,
|
||||
PRBool aNotify)
|
||||
{
|
||||
nsAutoString str(aBuffer);
|
||||
|
||||
StripCommentDelimiters(str);
|
||||
return mInner.SetText(str.GetUnicode(), str.Length(), aNotify);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::SetText(const char* aBuffer,
|
||||
PRInt32 aLength,
|
||||
PRBool aNotify)
|
||||
{
|
||||
nsAutoString str(aBuffer);
|
||||
|
||||
StripCommentDelimiters(str);
|
||||
return mInner.SetText(str.GetUnicode(), str.Length(), aNotify);
|
||||
}
|
||||
1088
mozilla/content/base/src/nsContentIterator.cpp
Normal file
1088
mozilla/content/base/src/nsContentIterator.cpp
Normal file
File diff suppressed because it is too large
Load Diff
545
mozilla/content/base/src/nsContentList.cpp
Normal file
545
mozilla/content/base/src/nsContentList.cpp
Normal file
@@ -0,0 +1,545 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsContentList.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsGenericElement.h"
|
||||
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsHTMLAtoms.h" // XXX until atoms get factored into nsLayoutAtoms
|
||||
|
||||
nsIAtom* nsContentList::gWildCardAtom = nsnull;
|
||||
|
||||
nsContentList::nsContentList(nsIDocument *aDocument)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mScriptObject = nsnull;
|
||||
mFunc = nsnull;
|
||||
mMatchAtom = nsnull;
|
||||
mDocument = aDocument;
|
||||
mData = nsnull;
|
||||
mMatchAll = PR_FALSE;
|
||||
}
|
||||
|
||||
nsContentList::nsContentList(nsIDocument *aDocument,
|
||||
nsIAtom* aMatchAtom,
|
||||
PRInt32 aMatchNameSpaceId,
|
||||
nsIContent* aRootContent)
|
||||
{
|
||||
mMatchAtom = aMatchAtom;
|
||||
NS_IF_ADDREF(mMatchAtom);
|
||||
if (nsnull == gWildCardAtom) {
|
||||
gWildCardAtom = NS_NewAtom("*");
|
||||
}
|
||||
if (gWildCardAtom == mMatchAtom) {
|
||||
mMatchAll = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
mMatchAll = PR_FALSE;
|
||||
}
|
||||
mMatchNameSpaceId = aMatchNameSpaceId;
|
||||
mFunc = nsnull;
|
||||
mData = nsnull;
|
||||
mRootContent = aRootContent;
|
||||
Init(aDocument);
|
||||
}
|
||||
|
||||
nsContentList::nsContentList(nsIDocument *aDocument,
|
||||
nsContentListMatchFunc aFunc,
|
||||
const nsString* aData,
|
||||
nsIContent* aRootContent)
|
||||
{
|
||||
mFunc = aFunc;
|
||||
if (nsnull != aData) {
|
||||
mData = new nsString(*aData);
|
||||
// If this fails, fail silently
|
||||
}
|
||||
else {
|
||||
mData = nsnull;
|
||||
}
|
||||
mMatchAtom = nsnull;
|
||||
mRootContent = aRootContent;
|
||||
mMatchAll = PR_FALSE;
|
||||
Init(aDocument);
|
||||
}
|
||||
|
||||
void nsContentList::Init(nsIDocument *aDocument)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mScriptObject = nsnull;
|
||||
// We don't reference count the reference to the document
|
||||
// If the document goes away first, we'll be informed and we
|
||||
// can drop our reference.
|
||||
// If we go away first, we'll get rid of ourselves from the
|
||||
// document's observer list.
|
||||
mDocument = aDocument;
|
||||
if (nsnull != mDocument) {
|
||||
mDocument->AddObserver(this);
|
||||
}
|
||||
PopulateSelf();
|
||||
}
|
||||
|
||||
nsContentList::~nsContentList()
|
||||
{
|
||||
if (nsnull != mDocument) {
|
||||
mDocument->RemoveObserver(this);
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(mMatchAtom);
|
||||
|
||||
if (nsnull != mData) {
|
||||
delete mData;
|
||||
}
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIDOMNodeListIID, NS_IDOMNODELIST_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLCollectionIID, NS_IDOMHTMLCOLLECTION_IID);
|
||||
|
||||
nsresult nsContentList::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIDOMNodeListIID)) {
|
||||
*aInstancePtr = (void*)(nsIDOMNodeList*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMHTMLCollectionIID)) {
|
||||
*aInstancePtr = (void*)(nsIDOMHTMLCollection*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
*aInstancePtr = (void*)(nsIScriptObjectOwner*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*)(nsISupports*)(nsIDOMNodeList*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsContentList)
|
||||
NS_IMPL_RELEASE(nsContentList)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::GetLength(PRUint32* aLength)
|
||||
{
|
||||
nsresult result = CheckDocumentExistence();
|
||||
if (NS_OK == result) {
|
||||
*aLength = mContent.Count();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsresult result = CheckDocumentExistence();
|
||||
if (NS_OK == result) {
|
||||
nsISupports *element = (nsISupports *)mContent.ElementAt(aIndex);
|
||||
|
||||
if (nsnull != element) {
|
||||
result = element->QueryInterface(kIDOMNodeIID, (void **)aReturn);
|
||||
}
|
||||
else {
|
||||
*aReturn = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::NamedItem(const nsString& aName, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsresult result = CheckDocumentExistence();
|
||||
|
||||
if (NS_OK == result) {
|
||||
PRInt32 i, count = mContent.Count();
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
nsIContent *content = (nsIContent *)mContent.ElementAt(i);
|
||||
if (nsnull != content) {
|
||||
nsAutoString name;
|
||||
// XXX Should it be an EqualsIgnoreCase?
|
||||
if (((content->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::name, name) == NS_CONTENT_ATTR_HAS_VALUE) &&
|
||||
(aName.Equals(name))) ||
|
||||
((content->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::id, name) == NS_CONTENT_ATTR_HAS_VALUE) &&
|
||||
(aName.Equals(name)))) {
|
||||
return content->QueryInterface(kIDOMNodeIID, (void **)aReturn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*aReturn = nsnull;
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
nsIScriptGlobalObject *global = aContext->GetGlobalObject();
|
||||
|
||||
if (nsnull == mScriptObject) {
|
||||
nsIDOMScriptObjectFactory *factory;
|
||||
|
||||
res = nsGenericElement::GetScriptObjectFactory(&factory);
|
||||
if (NS_OK != res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
res = factory->NewScriptHTMLCollection(aContext,
|
||||
(nsISupports*)(nsIDOMHTMLCollection*)this,
|
||||
global,
|
||||
(void**)&mScriptObject);
|
||||
NS_RELEASE(factory);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
|
||||
NS_RELEASE(global);
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::ContentAppended(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
PRInt32 i, count;
|
||||
aContainer->ChildCount(count);
|
||||
if ((count > 0) && IsDescendantOfRoot(aContainer)) {
|
||||
PRBool repopulate = PR_FALSE;
|
||||
for (i = aNewIndexInContainer; i <= count-1; i++) {
|
||||
nsIContent *content;
|
||||
aContainer->ChildAt(i, content);
|
||||
if (mMatchAll || MatchSelf(content)) {
|
||||
repopulate = PR_TRUE;
|
||||
}
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
if (repopulate) {
|
||||
PopulateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::ContentInserted(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
if (IsDescendantOfRoot(aContainer)) {
|
||||
if (mMatchAll || MatchSelf(aChild)) {
|
||||
PopulateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::ContentReplaced(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
nsIContent* aNewChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
if (IsDescendantOfRoot(aContainer)) {
|
||||
if (mMatchAll || MatchSelf(aOldChild) || MatchSelf(aNewChild)) {
|
||||
PopulateSelf();
|
||||
}
|
||||
}
|
||||
else if (ContainsRoot(aOldChild)) {
|
||||
DisconnectFromDocument();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
if (IsDescendantOfRoot(aContainer) && MatchSelf(aChild)) {
|
||||
PopulateSelf();
|
||||
}
|
||||
else if (ContainsRoot(aChild)) {
|
||||
DisconnectFromDocument();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::DocumentWillBeDestroyed(nsIDocument *aDocument)
|
||||
{
|
||||
if (nsnull != mDocument) {
|
||||
aDocument->RemoveObserver(this);
|
||||
mDocument = nsnull;
|
||||
}
|
||||
Reset();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Returns whether the content element matches the
|
||||
// criterion
|
||||
nsresult
|
||||
nsContentList::Match(nsIContent *aContent, PRBool *aMatch)
|
||||
{
|
||||
if (nsnull != mMatchAtom) {
|
||||
nsIAtom *name = nsnull;
|
||||
aContent->GetTag(name);
|
||||
|
||||
// If we have to match all, only do those that have
|
||||
// a tagName i.e. only the elements.
|
||||
if (mMatchAll && (nsLayoutAtoms::textTagName != name) &&
|
||||
(nsLayoutAtoms::commentTagName != name) &&
|
||||
(nsLayoutAtoms::processingInstructionTagName != name)) {
|
||||
*aMatch = PR_TRUE;
|
||||
}
|
||||
// XXX We don't yet match on namespace. Maybe we should??
|
||||
else if (name == mMatchAtom) {
|
||||
*aMatch = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
*aMatch = PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(name);
|
||||
}
|
||||
else if (nsnull != mFunc) {
|
||||
*aMatch = (*mFunc)(aContent, mData);
|
||||
}
|
||||
else {
|
||||
*aMatch = PR_FALSE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentList::Add(nsIContent *aContent)
|
||||
{
|
||||
// Shouldn't hold a reference since we'll be
|
||||
// told when the content leaves the document or
|
||||
// the document will be destroyed.
|
||||
mContent.AppendElement(aContent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentList::Remove(nsIContent *aContent)
|
||||
{
|
||||
mContent.RemoveElement(aContent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentList::Reset()
|
||||
{
|
||||
mContent.Clear();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If we were created outside the context of a document and we
|
||||
// have root content, then check if our content has been added
|
||||
// to a document yet. If so, we'll become an observer of the document.
|
||||
nsresult
|
||||
nsContentList::CheckDocumentExistence()
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
if ((nsnull == mDocument) && (nsnull != mRootContent)) {
|
||||
result = mRootContent->GetDocument(mDocument);
|
||||
if (nsnull != mDocument) {
|
||||
mDocument->AddObserver(this);
|
||||
PopulateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Match recursively. See if anything in the subtree
|
||||
// matches the criterion.
|
||||
PRBool
|
||||
nsContentList::MatchSelf(nsIContent *aContent)
|
||||
{
|
||||
PRBool match;
|
||||
PRInt32 i, count;
|
||||
|
||||
Match(aContent, &match);
|
||||
if (match) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
aContent->ChildCount(count);
|
||||
for (i = 0; i < count; i++) {
|
||||
nsIContent *child;
|
||||
aContent->ChildAt(i, child);
|
||||
if (MatchSelf(child)) {
|
||||
NS_RELEASE(child);
|
||||
return PR_TRUE;
|
||||
}
|
||||
NS_RELEASE(child);
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Add all elements in this subtree that match to
|
||||
// our list.
|
||||
void
|
||||
nsContentList::PopulateWith(nsIContent *aContent, PRBool aIncludeRoot)
|
||||
{
|
||||
PRBool match;
|
||||
PRInt32 i, count;
|
||||
|
||||
if (aIncludeRoot) {
|
||||
Match(aContent, &match);
|
||||
if (match) {
|
||||
Add(aContent);
|
||||
}
|
||||
}
|
||||
|
||||
aContent->ChildCount(count);
|
||||
for (i = 0; i < count; i++) {
|
||||
nsIContent *child;
|
||||
aContent->ChildAt(i, child);
|
||||
PopulateWith(child, PR_TRUE);
|
||||
NS_RELEASE(child);
|
||||
}
|
||||
}
|
||||
|
||||
// Clear out our old list and build up a new one
|
||||
void
|
||||
nsContentList::PopulateSelf()
|
||||
{
|
||||
Reset();
|
||||
if (nsnull != mRootContent) {
|
||||
PopulateWith(mRootContent, PR_FALSE);
|
||||
}
|
||||
else if (nsnull != mDocument) {
|
||||
nsIContent *root;
|
||||
root = mDocument->GetRootContent();
|
||||
PopulateWith(root, PR_TRUE);
|
||||
NS_RELEASE(root);
|
||||
}
|
||||
}
|
||||
|
||||
// Is the specified element a descendant of the root? If there
|
||||
// is no root, then yes. Otherwise keep tracing up the tree from
|
||||
// the element till we find our root, or until we reach the
|
||||
// document root.
|
||||
PRBool
|
||||
nsContentList::IsDescendantOfRoot(nsIContent* aContainer)
|
||||
{
|
||||
if (nsnull == mRootContent) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else if (mRootContent == aContainer) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else if (nsnull == aContainer) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
else {
|
||||
nsIContent* parent;
|
||||
PRBool ret;
|
||||
|
||||
aContainer->GetParent(parent);
|
||||
ret = IsDescendantOfRoot(parent);
|
||||
NS_IF_RELEASE(parent);
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
// Does this subtree contain the root?
|
||||
PRBool
|
||||
nsContentList::ContainsRoot(nsIContent* aContent)
|
||||
{
|
||||
if (nsnull == mRootContent) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
else if (mRootContent == aContent) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else {
|
||||
PRInt32 i, count;
|
||||
|
||||
aContent->ChildCount(count);
|
||||
for (i = 0; i < count; i++) {
|
||||
nsIContent *child;
|
||||
aContent->ChildAt(i, child);
|
||||
if (ContainsRoot(child)) {
|
||||
NS_RELEASE(child);
|
||||
return PR_TRUE;
|
||||
}
|
||||
NS_RELEASE(child);
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Our root content has been disconnected from the
|
||||
// document, so stop observing. The list then becomes
|
||||
// a snapshot rather than a dynamic list.
|
||||
void
|
||||
nsContentList::DisconnectFromDocument()
|
||||
{
|
||||
if (nsnull != mDocument) {
|
||||
mDocument->RemoveObserver(this);
|
||||
mDocument = nsnull;
|
||||
}
|
||||
}
|
||||
149
mozilla/content/base/src/nsContentList.h
Normal file
149
mozilla/content/base/src/nsContentList.h
Normal file
@@ -0,0 +1,149 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsContentList_h___
|
||||
#define nsContentList_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
|
||||
typedef PRBool (*nsContentListMatchFunc)(nsIContent* aContent, nsString* aData);
|
||||
|
||||
class nsIDocument;
|
||||
|
||||
class nsContentList : public nsIDOMNodeList,
|
||||
public nsIDOMHTMLCollection,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDocumentObserver {
|
||||
protected:
|
||||
nsContentList(nsIDocument *aDocument);
|
||||
public:
|
||||
nsContentList(nsIDocument *aDocument,
|
||||
nsIAtom* aMatchAtom,
|
||||
PRInt32 aMatchNameSpaceId,
|
||||
nsIContent* aRootContent=nsnull);
|
||||
nsContentList(nsIDocument *aDocument,
|
||||
nsContentListMatchFunc aFunc,
|
||||
const nsString* aData,
|
||||
nsIContent* aRootContent=nsnull);
|
||||
virtual ~nsContentList();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMHTMLCollection
|
||||
NS_IMETHOD GetLength(PRUint32* aLength);
|
||||
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
|
||||
|
||||
NS_IMETHOD NamedItem(const nsString& aName, nsIDOMNode** aReturn);
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
// nsIDocumentObserver
|
||||
NS_IMETHOD BeginUpdate(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD EndUpdate(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD BeginLoad(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD EndLoad(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD BeginReflow(nsIDocument *aDocument,
|
||||
nsIPresShell* aShell) { return NS_OK; }
|
||||
NS_IMETHOD EndReflow(nsIDocument *aDocument,
|
||||
nsIPresShell* aShell) { return NS_OK; }
|
||||
NS_IMETHOD ContentChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
nsISupports* aSubContent) { return NS_OK; }
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2) { return NS_OK; }
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint) { return NS_OK; }
|
||||
NS_IMETHOD ContentAppended(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer);
|
||||
NS_IMETHOD ContentInserted(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
NS_IMETHOD ContentReplaced(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
nsIContent* aNewChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
NS_IMETHOD ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet) { return NS_OK; }
|
||||
NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet) { return NS_OK; }
|
||||
NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDisabled) { return NS_OK; }
|
||||
NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule,
|
||||
PRInt32 aHint) { return NS_OK; }
|
||||
NS_IMETHOD StyleRuleAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) { return NS_OK; }
|
||||
NS_IMETHOD StyleRuleRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) { return NS_OK; }
|
||||
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument);
|
||||
|
||||
protected:
|
||||
nsresult Match(nsIContent *aContent, PRBool *aMatch);
|
||||
nsresult Add(nsIContent *aContent);
|
||||
nsresult Remove(nsIContent *aContent);
|
||||
nsresult Reset();
|
||||
void Init(nsIDocument *aDocument);
|
||||
void PopulateWith(nsIContent *aContent, PRBool aIncludeRoot);
|
||||
PRBool MatchSelf(nsIContent *aContent);
|
||||
void PopulateSelf();
|
||||
void DisconnectFromDocument();
|
||||
PRBool IsDescendantOfRoot(nsIContent* aContainer);
|
||||
PRBool ContainsRoot(nsIContent* aContent);
|
||||
nsresult CheckDocumentExistence();
|
||||
|
||||
static nsIAtom* gWildCardAtom;
|
||||
|
||||
nsIAtom* mMatchAtom;
|
||||
PRInt32 mMatchNameSpaceId;
|
||||
nsContentListMatchFunc mFunc;
|
||||
nsString* mData;
|
||||
nsVoidArray mContent;
|
||||
void *mScriptObject;
|
||||
nsIDocument* mDocument;
|
||||
nsIContent* mRootContent;
|
||||
PRBool mMatchAll;
|
||||
};
|
||||
|
||||
#endif // nsContentList_h___
|
||||
480
mozilla/content/base/src/nsDOMAttribute.cpp
Normal file
480
mozilla/content/base/src/nsDOMAttribute.cpp
Normal file
@@ -0,0 +1,480 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsDOMAttribute.h"
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMAttrIID, NS_IDOMATTR_IID);
|
||||
static NS_DEFINE_IID(kIDOMAttributePrivateIID, NS_IDOMATTRIBUTEPRIVATE_IID);
|
||||
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
|
||||
static NS_DEFINE_IID(kIDOMNodeListIID, NS_IDOMNODELIST_IID);
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsDOMAttribute::nsDOMAttribute(nsIContent* aContent,
|
||||
const nsString& aName,
|
||||
const nsString& aValue)
|
||||
: mName(aName), mValue(aValue)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
// We don't add a reference to our content. It will tell us
|
||||
// to drop our reference when it goes away.
|
||||
mContent = aContent;
|
||||
mScriptObject = nsnull;
|
||||
mChild = nsnull;
|
||||
mChildList = nsnull;
|
||||
}
|
||||
|
||||
nsDOMAttribute::~nsDOMAttribute()
|
||||
{
|
||||
NS_IF_RELEASE(mChild);
|
||||
NS_IF_RELEASE(mChildList);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIDOMAttrIID)) {
|
||||
nsIDOMAttr* tmp = this;
|
||||
*aInstancePtr = (void*)tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
nsIScriptObjectOwner* tmp = this;
|
||||
*aInstancePtr = (void*)tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMAttributePrivateIID)) {
|
||||
nsIDOMAttributePrivate* tmp = this;
|
||||
*aInstancePtr = (void*)tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMNodeIID)) {
|
||||
nsIDOMNode* tmp = this;
|
||||
*aInstancePtr = (void*)tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
nsIDOMAttr* tmp1 = this;
|
||||
nsISupports* tmp2 = tmp1;
|
||||
*aInstancePtr = (void*)tmp2;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsDOMAttribute)
|
||||
NS_IMPL_RELEASE(nsDOMAttribute)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::DropReference()
|
||||
{
|
||||
mContent = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::SetContent(nsIContent* aContent)
|
||||
{
|
||||
mContent = aContent;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetContent(nsIContent** aContent)
|
||||
{
|
||||
*aContent = mContent;
|
||||
NS_IF_ADDREF(mContent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::SetName(const nsString& aName)
|
||||
{
|
||||
mName=aName;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::GetScriptObject(nsIScriptContext *aContext,
|
||||
void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull == mScriptObject) {
|
||||
nsIDOMScriptObjectFactory *factory;
|
||||
|
||||
res = nsGenericElement::GetScriptObjectFactory(&factory);
|
||||
if (NS_OK != res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
res = factory->NewScriptAttr(aContext,
|
||||
(nsISupports *)(nsIDOMAttr *)this,
|
||||
(nsISupports *)mContent,
|
||||
(void **)&mScriptObject);
|
||||
NS_RELEASE(factory);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::GetName(nsString& aName)
|
||||
{
|
||||
aName=mName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::GetValue(nsString& aValue)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
if (nsnull != mContent) {
|
||||
nsIAtom* nameAtom;
|
||||
PRInt32 nameSpaceID;
|
||||
nsresult attrResult;
|
||||
|
||||
mContent->ParseAttributeString(mName, nameAtom, nameSpaceID);
|
||||
if (kNameSpaceID_Unknown == nameSpaceID) {
|
||||
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
|
||||
}
|
||||
attrResult = mContent->GetAttribute(nameSpaceID, nameAtom, mValue);
|
||||
if (NS_CONTENT_ATTR_NOT_THERE == attrResult) {
|
||||
mValue.Truncate();
|
||||
}
|
||||
NS_IF_RELEASE(nameAtom);
|
||||
}
|
||||
aValue=mValue;
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::SetValue(const nsString& aValue)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
if (nsnull != mContent) {
|
||||
nsIAtom* nameAtom;
|
||||
PRInt32 nameSpaceID;
|
||||
|
||||
mContent->ParseAttributeString(mName, nameAtom, nameSpaceID);
|
||||
if (kNameSpaceID_Unknown == nameSpaceID) {
|
||||
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
|
||||
}
|
||||
result = mContent->SetAttribute(nameSpaceID, nameAtom, aValue, PR_TRUE);
|
||||
NS_IF_RELEASE(nameAtom);
|
||||
}
|
||||
mValue=aValue;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::GetSpecified(PRBool* aSpecified)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
if (nsnull == mContent) {
|
||||
*aSpecified = PR_FALSE;
|
||||
}
|
||||
else {
|
||||
nsAutoString value;
|
||||
nsresult attrResult;
|
||||
nsIAtom* nameAtom;
|
||||
PRInt32 nameSpaceID;
|
||||
|
||||
mContent->ParseAttributeString(mName, nameAtom, nameSpaceID);
|
||||
if (kNameSpaceID_Unknown == nameSpaceID) {
|
||||
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
|
||||
}
|
||||
attrResult = mContent->GetAttribute(nameSpaceID, nameAtom, value);
|
||||
NS_IF_RELEASE(nameAtom);
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == attrResult) {
|
||||
*aSpecified = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
*aSpecified = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetNodeName(nsString& aNodeName)
|
||||
{
|
||||
return GetName(aNodeName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetNodeValue(nsString& aNodeValue)
|
||||
{
|
||||
return GetValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::SetNodeValue(const nsString& aNodeValue)
|
||||
{
|
||||
return SetValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = (PRUint16)nsIDOMNode::ATTRIBUTE_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetParentNode(nsIDOMNode** aParentNode)
|
||||
{
|
||||
*aParentNode = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
||||
{
|
||||
if (nsnull == mChildList) {
|
||||
mChildList = new nsAttributeChildList(this);
|
||||
if (nsnull == mChildList) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(mChildList);
|
||||
}
|
||||
|
||||
return mChildList->QueryInterface(kIDOMNodeListIID, (void**)aChildNodes);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::HasChildNodes(PRBool* aHasChildNodes)
|
||||
{
|
||||
*aHasChildNodes = PR_FALSE;
|
||||
if (nsnull != mChild) {
|
||||
*aHasChildNodes = PR_TRUE;
|
||||
}
|
||||
else if (nsnull != mContent) {
|
||||
nsAutoString value;
|
||||
|
||||
GetValue(value);
|
||||
if (0 < value.Length()) {
|
||||
*aHasChildNodes = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetFirstChild(nsIDOMNode** aFirstChild)
|
||||
{
|
||||
nsAutoString value;
|
||||
nsresult result;
|
||||
|
||||
result = GetValue(value);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
if (0 < value.Length()) {
|
||||
if (nsnull == mChild) {
|
||||
nsIContent* content;
|
||||
|
||||
result = NS_NewTextNode(&content);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
result = content->QueryInterface(kIDOMTextIID, (void**)&mChild);
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
mChild->SetData(value);
|
||||
result = mChild->QueryInterface(kIDOMNodeIID, (void**)aFirstChild);
|
||||
}
|
||||
else {
|
||||
*aFirstChild = nsnull;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetLastChild(nsIDOMNode** aLastChild)
|
||||
{
|
||||
return GetFirstChild(aLastChild);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
||||
{
|
||||
*aPreviousSibling = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{
|
||||
*aNextSibling = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
{
|
||||
*aAttributes = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsDOMAttribute* newAttr;
|
||||
|
||||
if (nsnull != mContent) {
|
||||
nsAutoString value;
|
||||
nsIAtom* nameAtom;
|
||||
PRInt32 nameSpaceID;
|
||||
|
||||
mContent->ParseAttributeString(mName, nameAtom, nameSpaceID);
|
||||
if (kNameSpaceID_Unknown == nameSpaceID) {
|
||||
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
|
||||
}
|
||||
mContent->GetAttribute(nameSpaceID, nameAtom, value);
|
||||
newAttr = new nsDOMAttribute(nsnull, mName, value);
|
||||
}
|
||||
else {
|
||||
newAttr = new nsDOMAttribute(nsnull, mName, mValue);
|
||||
}
|
||||
|
||||
if (nsnull == newAttr) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return newAttr->QueryInterface(kIDOMNodeIID, (void**)aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
if (nsnull != mContent) {
|
||||
nsIDOMNode* node;
|
||||
result = mContent->QueryInterface(kIDOMNodeIID, (void**)&node);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = node->GetOwnerDocument(aOwnerDocument);
|
||||
NS_RELEASE(node);
|
||||
}
|
||||
}
|
||||
else {
|
||||
*aOwnerDocument = nsnull;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsAttributeChildList::nsAttributeChildList(nsDOMAttribute* aAttribute)
|
||||
{
|
||||
// Don't increment the reference count. The attribute will tell
|
||||
// us when it's going away
|
||||
mAttribute = aAttribute;
|
||||
}
|
||||
|
||||
nsAttributeChildList::~nsAttributeChildList()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAttributeChildList::GetLength(PRUint32* aLength)
|
||||
{
|
||||
nsAutoString value;
|
||||
|
||||
*aLength = 0;
|
||||
if (nsnull != mAttribute) {
|
||||
mAttribute->GetValue(value);
|
||||
if (0 < value.Length()) {
|
||||
*aLength = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAttributeChildList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
if ((nsnull != mAttribute) && (0 == aIndex)) {
|
||||
mAttribute->GetFirstChild(aReturn);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsAttributeChildList::DropReference()
|
||||
{
|
||||
mAttribute = nsnull;
|
||||
}
|
||||
128
mozilla/content/base/src/nsDOMAttribute.h
Normal file
128
mozilla/content/base/src/nsDOMAttribute.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsDOMAttribute_h___
|
||||
#define nsDOMAttribute_h___
|
||||
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsDOMAttribute;
|
||||
|
||||
#define NS_IDOMATTRIBUTEPRIVATE_IID \
|
||||
{0xa6cf90dd, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
class nsIDOMAttributePrivate : public nsISupports {
|
||||
public:
|
||||
NS_IMETHOD DropReference() = 0;
|
||||
NS_IMETHOD SetContent(nsIContent* aContent) = 0;
|
||||
NS_IMETHOD GetContent(nsIContent** aContent) = 0;
|
||||
NS_IMETHOD SetName(const nsString& aName) = 0;
|
||||
};
|
||||
|
||||
// bogus child list for an attribute
|
||||
class nsAttributeChildList : public nsGenericDOMNodeList
|
||||
{
|
||||
public:
|
||||
nsAttributeChildList(nsDOMAttribute* aAttribute);
|
||||
virtual ~nsAttributeChildList();
|
||||
|
||||
// interface nsIDOMNodeList
|
||||
NS_IMETHOD GetLength(PRUint32* aLength);
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
|
||||
|
||||
void DropReference();
|
||||
|
||||
protected:
|
||||
nsDOMAttribute* mAttribute;
|
||||
};
|
||||
|
||||
// Attribute helper class used to wrap up an attribute with a dom
|
||||
// object that implements nsIDOMAttr and nsIDOMNode and
|
||||
// nsIScriptObjectOwner
|
||||
class nsDOMAttribute : public nsIDOMAttr,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMAttributePrivate
|
||||
{
|
||||
public:
|
||||
nsDOMAttribute(nsIContent* aContent,
|
||||
const nsString& aName,
|
||||
const nsString& aValue);
|
||||
virtual ~nsDOMAttribute();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
// nsIDOMAttr interface
|
||||
NS_IMETHOD GetSpecified(PRBool* aSpecified);
|
||||
NS_IMETHOD GetName(nsString& aReturn);
|
||||
NS_IMETHOD GetValue(nsString& aReturn);
|
||||
NS_IMETHOD SetValue(const nsString& aValue);
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_IMETHOD GetNodeName(nsString& aNodeName);
|
||||
NS_IMETHOD GetNodeValue(nsString& aNodeValue);
|
||||
NS_IMETHOD SetNodeValue(const nsString& aNodeValue);
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType);
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode);
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes);
|
||||
NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes);
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild);
|
||||
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild);
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling);
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling);
|
||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes);
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn);
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn);
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
|
||||
|
||||
// nsIDOMAttributePrivate interface
|
||||
NS_IMETHOD DropReference();
|
||||
NS_IMETHOD SetContent(nsIContent* aContent);
|
||||
NS_IMETHOD GetContent(nsIContent** aContent);
|
||||
NS_IMETHOD SetName(const nsString& aName);
|
||||
|
||||
private:
|
||||
nsIContent* mContent;
|
||||
nsString mName;
|
||||
nsString mValue;
|
||||
// XXX For now, there's only a single child - a text
|
||||
// element representing the value
|
||||
nsIDOMText* mChild;
|
||||
nsAttributeChildList* mChildList;
|
||||
void* mScriptObject;
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsDOMAttribute_h___ */
|
||||
508
mozilla/content/base/src/nsDOMAttributeMap.cpp
Normal file
508
mozilla/content/base/src/nsDOMAttributeMap.cpp
Normal file
@@ -0,0 +1,508 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsDOMAttributeMap.h"
|
||||
#include "nsDOMAttribute.h"
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsDOMError.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMNamedNodeMapIID, NS_IDOMNAMEDNODEMAP_IID);
|
||||
static NS_DEFINE_IID(kIDOMAttrIID, NS_IDOMATTR_IID);
|
||||
static NS_DEFINE_IID(kIDOMAttributePrivateIID, NS_IDOMATTRIBUTEPRIVATE_IID);
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsDOMAttributeMap::nsDOMAttributeMap(nsIContent* aContent)
|
||||
: mContent(aContent)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mScriptObject = nsnull;
|
||||
mAttributes = nsnull;
|
||||
// We don't add a reference to our content. If it goes away,
|
||||
// we'll be told to drop our reference
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK (PRIntn)
|
||||
RemoveAttributes(PLHashEntry* he, PRIntn i, void* arg)
|
||||
{
|
||||
nsIDOMAttr* attr = (nsIDOMAttr*)he->value;
|
||||
char* str = (char*)he->key;
|
||||
|
||||
if (nsnull != attr) {
|
||||
nsIDOMAttributePrivate* attrPrivate;
|
||||
attr->QueryInterface(kIDOMAttributePrivateIID, (void**)&attrPrivate);
|
||||
attrPrivate->DropReference();
|
||||
NS_RELEASE(attrPrivate);
|
||||
NS_RELEASE(attr);
|
||||
}
|
||||
delete [] str;
|
||||
|
||||
return HT_ENUMERATE_REMOVE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK (PRIntn)
|
||||
DropReferencesInAttributes(PLHashEntry* he, PRIntn i, void* arg)
|
||||
{
|
||||
nsDOMAttribute* attr = (nsDOMAttribute*)he->value;
|
||||
|
||||
if (nsnull != attr) {
|
||||
nsIDOMAttributePrivate* attrPrivate;
|
||||
attr->QueryInterface(kIDOMAttributePrivateIID, (void**)&attrPrivate);
|
||||
attrPrivate->DropReference();
|
||||
NS_RELEASE(attrPrivate);
|
||||
}
|
||||
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
|
||||
nsDOMAttributeMap::~nsDOMAttributeMap()
|
||||
{
|
||||
if (nsnull != mAttributes) {
|
||||
PL_HashTableEnumerateEntries(mAttributes, RemoveAttributes, nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMAttributeMap::DropReference()
|
||||
{
|
||||
mContent = nsnull;
|
||||
if (nsnull != mAttributes) {
|
||||
PL_HashTableEnumerateEntries(mAttributes, DropReferencesInAttributes, nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIDOMNamedNodeMapIID)) {
|
||||
nsIDOMNamedNodeMap* tmp = this;
|
||||
*aInstancePtr = (void*)tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
nsIScriptObjectOwner* tmp = this;
|
||||
*aInstancePtr = (void*)tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
nsIDOMNamedNodeMap* tmp1 = this;
|
||||
nsISupports* tmp2 = tmp1;
|
||||
*aInstancePtr = (void*)tmp2;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsDOMAttributeMap)
|
||||
NS_IMPL_RELEASE(nsDOMAttributeMap)
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::GetScriptObject(nsIScriptContext *aContext,
|
||||
void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull == mScriptObject) {
|
||||
nsIDOMScriptObjectFactory *factory;
|
||||
|
||||
res = nsGenericElement::GetScriptObjectFactory(&factory);
|
||||
if (NS_OK != res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
res = factory->NewScriptNamedNodeMap(aContext,
|
||||
(nsISupports *)(nsIDOMNamedNodeMap *)this,
|
||||
(nsISupports *)mContent,
|
||||
(void**)&mScriptObject);
|
||||
NS_RELEASE(factory);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PLHashTable*
|
||||
nsDOMAttributeMap::GetAttributeTable()
|
||||
{
|
||||
if ((nsnull == mAttributes) && (nsnull != mContent)) {
|
||||
PRInt32 count;
|
||||
mContent->GetAttributeCount(count);
|
||||
mAttributes = PL_NewHashTable(count, PL_HashString, PL_CompareStrings,
|
||||
PL_CompareValues, nsnull, nsnull);
|
||||
}
|
||||
|
||||
return mAttributes;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::GetNamedItemCommon(const nsString& aAttrName,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aNameAtom,
|
||||
nsIDOMNode** aAttribute)
|
||||
{
|
||||
nsIDOMAttr* attribute;
|
||||
char buf[128];
|
||||
nsresult result = NS_OK;
|
||||
|
||||
PLHashTable* attrHash = GetAttributeTable();
|
||||
aAttrName.ToCString(buf, sizeof(buf));
|
||||
if (nsnull != attrHash) {
|
||||
attribute = (nsIDOMAttr*)PL_HashTableLookup(attrHash, buf);
|
||||
if (nsnull == attribute) {
|
||||
nsresult attrResult;
|
||||
nsAutoString value;
|
||||
attrResult = mContent->GetAttribute(aNameSpaceID, aNameAtom, value);
|
||||
if (NS_CONTENT_ATTR_NOT_THERE != attrResult) {
|
||||
nsDOMAttribute* domAttribute;
|
||||
domAttribute = new nsDOMAttribute(mContent, aAttrName, value);
|
||||
if (nsnull == domAttribute) {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else {
|
||||
result = domAttribute->QueryInterface(kIDOMAttrIID,
|
||||
(void **)&attribute);
|
||||
char* hashKey = aAttrName.ToNewCString();
|
||||
PL_HashTableAdd(attrHash, hashKey, attribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nsnull != attribute) {
|
||||
result = attribute->QueryInterface(kIDOMNodeIID, (void**)aAttribute);
|
||||
}
|
||||
else {
|
||||
*aAttribute = nsnull;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMAttributeMap::GetNormalizedName(PRInt32 aNameSpaceID,
|
||||
nsIAtom* aNameAtom,
|
||||
nsString& aAttrName)
|
||||
{
|
||||
nsIAtom* prefix;
|
||||
aAttrName.Truncate();
|
||||
mContent->GetNameSpacePrefixFromId(aNameSpaceID, prefix);
|
||||
|
||||
if (nsnull != prefix) {
|
||||
prefix->ToString(aAttrName);
|
||||
aAttrName.Append(":");
|
||||
NS_RELEASE(prefix);
|
||||
}
|
||||
|
||||
if (nsnull != aNameAtom) {
|
||||
nsAutoString tmp;
|
||||
|
||||
aNameAtom->ToString(tmp);
|
||||
aAttrName.Append(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::GetNamedItem(const nsString &aAttrName,
|
||||
nsIDOMNode** aAttribute)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
if (nsnull != mContent) {
|
||||
nsIAtom* nameAtom;
|
||||
PRInt32 nameSpaceID;
|
||||
nsAutoString normalizedName;
|
||||
|
||||
mContent->ParseAttributeString(aAttrName, nameAtom, nameSpaceID);
|
||||
if (kNameSpaceID_Unknown == nameSpaceID) {
|
||||
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
|
||||
}
|
||||
GetNormalizedName(nameSpaceID, nameAtom, normalizedName);
|
||||
result = GetNamedItemCommon(normalizedName,
|
||||
nameSpaceID,
|
||||
nameAtom,
|
||||
aAttribute);
|
||||
NS_IF_RELEASE(nameAtom);
|
||||
}
|
||||
else {
|
||||
*aAttribute = nsnull;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::SetNamedItem(nsIDOMNode *aNode, nsIDOMNode **aReturn)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMAttr* attribute;
|
||||
|
||||
if (nsnull == aNode) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
if (nsnull != mContent) {
|
||||
result = aNode->QueryInterface(kIDOMAttrIID, (void**)&attribute);
|
||||
if (NS_OK == result) {
|
||||
PLHashTable* attrHash;
|
||||
|
||||
attrHash = GetAttributeTable();
|
||||
if (nsnull != attrHash) {
|
||||
nsIDOMNode* oldAttribute;
|
||||
nsIDOMAttributePrivate* attrPrivate;
|
||||
nsAutoString name, value;
|
||||
char buf[128];
|
||||
char* key;
|
||||
nsIAtom* nameAtom;
|
||||
PRInt32 nameSpaceID;
|
||||
|
||||
// Get normalized attribute name
|
||||
attribute->GetName(name);
|
||||
mContent->ParseAttributeString(name, nameAtom, nameSpaceID);
|
||||
if (kNameSpaceID_Unknown == nameSpaceID) {
|
||||
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
|
||||
}
|
||||
GetNormalizedName(nameSpaceID, nameAtom, name);
|
||||
name.ToCString(buf, sizeof(buf));
|
||||
result = GetNamedItemCommon(name, nameSpaceID, nameAtom, &oldAttribute);
|
||||
|
||||
if (nsnull != oldAttribute) {
|
||||
nsIDOMAttributePrivate* oldAttributePrivate;
|
||||
PLHashEntry** he;
|
||||
|
||||
// Remove the attribute from the hash table, cleaning
|
||||
// the hash table entry as we go about it.
|
||||
he = PL_HashTableRawLookup(attrHash, PL_HashString(buf), buf);
|
||||
key = (char*)(*he)->key;
|
||||
PL_HashTableRemove(attrHash, buf);
|
||||
if (nsnull != key) {
|
||||
delete [] key;
|
||||
}
|
||||
|
||||
result = oldAttribute->QueryInterface(kIDOMAttributePrivateIID,
|
||||
(void **)&oldAttributePrivate);
|
||||
if (NS_OK == result) {
|
||||
oldAttributePrivate->DropReference();
|
||||
NS_RELEASE(oldAttributePrivate);
|
||||
}
|
||||
|
||||
*aReturn = oldAttribute;
|
||||
|
||||
// Drop the reference held in the hash table
|
||||
NS_RELEASE(oldAttribute);
|
||||
}
|
||||
else {
|
||||
*aReturn = nsnull;
|
||||
}
|
||||
|
||||
attribute->GetValue(value);
|
||||
|
||||
// Associate the new attribute with the content
|
||||
key = name.ToNewCString();
|
||||
result = attribute->QueryInterface(kIDOMAttributePrivateIID,
|
||||
(void **)&attrPrivate);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
nsIContent* owner;
|
||||
|
||||
attrPrivate->GetContent(&owner);
|
||||
if (owner) {
|
||||
// The old attribute is already associated with another
|
||||
// piece of content.
|
||||
result = NS_ERROR_DOM_INUSE_ATTRIBUTE_ERR;
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
else {
|
||||
attrPrivate->SetContent(mContent);
|
||||
attrPrivate->SetName(name);
|
||||
|
||||
// Add the new attribute node to the hash table (maintaining
|
||||
// a reference to it)
|
||||
PL_HashTableAdd(attrHash, key, attribute);
|
||||
|
||||
// Set the attribute on the content
|
||||
result = mContent->SetAttribute(nameSpaceID, nameAtom, value, PR_TRUE);
|
||||
NS_IF_RELEASE(nameAtom);
|
||||
}
|
||||
NS_RELEASE(attrPrivate);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*aReturn = nsnull;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttributeMap::RemoveNamedItem(const nsString& aName, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
if (nsnull != mContent) {
|
||||
PLHashTable* attrHash;
|
||||
|
||||
attrHash = GetAttributeTable();
|
||||
if (nsnull != attrHash) {
|
||||
nsIDOMNode* attribute;
|
||||
nsIDOMAttributePrivate* attrPrivate;
|
||||
char buf[128];
|
||||
char* key;
|
||||
nsIAtom* nameAtom;
|
||||
PRInt32 nameSpaceID;
|
||||
nsAutoString name;
|
||||
|
||||
mContent->ParseAttributeString(aName, nameAtom, nameSpaceID);
|
||||
if (kNameSpaceID_Unknown == nameSpaceID) {
|
||||
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
|
||||
}
|
||||
GetNormalizedName(nameSpaceID, nameAtom, name);
|
||||
name.ToCString(buf, sizeof(buf));
|
||||
result = GetNamedItemCommon(name, nameSpaceID, nameAtom, &attribute);
|
||||
|
||||
if (nsnull != attribute) {
|
||||
PLHashEntry** he;
|
||||
|
||||
// Remove the attribute from the hash table, cleaning
|
||||
// the hash table entry as we go about it.
|
||||
he = PL_HashTableRawLookup(attrHash, PL_HashString(buf), buf);
|
||||
key = (char*)(*he)->key;
|
||||
|
||||
PL_HashTableRemove(attrHash, buf);
|
||||
if (nsnull != key) {
|
||||
delete [] key;
|
||||
}
|
||||
|
||||
result = attribute->QueryInterface(kIDOMAttributePrivateIID,
|
||||
(void **)&attrPrivate);
|
||||
if (NS_OK == result) {
|
||||
attrPrivate->DropReference();
|
||||
NS_RELEASE(attrPrivate);
|
||||
}
|
||||
|
||||
*aReturn = attribute;
|
||||
|
||||
// Drop the reference held in the hash table
|
||||
NS_RELEASE(attribute);
|
||||
}
|
||||
else {
|
||||
result = NS_ERROR_DOM_NOT_FOUND_ERR;
|
||||
*aReturn = nsnull;
|
||||
}
|
||||
|
||||
// Unset the attribute in the content
|
||||
result = mContent->UnsetAttribute(nameSpaceID, nameAtom, PR_TRUE);
|
||||
NS_IF_RELEASE(nameAtom);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
PRInt32 nameSpaceID;
|
||||
nsIAtom* nameAtom = nsnull;
|
||||
nsresult result = NS_OK;
|
||||
if ((nsnull != mContent) &&
|
||||
NS_SUCCEEDED(mContent->GetAttributeNameAt(aIndex,
|
||||
nameSpaceID,
|
||||
nameAtom))) {
|
||||
nsAutoString attrName;
|
||||
|
||||
GetNormalizedName(nameSpaceID, nameAtom, attrName);
|
||||
result = GetNamedItemCommon(attrName, nameSpaceID, nameAtom, aReturn);
|
||||
NS_IF_RELEASE(nameAtom);
|
||||
}
|
||||
else {
|
||||
*aReturn = nsnull;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::GetLength(PRUint32 *aLength)
|
||||
{
|
||||
PRInt32 n;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (nsnull != mContent) {
|
||||
rv = mContent->GetAttributeCount(n);
|
||||
*aLength = PRUint32(n);
|
||||
}
|
||||
else {
|
||||
*aLength = 0;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
PR_STATIC_CALLBACK (PRIntn)
|
||||
SizeAttributes(PLHashEntry* he, PRIntn i, void* arg)
|
||||
{
|
||||
char* str = (char*)he->key;
|
||||
PRUint32 size = sizeof(PLHashEntry);
|
||||
if (str) {
|
||||
size += PL_strlen(str) + 1;
|
||||
}
|
||||
PRUint32* sump = (PRUint32*) arg;
|
||||
*sump = *sump + size;
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::SizeOfNamedNodeMap(nsIDOMNamedNodeMap* aMap,
|
||||
nsISizeOfHandler* aSizer,
|
||||
PRUint32* aResult)
|
||||
{
|
||||
if (!aResult) return NS_ERROR_NULL_POINTER;
|
||||
nsDOMAttributeMap* map = (nsDOMAttributeMap*) aMap;
|
||||
PRUint32 sum = sizeof(nsDOMAttributeMap);
|
||||
if (map->mAttributes) {
|
||||
sum += sizeof(*map->mAttributes);
|
||||
PRUint32 esize = 0;
|
||||
PL_HashTableEnumerateEntries(map->mAttributes, SizeAttributes,
|
||||
(void*) &esize);
|
||||
sum += esize;
|
||||
}
|
||||
*aResult = sum;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
80
mozilla/content/base/src/nsDOMAttributeMap.h
Normal file
80
mozilla/content/base/src/nsDOMAttributeMap.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsDOMAttributeMap_h___
|
||||
#define nsDOMAttributeMap_h___
|
||||
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
#include "plhash.h"
|
||||
|
||||
class nsIContent;
|
||||
|
||||
// Helper class that implements the nsIDOMNamedNodeMap interface.
|
||||
class nsDOMAttributeMap : public nsIDOMNamedNodeMap,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
public:
|
||||
nsDOMAttributeMap(nsIContent* aContent);
|
||||
virtual ~nsDOMAttributeMap();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
// nsIDOMNamedNodeMap interface
|
||||
NS_IMETHOD GetLength(PRUint32* aSize);
|
||||
NS_IMETHOD GetNamedItem(const nsString& aName, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD SetNamedItem(nsIDOMNode* aNode, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD RemoveNamedItem(const nsString& aName, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
|
||||
|
||||
void DropReference();
|
||||
|
||||
#ifdef DEBUG
|
||||
static nsresult SizeOfNamedNodeMap(nsIDOMNamedNodeMap* aMap,
|
||||
nsISizeOfHandler* aSizer,
|
||||
PRUint32* aResult);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
nsresult GetNamedItemCommon(const nsString& aAttrName,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aNameAtom,
|
||||
nsIDOMNode** aAttribute);
|
||||
void GetNormalizedName(PRInt32 aNameSpaceID,
|
||||
nsIAtom* aNameAtom,
|
||||
nsString& aAttrName);
|
||||
PLHashTable* GetAttributeTable();
|
||||
|
||||
private:
|
||||
nsIContent* mContent;
|
||||
// XXX We really don't need to use a hashtable here.
|
||||
// We generally deal with a small number of attributes
|
||||
PLHashTable* mAttributes;
|
||||
void* mScriptObject;
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsDOMAttributeMap_h___ */
|
||||
3100
mozilla/content/base/src/nsDocument.cpp
Normal file
3100
mozilla/content/base/src/nsDocument.cpp
Normal file
File diff suppressed because it is too large
Load Diff
488
mozilla/content/base/src/nsDocument.h
Normal file
488
mozilla/content/base/src/nsDocument.h
Normal file
@@ -0,0 +1,488 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsDocument_h___
|
||||
#define nsDocument_h___
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMNSDocument.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDiskDocument.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsXIFConverter.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
#include "nsIPrincipal.h"
|
||||
|
||||
class nsIEventListenerManager;
|
||||
class nsDOMStyleSheetCollection;
|
||||
class nsIOutputStream;
|
||||
class nsDocument;
|
||||
|
||||
#if 0
|
||||
class nsPostData : public nsIPostData {
|
||||
public:
|
||||
nsPostData(PRBool aIsFile, char* aData);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
virtual PRBool IsFile();
|
||||
virtual const char* GetData();
|
||||
virtual PRInt32 GetDataLength();
|
||||
|
||||
protected:
|
||||
virtual ~nsPostData();
|
||||
|
||||
PRBool mIsFile;
|
||||
char* mData;
|
||||
PRInt32 mDataLen;
|
||||
};
|
||||
#endif
|
||||
|
||||
class nsDocHeaderData
|
||||
{
|
||||
public:
|
||||
nsDocHeaderData(nsIAtom* aField, const nsString& aData)
|
||||
{
|
||||
mField = aField;
|
||||
NS_IF_ADDREF(mField);
|
||||
mData = aData;
|
||||
mNext = nsnull;
|
||||
}
|
||||
~nsDocHeaderData(void)
|
||||
{
|
||||
NS_IF_RELEASE(mField);
|
||||
if (nsnull != mNext) {
|
||||
delete mNext;
|
||||
mNext = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
nsIAtom* mField;
|
||||
nsAutoString mData;
|
||||
nsDocHeaderData* mNext;
|
||||
};
|
||||
|
||||
// Represents the children of a document (prolog, epilog and
|
||||
// document element)
|
||||
class nsDocumentChildNodes : public nsGenericDOMNodeList
|
||||
{
|
||||
public:
|
||||
nsDocumentChildNodes(nsIDocument* aDocument);
|
||||
~nsDocumentChildNodes();
|
||||
|
||||
NS_IMETHOD GetLength(PRUint32* aLength);
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
|
||||
|
||||
void DropReference();
|
||||
|
||||
protected:
|
||||
nsIDocument* mDocument;
|
||||
};
|
||||
|
||||
// Base class for our document implementations
|
||||
class nsDocument : public nsIDocument,
|
||||
public nsIDOMDocument,
|
||||
public nsIDOMNSDocument,
|
||||
public nsIDiskDocument,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIJSScriptObject,
|
||||
public nsSupportsWeakReference,
|
||||
public nsIDOMEventReceiver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
virtual nsIArena* GetArena();
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener);
|
||||
|
||||
/**
|
||||
* Return the title of the document. May return null.
|
||||
*/
|
||||
virtual const nsString* GetDocumentTitle() const;
|
||||
|
||||
/**
|
||||
* Return the URL for the document. May return null.
|
||||
*/
|
||||
virtual nsIURI* GetDocumentURL() const;
|
||||
|
||||
/**
|
||||
* Return the principal responsible for this document.
|
||||
*/
|
||||
virtual nsIPrincipal* GetDocumentPrincipal();
|
||||
|
||||
/**
|
||||
* Return the content (mime) type of this document.
|
||||
*/
|
||||
NS_IMETHOD GetContentType(nsString& aContentType) const;
|
||||
|
||||
/**
|
||||
* Return the LoadGroup for the document. May return null.
|
||||
*/
|
||||
NS_IMETHOD GetDocumentLoadGroup(nsILoadGroup **aGroup) const;
|
||||
|
||||
/**
|
||||
* Return the base URL for realtive URLs in the document. May return null (or the document URL).
|
||||
*/
|
||||
NS_IMETHOD GetBaseURL(nsIURI*& aURL) const;
|
||||
|
||||
/**
|
||||
* Return a standard name for the document's character set. This will
|
||||
* trigger a startDocumentLoad if necessary to answer the question.
|
||||
*/
|
||||
NS_IMETHOD GetDocumentCharacterSet(nsString& oCharsetID);
|
||||
NS_IMETHOD SetDocumentCharacterSet(const nsString& aCharSetID);
|
||||
|
||||
/**
|
||||
* Return the Line Breaker for the document
|
||||
*/
|
||||
NS_IMETHOD GetLineBreaker(nsILineBreaker** aResult) ;
|
||||
NS_IMETHOD SetLineBreaker(nsILineBreaker* aLineBreaker) ;
|
||||
NS_IMETHOD GetWordBreaker(nsIWordBreaker** aResult) ;
|
||||
NS_IMETHOD SetWordBreaker(nsIWordBreaker* aWordBreaker) ;
|
||||
|
||||
/**
|
||||
* Access HTTP header data (this may also get set from other sources, like
|
||||
* HTML META tags).
|
||||
*/
|
||||
NS_IMETHOD GetHeaderData(nsIAtom* aHeaderField, nsString& aData) const;
|
||||
NS_IMETHOD SetHeaderData(nsIAtom* aheaderField, const nsString& aData);
|
||||
|
||||
/**
|
||||
* Create a new presentation shell that will use aContext for
|
||||
* it's presentation context (presentation context's <b>must not</b> be
|
||||
* shared among multiple presentation shell's).
|
||||
*/
|
||||
#if 0
|
||||
// XXX Temp hack: moved to nsMarkupDocument
|
||||
NS_IMETHOD CreateShell(nsIPresContext* aContext,
|
||||
nsIViewManager* aViewManager,
|
||||
nsIStyleSet* aStyleSet,
|
||||
nsIPresShell** aInstancePtrResult);
|
||||
#endif
|
||||
virtual PRBool DeleteShell(nsIPresShell* aShell);
|
||||
virtual PRInt32 GetNumberOfShells();
|
||||
virtual nsIPresShell* GetShellAt(PRInt32 aIndex);
|
||||
|
||||
/**
|
||||
* Return the parent document of this document. Will return null
|
||||
* unless this document is within a compound document and has a parent.
|
||||
*/
|
||||
virtual nsIDocument* GetParentDocument();
|
||||
virtual void SetParentDocument(nsIDocument* aParent);
|
||||
virtual void AddSubDocument(nsIDocument* aSubDoc);
|
||||
virtual PRInt32 GetNumberOfSubDocuments();
|
||||
virtual nsIDocument* GetSubDocumentAt(PRInt32 aIndex);
|
||||
|
||||
/**
|
||||
* Return the root content object for this document.
|
||||
*/
|
||||
virtual nsIContent* GetRootContent();
|
||||
virtual void SetRootContent(nsIContent* aRoot);
|
||||
|
||||
/**
|
||||
* Methods to append to the prolog and epilog of
|
||||
* a document. The prolog is the content before the document
|
||||
* element, the epilog after.
|
||||
*/
|
||||
NS_IMETHOD AppendToProlog(nsIContent* aContent);
|
||||
NS_IMETHOD AppendToEpilog(nsIContent* aContent);
|
||||
|
||||
/**
|
||||
* Get the direct children of the document - content in
|
||||
* the prolog, the root content and content in the epilog.
|
||||
*/
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const;
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const;
|
||||
NS_IMETHOD GetChildCount(PRInt32& aCount);
|
||||
|
||||
/**
|
||||
* Get the style sheets owned by this document.
|
||||
* These are ordered, highest priority last
|
||||
*/
|
||||
virtual PRInt32 GetNumberOfStyleSheets();
|
||||
virtual nsIStyleSheet* GetStyleSheetAt(PRInt32 aIndex);
|
||||
virtual PRInt32 GetIndexOfStyleSheet(nsIStyleSheet* aSheet);
|
||||
virtual void AddStyleSheet(nsIStyleSheet* aSheet);
|
||||
virtual void RemoveStyleSheet(nsIStyleSheet* aSheet);
|
||||
NS_IMETHOD InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex, PRBool aNotify);
|
||||
virtual void SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
|
||||
PRBool mDisabled);
|
||||
|
||||
/**
|
||||
* Set the object from which a document can get a script context.
|
||||
* This is the context within which all scripts (during document
|
||||
* creation and during event handling) will run.
|
||||
*/
|
||||
NS_IMETHOD GetScriptGlobalObject(nsIScriptGlobalObject** aGlobalObject);
|
||||
NS_IMETHOD SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject);
|
||||
|
||||
/**
|
||||
* Get the name space manager for this document
|
||||
*/
|
||||
NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager);
|
||||
|
||||
/**
|
||||
* Add a new observer of document change notifications. Whenever
|
||||
* content is changed, appended, inserted or removed the observers are
|
||||
* informed.
|
||||
*/
|
||||
virtual void AddObserver(nsIDocumentObserver* aObserver);
|
||||
|
||||
/**
|
||||
* Remove an observer of document change notifications. This will
|
||||
* return false if the observer cannot be found.
|
||||
*/
|
||||
virtual PRBool RemoveObserver(nsIDocumentObserver* aObserver);
|
||||
|
||||
// Observation hooks used by content nodes to propagate
|
||||
// notifications to document observers.
|
||||
NS_IMETHOD BeginLoad();
|
||||
NS_IMETHOD EndLoad();
|
||||
NS_IMETHOD ContentChanged(nsIContent* aContent,
|
||||
nsISupports* aSubContent);
|
||||
NS_IMETHOD ContentStatesChanged(nsIContent* aContent1, nsIContent* aContent2);
|
||||
NS_IMETHOD AttributeChanged(nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint);
|
||||
NS_IMETHOD ContentAppended(nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer);
|
||||
NS_IMETHOD ContentInserted(nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
NS_IMETHOD ContentReplaced(nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
nsIContent* aNewChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
NS_IMETHOD ContentRemoved(nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
|
||||
NS_IMETHOD StyleRuleChanged(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule,
|
||||
PRInt32 aHint); // See nsStyleConsts fot hint values
|
||||
NS_IMETHOD StyleRuleAdded(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule);
|
||||
NS_IMETHOD StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule);
|
||||
|
||||
/**
|
||||
* Finds text in content
|
||||
*/
|
||||
NS_IMETHOD FindNext(const nsString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound);
|
||||
|
||||
/**
|
||||
* Converts the document or a selection of the
|
||||
* document to XIF (XML Interchange Format)
|
||||
* and places the result in aBuffer.
|
||||
*/
|
||||
NS_IMETHOD CreateXIF(nsString & aBuffer, nsIDOMSelection* aSelection);
|
||||
NS_IMETHOD ToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
|
||||
virtual void BeginConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
|
||||
virtual void ConvertChildrenToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
|
||||
virtual void FinishConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
// nsIDOMDocument interface
|
||||
NS_IMETHOD GetDoctype(nsIDOMDocumentType** aDoctype);
|
||||
NS_IMETHOD GetImplementation(nsIDOMDOMImplementation** aImplementation);
|
||||
NS_IMETHOD GetDocumentElement(nsIDOMElement** aDocumentElement);
|
||||
|
||||
NS_IMETHOD CreateElement(const nsString& aTagName, nsIDOMElement** aReturn);
|
||||
NS_IMETHOD CreateDocumentFragment(nsIDOMDocumentFragment** aReturn);
|
||||
NS_IMETHOD CreateTextNode(const nsString& aData, nsIDOMText** aReturn);
|
||||
NS_IMETHOD CreateComment(const nsString& aData, nsIDOMComment** aReturn);
|
||||
NS_IMETHOD CreateCDATASection(const nsString& aData, nsIDOMCDATASection** aReturn);
|
||||
NS_IMETHOD CreateProcessingInstruction(const nsString& aTarget, const nsString& aData, nsIDOMProcessingInstruction** aReturn);
|
||||
NS_IMETHOD CreateAttribute(const nsString& aName, nsIDOMAttr** aReturn);
|
||||
NS_IMETHOD CreateEntityReference(const nsString& aName, nsIDOMEntityReference** aReturn);
|
||||
NS_IMETHOD GetElementsByTagName(const nsString& aTagname, nsIDOMNodeList** aReturn);
|
||||
NS_IMETHOD GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets);
|
||||
NS_IMETHOD CreateElementWithNameSpace(const nsString& aTagName,
|
||||
const nsString& aNameSpace,
|
||||
nsIDOMElement** aReturn);
|
||||
NS_IMETHOD CreateRange(nsIDOMRange** aReturn);
|
||||
NS_IMETHOD GetWidth(PRInt32* aWidth);
|
||||
NS_IMETHOD GetHeight(PRInt32* aHeight);
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_IMETHOD GetNodeName(nsString& aNodeName);
|
||||
NS_IMETHOD GetNodeValue(nsString& aNodeValue);
|
||||
NS_IMETHOD SetNodeValue(const nsString& aNodeValue);
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType);
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode);
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes);
|
||||
NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes);
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild);
|
||||
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild);
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling);
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling);
|
||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes);
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
|
||||
// nsIDOMEventReceiver interface
|
||||
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
NS_IMETHOD GetNewListenerManager(nsIEventListenerManager **aInstancePtrResult);
|
||||
|
||||
// nsIDiskDocument inteface
|
||||
NS_IMETHOD InitDiskDocument(nsFileSpec *aFileSpec);
|
||||
NS_IMETHOD SaveFile( nsFileSpec* aFileSpec,
|
||||
PRBool aReplaceExisting,
|
||||
PRBool aSaveCopy,
|
||||
ESaveFileType aSaveFileType,
|
||||
const nsString& aSaveCharset);
|
||||
|
||||
NS_IMETHOD GetFileSpec(nsFileSpec& aFileSpec);
|
||||
NS_IMETHOD GetModCount(PRInt32 *outModCount);
|
||||
NS_IMETHOD ResetModCount();
|
||||
NS_IMETHOD IncrementModCount(PRInt32 aNumMods);
|
||||
|
||||
// nsIDOMEventTarget interface
|
||||
NS_IMETHOD AddEventListener(const nsString& aType, nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture);
|
||||
NS_IMETHOD RemoveEventListener(const nsString& aType, nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture);
|
||||
|
||||
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus);
|
||||
|
||||
|
||||
virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const;
|
||||
virtual nsIContent* GetPrevContent(const nsIContent *aContent) const;
|
||||
virtual nsIContent* GetNextContent(const nsIContent *aContent) const;
|
||||
virtual void SetDisplaySelection(PRBool aToggle);
|
||||
virtual PRBool GetDisplaySelection() const;
|
||||
|
||||
// nsIJSScriptObject interface
|
||||
virtual PRBool AddProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
virtual PRBool DeleteProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
virtual PRBool GetProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
virtual PRBool SetProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
virtual PRBool EnumerateProperty(JSContext *aContext);
|
||||
virtual PRBool Resolve(JSContext *aContext, jsval aID);
|
||||
virtual PRBool Convert(JSContext *aContext, jsval aID);
|
||||
virtual void Finalize(JSContext *aContext);
|
||||
|
||||
/**
|
||||
* Methods to output the document contents as Text or HTML, outputting into
|
||||
* the given output stream. If charset is not an empty string, the contents
|
||||
* will be converted into the given charset.
|
||||
*
|
||||
* If the selection is passed in is not null, only the selected content
|
||||
* will be output. Note that the selection is stored on a per-presentation
|
||||
* shell basis, not per document, hence it is a parameter here.
|
||||
* These should be exposed in an interface, but aren't yet.
|
||||
*/
|
||||
|
||||
virtual nsresult OutputDocumentAsText(nsIOutputStream* aStream, nsIDOMSelection* selection, const nsString& aCharset);
|
||||
virtual nsresult OutputDocumentAsHTML(nsIOutputStream* aStream, nsIDOMSelection* selection, const nsString& aCharset);
|
||||
|
||||
protected:
|
||||
nsIContent* FindContent(const nsIContent* aStartNode,
|
||||
const nsIContent* aTest1,
|
||||
const nsIContent* aTest2) const;
|
||||
virtual nsresult Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup);
|
||||
|
||||
// this enum is temporary; there should be no knowledge of HTML in
|
||||
// nsDocument. That will be fixed when content sink stream factories
|
||||
// are available.
|
||||
enum EOutputFormat {
|
||||
eOutputText,
|
||||
eOutputHTML
|
||||
};
|
||||
|
||||
virtual nsresult OutputDocumentAs(nsIOutputStream* aStream, nsIDOMSelection* selection, EOutputFormat aOutputFormat, const nsString& aCharset);
|
||||
|
||||
nsresult GetPixelDimensions(nsIPresShell* aShell,
|
||||
PRInt32* aWidth,
|
||||
PRInt32* aHeight);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void InternalAddStyleSheet(nsIStyleSheet* aSheet); // subclass hooks for sheet ordering
|
||||
virtual void InternalInsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex);
|
||||
|
||||
nsDocument();
|
||||
virtual ~nsDocument();
|
||||
nsresult Init();
|
||||
|
||||
nsIArena* mArena;
|
||||
nsString* mDocumentTitle;
|
||||
nsIURI* mDocumentURL;
|
||||
nsIPrincipal* mPrincipal;
|
||||
nsWeakPtr mDocumentLoadGroup;
|
||||
nsString mCharacterSet;
|
||||
nsIDocument* mParentDocument;
|
||||
nsVoidArray mSubDocuments;
|
||||
nsVoidArray mPresShells;
|
||||
nsIContent* mRootContent;
|
||||
nsVoidArray mStyleSheets;
|
||||
nsVoidArray mObservers;
|
||||
void* mScriptObject;
|
||||
nsCOMPtr<nsIScriptGlobalObject> mScriptGlobalObject;
|
||||
nsIEventListenerManager* mListenerManager;
|
||||
PRBool mDisplaySelection;
|
||||
PRBool mInDestructor;
|
||||
nsDOMStyleSheetCollection *mDOMStyleSheets;
|
||||
nsINameSpaceManager* mNameSpaceManager;
|
||||
nsDocHeaderData* mHeaderData;
|
||||
nsILineBreaker* mLineBreaker;
|
||||
nsVoidArray *mProlog;
|
||||
nsVoidArray *mEpilog;
|
||||
nsDocumentChildNodes* mChildNodes;
|
||||
nsIWordBreaker* mWordBreaker;
|
||||
|
||||
// disk file members
|
||||
nsFileSpec* mFileSpec;
|
||||
PRInt32 mModCount;
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsDocument_h___ */
|
||||
361
mozilla/content/base/src/nsDocumentEncoder.cpp
Normal file
361
mozilla/content/base/src/nsDocumentEncoder.cpp
Normal file
@@ -0,0 +1,361 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsIDocumentEncoder.h"
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsXIFDTD.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsHTMLContentSinkStream.h"
|
||||
#include "nsHTMLToTXTSinkStream.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
|
||||
static NS_DEFINE_CID(kCTextEncoderCID, NS_TEXT_ENCODER_CID);
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
||||
class nsTextEncoder : public nsIDocumentEncoder
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOCUMENT_ENCODER_IID; return iid; }
|
||||
|
||||
nsTextEncoder();
|
||||
virtual ~nsTextEncoder();
|
||||
|
||||
NS_IMETHOD Init(nsIDocument* aDocument, const nsString& aMimeType, PRUint32 aFlags);
|
||||
|
||||
/* Interfaces for addref and release and queryinterface */
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// Inherited methods from nsIDocumentEncoder
|
||||
NS_IMETHOD SetSelection(nsIDOMSelection* aSelection);
|
||||
NS_IMETHOD SetWrapColumn(PRUint32 aWC);
|
||||
NS_IMETHOD SetCharset(const nsString& aCharset);
|
||||
|
||||
NS_IMETHOD EncodeToStream(nsIOutputStream* aStream);
|
||||
NS_IMETHOD EncodeToString(nsString& aOutputString);
|
||||
|
||||
protected:
|
||||
// Local methods to the text encoder -- used to be in nsITextEncoder,
|
||||
// but that interface is obsolete now.
|
||||
//NS_IMETHOD PrettyPrint(PRBool aYes);
|
||||
//NS_IMETHOD AddHeader(PRBool aYes);
|
||||
|
||||
nsIDocument* mDocument;
|
||||
nsIDOMSelection* mSelection;
|
||||
nsString mMimeType;
|
||||
nsString mCharset;
|
||||
PRUint32 mFlags;
|
||||
PRUint32 mWrapColumn;
|
||||
};
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsTextEncoder)
|
||||
NS_IMPL_RELEASE(nsTextEncoder)
|
||||
|
||||
nsTextEncoder::nsTextEncoder() : mMimeType("text/plain")
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mDocument = 0;
|
||||
mSelection = 0;
|
||||
mFlags = 0;
|
||||
mWrapColumn = 72;
|
||||
}
|
||||
|
||||
nsTextEncoder::~nsTextEncoder()
|
||||
{
|
||||
NS_IF_RELEASE(mDocument);
|
||||
//NS_IF_RELEASE(mSelection); // no. we never addref'd it.
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::Init(nsIDocument* aDocument, const nsString& aMimeType, PRUint32 aFlags)
|
||||
{
|
||||
if (!aDocument)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
mDocument = aDocument;
|
||||
NS_ADDREF(mDocument);
|
||||
|
||||
mMimeType = aMimeType;
|
||||
|
||||
mFlags = aFlags;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsTextEncoder::QueryInterface(REFNSIID aIID,
|
||||
void **aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aInstancePtr = 0;
|
||||
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void *)(nsISupports*)this;
|
||||
} else if (aIID.Equals(nsIDocumentEncoder::GetIID())) {
|
||||
*aInstancePtr = (void *)(nsIDocumentEncoder*)this;
|
||||
}
|
||||
|
||||
if (nsnull == *aInstancePtr)
|
||||
return NS_NOINTERFACE;
|
||||
|
||||
NS_ADDREF_THIS();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::SetWrapColumn(PRUint32 aWC)
|
||||
{
|
||||
mWrapColumn = aWC;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::SetSelection(nsIDOMSelection* aSelection)
|
||||
{
|
||||
mSelection = aSelection;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::SetCharset(const nsString& aCharset)
|
||||
{
|
||||
mCharset = aCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::EncodeToString(nsString& aOutputString)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// xxx Also make sure mString is a mime type "text/html" or "text/plain"
|
||||
|
||||
if (mDocument)
|
||||
{
|
||||
nsString buffer;
|
||||
|
||||
if (mMimeType == "text/xif")
|
||||
{
|
||||
mDocument->CreateXIF(aOutputString, mSelection);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mDocument->CreateXIF(buffer, mSelection);
|
||||
|
||||
nsIParser* parser;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCParserCID,
|
||||
nsnull,
|
||||
kCParserIID,
|
||||
(void **)&parser);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsIHTMLContentSink* sink = nsnull;
|
||||
|
||||
if (mMimeType == "text/html")
|
||||
rv = NS_New_HTML_ContentSinkStream(&sink, &aOutputString, mFlags);
|
||||
|
||||
else // default to text/plain
|
||||
rv = NS_New_HTMLToTXT_SinkStream(&sink, &aOutputString,
|
||||
mWrapColumn, mFlags);
|
||||
|
||||
if (sink && NS_SUCCEEDED(rv))
|
||||
{
|
||||
parser->SetContentSink(sink);
|
||||
nsIDTD* dtd = nsnull;
|
||||
rv = NS_NewXIFDTD(&dtd);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
parser->RegisterDTD(dtd);
|
||||
parser->Parse(buffer, 0, "text/xif", PR_FALSE, PR_TRUE);
|
||||
}
|
||||
NS_IF_RELEASE(dtd);
|
||||
NS_IF_RELEASE(sink);
|
||||
}
|
||||
NS_RELEASE(parser);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::EncodeToStream(nsIOutputStream* aStream)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// xxx Also make sure mString is a mime type "text/html" or "text/plain"
|
||||
|
||||
if (mDocument)
|
||||
{
|
||||
nsString buffer;
|
||||
|
||||
mDocument->CreateXIF(buffer,mSelection);
|
||||
|
||||
nsString* charset = nsnull;
|
||||
nsAutoString defaultCharset("ISO-8859-1");
|
||||
if (!mCharset.Equals("null") && !mCharset.Equals(""))
|
||||
charset = &mCharset;
|
||||
|
||||
nsIParser* parser;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCParserCID,
|
||||
nsnull,
|
||||
kCParserIID,
|
||||
(void **)&parser);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsIHTMLContentSink* sink = nsnull;
|
||||
|
||||
if (mMimeType == "text/html")
|
||||
rv = NS_New_HTML_ContentSinkStream(&sink, aStream, charset, mFlags);
|
||||
|
||||
else
|
||||
rv = NS_New_HTMLToTXT_SinkStream(&sink, aStream, charset,
|
||||
mWrapColumn, mFlags);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
parser->SetContentSink(sink);
|
||||
|
||||
nsIDTD* dtd = nsnull;
|
||||
rv = NS_NewXIFDTD(&dtd);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
parser->RegisterDTD(dtd);
|
||||
parser->Parse(buffer, 0, "text/xif", PR_FALSE, PR_TRUE);
|
||||
}
|
||||
NS_IF_RELEASE(dtd);
|
||||
NS_IF_RELEASE(sink);
|
||||
}
|
||||
NS_RELEASE(parser);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewTextEncoder(nsIDocumentEncoder** aResult)
|
||||
{
|
||||
*aResult = new nsTextEncoder;
|
||||
if (!*aResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
class nsDocumentEncoderFactory : public nsIFactory
|
||||
{
|
||||
public:
|
||||
nsDocumentEncoderFactory();
|
||||
virtual ~nsDocumentEncoderFactory();
|
||||
|
||||
// nsISupports methods
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult);
|
||||
};
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(nsDocumentEncoderFactory);
|
||||
|
||||
nsDocumentEncoderFactory::nsDocumentEncoderFactory()
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsDocumentEncoderFactory);
|
||||
mRefCnt = 0;
|
||||
}
|
||||
|
||||
nsDocumentEncoderFactory::~nsDocumentEncoderFactory()
|
||||
{
|
||||
MOZ_COUNT_DTOR(nsDocumentEncoderFactory);
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsDocumentEncoderFactory)
|
||||
NS_IMPL_RELEASE(nsDocumentEncoderFactory)
|
||||
|
||||
nsresult nsDocumentEncoderFactory::QueryInterface(REFNSIID aIID,
|
||||
void **aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aInstancePtr = 0;
|
||||
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void *)(nsISupports*)this;
|
||||
} else if (aIID.Equals(kIFactoryIID)) {
|
||||
*aInstancePtr = (void *)(nsIFactory*)this;
|
||||
}
|
||||
|
||||
if (nsnull == *aInstancePtr)
|
||||
return NS_NOINTERFACE;
|
||||
|
||||
NS_ADDREF_THIS();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocumentEncoderFactory::CreateInstance(nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (!aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aResult = 0;
|
||||
|
||||
if (aIID.Equals(kCTextEncoderCID))
|
||||
*aResult = new nsTextEncoder;
|
||||
else
|
||||
return NS_NOINTERFACE;
|
||||
|
||||
if (*aResult == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
382
mozilla/content/base/src/nsDocumentFragment.cpp
Normal file
382
mozilla/content/base/src/nsDocumentFragment.cpp
Normal file
@@ -0,0 +1,382 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsDOMError.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIDOMDocumentFragmentIID, NS_IDOMDOCUMENTFRAGMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
|
||||
|
||||
class nsDocumentFragment : public nsIContent,
|
||||
public nsIDOMDocumentFragment,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
public:
|
||||
nsDocumentFragment(nsIDocument* aOwnerDocument);
|
||||
virtual ~nsDocumentFragment();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// interface nsIDOMDocumentFragment
|
||||
NS_IMETHOD GetNodeName(nsString& aNodeName);
|
||||
NS_IMETHOD GetNodeValue(nsString& aNodeValue);
|
||||
NS_IMETHOD SetNodeValue(const nsString& aNodeValue);
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType);
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode)
|
||||
{
|
||||
*aParentNode = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes)
|
||||
{ return mInner.GetChildNodes(aChildNodes); }
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild)
|
||||
{ return mInner.GetFirstChild(aFirstChild); }
|
||||
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild)
|
||||
{ return mInner.GetLastChild(aLastChild); }
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
||||
{
|
||||
*aPreviousSibling = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{
|
||||
*aNextSibling = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
{
|
||||
*aAttributes = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{ return mInner.InsertBefore(aNewChild, aRefChild, aReturn); }
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{ return mInner.ReplaceChild(aNewChild, aOldChild, aReturn); }
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{ return mInner.RemoveChild(aOldChild, aReturn); }
|
||||
NS_IMETHOD AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{ return mInner.AppendChild(aNewChild, aReturn); }
|
||||
NS_IMETHOD HasChildNodes(PRBool* aReturn)
|
||||
{ return mInner.HasChildNodes(aReturn); }
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
|
||||
// interface nsIScriptObjectOwner
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void* aScriptObject);
|
||||
|
||||
// interface nsIContent
|
||||
NS_IMETHOD ParseAttributeString(const nsString& aStr,
|
||||
nsIAtom*& aName,
|
||||
PRInt32& aNameSpaceID)
|
||||
{ aName = nsnull;
|
||||
aNameSpaceID = kNameSpaceID_None;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
{
|
||||
aPrefix = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const
|
||||
{ return mInner.GetDocument(aResult); }
|
||||
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep)
|
||||
{ return mInner.SetDocument(aDocument, aDeep); }
|
||||
NS_IMETHOD GetParent(nsIContent*& aResult) const
|
||||
{
|
||||
aResult = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD SetParent(nsIContent* aParent)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32& aResult) const
|
||||
{
|
||||
aResult = kNameSpaceID_None;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const
|
||||
{
|
||||
aResult = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const
|
||||
{ return mInner.CanContainChildren(aResult); }
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const
|
||||
{ return mInner.ChildCount(aResult); }
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const
|
||||
{ return mInner.ChildAt(aIndex, aResult); }
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const
|
||||
{ return mInner.IndexOf(aPossibleChild, aIndex); }
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
PRBool aNotify)
|
||||
{ return mInner.InsertChildAt(aKid, aIndex, aNotify); }
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
PRBool aNotify)
|
||||
{ return mInner.ReplaceChildAt(aKid, aIndex, aNotify); }
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify)
|
||||
{ return mInner.AppendChildTo(aKid, aNotify); }
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
{ return mInner.RemoveChildAt(aIndex, aNotify); }
|
||||
NS_IMETHOD IsSynthetic(PRBool& aResult)
|
||||
{ return mInner.IsSynthetic(aResult); }
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsString& aValue,
|
||||
PRBool aNotify)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsString& aResult) const
|
||||
{ return NS_CONTENT_ATTR_NOT_THERE; }
|
||||
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
PRBool aNotify)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex,
|
||||
PRInt32& aNameSpaceID,
|
||||
nsIAtom*& aName) const
|
||||
{
|
||||
aName = nsnull;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aCountResult) const
|
||||
{
|
||||
aCountResult = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const
|
||||
{ return mInner.List(out, aIndent); }
|
||||
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEventStatus);
|
||||
*aEventStatus = nsEventStatus_eIgnore;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetContentID(PRUint32* aID) {
|
||||
*aID = 0;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD SetContentID(PRUint32 aID) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD RangeAdd(nsIDOMRange& aRange)
|
||||
{ return mInner.RangeAdd(aRange); }
|
||||
NS_IMETHOD RangeRemove(nsIDOMRange& aRange)
|
||||
{ return mInner.RangeRemove(aRange); }
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const
|
||||
{ return mInner.GetRangeList(aResult); }
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
*aResult = sizeof(*this);
|
||||
#else
|
||||
*aResult = 0;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
nsGenericContainerElement mInner;
|
||||
void* mScriptObject;
|
||||
nsIDocument* mOwnerDocument;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
|
||||
nsIDocument* aOwnerDocument)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsDocumentFragment* it = new nsDocumentFragment(aOwnerDocument);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIDOMDocumentFragmentIID,
|
||||
(void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
nsDocumentFragment::nsDocumentFragment(nsIDocument* aOwnerDocument)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInner.Init(this, nsnull);
|
||||
mScriptObject = nsnull;
|
||||
mOwnerDocument = aOwnerDocument;
|
||||
NS_IF_ADDREF(mOwnerDocument);
|
||||
}
|
||||
|
||||
nsDocumentFragment::~nsDocumentFragment()
|
||||
{
|
||||
NS_IF_RELEASE(mOwnerDocument);
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsDocumentFragment)
|
||||
NS_IMPL_RELEASE(nsDocumentFragment)
|
||||
|
||||
nsresult
|
||||
nsDocumentFragment::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
nsIDOMDocumentFragment* tmp = this;
|
||||
nsISupports* tmp2 = tmp;
|
||||
*aInstancePtr = (void*) tmp2;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMDocumentFragmentIID)) {
|
||||
nsIDOMDocumentFragment* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMNodeIID)) {
|
||||
nsIDOMDocumentFragment* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
nsIScriptObjectOwner* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIContentIID)) {
|
||||
nsIContent* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::GetNodeName(nsString& aNodeName)
|
||||
{
|
||||
aNodeName.SetString("#document-fragment");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::GetNodeValue(nsString& aNodeValue)
|
||||
{
|
||||
aNodeValue.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::SetNodeValue(const nsString& aNodeValue)
|
||||
{
|
||||
// The node value can't be modified
|
||||
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = (PRUint16)nsIDOMNode::DOCUMENT_FRAGMENT_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
{
|
||||
if (nsnull != mOwnerDocument) {
|
||||
return mOwnerDocument->QueryInterface(kIDOMDocumentIID, (void **)aOwnerDocument);
|
||||
}
|
||||
else {
|
||||
*aOwnerDocument = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsDocumentFragment* it;
|
||||
it = new nsDocumentFragment(mOwnerDocument);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
//XXX mInner.CopyInnerTo(this, &it->mInner);
|
||||
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::GetScriptObject(nsIScriptContext* aContext,
|
||||
void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (nsnull == mScriptObject) {
|
||||
nsIDOMScriptObjectFactory *factory;
|
||||
|
||||
res = mInner.GetScriptObjectFactory(&factory);
|
||||
if (NS_OK != res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
res = factory->NewScriptDocumentFragment(aContext,
|
||||
(nsISupports*)(nsIDOMDocumentFragment*)this,
|
||||
mOwnerDocument,
|
||||
(void**)&mScriptObject);
|
||||
NS_RELEASE(factory);
|
||||
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::SetScriptObject(void* aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
1510
mozilla/content/base/src/nsDocumentViewer.cpp
Normal file
1510
mozilla/content/base/src/nsDocumentViewer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
22
mozilla/content/base/src/nsGenericCaretProperties.cpp
Normal file
22
mozilla/content/base/src/nsGenericCaretProperties.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
#include "nsCaretProperties.h"
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
nsCaretProperties::nsCaretProperties()
|
||||
: mCaretWidth(eDefaultCaretWidth)
|
||||
, mBlinkRate(eDefaulBlinkRate)
|
||||
{
|
||||
// in your platform-specific class, get data from the OS in your constructor
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
nsCaretProperties* NewCaretProperties()
|
||||
{
|
||||
return new nsCaretProperties();
|
||||
}
|
||||
1048
mozilla/content/base/src/nsGenericDOMDataNode.cpp
Normal file
1048
mozilla/content/base/src/nsGenericDOMDataNode.cpp
Normal file
File diff suppressed because it is too large
Load Diff
571
mozilla/content/base/src/nsGenericDOMDataNode.h
Normal file
571
mozilla/content/base/src/nsGenericDOMDataNode.h
Normal file
@@ -0,0 +1,571 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsGenericDOMDataNode_h___
|
||||
#define nsGenericDOMDataNode_h___
|
||||
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsTextFragment.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsDOMError.h"
|
||||
|
||||
extern const nsIID kIDOMCharacterDataIID;
|
||||
extern const nsIID kIDOMNodeIID;
|
||||
extern const nsIID kIDOMEventReceiverIID;
|
||||
extern const nsIID kIDOMEventTargetIID;
|
||||
extern const nsIID kIScriptObjectOwnerIID;
|
||||
extern const nsIID kISupportsIID;
|
||||
extern const nsIID kIContentIID;
|
||||
|
||||
class nsIDOMAttr;
|
||||
class nsIDOMEventListener;
|
||||
class nsIDOMNodeList;
|
||||
class nsIEventListenerManager;
|
||||
class nsIFrame;
|
||||
class nsIStyleContext;
|
||||
class nsIStyleRule;
|
||||
class nsISupportsArray;
|
||||
class nsIDOMText;
|
||||
|
||||
struct nsGenericDOMDataNode {
|
||||
nsGenericDOMDataNode();
|
||||
virtual ~nsGenericDOMDataNode();
|
||||
|
||||
void Init(nsIContent* aOuterContentObject);
|
||||
|
||||
// Implementation for nsIDOMNode
|
||||
nsresult GetNodeValue(nsString& aNodeValue);
|
||||
nsresult SetNodeValue(const nsString& aNodeValue);
|
||||
nsresult GetParentNode(nsIDOMNode** aParentNode);
|
||||
nsresult GetAttributes(nsIDOMNamedNodeMap** aAttributes) {
|
||||
*aAttributes = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetPreviousSibling(nsIDOMNode** aPreviousSibling);
|
||||
nsresult GetNextSibling(nsIDOMNode** aNextSibling);
|
||||
nsresult GetChildNodes(nsIDOMNodeList** aChildNodes);
|
||||
nsresult HasChildNodes(PRBool* aHasChildNodes) {
|
||||
*aHasChildNodes = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetFirstChild(nsIDOMNode** aFirstChild) {
|
||||
*aFirstChild = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetLastChild(nsIDOMNode** aLastChild) {
|
||||
*aLastChild = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn) {
|
||||
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
||||
}
|
||||
nsresult ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn) {
|
||||
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
||||
}
|
||||
nsresult RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) {
|
||||
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
||||
}
|
||||
nsresult AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn) {
|
||||
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
||||
}
|
||||
nsresult GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
|
||||
|
||||
// Implementation for nsIDOMCharacterData
|
||||
nsresult GetData(nsString& aData);
|
||||
nsresult SetData(const nsString& aData);
|
||||
nsresult GetLength(PRUint32* aLength);
|
||||
nsresult SubstringData(PRUint32 aOffset, PRUint32 aCount, nsString& aReturn);
|
||||
nsresult AppendData(const nsString& aArg);
|
||||
nsresult InsertData(PRUint32 aOffset, const nsString& aArg);
|
||||
nsresult DeleteData(PRUint32 aOffset, PRUint32 aCount);
|
||||
nsresult ReplaceData(PRUint32 aOffset, PRUint32 aCount, const nsString& aArg);
|
||||
|
||||
// nsIDOMEventReceiver interface
|
||||
nsresult AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
nsresult RemoveEventListenerByIID(nsIDOMEventListener* aListener,
|
||||
const nsIID& aIID);
|
||||
nsresult GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
nsresult GetNewListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
|
||||
// nsIDOMEventTarget interface
|
||||
nsresult AddEventListener(const nsString& aType, nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture);
|
||||
nsresult RemoveEventListener(const nsString& aType, nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture);
|
||||
|
||||
// nsIScriptObjectOwner interface
|
||||
nsresult GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
|
||||
nsresult SetScriptObject(void *aScriptObject);
|
||||
|
||||
// Implementation for nsIContent
|
||||
nsresult GetDocument(nsIDocument*& aResult) const;
|
||||
nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep);
|
||||
nsresult GetParent(nsIContent*& aResult) const;
|
||||
nsresult SetParent(nsIContent* aParent);
|
||||
nsresult IsSynthetic(PRBool& aResult) {
|
||||
aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetNameSpaceID(PRInt32& aID) const {
|
||||
aID = kNameSpaceID_None;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult ParseAttributeString(const nsString& aStr,
|
||||
nsIAtom*& aName,
|
||||
PRInt32& aNameSpaceID) {
|
||||
aName = nsnull;
|
||||
aNameSpaceID = kNameSpaceID_None;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) {
|
||||
aPrefix = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, const nsString& aValue,
|
||||
PRBool aNotify) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom *aAttribute, nsString &aResult) const {
|
||||
return NS_CONTENT_ATTR_NOT_THERE;
|
||||
}
|
||||
nsresult GetAttributeNameAt(PRInt32 aIndex, PRInt32& aNameSpaceID,
|
||||
nsIAtom*& aName) const {
|
||||
aName = nsnull;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
nsresult GetAttributeCount(PRInt32& aResult) const {
|
||||
aResult = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult List(FILE* out, PRInt32 aIndent) const;
|
||||
nsresult HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus);
|
||||
nsresult RangeAdd(nsIDOMRange& aRange);
|
||||
nsresult RangeRemove(nsIDOMRange& aRange);
|
||||
nsresult GetRangeList(nsVoidArray*& aResult) const;
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const;
|
||||
|
||||
// Implementation for nsIContent
|
||||
nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult FinishConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult CanContainChildren(PRBool& aResult) const {
|
||||
aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult ChildCount(PRInt32& aResult) const {
|
||||
aResult = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult ChildAt(PRInt32 aIndex, nsIContent*& aResult) const {
|
||||
aResult = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const {
|
||||
aResult = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult RemoveChildAt(PRInt32 aIndex, PRBool aNotify) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult SplitText(PRUint32 aOffset, nsIDOMText** aReturn);
|
||||
|
||||
nsresult GetText(const nsTextFragment** aFragmentsResult);
|
||||
nsresult GetTextLength(PRInt32* aLengthResult);
|
||||
nsresult CopyText(nsString& aResult);
|
||||
nsresult SetText(const PRUnichar* aBuffer,
|
||||
PRInt32 aLength,
|
||||
PRBool aNotify);
|
||||
nsresult SetText(const char* aBuffer,
|
||||
PRInt32 aLength,
|
||||
PRBool aNotify);
|
||||
nsresult IsOnlyWhitespace(PRBool* aResult);
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
void ToCString(nsString& aBuf, PRInt32 aOffset, PRInt32 aLen) const;
|
||||
|
||||
// Up pointer to the real content object that we are
|
||||
// supporting. Sometimes there is work that we just can't do
|
||||
// ourselves, so this is needed to ask the real object to do the
|
||||
// work.
|
||||
nsIContent* mContent;
|
||||
|
||||
nsIDocument* mDocument;
|
||||
nsIContent* mParent;
|
||||
void* mScriptObject;
|
||||
nsIEventListenerManager* mListenerManager;
|
||||
nsIContent* mCapturer;
|
||||
|
||||
nsTextFragment mText;
|
||||
nsVoidArray *mRangeList;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Mostly implement the nsIDOMNode API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*
|
||||
* Note that classes using this macro will need to implement:
|
||||
* NS_IMETHOD GetNodeType(PRUint16* aNodeType);
|
||||
* NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
*/
|
||||
#define NS_IMPL_IDOMNODE_USING_GENERIC_DOM_DATA(_g) \
|
||||
NS_IMETHOD GetNodeName(nsString& aNodeName); \
|
||||
NS_IMETHOD GetNodeValue(nsString& aNodeValue) { \
|
||||
return _g.GetNodeValue(aNodeValue); \
|
||||
} \
|
||||
NS_IMETHOD SetNodeValue(const nsString& aNodeValue) { \
|
||||
return _g.SetNodeValue(aNodeValue); \
|
||||
} \
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType); \
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) { \
|
||||
return _g.GetParentNode(aParentNode); \
|
||||
} \
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes) { \
|
||||
return _g.GetChildNodes(aChildNodes); \
|
||||
} \
|
||||
NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes) { \
|
||||
return _g.HasChildNodes(aHasChildNodes); \
|
||||
} \
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) { \
|
||||
return _g.GetFirstChild(aFirstChild); \
|
||||
} \
|
||||
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild) { \
|
||||
return _g.GetLastChild(aLastChild); \
|
||||
} \
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling) { \
|
||||
return _g.GetPreviousSibling(aPreviousSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling) { \
|
||||
return _g.GetNextSibling(aNextSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes) { \
|
||||
return _g.GetAttributes(aAttributes); \
|
||||
} \
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, \
|
||||
nsIDOMNode** aReturn) { \
|
||||
return _g.InsertBefore(aNewChild, aRefChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD AppendChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
|
||||
return _g.AppendChild(aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, \
|
||||
nsIDOMNode** aReturn) { \
|
||||
return _g.ReplaceChild(aNewChild, aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
|
||||
return _g.RemoveChild(aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument) { \
|
||||
return _g.GetOwnerDocument(aOwnerDocument); \
|
||||
} \
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
|
||||
#define NS_IMPL_IDOMCHARACTERDATA_USING_GENERIC_DOM_DATA(_g) \
|
||||
NS_IMETHOD GetData(nsString& aData) { \
|
||||
return _g.GetData(aData); \
|
||||
} \
|
||||
NS_IMETHOD SetData(const nsString& aData) { \
|
||||
return _g.SetData(aData); \
|
||||
} \
|
||||
NS_IMETHOD GetLength(PRUint32* aLength) { \
|
||||
return _g.GetLength(aLength); \
|
||||
} \
|
||||
NS_IMETHOD SubstringData(PRUint32 aStart, PRUint32 aEnd, nsString& aReturn) { \
|
||||
return _g.SubstringData(aStart, aEnd, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD AppendData(const nsString& aData) { \
|
||||
return _g.AppendData(aData); \
|
||||
} \
|
||||
NS_IMETHOD InsertData(PRUint32 aOffset, const nsString& aData) { \
|
||||
return _g.InsertData(aOffset, aData); \
|
||||
} \
|
||||
NS_IMETHOD DeleteData(PRUint32 aOffset, PRUint32 aCount) { \
|
||||
return _g.DeleteData(aOffset, aCount); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceData(PRUint32 aOffset, PRUint32 aCount, \
|
||||
const nsString& aData) { \
|
||||
return _g.ReplaceData(aOffset, aCount, aData); \
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement the nsIDOMEventReceiver API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*/
|
||||
#define NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC_DOM_DATA(_g) \
|
||||
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, \
|
||||
const nsIID& aIID) { \
|
||||
return _g.AddEventListenerByIID(aListener, aIID); \
|
||||
} \
|
||||
NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener, \
|
||||
const nsIID& aIID) { \
|
||||
return _g.RemoveEventListenerByIID(aListener, aIID); \
|
||||
} \
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aResult) { \
|
||||
return _g.GetListenerManager(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetNewListenerManager(nsIEventListenerManager** aResult) { \
|
||||
return _g.GetNewListenerManager(aResult); \
|
||||
} \
|
||||
NS_IMETHOD AddEventListener(const nsString& aType, \
|
||||
nsIDOMEventListener* aListener, \
|
||||
PRBool aUseCapture) { \
|
||||
return _g.AddEventListener(aType, aListener, aUseCapture); \
|
||||
} \
|
||||
NS_IMETHOD RemoveEventListener(const nsString& aType, \
|
||||
nsIDOMEventListener* aListener, \
|
||||
PRBool aUseCapture) { \
|
||||
return _g.RemoveEventListener(aType, aListener, aUseCapture); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement the nsIScriptObjectOwner API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*/
|
||||
#define NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC_DOM_DATA(_g) \
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, \
|
||||
void** aScriptObject) { \
|
||||
return _g.GetScriptObject(aContext, aScriptObject); \
|
||||
} \
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject) { \
|
||||
return _g.SetScriptObject(aScriptObject); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_ICONTENT_USING_GENERIC_DOM_DATA(_g) \
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \
|
||||
return _g.GetDocument(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { \
|
||||
return _g.SetDocument(aDocument, aDeep); \
|
||||
} \
|
||||
NS_IMETHOD GetParent(nsIContent*& aResult) const { \
|
||||
return _g.GetParent(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetParent(nsIContent* aParent) { \
|
||||
return _g.SetParent(aParent); \
|
||||
} \
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const { \
|
||||
return _g.CanContainChildren(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const { \
|
||||
return _g.ChildCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { \
|
||||
return _g.ChildAt(aIndex, aResult); \
|
||||
} \
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { \
|
||||
return _g.IndexOf(aPossibleChild, aResult); \
|
||||
} \
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, \
|
||||
PRBool aNotify) { \
|
||||
return _g.InsertChildAt(aKid, aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, \
|
||||
PRBool aNotify) { \
|
||||
return _g.ReplaceChildAt(aKid, aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { \
|
||||
return _g.AppendChildTo(aKid, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { \
|
||||
return _g.RemoveChildAt(aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD IsSynthetic(PRBool& aResult) { \
|
||||
return _g.IsSynthetic(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32& aID) const { \
|
||||
return _g.GetNameSpaceID(aID); \
|
||||
} \
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const; \
|
||||
NS_IMETHOD ParseAttributeString(const nsString& aStr, \
|
||||
nsIAtom*& aName, \
|
||||
PRInt32& aNameSpaceID) { \
|
||||
return _g.ParseAttributeString(aStr, aName, aNameSpaceID); \
|
||||
} \
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID, \
|
||||
nsIAtom*& aPrefix) { \
|
||||
return _g.GetNameSpacePrefixFromId(aNameSpaceID, aPrefix); \
|
||||
} \
|
||||
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom *aAttribute, \
|
||||
nsString &aResult) const { \
|
||||
return _g.GetAttribute(aNameSpaceID, aAttribute, aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, \
|
||||
const nsString& aValue, PRBool aNotify) { \
|
||||
return _g.SetAttribute(aNameSpaceID, aAttribute, aValue, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, \
|
||||
PRBool aNotify) { \
|
||||
return _g.UnsetAttribute(aNameSpaceID, aAttribute, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex, \
|
||||
PRInt32& aNameSpaceID, \
|
||||
nsIAtom*& aName) const { \
|
||||
return _g.GetAttributeNameAt(aIndex, aNameSpaceID, aName); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \
|
||||
return _g.GetAttributeCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const; \
|
||||
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.BeginConvertToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.ConvertContentToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.FinishConvertToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, \
|
||||
nsEvent* aEvent, \
|
||||
nsIDOMEvent** aDOMEvent, \
|
||||
PRUint32 aFlags, \
|
||||
nsEventStatus* aEventStatus); \
|
||||
NS_IMETHOD GetContentID(PRUint32* aID); \
|
||||
NS_IMETHOD SetContentID(PRUint32 aID); \
|
||||
NS_IMETHOD RangeAdd(nsIDOMRange& aRange){ \
|
||||
return _g.RangeAdd(aRange); \
|
||||
} \
|
||||
NS_IMETHOD RangeRemove(nsIDOMRange& aRange){ \
|
||||
return _g.RangeRemove(aRange); \
|
||||
} \
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const { \
|
||||
return _g.GetRangeList(aResult); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement the nsIDOMText API by forwarding the methods to a
|
||||
* generic character data content object.
|
||||
*/
|
||||
#define NS_IMPL_IDOMTEXT_USING_GENERIC_DOM_DATA(_g) \
|
||||
NS_IMETHOD SplitText(PRUint32 aOffset, nsIDOMText** aReturn){ \
|
||||
return _g.SplitText(aOffset, aReturn); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement the nsITextContent API by forwarding the methods to a
|
||||
* generic character data content object.
|
||||
*/
|
||||
#define NS_IMPL_ITEXTCONTENT_USING_GENERIC_DOM_DATA(_g) \
|
||||
NS_IMETHOD GetText(const nsTextFragment** aFragmentsResult) { \
|
||||
return mInner.GetText(aFragmentsResult); \
|
||||
} \
|
||||
NS_IMETHOD GetTextLength(PRInt32* aLengthResult) { \
|
||||
return mInner.GetTextLength(aLengthResult); \
|
||||
} \
|
||||
NS_IMETHOD CopyText(nsString& aResult) { \
|
||||
return mInner.CopyText(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetText(const PRUnichar* aBuffer, \
|
||||
PRInt32 aLength, \
|
||||
PRBool aNotify){ \
|
||||
return mInner.SetText(aBuffer, aLength, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD SetText(const char* aBuffer, \
|
||||
PRInt32 aLength, \
|
||||
PRBool aNotify){ \
|
||||
return mInner.SetText(aBuffer, aLength, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD IsOnlyWhitespace(PRBool* aResult){ \
|
||||
return mInner.IsOnlyWhitespace(aResult); \
|
||||
}
|
||||
|
||||
/**
|
||||
* This macro implements the portion of query interface that is
|
||||
* generic to all html content objects.
|
||||
*/
|
||||
#define NS_IMPL_DOM_DATA_QUERY_INTERFACE(_id, _iptr, _this) \
|
||||
if (_id.Equals(kISupportsIID)) { \
|
||||
nsIContent* tmp = _this; \
|
||||
nsISupports* tmp2 = tmp; \
|
||||
*_iptr = (void*) tmp2; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMNodeIID)) { \
|
||||
nsIDOMNode* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMCharacterDataIID)) { \
|
||||
nsIDOMCharacterData* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMEventReceiverIID)) { \
|
||||
nsIDOMEventReceiver* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMEventTargetIID)) { \
|
||||
nsIDOMEventTarget* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIScriptObjectOwnerIID)) { \
|
||||
nsIScriptObjectOwner* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIContentIID)) { \
|
||||
nsIContent* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
#endif /* nsGenericDOMDataNode_h___ */
|
||||
89
mozilla/content/base/src/nsGenericDOMNodeList.cpp
Normal file
89
mozilla/content/base/src/nsGenericDOMNodeList.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsGenericElement.h"
|
||||
|
||||
nsGenericDOMNodeList::nsGenericDOMNodeList()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mScriptObject = nsnull;
|
||||
}
|
||||
|
||||
nsGenericDOMNodeList::~nsGenericDOMNodeList()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMNodeList::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
static NS_DEFINE_IID(kIDOMNodeListIID, NS_IDOMNODELIST_IID);
|
||||
if (aIID.Equals(kIDOMNodeListIID)) {
|
||||
*aInstancePtr = (void*)(nsIDOMNodeList*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
*aInstancePtr = (void*)(nsIScriptObjectOwner*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*)(nsISupports*)(nsIDOMNodeList*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsGenericDOMNodeList)
|
||||
NS_IMPL_RELEASE(nsGenericDOMNodeList)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericDOMNodeList::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull == mScriptObject) {
|
||||
nsIDOMScriptObjectFactory *factory;
|
||||
|
||||
res = nsGenericElement::GetScriptObjectFactory(&factory);
|
||||
if (NS_OK != res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
res = factory->NewScriptNodeList(aContext, (nsISupports *)(nsIDOMNodeList *)this, nsnull, (void**)&mScriptObject);
|
||||
NS_RELEASE(factory);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericDOMNodeList::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
60
mozilla/content/base/src/nsGenericDOMNodeList.h
Normal file
60
mozilla/content/base/src/nsGenericDOMNodeList.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsGenericDOMNodeList_h__
|
||||
#define nsGenericDOMNodeList_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
|
||||
/**
|
||||
* This is a base class for a generic DOM Node List. The base class
|
||||
* provides implementations for nsISupports and nsIScriptObjectOwner,
|
||||
* but it is up to the subclass to implement the core node list
|
||||
* methods:
|
||||
* GetLength
|
||||
* Item
|
||||
*
|
||||
*/
|
||||
class nsGenericDOMNodeList : public nsIDOMNodeList,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
public:
|
||||
nsGenericDOMNodeList();
|
||||
virtual ~nsGenericDOMNodeList();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
// The following need to be defined in the subclass
|
||||
// nsIDOMNodeList interface
|
||||
NS_IMETHOD GetLength(PRUint32* aLength)=0;
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn)=0;
|
||||
|
||||
protected:
|
||||
void* mScriptObject;
|
||||
};
|
||||
|
||||
#endif // nsGenericDOMNodeList_h__
|
||||
2220
mozilla/content/base/src/nsGenericElement.cpp
Normal file
2220
mozilla/content/base/src/nsGenericElement.cpp
Normal file
File diff suppressed because it is too large
Load Diff
929
mozilla/content/base/src/nsGenericElement.h
Normal file
929
mozilla/content/base/src/nsGenericElement.h
Normal file
@@ -0,0 +1,929 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsGenericElement_h___
|
||||
#define nsGenericElement_h___
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsILinkHandler.h"
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
|
||||
extern const nsIID kIDOMNodeIID;
|
||||
extern const nsIID kIDOMElementIID;
|
||||
extern const nsIID kIDOMEventReceiverIID;
|
||||
extern const nsIID kIDOMEventTargetIID;
|
||||
extern const nsIID kIScriptObjectOwnerIID;
|
||||
extern const nsIID kIJSScriptObjectIID;
|
||||
extern const nsIID kISupportsIID;
|
||||
extern const nsIID kIContentIID;
|
||||
|
||||
class nsIDOMAttr;
|
||||
class nsIDOMEventListener;
|
||||
class nsIEventListenerManager;
|
||||
class nsIFrame;
|
||||
class nsISupportsArray;
|
||||
class nsIDOMScriptObjectFactory;
|
||||
class nsDOMCSSDeclaration;
|
||||
class nsIDOMCSSStyleDeclaration;
|
||||
class nsDOMAttributeMap;
|
||||
class nsIURI;
|
||||
|
||||
|
||||
// Class that holds the child list of a content element and also
|
||||
// implements the nsIDOMNodeList interface.
|
||||
class nsChildContentList : public nsGenericDOMNodeList
|
||||
{
|
||||
public:
|
||||
nsChildContentList(nsIContent *aContent);
|
||||
virtual ~nsChildContentList();
|
||||
|
||||
// nsIDOMNodeList interface
|
||||
NS_DECL_IDOMNODELIST
|
||||
|
||||
void DropReference();
|
||||
|
||||
private:
|
||||
nsIContent *mContent;
|
||||
};
|
||||
|
||||
// There are a set of DOM- and scripting-specific instance variables
|
||||
// that may only be instantiated when a content object is accessed
|
||||
// through the DOM. Rather than burn actual slots in the content
|
||||
// objects for each of these instance variables, we put them off
|
||||
// in a side structure that's only allocated when the content is
|
||||
// accessed through the DOM.
|
||||
typedef struct {
|
||||
void *mScriptObject;
|
||||
nsChildContentList *mChildNodes;
|
||||
nsDOMCSSDeclaration *mStyle;
|
||||
nsDOMAttributeMap* mAttributeMap;
|
||||
nsVoidArray *mRangeList;
|
||||
nsIContent* mCapturer;
|
||||
} nsDOMSlots;
|
||||
|
||||
class nsGenericElement : public nsIJSScriptObject {
|
||||
public:
|
||||
nsGenericElement();
|
||||
#if 1
|
||||
virtual // XXX temporary until vidur fixes this up
|
||||
#endif
|
||||
~nsGenericElement();
|
||||
|
||||
void Init(nsIContent* aOuterContentObject, nsIAtom* aTag);
|
||||
|
||||
// Implementation for nsIDOMNode
|
||||
nsresult GetNodeName(nsString& aNodeName);
|
||||
nsresult GetNodeValue(nsString& aNodeValue);
|
||||
nsresult SetNodeValue(const nsString& aNodeValue);
|
||||
nsresult GetNodeType(PRUint16* aNodeType);
|
||||
nsresult GetParentNode(nsIDOMNode** aParentNode);
|
||||
nsresult GetAttributes(nsIDOMNamedNodeMap** aAttributes);
|
||||
nsresult GetPreviousSibling(nsIDOMNode** aPreviousSibling);
|
||||
nsresult GetNextSibling(nsIDOMNode** aNextSibling);
|
||||
nsresult GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
|
||||
|
||||
// Implementation for nsIDOMElement
|
||||
nsresult GetTagName(nsString& aTagName);
|
||||
nsresult GetAttribute(const nsString& aName, nsString& aReturn);
|
||||
nsresult SetAttribute(const nsString& aName, const nsString& aValue);
|
||||
nsresult RemoveAttribute(const nsString& aName);
|
||||
nsresult GetAttributeNode(const nsString& aName,
|
||||
nsIDOMAttr** aReturn);
|
||||
nsresult SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn);
|
||||
nsresult RemoveAttributeNode(nsIDOMAttr* aOldAttr, nsIDOMAttr** aReturn);
|
||||
nsresult GetElementsByTagName(const nsString& aTagname,
|
||||
nsIDOMNodeList** aReturn);
|
||||
nsresult Normalize();
|
||||
|
||||
// nsIDOMEventReceiver interface
|
||||
nsresult AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
nsresult RemoveEventListenerByIID(nsIDOMEventListener* aListener,
|
||||
const nsIID& aIID);
|
||||
nsresult GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
nsresult GetNewListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
|
||||
// nsIDOMEventTarget interface
|
||||
nsresult AddEventListener(const nsString& aType, nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture);
|
||||
nsresult RemoveEventListener(const nsString& aType, nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture);
|
||||
|
||||
// nsIScriptObjectOwner interface
|
||||
nsresult GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
|
||||
nsresult SetScriptObject(void *aScriptObject);
|
||||
|
||||
// Implementation for nsIContent
|
||||
nsresult GetDocument(nsIDocument*& aResult) const;
|
||||
nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep);
|
||||
nsresult GetParent(nsIContent*& aResult) const;
|
||||
nsresult SetParent(nsIContent* aParent);
|
||||
nsresult IsSynthetic(PRBool& aResult) {
|
||||
aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetNameSpaceID(PRInt32& aNameSpaceID) const;
|
||||
nsresult GetTag(nsIAtom*& aResult) const;
|
||||
nsresult HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus);
|
||||
|
||||
nsresult GetContentID(PRUint32* aID) {
|
||||
*aID = mContentID;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult SetContentID(PRUint32 aID) {
|
||||
mContentID = aID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult RangeAdd(nsIDOMRange& aRange);
|
||||
nsresult RangeRemove(nsIDOMRange& aRange);
|
||||
nsresult GetRangeList(nsVoidArray*& aResult) const;
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const;
|
||||
|
||||
// Implementation for nsIJSScriptObject
|
||||
PRBool AddProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
PRBool DeleteProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
PRBool GetProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
PRBool SetProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
PRBool EnumerateProperty(JSContext *aContext);
|
||||
PRBool Resolve(JSContext *aContext, jsval aID);
|
||||
PRBool Convert(JSContext *aContext, jsval aID);
|
||||
void Finalize(JSContext *aContext);
|
||||
|
||||
// Implementation for nsISupports
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID,
|
||||
void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
nsresult RenderFrame(nsIPresContext*);
|
||||
|
||||
nsresult AddScriptEventListener(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
REFNSIID aIID);
|
||||
|
||||
void TriggerLink(nsIPresContext* aPresContext,
|
||||
nsLinkVerb aVerb,
|
||||
nsIURI* aBaseURL,
|
||||
const nsString& aURLSpec,
|
||||
const nsString& aTargetSpec,
|
||||
PRBool aClick);
|
||||
|
||||
nsresult JoinTextNodes(nsIContent* aFirst,
|
||||
nsIContent* aSecond);
|
||||
|
||||
static void SetDocumentInChildrenOf(nsIContent* aContent,
|
||||
nsIDocument* aDocument);
|
||||
|
||||
static nsresult GetScriptObjectFactory(nsIDOMScriptObjectFactory **aFactory);
|
||||
|
||||
static nsIDOMScriptObjectFactory *gScriptObjectFactory;
|
||||
|
||||
static nsIAtom* CutNameSpacePrefix(nsString& aString);
|
||||
|
||||
nsDOMSlots *GetDOMSlots();
|
||||
|
||||
// Up pointer to the real content object that we are
|
||||
// supporting. Sometimes there is work that we just can't do
|
||||
// ourselves, so this is needed to ask the real object to do the
|
||||
// work.
|
||||
nsIContent* mContent;
|
||||
|
||||
nsIDocument* mDocument;
|
||||
nsIContent* mParent;
|
||||
nsIAtom* mTag;
|
||||
nsIEventListenerManager* mListenerManager;
|
||||
nsDOMSlots *mDOMSlots;
|
||||
PRUint32 mContentID;
|
||||
};
|
||||
|
||||
class nsGenericContainerElement : public nsGenericElement {
|
||||
public:
|
||||
nsGenericContainerElement();
|
||||
~nsGenericContainerElement();
|
||||
|
||||
nsresult CopyInnerTo(nsIContent* aSrcContent,
|
||||
nsGenericContainerElement* aDest,
|
||||
PRBool aDeep);
|
||||
|
||||
// Remainder of nsIDOMHTMLElement (and nsIDOMNode)
|
||||
nsresult GetAttribute(const nsString& aName, nsString& aReturn)
|
||||
{
|
||||
return nsGenericElement::GetAttribute(aName, aReturn);
|
||||
}
|
||||
nsresult SetAttribute(const nsString& aName, const nsString& aValue)
|
||||
{
|
||||
return nsGenericElement::SetAttribute(aName, aValue);
|
||||
}
|
||||
nsresult GetChildNodes(nsIDOMNodeList** aChildNodes);
|
||||
nsresult HasChildNodes(PRBool* aHasChildNodes);
|
||||
nsresult GetFirstChild(nsIDOMNode** aFirstChild);
|
||||
nsresult GetLastChild(nsIDOMNode** aLastChild);
|
||||
|
||||
nsresult InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn);
|
||||
nsresult ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn);
|
||||
nsresult RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn);
|
||||
nsresult AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn);
|
||||
|
||||
// Remainder of nsIContent
|
||||
nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsString& aValue,
|
||||
PRBool aNotify);
|
||||
nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsString& aResult) const;
|
||||
nsresult UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
PRBool aNotify);
|
||||
nsresult GetAttributeNameAt(PRInt32 aIndex,
|
||||
PRInt32& aNameSpaceID,
|
||||
nsIAtom*& aName) const;
|
||||
nsresult GetAttributeCount(PRInt32& aResult) const;
|
||||
nsresult List(FILE* out, PRInt32 aIndent) const;
|
||||
nsresult CanContainChildren(PRBool& aResult) const;
|
||||
nsresult ChildCount(PRInt32& aResult) const;
|
||||
nsresult ChildAt(PRInt32 aIndex, nsIContent*& aResult) const;
|
||||
nsresult IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const;
|
||||
nsresult InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify);
|
||||
nsresult ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify);
|
||||
nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify);
|
||||
nsresult RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult FinishConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const;
|
||||
|
||||
void ListAttributes(FILE* out) const;
|
||||
|
||||
nsVoidArray* mAttributes;
|
||||
nsVoidArray mChildren;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Mostly implement the nsIDOMNode API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*
|
||||
* Note that classes using this macro will need to implement:
|
||||
* NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
*/
|
||||
#define NS_IMPL_IDOMNODE_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetNodeName(nsString& aNodeName) { \
|
||||
return _g.GetNodeName(aNodeName); \
|
||||
} \
|
||||
NS_IMETHOD GetNodeValue(nsString& aNodeValue) { \
|
||||
return _g.GetNodeValue(aNodeValue); \
|
||||
} \
|
||||
NS_IMETHOD SetNodeValue(const nsString& aNodeValue) { \
|
||||
return _g.SetNodeValue(aNodeValue); \
|
||||
} \
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType) { \
|
||||
return _g.GetNodeType(aNodeType); \
|
||||
} \
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) { \
|
||||
return _g.GetParentNode(aParentNode); \
|
||||
} \
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes) { \
|
||||
return _g.GetChildNodes(aChildNodes); \
|
||||
} \
|
||||
NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes) { \
|
||||
return _g.HasChildNodes(aHasChildNodes); \
|
||||
} \
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) { \
|
||||
return _g.GetFirstChild(aFirstChild); \
|
||||
} \
|
||||
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild) { \
|
||||
return _g.GetLastChild(aLastChild); \
|
||||
} \
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling) { \
|
||||
return _g.GetPreviousSibling(aPreviousSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling) { \
|
||||
return _g.GetNextSibling(aNextSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes) { \
|
||||
return _g.GetAttributes(aAttributes); \
|
||||
} \
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, \
|
||||
nsIDOMNode** aReturn) { \
|
||||
return _g.InsertBefore(aNewChild, aRefChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD AppendChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
|
||||
return _g.AppendChild(aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, \
|
||||
nsIDOMNode** aReturn) { \
|
||||
return _g.ReplaceChild(aNewChild, aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
|
||||
return _g.RemoveChild(aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument) { \
|
||||
return _g.GetOwnerDocument(aOwnerDocument); \
|
||||
} \
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
|
||||
/**
|
||||
* Implement the nsIDOMElement API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*/
|
||||
#define NS_IMPL_IDOMELEMENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetTagName(nsString& aTagName) { \
|
||||
return _g.GetTagName(aTagName); \
|
||||
} \
|
||||
NS_IMETHOD GetAttribute(const nsString& aName, nsString& aReturn) { \
|
||||
return _g.GetAttribute(aName, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD SetAttribute(const nsString& aName, const nsString& aValue) { \
|
||||
return _g.SetAttribute(aName, aValue); \
|
||||
} \
|
||||
NS_IMETHOD RemoveAttribute(const nsString& aName) { \
|
||||
return _g.RemoveAttribute(aName); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeNode(const nsString& aName, \
|
||||
nsIDOMAttr** aReturn) { \
|
||||
return _g.GetAttributeNode(aName, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn) { \
|
||||
return _g.SetAttributeNode(aNewAttr, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD RemoveAttributeNode(nsIDOMAttr* aOldAttr, nsIDOMAttr** aReturn) {\
|
||||
return _g.RemoveAttributeNode(aOldAttr, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD GetElementsByTagName(const nsString& aTagname, \
|
||||
nsIDOMNodeList** aReturn) { \
|
||||
return _g.GetElementsByTagName(aTagname, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD Normalize() { \
|
||||
return _g.Normalize(); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement the nsIDOMEventReceiver API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*/
|
||||
#define NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(_g) \
|
||||
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, \
|
||||
const nsIID& aIID) { \
|
||||
return _g.AddEventListenerByIID(aListener, aIID); \
|
||||
} \
|
||||
NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener, \
|
||||
const nsIID& aIID) { \
|
||||
return _g.RemoveEventListenerByIID(aListener, aIID); \
|
||||
} \
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aResult) { \
|
||||
return _g.GetListenerManager(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetNewListenerManager(nsIEventListenerManager** aResult) { \
|
||||
return _g.GetNewListenerManager(aResult); \
|
||||
} \
|
||||
NS_IMETHOD AddEventListener(const nsString& aType, \
|
||||
nsIDOMEventListener* aListener, \
|
||||
PRBool aUseCapture) { \
|
||||
return _g.AddEventListener(aType, aListener, aUseCapture); \
|
||||
} \
|
||||
NS_IMETHOD RemoveEventListener(const nsString& aType, \
|
||||
nsIDOMEventListener* aListener, \
|
||||
PRBool aUseCapture) { \
|
||||
return _g.RemoveEventListener(aType, aListener, aUseCapture); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_ICONTENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \
|
||||
return _g.GetDocument(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { \
|
||||
return _g.SetDocument(aDocument, aDeep); \
|
||||
} \
|
||||
NS_IMETHOD GetParent(nsIContent*& aResult) const { \
|
||||
return _g.GetParent(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetParent(nsIContent* aParent) { \
|
||||
return _g.SetParent(aParent); \
|
||||
} \
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const { \
|
||||
return _g.CanContainChildren(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const { \
|
||||
return _g.ChildCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { \
|
||||
return _g.ChildAt(aIndex, aResult); \
|
||||
} \
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { \
|
||||
return _g.IndexOf(aPossibleChild, aResult); \
|
||||
} \
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, \
|
||||
PRBool aNotify) { \
|
||||
return _g.InsertChildAt(aKid, aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, \
|
||||
PRBool aNotify) { \
|
||||
return _g.ReplaceChildAt(aKid, aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { \
|
||||
return _g.AppendChildTo(aKid, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { \
|
||||
return _g.RemoveChildAt(aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD IsSynthetic(PRBool& aResult) { \
|
||||
return _g.IsSynthetic(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32& aResult) const { \
|
||||
return _g.GetNameSpaceID(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const { \
|
||||
return _g.GetTag(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ParseAttributeString(const nsString& aStr, \
|
||||
nsIAtom*& aName, \
|
||||
PRInt32& aNameSpaceID) { \
|
||||
return _g.ParseAttributeString(aStr, aName, aNameSpaceID); \
|
||||
} \
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID, \
|
||||
nsIAtom*& aPrefix) { \
|
||||
return _g.GetNameSpacePrefixFromId(aNameSpaceID, aPrefix); \
|
||||
} \
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \
|
||||
const nsString& aValue, PRBool aNotify) { \
|
||||
return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \
|
||||
nsString& aResult) const { \
|
||||
return _g.GetAttribute(aNameSpaceID, aName, aResult); \
|
||||
} \
|
||||
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, \
|
||||
PRBool aNotify) { \
|
||||
return _g.UnsetAttribute(aNameSpaceID, aAttribute, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex, \
|
||||
PRInt32& aNameSpaceID, \
|
||||
nsIAtom*& aName) const { \
|
||||
return _g.GetAttributeNameAt(aIndex, aNameSpaceID, aName); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \
|
||||
return _g.GetAttributeCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const { \
|
||||
return _g.List(out, aIndent); \
|
||||
} \
|
||||
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.BeginConvertToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.ConvertContentToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.FinishConvertToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, \
|
||||
nsEvent* aEvent, \
|
||||
nsIDOMEvent** aDOMEvent, \
|
||||
PRUint32 aFlags, \
|
||||
nsEventStatus* aEventStatus); \
|
||||
NS_IMETHOD GetContentID(PRUint32* aID) { \
|
||||
return _g.GetContentID(aID); \
|
||||
} \
|
||||
NS_IMETHOD SetContentID(PRUint32 aID) { \
|
||||
return _g.SetContentID(aID); \
|
||||
} \
|
||||
NS_IMETHOD RangeAdd(nsIDOMRange& aRange) { \
|
||||
return _g.RangeAdd(aRange); \
|
||||
} \
|
||||
NS_IMETHOD RangeRemove(nsIDOMRange& aRange) { \
|
||||
return _g.RangeRemove(aRange); \
|
||||
} \
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const { \
|
||||
return _g.GetRangeList(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
|
||||
#define NS_IMPL_ICONTENT_NO_SETPARENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \
|
||||
return _g.GetDocument(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { \
|
||||
return _g.SetDocument(aDocument, aDeep); \
|
||||
} \
|
||||
NS_IMETHOD GetParent(nsIContent*& aResult) const { \
|
||||
return _g.GetParent(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetParent(nsIContent* aParent); \
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const { \
|
||||
return _g.CanContainChildren(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const { \
|
||||
return _g.ChildCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { \
|
||||
return _g.ChildAt(aIndex, aResult); \
|
||||
} \
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { \
|
||||
return _g.IndexOf(aPossibleChild, aResult); \
|
||||
} \
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, \
|
||||
PRBool aNotify) { \
|
||||
return _g.InsertChildAt(aKid, aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, \
|
||||
PRBool aNotify) { \
|
||||
return _g.ReplaceChildAt(aKid, aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { \
|
||||
return _g.AppendChildTo(aKid, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { \
|
||||
return _g.RemoveChildAt(aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD IsSynthetic(PRBool& aResult) { \
|
||||
return _g.IsSynthetic(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32& aResult) const { \
|
||||
return _g.GetNameSpaceID(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const { \
|
||||
return _g.GetTag(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ParseAttributeString(const nsString& aStr, \
|
||||
nsIAtom*& aName, \
|
||||
PRInt32& aNameSpaceID) { \
|
||||
return _g.ParseAttributeString(aStr, aName, aNameSpaceID); \
|
||||
} \
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID, \
|
||||
nsIAtom*& aPrefix) { \
|
||||
return _g.GetNameSpacePrefixFromId(aNameSpaceID, aPrefix); \
|
||||
} \
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \
|
||||
const nsString& aValue, PRBool aNotify) { \
|
||||
return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \
|
||||
nsString& aResult) const { \
|
||||
return _g.GetAttribute(aNameSpaceID, aName, aResult); \
|
||||
} \
|
||||
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, \
|
||||
PRBool aNotify) { \
|
||||
return _g.UnsetAttribute(aNameSpaceID, aAttribute, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex, \
|
||||
PRInt32& aNameSpaceID, \
|
||||
nsIAtom*& aName) const { \
|
||||
return _g.GetAttributeNameAt(aIndex, aNameSpaceID, aName); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \
|
||||
return _g.GetAttributeCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const { \
|
||||
return _g.List(out, aIndent); \
|
||||
} \
|
||||
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.BeginConvertToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.ConvertContentToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.FinishConvertToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, \
|
||||
nsEvent* aEvent, \
|
||||
nsIDOMEvent** aDOMEvent, \
|
||||
PRUint32 aFlags, \
|
||||
nsEventStatus* aEventStatus); \
|
||||
NS_IMETHOD GetContentID(PRUint32* aID) { \
|
||||
return _g.GetContentID(aID); \
|
||||
} \
|
||||
NS_IMETHOD SetContentID(PRUint32 aID) { \
|
||||
return _g.SetContentID(aID); \
|
||||
} \
|
||||
NS_IMETHOD RangeAdd(nsIDOMRange& aRange) { \
|
||||
return _g.RangeAdd(aRange); \
|
||||
} \
|
||||
NS_IMETHOD RangeRemove(nsIDOMRange& aRange) { \
|
||||
return _g.RangeRemove(aRange); \
|
||||
} \
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const { \
|
||||
return _g.GetRangeList(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
|
||||
#define NS_IMPL_ICONTENT_NO_SETDOCUMENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \
|
||||
return _g.GetDocument(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep); \
|
||||
NS_IMETHOD GetParent(nsIContent*& aResult) const { \
|
||||
return _g.GetParent(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetParent(nsIContent* aParent) { \
|
||||
return _g.SetParent(aParent); \
|
||||
} \
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const { \
|
||||
return _g.CanContainChildren(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const { \
|
||||
return _g.ChildCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { \
|
||||
return _g.ChildAt(aIndex, aResult); \
|
||||
} \
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { \
|
||||
return _g.IndexOf(aPossibleChild, aResult); \
|
||||
} \
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, \
|
||||
PRBool aNotify) { \
|
||||
return _g.InsertChildAt(aKid, aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, \
|
||||
PRBool aNotify) { \
|
||||
return _g.ReplaceChildAt(aKid, aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { \
|
||||
return _g.AppendChildTo(aKid, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { \
|
||||
return _g.RemoveChildAt(aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD IsSynthetic(PRBool& aResult) { \
|
||||
return _g.IsSynthetic(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32& aResult) const { \
|
||||
return _g.GetNameSpaceID(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const { \
|
||||
return _g.GetTag(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ParseAttributeString(const nsString& aStr, \
|
||||
nsIAtom*& aName, \
|
||||
PRInt32& aNameSpaceID) { \
|
||||
return _g.ParseAttributeString(aStr, aName, aNameSpaceID); \
|
||||
} \
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID, \
|
||||
nsIAtom*& aPrefix) { \
|
||||
return _g.GetNameSpacePrefixFromId(aNameSpaceID, aPrefix); \
|
||||
} \
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \
|
||||
const nsString& aValue, PRBool aNotify) { \
|
||||
return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \
|
||||
nsString& aResult) const { \
|
||||
return _g.GetAttribute(aNameSpaceID, aName, aResult); \
|
||||
} \
|
||||
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, \
|
||||
PRBool aNotify) { \
|
||||
return _g.UnsetAttribute(aNameSpaceID, aAttribute, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex, \
|
||||
PRInt32& aNameSpaceID, \
|
||||
nsIAtom*& aName) const { \
|
||||
return _g.GetAttributeNameAt(aIndex, aNameSpaceID, aName); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \
|
||||
return _g.GetAttributeCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const { \
|
||||
return _g.List(out, aIndent); \
|
||||
} \
|
||||
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.BeginConvertToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.ConvertContentToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.FinishConvertToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, \
|
||||
nsEvent* aEvent, \
|
||||
nsIDOMEvent** aDOMEvent, \
|
||||
PRUint32 aFlags, \
|
||||
nsEventStatus* aEventStatus); \
|
||||
NS_IMETHOD GetContentID(PRUint32* aID) { \
|
||||
return _g.GetContentID(aID); \
|
||||
} \
|
||||
NS_IMETHOD SetContentID(PRUint32 aID) { \
|
||||
return _g.SetContentID(aID); \
|
||||
} \
|
||||
NS_IMETHOD RangeAdd(nsIDOMRange& aRange) { \
|
||||
return _g.RangeAdd(aRange); \
|
||||
} \
|
||||
NS_IMETHOD RangeRemove(nsIDOMRange& aRange) { \
|
||||
return _g.RangeRemove(aRange); \
|
||||
} \
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const { \
|
||||
return _g.GetRangeList(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
|
||||
#define NS_IMPL_ICONTENT_NO_SETPARENT_NO_SETDOCUMENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \
|
||||
return _g.GetDocument(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep); \
|
||||
NS_IMETHOD GetParent(nsIContent*& aResult) const { \
|
||||
return _g.GetParent(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetParent(nsIContent* aParent); \
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const { \
|
||||
return _g.CanContainChildren(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const { \
|
||||
return _g.ChildCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { \
|
||||
return _g.ChildAt(aIndex, aResult); \
|
||||
} \
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { \
|
||||
return _g.IndexOf(aPossibleChild, aResult); \
|
||||
} \
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, \
|
||||
PRBool aNotify) { \
|
||||
return _g.InsertChildAt(aKid, aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, \
|
||||
PRBool aNotify) { \
|
||||
return _g.ReplaceChildAt(aKid, aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { \
|
||||
return _g.AppendChildTo(aKid, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { \
|
||||
return _g.RemoveChildAt(aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD IsSynthetic(PRBool& aResult) { \
|
||||
return _g.IsSynthetic(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32& aResult) const { \
|
||||
return _g.GetNameSpaceID(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const { \
|
||||
return _g.GetTag(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ParseAttributeString(const nsString& aStr, \
|
||||
nsIAtom*& aName, \
|
||||
PRInt32& aNameSpaceID) { \
|
||||
return _g.ParseAttributeString(aStr, aName, aNameSpaceID); \
|
||||
} \
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID, \
|
||||
nsIAtom*& aPrefix) { \
|
||||
return _g.GetNameSpacePrefixFromId(aNameSpaceID, aPrefix); \
|
||||
} \
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \
|
||||
const nsString& aValue, PRBool aNotify) { \
|
||||
return _g.SetAttribute(aNameSpaceID, aName, aValue, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \
|
||||
nsString& aResult) const { \
|
||||
return _g.GetAttribute(aNameSpaceID, aName, aResult); \
|
||||
} \
|
||||
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, \
|
||||
PRBool aNotify) { \
|
||||
return _g.UnsetAttribute(aNameSpaceID, aAttribute, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex, \
|
||||
PRInt32& aNameSpaceID, \
|
||||
nsIAtom*& aName) const { \
|
||||
return _g.GetAttributeNameAt(aIndex, aNameSpaceID, aName); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \
|
||||
return _g.GetAttributeCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const { \
|
||||
return _g.List(out, aIndent); \
|
||||
} \
|
||||
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.BeginConvertToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.ConvertContentToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.FinishConvertToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, \
|
||||
nsEvent* aEvent, \
|
||||
nsIDOMEvent** aDOMEvent, \
|
||||
PRUint32 aFlags, \
|
||||
nsEventStatus* aEventStatus); \
|
||||
NS_IMETHOD GetContentID(PRUint32* aID) { \
|
||||
return _g.GetContentID(aID); \
|
||||
} \
|
||||
NS_IMETHOD SetContentID(PRUint32 aID) { \
|
||||
return _g.SetContentID(aID); \
|
||||
} \
|
||||
NS_IMETHOD RangeAdd(nsIDOMRange& aRange) { \
|
||||
return _g.RangeAdd(aRange); \
|
||||
} \
|
||||
NS_IMETHOD RangeRemove(nsIDOMRange& aRange) { \
|
||||
return _g.RangeRemove(aRange); \
|
||||
} \
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const { \
|
||||
return _g.GetRangeList(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
|
||||
/**
|
||||
* Implement the nsIScriptObjectOwner API by forwarding the methods to a
|
||||
* generic content object
|
||||
*/
|
||||
#define NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, \
|
||||
void** aScriptObject) { \
|
||||
return _g.GetScriptObject(aContext, aScriptObject); \
|
||||
} \
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject) { \
|
||||
return _g.SetScriptObject(aScriptObject); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_CONTENT_QUERY_INTERFACE(_id, _iptr, _this, _base) \
|
||||
if (_id.Equals(kISupportsIID)) { \
|
||||
_base* tmp = _this; \
|
||||
nsISupports* tmp2 = tmp; \
|
||||
*_iptr = (void*) tmp2; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMNodeIID)) { \
|
||||
nsIDOMNode* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMElementIID)) { \
|
||||
nsIDOMElement* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMEventReceiverIID)) { \
|
||||
nsIDOMEventReceiver* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMEventTargetIID)) { \
|
||||
nsIDOMEventTarget* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIScriptObjectOwnerIID)) { \
|
||||
nsIScriptObjectOwner* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIContentIID)) { \
|
||||
_base* tmp = _this; \
|
||||
nsIContent* tmp2 = tmp; \
|
||||
*_iptr = (void*) tmp2; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIJSScriptObjectIID)) { \
|
||||
nsIJSScriptObject* tmp = (nsIJSScriptObject*)&mInner; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
#endif /* nsGenericElement_h___ */
|
||||
478
mozilla/content/base/src/nsNameSpaceManager.cpp
Normal file
478
mozilla/content/base/src/nsNameSpaceManager.cpp
Normal file
@@ -0,0 +1,478 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsINameSpace.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
static NS_DEFINE_IID(kINameSpaceManagerIID, NS_INAMESPACEMANAGER_IID);
|
||||
static NS_DEFINE_IID(kINameSpaceIID, NS_INAMESPACE_IID);
|
||||
|
||||
|
||||
static const char kXMLNSNameSpaceURI[] = "<This isn't really a namespace>";
|
||||
static const char kXMLNameSpaceURI[] = "http://www.w3.org/XML/1998/namespace";
|
||||
static const char kHTMLNameSpaceURI[] = "http://www.w3.org/TR/REC-html40"; // XXX?? "urn:w3-org-ns:HTML"??
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Name Space ID table support
|
||||
|
||||
static PRInt32 gNameSpaceTableRefs;
|
||||
static nsHashtable* gURIToIDTable;
|
||||
static nsVoidArray* gURIArray;
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(NameSpaceURIKey);
|
||||
|
||||
class NameSpaceURIKey : public nsHashKey {
|
||||
public:
|
||||
NameSpaceURIKey(const nsString* aString)
|
||||
: mString(aString)
|
||||
{
|
||||
MOZ_COUNT_CTOR(NameSpaceURIKey);
|
||||
}
|
||||
|
||||
virtual ~NameSpaceURIKey(void)
|
||||
{
|
||||
MOZ_COUNT_DTOR(NameSpaceURIKey);
|
||||
}
|
||||
|
||||
virtual PRUint32 HashValue(void) const
|
||||
{
|
||||
#if 1 // case insensitive XXX should this be case sensitive???
|
||||
PRUint32 hash = 0;
|
||||
const PRUnichar* string = mString->GetUnicode();
|
||||
PRUnichar ch;
|
||||
while ((ch = *string++) != 0) {
|
||||
// FYI: hash = hash*37 + ch
|
||||
ch = nsCRT::ToLower(ch);
|
||||
hash = ((hash << 5) + (hash << 2) + hash) + ch;
|
||||
}
|
||||
return hash;
|
||||
#else
|
||||
if (nsnull != mString) {
|
||||
return nsCRT::HashValue(mString->GetUnicode());
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual PRBool Equals(const nsHashKey *aKey) const
|
||||
{
|
||||
const nsString* other = ((const NameSpaceURIKey*)aKey)->mString;
|
||||
if (nsnull != mString) {
|
||||
if (nsnull != other) {
|
||||
return mString->EqualsIgnoreCase(*other); // XXX case sensitive?
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
return PRBool(nsnull == other);
|
||||
}
|
||||
|
||||
virtual nsHashKey *Clone(void) const
|
||||
{
|
||||
return new NameSpaceURIKey(mString);
|
||||
}
|
||||
|
||||
const nsString* mString;
|
||||
};
|
||||
|
||||
static void AddRefTable()
|
||||
{
|
||||
if (0 == gNameSpaceTableRefs++) {
|
||||
NS_ASSERTION(nsnull == gURIToIDTable, "already have URI table");
|
||||
NS_ASSERTION(nsnull == gURIArray, "already have URI array");
|
||||
|
||||
gURIToIDTable = new nsHashtable();
|
||||
gURIArray = new nsVoidArray();
|
||||
|
||||
nsString* xmlns = new nsString(kXMLNSNameSpaceURI);
|
||||
nsString* xml = new nsString(kXMLNameSpaceURI);
|
||||
nsString* html = new nsString(kHTMLNameSpaceURI);
|
||||
gURIArray->AppendElement(xmlns); // ordering here needs to match IDs
|
||||
gURIArray->AppendElement(xml);
|
||||
gURIArray->AppendElement(html);
|
||||
NameSpaceURIKey xmlnsKey(xmlns);
|
||||
NameSpaceURIKey xmlKey(xml);
|
||||
NameSpaceURIKey htmlKey(html);
|
||||
gURIToIDTable->Put(&xmlnsKey, (void*)kNameSpaceID_XMLNS);
|
||||
gURIToIDTable->Put(&xmlKey, (void*)kNameSpaceID_XML);
|
||||
gURIToIDTable->Put(&htmlKey, (void*)kNameSpaceID_HTML);
|
||||
}
|
||||
NS_ASSERTION(nsnull != gURIToIDTable, "no URI table");
|
||||
NS_ASSERTION(nsnull != gURIArray, "no URI array");
|
||||
}
|
||||
|
||||
static void ReleaseTable()
|
||||
{
|
||||
if (0 == --gNameSpaceTableRefs) {
|
||||
delete gURIToIDTable;
|
||||
PRInt32 index = gURIArray->Count();
|
||||
while (0 < index--) {
|
||||
nsString* str = (nsString*)gURIArray->ElementAt(index);
|
||||
delete str;
|
||||
}
|
||||
delete gURIArray;
|
||||
gURIToIDTable = nsnull;
|
||||
gURIArray = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
static PRInt32 FindNameSpaceID(const nsString& aURI)
|
||||
{
|
||||
NS_ASSERTION(nsnull != gURIToIDTable, "no URI table");
|
||||
NameSpaceURIKey key(&aURI);
|
||||
void* value = gURIToIDTable->Get(&key);
|
||||
if (nsnull != value) {
|
||||
return PRInt32(value);
|
||||
}
|
||||
return kNameSpaceID_Unknown;
|
||||
}
|
||||
|
||||
static const nsString* FindNameSpaceURI(PRInt32 aID)
|
||||
{
|
||||
NS_ASSERTION(nsnull != gURIArray, "no URI array");
|
||||
return (const nsString*)gURIArray->ElementAt(aID - 1);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Name Space
|
||||
|
||||
class NameSpaceImpl : public nsINameSpace {
|
||||
public:
|
||||
NameSpaceImpl(nsINameSpaceManager* aManager,
|
||||
NameSpaceImpl* aParent,
|
||||
nsIAtom* aPrefix,
|
||||
const nsString& aURI);
|
||||
NameSpaceImpl(nsINameSpaceManager* aManager,
|
||||
NameSpaceImpl* aParent,
|
||||
nsIAtom* aPrefix,
|
||||
PRInt32 aNameSpaceID);
|
||||
virtual ~NameSpaceImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager) const;
|
||||
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32& aID) const;
|
||||
NS_IMETHOD GetNameSpaceURI(nsString& aURI) const;
|
||||
NS_IMETHOD GetNameSpacePrefix(nsIAtom*& aPrefix) const;
|
||||
|
||||
NS_IMETHOD GetParentNameSpace(nsINameSpace*& aParent) const;
|
||||
|
||||
NS_IMETHOD FindNameSpace(nsIAtom* aPrefix, nsINameSpace*& aNameSpace) const;
|
||||
NS_IMETHOD FindNameSpaceID(nsIAtom* aPrefix, PRInt32& aNameSpaceID) const;
|
||||
NS_IMETHOD FindNameSpacePrefix(PRInt32 aNameSpaceID, nsIAtom*& aPrefix) const;
|
||||
|
||||
NS_IMETHOD CreateChildNameSpace(nsIAtom* aPrefix, const nsString& aURI,
|
||||
nsINameSpace*& aChildNameSpace);
|
||||
NS_IMETHOD CreateChildNameSpace(nsIAtom* aPrefix, PRInt32 aNameSpaceID,
|
||||
nsINameSpace*& aChildNameSpace);
|
||||
|
||||
private:
|
||||
// These are not supported and are not implemented!
|
||||
NameSpaceImpl(const NameSpaceImpl& aCopy);
|
||||
NameSpaceImpl& operator=(const NameSpaceImpl& aCopy);
|
||||
|
||||
public:
|
||||
nsINameSpaceManager* mManager;
|
||||
NameSpaceImpl* mParent;
|
||||
nsIAtom* mPrefix;
|
||||
PRInt32 mID;
|
||||
};
|
||||
|
||||
NameSpaceImpl::NameSpaceImpl(nsINameSpaceManager* aManager,
|
||||
NameSpaceImpl* aParent,
|
||||
nsIAtom* aPrefix,
|
||||
const nsString& aURI)
|
||||
: mManager(aManager),
|
||||
mParent(aParent),
|
||||
mPrefix(aPrefix)
|
||||
{
|
||||
NS_ASSERTION(nsnull != aManager, "null namespace manager");
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF(mManager);
|
||||
NS_IF_ADDREF(mParent);
|
||||
NS_IF_ADDREF(mPrefix);
|
||||
mManager->RegisterNameSpace(aURI, mID);
|
||||
}
|
||||
|
||||
NameSpaceImpl::NameSpaceImpl(nsINameSpaceManager* aManager,
|
||||
NameSpaceImpl* aParent,
|
||||
nsIAtom* aPrefix,
|
||||
PRInt32 aNameSpaceID)
|
||||
: mManager(aManager),
|
||||
mParent(aParent),
|
||||
mPrefix(aPrefix),
|
||||
mID(aNameSpaceID)
|
||||
{
|
||||
NS_ASSERTION(nsnull != aManager, "null namespace manager");
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF(mManager);
|
||||
NS_IF_ADDREF(mParent);
|
||||
NS_IF_ADDREF(mPrefix);
|
||||
}
|
||||
|
||||
NameSpaceImpl::~NameSpaceImpl()
|
||||
{
|
||||
NS_RELEASE(mManager);
|
||||
NS_IF_RELEASE(mParent);
|
||||
NS_IF_RELEASE(mPrefix);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(NameSpaceImpl, kINameSpaceIID)
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::GetNameSpaceManager(nsINameSpaceManager*& aManager) const
|
||||
{
|
||||
NS_ASSERTION(nsnull != aManager, "null namespace manager");
|
||||
aManager = mManager;
|
||||
NS_ADDREF(aManager);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::GetNameSpaceID(PRInt32& aID) const
|
||||
{
|
||||
aID = mID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::GetNameSpaceURI(nsString& aURI) const
|
||||
{
|
||||
NS_ASSERTION(nsnull != mManager, "null namespace manager");
|
||||
return mManager->GetNameSpaceURI(mID, aURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::GetNameSpacePrefix(nsIAtom*& aPrefix) const
|
||||
{
|
||||
aPrefix = mPrefix;
|
||||
NS_IF_ADDREF(aPrefix);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::GetParentNameSpace(nsINameSpace*& aParent) const
|
||||
{
|
||||
aParent = mParent;
|
||||
NS_IF_ADDREF(aParent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::FindNameSpace(nsIAtom* aPrefix, nsINameSpace*& aNameSpace) const
|
||||
{
|
||||
const NameSpaceImpl* nameSpace = this;
|
||||
do {
|
||||
if (aPrefix == nameSpace->mPrefix) {
|
||||
aNameSpace = (nsINameSpace*)nameSpace;
|
||||
NS_ADDREF(aNameSpace);
|
||||
return NS_OK;
|
||||
}
|
||||
nameSpace = nameSpace->mParent;
|
||||
}
|
||||
while (nsnull != nameSpace);
|
||||
aNameSpace = nsnull;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::FindNameSpaceID(nsIAtom* aPrefix, PRInt32& aNameSpaceID) const
|
||||
{
|
||||
const NameSpaceImpl* nameSpace = this;
|
||||
do {
|
||||
if (aPrefix == nameSpace->mPrefix) {
|
||||
aNameSpaceID = nameSpace->mID;
|
||||
return NS_OK;
|
||||
}
|
||||
nameSpace = nameSpace->mParent;
|
||||
}
|
||||
while (nsnull != nameSpace);
|
||||
if (nsnull == aPrefix) {
|
||||
aNameSpaceID = kNameSpaceID_None;
|
||||
}
|
||||
else {
|
||||
aNameSpaceID = kNameSpaceID_Unknown;
|
||||
}
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::FindNameSpacePrefix(PRInt32 aNameSpaceID, nsIAtom*& aPrefix) const
|
||||
{
|
||||
const NameSpaceImpl* nameSpace = this;
|
||||
do {
|
||||
if (aNameSpaceID == nameSpace->mID) {
|
||||
aPrefix = nameSpace->mPrefix;
|
||||
NS_IF_ADDREF(aPrefix);
|
||||
return NS_OK;
|
||||
}
|
||||
nameSpace = nameSpace->mParent;
|
||||
}
|
||||
while (nsnull != nameSpace);
|
||||
aPrefix = nsnull;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::CreateChildNameSpace(nsIAtom* aPrefix, const nsString& aURI,
|
||||
nsINameSpace*& aChildNameSpace)
|
||||
{
|
||||
NameSpaceImpl* child = new NameSpaceImpl(mManager, this, aPrefix, aURI);
|
||||
|
||||
if (child) {
|
||||
return child->QueryInterface(kINameSpaceIID, (void**)&aChildNameSpace);
|
||||
}
|
||||
aChildNameSpace = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::CreateChildNameSpace(nsIAtom* aPrefix, PRInt32 aNameSpaceID,
|
||||
nsINameSpace*& aChildNameSpace)
|
||||
{
|
||||
if (FindNameSpaceURI(aNameSpaceID)) {
|
||||
NameSpaceImpl* child = new NameSpaceImpl(mManager, this, aPrefix, aNameSpaceID);
|
||||
|
||||
if (child) {
|
||||
return child->QueryInterface(kINameSpaceIID, (void**)&aChildNameSpace);
|
||||
}
|
||||
aChildNameSpace = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
aChildNameSpace = nsnull;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Name Space Manager
|
||||
|
||||
class NameSpaceManagerImpl : public nsINameSpaceManager {
|
||||
public:
|
||||
NameSpaceManagerImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CreateRootNameSpace(nsINameSpace*& aRootNameSpace);
|
||||
|
||||
NS_IMETHOD RegisterNameSpace(const nsString& aURI,
|
||||
PRInt32& aNameSpaceID);
|
||||
|
||||
NS_IMETHOD GetNameSpaceURI(PRInt32 aNameSpaceID, nsString& aURI);
|
||||
NS_IMETHOD GetNameSpaceID(const nsString& aURI, PRInt32& aNameSpaceID);
|
||||
|
||||
private:
|
||||
// These are not supported and are not implemented!
|
||||
NameSpaceManagerImpl(const NameSpaceManagerImpl& aCopy);
|
||||
NameSpaceManagerImpl& operator=(const NameSpaceManagerImpl& aCopy);
|
||||
|
||||
protected:
|
||||
virtual ~NameSpaceManagerImpl();
|
||||
|
||||
};
|
||||
|
||||
NameSpaceManagerImpl::NameSpaceManagerImpl()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
AddRefTable();
|
||||
}
|
||||
|
||||
NameSpaceManagerImpl::~NameSpaceManagerImpl()
|
||||
{
|
||||
ReleaseTable();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(NameSpaceManagerImpl, kINameSpaceManagerIID)
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceManagerImpl::CreateRootNameSpace(nsINameSpace*& aRootNameSpace)
|
||||
{
|
||||
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
aRootNameSpace = nsnull;
|
||||
|
||||
NameSpaceImpl* xmlns = new NameSpaceImpl(this, nsnull, nsLayoutAtoms::xmlnsNameSpace, kNameSpaceID_XMLNS);
|
||||
if (nsnull != xmlns) {
|
||||
NameSpaceImpl* xml = new NameSpaceImpl(this, xmlns, nsLayoutAtoms::xmlNameSpace, kNameSpaceID_XML);
|
||||
if (nsnull != xml) {
|
||||
rv = xml->QueryInterface(kINameSpaceIID, (void**)&aRootNameSpace);
|
||||
}
|
||||
else {
|
||||
delete xmlns;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceManagerImpl::RegisterNameSpace(const nsString& aURI,
|
||||
PRInt32& aNameSpaceID)
|
||||
{
|
||||
PRInt32 id = FindNameSpaceID(aURI);
|
||||
|
||||
if (kNameSpaceID_Unknown == id) {
|
||||
nsString* uri = new nsString(aURI);
|
||||
gURIArray->AppendElement(uri);
|
||||
id = gURIArray->Count(); // id is index + 1
|
||||
NameSpaceURIKey key(uri);
|
||||
gURIToIDTable->Put(&key, (void*)id);
|
||||
}
|
||||
aNameSpaceID = id;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceManagerImpl::GetNameSpaceURI(PRInt32 aNameSpaceID, nsString& aURI)
|
||||
{
|
||||
const nsString* result = FindNameSpaceURI(aNameSpaceID);
|
||||
if (nsnull != result) {
|
||||
aURI = *result;
|
||||
return NS_OK;
|
||||
}
|
||||
aURI.Truncate();
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceManagerImpl::GetNameSpaceID(const nsString& aURI, PRInt32& aNameSpaceID)
|
||||
{
|
||||
aNameSpaceID = FindNameSpaceID(aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_LAYOUT nsresult
|
||||
NS_NewNameSpaceManager(nsINameSpaceManager** aInstancePtrResult)
|
||||
{
|
||||
if (aInstancePtrResult == nsnull) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
NameSpaceManagerImpl *it = new NameSpaceManagerImpl();
|
||||
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return it->QueryInterface(kINameSpaceManagerIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
2000
mozilla/content/base/src/nsRange.cpp
Normal file
2000
mozilla/content/base/src/nsRange.cpp
Normal file
File diff suppressed because it is too large
Load Diff
217
mozilla/content/base/src/nsRange.h
Normal file
217
mozilla/content/base/src/nsRange.h
Normal file
@@ -0,0 +1,217 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsRange_h___
|
||||
#define nsRange_h___
|
||||
|
||||
/*
|
||||
* nsRange.h: interface of the nsRange object.
|
||||
*/
|
||||
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMNSRange.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "prmon.h"
|
||||
|
||||
class nsVoidArray;
|
||||
|
||||
class nsRange : public nsIDOMRange,
|
||||
public nsIDOMNSRange,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsRange();
|
||||
virtual ~nsRange();
|
||||
|
||||
// nsIDOMRange interface
|
||||
|
||||
NS_IMETHOD GetIsPositioned(PRBool* aIsPositioned);
|
||||
|
||||
NS_IMETHOD GetStartParent(nsIDOMNode** aStartParent);
|
||||
NS_IMETHOD GetStartOffset(PRInt32* aStartOffset);
|
||||
|
||||
NS_IMETHOD GetEndParent(nsIDOMNode** aEndParent);
|
||||
NS_IMETHOD GetEndOffset(PRInt32* aEndOffset);
|
||||
|
||||
NS_IMETHOD GetIsCollapsed(PRBool* aIsCollapsed);
|
||||
|
||||
NS_IMETHOD GetCommonParent(nsIDOMNode** aCommonParent);
|
||||
|
||||
NS_IMETHOD SetStart(nsIDOMNode* aParent, PRInt32 aOffset);
|
||||
NS_IMETHOD SetStartBefore(nsIDOMNode* aSibling);
|
||||
NS_IMETHOD SetStartAfter(nsIDOMNode* aSibling);
|
||||
|
||||
NS_IMETHOD SetEnd(nsIDOMNode* aParent, PRInt32 aOffset);
|
||||
NS_IMETHOD SetEndBefore(nsIDOMNode* aSibling);
|
||||
NS_IMETHOD SetEndAfter(nsIDOMNode* aSibling);
|
||||
|
||||
NS_IMETHOD Collapse(PRBool aToStart);
|
||||
|
||||
NS_IMETHOD Unposition();
|
||||
|
||||
NS_IMETHOD SelectNode(nsIDOMNode* aN);
|
||||
NS_IMETHOD SelectNodeContents(nsIDOMNode* aN);
|
||||
|
||||
NS_IMETHOD CompareEndPoints(PRUint16 how, nsIDOMRange* srcRange, PRInt32* ret);
|
||||
|
||||
NS_IMETHOD DeleteContents();
|
||||
|
||||
NS_IMETHOD ExtractContents(nsIDOMDocumentFragment** aReturn);
|
||||
NS_IMETHOD CloneContents(nsIDOMDocumentFragment** aReturn);
|
||||
|
||||
NS_IMETHOD InsertNode(nsIDOMNode* aN);
|
||||
NS_IMETHOD SurroundContents(nsIDOMNode* aN);
|
||||
|
||||
NS_IMETHOD Clone(nsIDOMRange** aReturn);
|
||||
|
||||
NS_IMETHOD ToString(nsString& aReturn);
|
||||
|
||||
// nsIDOMNSRange interface
|
||||
NS_IMETHOD CreateContextualFragment(const nsString& aFragment,
|
||||
nsIDOMDocumentFragment** aReturn);
|
||||
NS_IMETHOD IsValidFragment(const nsString& aFragment, PRBool* aReturn);
|
||||
|
||||
/*BEGIN nsIScriptObjectOwner interface implementations*/
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
/*END nsIScriptObjectOwner interface implementations*/
|
||||
|
||||
// nsRange interface extensions
|
||||
|
||||
static NS_METHOD OwnerGone(nsIContent* aParentNode);
|
||||
|
||||
static NS_METHOD OwnerChildInserted(nsIContent* aParentNode, PRInt32 aOffset);
|
||||
|
||||
static NS_METHOD OwnerChildRemoved(nsIContent* aParentNode, PRInt32 aOffset, nsIContent* aRemovedNode);
|
||||
|
||||
static NS_METHOD OwnerChildReplaced(nsIContent* aParentNode, PRInt32 aOffset, nsIContent* aReplacedNode);
|
||||
|
||||
static NS_METHOD TextOwnerChanged(nsIContent* aTextNode, PRInt32 aStartOffset, PRInt32 aEndOffset, PRInt32 aReplaceLength);
|
||||
|
||||
//private: I wish VC++ would give me a &&*@!#$ break
|
||||
PRBool mIsPositioned;
|
||||
PRInt32 mStartOffset;
|
||||
PRInt32 mEndOffset;
|
||||
nsCOMPtr<nsIDOMNode> mStartParent;
|
||||
nsCOMPtr<nsIDOMNode> mEndParent;
|
||||
static PRMonitor *mMonitor; // monitor to protect the following statics
|
||||
static nsVoidArray *mStartAncestors; // just keeping these static to avoid reallocing the arrays.
|
||||
static nsVoidArray *mEndAncestors; // the contents of these arrays are discarded across calls.
|
||||
static nsVoidArray *mStartAncestorOffsets; // this also makes nsRange objects lighter weight.
|
||||
static nsVoidArray *mEndAncestorOffsets; //
|
||||
|
||||
// no copy's or assigns
|
||||
nsRange(const nsRange&);
|
||||
nsRange& operator=(const nsRange&);
|
||||
|
||||
// helper routines
|
||||
|
||||
static PRBool InSameDoc(nsIDOMNode* aNode1, nsIDOMNode* aNode2);
|
||||
static PRInt32 IndexOf(nsIDOMNode* aNode);
|
||||
static PRInt32 FillArrayWithAncestors(nsVoidArray* aArray,nsIDOMNode* aNode);
|
||||
static nsCOMPtr<nsIDOMNode> CommonParent(nsIDOMNode* aNode1, nsIDOMNode* aNode2);
|
||||
static nsresult GetDOMNodeFromContent(nsIContent* inContentNode, nsCOMPtr<nsIDOMNode>* outDomNode);
|
||||
static nsresult GetContentFromDOMNode(nsIDOMNode* inDomNode, nsCOMPtr<nsIContent>* outContentNode);
|
||||
static nsresult PopRanges(nsIDOMNode* aDestNode, PRInt32 aOffset, nsIContent* aSourceNode);
|
||||
static nsresult Lock();
|
||||
static nsresult Unlock();
|
||||
|
||||
static nsresult CloneSibsAndParents(nsIDOMNode* parentNode,
|
||||
PRInt32 nodeOffset,
|
||||
nsIDOMNode* clonedNode,
|
||||
nsIDOMNode* commonParent,
|
||||
nsIDOMDocumentFragment* docfrag,
|
||||
PRBool leftP);
|
||||
|
||||
nsresult DoSetRange(nsIDOMNode* aStartN, PRInt32 aStartOffset,
|
||||
nsIDOMNode* aEndN, PRInt32 aEndOffset);
|
||||
|
||||
PRBool IsIncreasing(nsIDOMNode* aStartN, PRInt32 aStartOff,
|
||||
nsIDOMNode* aEndN, PRInt32 aEndOff);
|
||||
|
||||
nsresult IsPointInRange(nsIDOMNode* aParent, PRInt32 aOffset, PRBool* aResult);
|
||||
|
||||
nsresult ComparePointToRange(nsIDOMNode* aParent, PRInt32 aOffset, PRInt32* aResult);
|
||||
|
||||
|
||||
PRInt32 GetAncestorsAndOffsets(nsIDOMNode* aNode, PRInt32 aOffset,
|
||||
nsVoidArray* aAncestorNodes, nsVoidArray* aAncestorOffsets);
|
||||
|
||||
nsresult AddToListOf(nsIDOMNode* aNode);
|
||||
|
||||
nsresult RemoveFromListOf(nsIDOMNode* aNode);
|
||||
|
||||
nsresult ContentOwnsUs(nsIDOMNode* domNode);
|
||||
|
||||
protected:
|
||||
void* mScriptObject;
|
||||
|
||||
};
|
||||
|
||||
// Make a new nsIDOMRange object
|
||||
nsresult NS_NewRange(nsIDOMRange** aInstancePtrResult);
|
||||
|
||||
|
||||
/*************************************************************************************
|
||||
* Utility routine to compare two "points", were a point is a node/offset pair
|
||||
* Returns -1 if point1 < point2, 1, if point1 > point2,
|
||||
* 0 if error or if point1 == point2.
|
||||
************************************************************************************/
|
||||
PRInt32 ComparePoints(nsIDOMNode* aParent1, PRInt32 aOffset1,
|
||||
nsIDOMNode* aParent2, PRInt32 aOffset2);
|
||||
|
||||
|
||||
/*************************************************************************************
|
||||
* Utility routine to detect if a content node intersects a range
|
||||
************************************************************************************/
|
||||
PRBool IsNodeIntersectsRange(nsIContent* aNode, nsIDOMRange* aRange);
|
||||
|
||||
|
||||
/*************************************************************************************
|
||||
* Utility routine to detect if a content node starts before a range and/or
|
||||
* ends after a range. If neither it is contained inside the range.
|
||||
*
|
||||
* XXX - callers responsibility to ensure node in same doc as range!
|
||||
*
|
||||
************************************************************************************/
|
||||
nsresult CompareNodeToRange(nsIContent* aNode,
|
||||
nsIDOMRange* aRange,
|
||||
PRBool *outNodeBefore,
|
||||
PRBool *outNodeAfter);
|
||||
|
||||
|
||||
/*************************************************************************************
|
||||
* Utility routine to create a pair of dom points to represent
|
||||
* the start and end locations of a single node. Return false
|
||||
* if we dont' succeed.
|
||||
************************************************************************************/
|
||||
PRBool GetNodeBracketPoints(nsIContent* aNode,
|
||||
nsCOMPtr<nsIDOMNode>* outParent,
|
||||
PRInt32* outStartOffset,
|
||||
PRInt32* outEndOffset);
|
||||
|
||||
#endif /* nsRange_h___ */
|
||||
2339
mozilla/content/base/src/nsStyleContext.cpp
Normal file
2339
mozilla/content/base/src/nsStyleContext.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1165
mozilla/content/base/src/nsStyleSet.cpp
Normal file
1165
mozilla/content/base/src/nsStyleSet.cpp
Normal file
File diff suppressed because it is too large
Load Diff
96
mozilla/content/base/src/nsTextContentChangeData.cpp
Normal file
96
mozilla/content/base/src/nsTextContentChangeData.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsTextContentChangeData.h"
|
||||
|
||||
// Create a new instance of nsTextContentChangeData with a refcnt of 1
|
||||
nsresult
|
||||
NS_NewTextContentChangeData(nsTextContentChangeData** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
nsTextContentChangeData* it = new nsTextContentChangeData();
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(it);
|
||||
*aResult = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsTextContentChangeData::nsTextContentChangeData()
|
||||
: mType(Insert),
|
||||
mOffset(0),
|
||||
mLength(0),
|
||||
mReplaceLength(0)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsTextContentChangeData::~nsTextContentChangeData()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsTextContentChangeData, nsITextContentChangeData);
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextContentChangeData::GetChangeType(ChangeType* aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = mType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextContentChangeData::GetReplaceData(PRInt32* aOffset,
|
||||
PRInt32* aSourceLength,
|
||||
PRInt32* aReplaceLength)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOffset);
|
||||
NS_ENSURE_ARG_POINTER(aSourceLength);
|
||||
NS_ENSURE_ARG_POINTER(aReplaceLength);
|
||||
*aOffset = mOffset;
|
||||
*aSourceLength = mLength;
|
||||
*aReplaceLength = mReplaceLength;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextContentChangeData::GetInsertData(PRInt32* aOffset,
|
||||
PRInt32* aInsertLength)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOffset);
|
||||
NS_ENSURE_ARG_POINTER(aInsertLength);
|
||||
*aOffset = mOffset;
|
||||
*aInsertLength = mLength;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextContentChangeData::GetAppendData(PRInt32* aOffset,
|
||||
PRInt32* aAppendLength)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOffset);
|
||||
NS_ENSURE_ARG_POINTER(aAppendLength);
|
||||
*aOffset = mOffset;
|
||||
*aAppendLength = mLength;
|
||||
return NS_OK;
|
||||
}
|
||||
72
mozilla/content/base/src/nsTextContentChangeData.h
Normal file
72
mozilla/content/base/src/nsTextContentChangeData.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsTextContentChangeData_h___
|
||||
#define nsTextContentChangeData_h___
|
||||
|
||||
#include "nsITextContent.h"
|
||||
|
||||
class nsTextContentChangeData : public nsITextContentChangeData {
|
||||
public:
|
||||
friend nsresult
|
||||
NS_NewTextContentChangeData(nsTextContentChangeData** aResult);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsITextContentChangedData
|
||||
NS_IMETHOD GetChangeType(ChangeType* aResult);
|
||||
|
||||
NS_IMETHOD GetReplaceData(PRInt32* aOffset,
|
||||
PRInt32* aSourceLength,
|
||||
PRInt32* aReplaceLength);
|
||||
|
||||
NS_IMETHOD GetInsertData(PRInt32* aOffset,
|
||||
PRInt32* aInsertLength);
|
||||
|
||||
NS_IMETHOD GetAppendData(PRInt32* aOffset,
|
||||
PRInt32* aAppendLength);
|
||||
|
||||
void SetData(ChangeType aType, PRInt32 aOffset, PRInt32 aLength) {
|
||||
mType = aType;
|
||||
mOffset = aOffset;
|
||||
mLength = aLength;
|
||||
}
|
||||
|
||||
void SetReplaceLength(PRInt32 aReplaceLength) {
|
||||
mReplaceLength = aReplaceLength;
|
||||
}
|
||||
|
||||
protected:
|
||||
nsTextContentChangeData();
|
||||
virtual ~nsTextContentChangeData();
|
||||
|
||||
ChangeType mType;
|
||||
PRInt32 mOffset;
|
||||
PRInt32 mLength;
|
||||
PRInt32 mReplaceLength; // only used for replace type
|
||||
};
|
||||
|
||||
// Create a new instance of nsTextContentChangeData with a refcnt of 1
|
||||
extern nsresult
|
||||
NS_NewTextContentChangeData(nsTextContentChangeData** aResult);
|
||||
|
||||
#endif /* nsTextContentChangeData_h___ */
|
||||
245
mozilla/content/base/src/nsTextFragment.cpp
Normal file
245
mozilla/content/base/src/nsTextFragment.cpp
Normal file
@@ -0,0 +1,245 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsTextFragment.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
nsTextFragment::~nsTextFragment()
|
||||
{
|
||||
ReleaseText();
|
||||
}
|
||||
|
||||
void
|
||||
nsTextFragment::ReleaseText()
|
||||
{
|
||||
if (mState.mLength && m1b && mState.mInHeap) {
|
||||
if (mState.mIs2b) {
|
||||
delete [] m2b;
|
||||
}
|
||||
else {
|
||||
delete [] m1b;
|
||||
}
|
||||
}
|
||||
m1b = nsnull;
|
||||
mState.mIs2b = 0;
|
||||
mState.mInHeap = 0;
|
||||
mState.mLength = 0;
|
||||
}
|
||||
|
||||
nsTextFragment::nsTextFragment(const nsTextFragment& aOther)
|
||||
: m1b(nsnull),
|
||||
mAllBits(0)
|
||||
{
|
||||
if (aOther.Is2b()) {
|
||||
SetTo(aOther.Get2b(), aOther.GetLength());
|
||||
}
|
||||
else {
|
||||
SetTo(aOther.Get1b(), aOther.GetLength());
|
||||
}
|
||||
}
|
||||
|
||||
nsTextFragment::nsTextFragment(const char* aString)
|
||||
: m1b(nsnull),
|
||||
mAllBits(0)
|
||||
{
|
||||
SetTo(aString, strlen(aString));
|
||||
}
|
||||
|
||||
nsTextFragment::nsTextFragment(const PRUnichar* aString)
|
||||
: m1b(nsnull),
|
||||
mAllBits(0)
|
||||
{
|
||||
SetTo(aString, nsCRT::strlen(aString));
|
||||
}
|
||||
|
||||
nsTextFragment::nsTextFragment(const nsString& aString)
|
||||
: m1b(nsnull),
|
||||
mAllBits(0)
|
||||
{
|
||||
SetTo(aString.GetUnicode(), aString.Length());
|
||||
}
|
||||
|
||||
nsTextFragment&
|
||||
nsTextFragment::operator=(const nsTextFragment& aOther)
|
||||
{
|
||||
if (aOther.Is2b()) {
|
||||
SetTo(aOther.Get2b(), aOther.GetLength());
|
||||
}
|
||||
else {
|
||||
SetTo(aOther.Get1b(), aOther.GetLength());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
nsTextFragment&
|
||||
nsTextFragment::operator=(const char* aString)
|
||||
{
|
||||
SetTo(aString, nsCRT::strlen(aString));
|
||||
return *this;
|
||||
}
|
||||
|
||||
nsTextFragment&
|
||||
nsTextFragment::operator=(const PRUnichar* aString)
|
||||
{
|
||||
SetTo(aString, nsCRT::strlen(aString));
|
||||
return *this;
|
||||
}
|
||||
|
||||
nsTextFragment&
|
||||
nsTextFragment::operator=(const nsString& aString)
|
||||
{
|
||||
SetTo(aString.GetUnicode(), aString.Length());
|
||||
return *this;
|
||||
}
|
||||
|
||||
void
|
||||
nsTextFragment::SetTo(PRUnichar* aBuffer, PRInt32 aLength, PRBool aRelease)
|
||||
{
|
||||
ReleaseText();
|
||||
|
||||
m2b = aBuffer;
|
||||
mState.mIs2b = 1;
|
||||
mState.mInHeap = aRelease ? 1 : 0;
|
||||
mState.mLength = aLength;
|
||||
}
|
||||
|
||||
void
|
||||
nsTextFragment::SetTo(const PRUnichar* aBuffer, PRInt32 aLength)
|
||||
{
|
||||
ReleaseText();
|
||||
if (0 != aLength) {
|
||||
// See if we need to store the data in ucs2 or not
|
||||
PRBool need2 = PR_FALSE;
|
||||
const PRUnichar* ucp = aBuffer;
|
||||
const PRUnichar* uend = aBuffer + aLength;
|
||||
while (ucp < uend) {
|
||||
PRUnichar ch = *ucp++;
|
||||
if (ch >> 8) {
|
||||
need2 = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (need2) {
|
||||
// Use ucs2 storage because we have to
|
||||
PRUnichar* nt = new PRUnichar[aLength];
|
||||
if (nsnull != nt) {
|
||||
// Copy data
|
||||
nsCRT::memcpy(nt, aBuffer, sizeof(PRUnichar) * aLength);
|
||||
|
||||
// Setup our fields
|
||||
m2b = nt;
|
||||
mState.mIs2b = 1;
|
||||
mState.mInHeap = 1;
|
||||
mState.mLength = aLength;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Use 1 byte storage because we can
|
||||
unsigned char* nt = new unsigned char[aLength];
|
||||
if (nsnull != nt) {
|
||||
// Copy data
|
||||
unsigned char* cp = nt;
|
||||
unsigned char* end = nt + aLength;
|
||||
while (cp < end) {
|
||||
*cp++ = (unsigned char) *aBuffer++;
|
||||
}
|
||||
|
||||
// Setup our fields
|
||||
m1b = nt;
|
||||
mState.mIs2b = 0;
|
||||
mState.mInHeap = 1;
|
||||
mState.mLength = aLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsTextFragment::SetTo(const char* aBuffer, PRInt32 aLength)
|
||||
{
|
||||
ReleaseText();
|
||||
if (0 != aLength) {
|
||||
unsigned char* nt = new unsigned char[aLength];
|
||||
if (nsnull != nt) {
|
||||
nsCRT::memcpy(nt, aBuffer, sizeof(unsigned char) * aLength);
|
||||
|
||||
m1b = nt;
|
||||
mState.mIs2b = 0;
|
||||
mState.mInHeap = 1;
|
||||
mState.mLength = aLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsTextFragment::AppendTo(nsString& aString) const
|
||||
{
|
||||
if (mState.mIs2b) {
|
||||
aString.Append(m2b, mState.mLength);
|
||||
}
|
||||
else {
|
||||
aString.Append((char*)m1b, mState.mLength);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsTextFragment::CopyTo(PRUnichar* aDest, PRInt32 aOffset, PRInt32 aCount)
|
||||
{
|
||||
if (aOffset < 0) aOffset = 0;
|
||||
if (aOffset + aCount > GetLength()) {
|
||||
aCount = mState.mLength - aOffset;
|
||||
}
|
||||
if (0 != aCount) {
|
||||
if (mState.mIs2b) {
|
||||
nsCRT::memcpy(aDest, m2b + aOffset, sizeof(PRUnichar) * aCount);
|
||||
}
|
||||
else {
|
||||
unsigned char* cp = m1b + aOffset;
|
||||
unsigned char* end = cp + aCount;
|
||||
while (cp < end) {
|
||||
*aDest++ = PRUnichar(*cp++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsTextFragment::CopyTo(char* aDest, PRInt32 aOffset, PRInt32 aCount)
|
||||
{
|
||||
if (aOffset < 0) aOffset = 0;
|
||||
if (aOffset + aCount > GetLength()) {
|
||||
aCount = mState.mLength - aOffset;
|
||||
}
|
||||
if (0 != aCount) {
|
||||
if (mState.mIs2b) {
|
||||
PRUnichar* cp = m2b + aOffset;
|
||||
PRUnichar* end = cp + aCount;
|
||||
while (cp < end) {
|
||||
*aDest++ = (unsigned char) (*cp++);
|
||||
}
|
||||
}
|
||||
else {
|
||||
nsCRT::memcpy(aDest, m1b + aOffset, sizeof(char) * aCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
221
mozilla/content/base/src/nsTextNode.cpp
Normal file
221
mozilla/content/base/src/nsTextNode.cpp
Normal file
@@ -0,0 +1,221 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "nsFrame.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
|
||||
static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID);
|
||||
|
||||
class nsTextNode : public nsIDOMText,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIContent,
|
||||
public nsITextContent
|
||||
{
|
||||
public:
|
||||
nsTextNode();
|
||||
virtual ~nsTextNode();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_IDOMNODE_USING_GENERIC_DOM_DATA(mInner)
|
||||
|
||||
// nsIDOMCharacterData
|
||||
NS_IMPL_IDOMCHARACTERDATA_USING_GENERIC_DOM_DATA(mInner)
|
||||
|
||||
// nsIDOMText
|
||||
NS_IMPL_IDOMTEXT_USING_GENERIC_DOM_DATA(mInner)
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC_DOM_DATA(mInner)
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC_DOM_DATA(mInner)
|
||||
|
||||
// nsIContent
|
||||
NS_IMPL_ICONTENT_USING_GENERIC_DOM_DATA(mInner)
|
||||
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
return mInner.SizeOf(aSizer, aResult, sizeof(*this));
|
||||
}
|
||||
|
||||
// nsITextContent
|
||||
NS_IMPL_ITEXTCONTENT_USING_GENERIC_DOM_DATA(mInner)
|
||||
|
||||
protected:
|
||||
nsGenericDOMDataNode mInner;
|
||||
PRUint32 mContentID;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewTextNode(nsIContent** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsTextNode* it;
|
||||
NS_NEWXPCOM(it, nsTextNode);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIContentIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
|
||||
nsTextNode::nsTextNode()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInner.Init(this);
|
||||
mContentID = 0;
|
||||
}
|
||||
|
||||
nsTextNode::~nsTextNode()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsTextNode)
|
||||
NS_IMPL_RELEASE(nsTextNode)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextNode::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_IMPL_DOM_DATA_QUERY_INTERFACE(aIID, aInstancePtr, this)
|
||||
if (aIID.Equals(kIDOMTextIID)) {
|
||||
nsIDOMText* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kITextContentIID)) {
|
||||
nsITextContent* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextNode::GetTag(nsIAtom*& aResult) const
|
||||
{
|
||||
aResult = nsLayoutAtoms::textTagName;
|
||||
NS_ADDREF(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextNode::GetNodeName(nsString& aNodeName)
|
||||
{
|
||||
aNodeName.SetString("#text");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextNode::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = (PRUint16)nsIDOMNode::TEXT_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextNode::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
nsTextNode* it;
|
||||
NS_NEWXPCOM(it, nsTextNode);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
// XXX Increment the ref count before calling any
|
||||
// methods. If they do a QI and then a Release()
|
||||
// the instance will be deleted.
|
||||
result = it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
nsAutoString data;
|
||||
result = GetData(data);
|
||||
if (NS_FAILED(result)) {
|
||||
NS_RELEASE(*aReturn);
|
||||
return result;
|
||||
}
|
||||
result = it->SetData(data);
|
||||
if (NS_FAILED(result)) {
|
||||
NS_RELEASE(*aReturn);
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextNode::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
NS_PRECONDITION(nsnull != mInner.mDocument, "bad content");
|
||||
|
||||
PRInt32 index;
|
||||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
||||
fprintf(out, "Text@%p refcount=%d<", this, mRefCnt);
|
||||
|
||||
nsAutoString tmp;
|
||||
mInner.ToCString(tmp, 0, mInner.mText.GetLength());
|
||||
fputs(tmp, out);
|
||||
|
||||
fputs(">\n", out);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextNode::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextNode::GetContentID(PRUint32* aID)
|
||||
{
|
||||
*aID = mContentID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextNode::SetContentID(PRUint32 aID)
|
||||
{
|
||||
mContentID = aID;
|
||||
return NS_OK;
|
||||
}
|
||||
32
mozilla/content/events/Makefile.in
Normal file
32
mozilla/content/events/Makefile.in
Normal file
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# 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/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
27
mozilla/content/events/makefile.win
Normal file
27
mozilla/content/events/makefile.win
Normal file
@@ -0,0 +1,27 @@
|
||||
#!nmake
|
||||
#
|
||||
# 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/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
|
||||
DIRS=public src
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
9
mozilla/content/events/public/MANIFEST
Normal file
9
mozilla/content/events/public/MANIFEST
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist:layout directory
|
||||
#
|
||||
nsIEventListenerManager.h
|
||||
nsIEventStateManager.h
|
||||
nsIPrivateDOMEvent.h
|
||||
nsIPrivateTextEvent.h
|
||||
nsIPrivateTextRange.h
|
||||
nsIPrivateCompositionEvent.h
|
||||
43
mozilla/content/events/public/Makefile.in
Normal file
43
mozilla/content/events/public/Makefile.in
Normal file
@@ -0,0 +1,43 @@
|
||||
#
|
||||
# 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/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = layout
|
||||
|
||||
EXPORTS = \
|
||||
nsIEventListenerManager.h \
|
||||
nsIEventStateManager.h \
|
||||
nsIPrivateDOMEvent.h \
|
||||
nsIPrivateTextEvent.h \
|
||||
nsIPrivateTextRange.h \
|
||||
nsIPrivateCompositionEvent.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
37
mozilla/content/events/public/makefile.win
Normal file
37
mozilla/content/events/public/makefile.win
Normal file
@@ -0,0 +1,37 @@
|
||||
#!nmake
|
||||
#
|
||||
# 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/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
|
||||
EXPORTS = \
|
||||
nsIEventListenerManager.h \
|
||||
nsIEventStateManager.h \
|
||||
nsIPrivateDOMEvent.h \
|
||||
nsIPrivateTextEvent.h \
|
||||
nsIPrivateTextRange.h \
|
||||
nsIPrivateCompositionEvent.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE=raptor
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
141
mozilla/content/events/public/nsIEventListenerManager.h
Normal file
141
mozilla/content/events/public/nsIEventListenerManager.h
Normal file
@@ -0,0 +1,141 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIEventListenerManager_h__
|
||||
#define nsIEventListenerManager_h__
|
||||
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
class nsIPresContext;
|
||||
class nsIDOMEventListener;
|
||||
class nsIScriptObjectOwner;
|
||||
|
||||
/*
|
||||
* Event listener manager interface.
|
||||
*/
|
||||
#define NS_IEVENTLISTENERMANAGER_IID \
|
||||
{ /* cd91bcf0-ded9-11d1-bd85-00805f8ae3f4 */ \
|
||||
0xcd91bcf0, 0xded9, 0x11d1, \
|
||||
{0xbd, 0x85, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4} }
|
||||
|
||||
class nsIEventListenerManager : public nsISupports {
|
||||
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IEVENTLISTENERMANAGER_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Retrieves events listeners of all types.
|
||||
* @param
|
||||
*/
|
||||
virtual nsresult GetEventListeners(nsVoidArray **aListeners, const nsIID& aIID) = 0;
|
||||
|
||||
/**
|
||||
* Sets events listeners of all types.
|
||||
* @param an event listener
|
||||
*/
|
||||
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID, PRInt32 flags) = 0;
|
||||
|
||||
/**
|
||||
* Removes events listeners of all types.
|
||||
* @param an event listener
|
||||
*/
|
||||
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID, PRInt32 flags) = 0;
|
||||
|
||||
/**
|
||||
* Sets events listeners of all types.
|
||||
* @param an event listener
|
||||
*/
|
||||
virtual nsresult AddEventListenerByType(nsIDOMEventListener *aListener, const nsString& type, PRInt32 flags) = 0;
|
||||
|
||||
/**
|
||||
* Removes events listeners of all types.
|
||||
* @param an event listener
|
||||
*/
|
||||
virtual nsresult RemoveEventListenerByType(nsIDOMEventListener *aListener, const nsString& type, PRInt32 flags) = 0;
|
||||
|
||||
/**
|
||||
* Creates a script event listener for the given script object with name mName and function
|
||||
* body mFunc.
|
||||
* @param an event listener
|
||||
*/
|
||||
virtual nsresult AddScriptEventListener(nsIScriptContext*aContext,
|
||||
nsIScriptObjectOwner *aScriptObjectOwner,
|
||||
nsIAtom *aName,
|
||||
const nsString& aFunc,
|
||||
REFNSIID aIID,
|
||||
PRBool aDeferCompilation) = 0;
|
||||
|
||||
/**
|
||||
* Registers an event listener that already exists on the given script object with the event
|
||||
* listener manager.
|
||||
* @param an event listener
|
||||
*/
|
||||
virtual nsresult RegisterScriptEventListener(nsIScriptContext *aContext,
|
||||
nsIScriptObjectOwner *aScriptObjectOwner,
|
||||
nsIAtom* aName,
|
||||
REFNSIID aIID) = 0;
|
||||
|
||||
/**
|
||||
* Causes a check for event listeners and processing by them if they exist.
|
||||
* Event flags live in nsGUIEvent.h
|
||||
* @param an event listener
|
||||
*/
|
||||
virtual nsresult HandleEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus) = 0;
|
||||
|
||||
/**
|
||||
* Creates a DOM event that can subsequently be passed into HandleEvent.
|
||||
* (used rarely in the situation where methods on the event need to be
|
||||
* invoked prior to the processing of the event).
|
||||
*/
|
||||
virtual nsresult CreateEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent) = 0;
|
||||
|
||||
/**
|
||||
* Captures all events designated for descendant objects at the current level.
|
||||
* @param an event listener
|
||||
*/
|
||||
virtual nsresult CaptureEvent(nsIDOMEventListener *aListener) = 0;
|
||||
|
||||
/**
|
||||
* Releases all events designated for descendant objects at the current level.
|
||||
* @param an event listener
|
||||
*/
|
||||
virtual nsresult ReleaseEvent(nsIDOMEventListener *aListener) = 0;
|
||||
|
||||
/**
|
||||
* Removes all event listeners registered by this instance of the listener
|
||||
* manager.
|
||||
*/
|
||||
virtual nsresult RemoveAllListeners(PRBool aScriptOnly) = 0;
|
||||
|
||||
};
|
||||
|
||||
extern NS_HTML nsresult NS_NewEventListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
|
||||
#endif // nsIEventListenerManager_h__
|
||||
87
mozilla/content/events/public/nsIEventStateManager.h
Normal file
87
mozilla/content/events/public/nsIEventStateManager.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIEventStateManager_h__
|
||||
#define nsIEventStateManager_h__
|
||||
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIPresContext;
|
||||
class nsIDOMEvent;
|
||||
class nsIFrame;
|
||||
class nsIView;
|
||||
|
||||
/*
|
||||
* Event listener manager interface.
|
||||
*/
|
||||
#define NS_IEVENTSTATEMANAGER_IID \
|
||||
{ /* 80a98c80-2036-11d2-bd89-00805f8ae3f4 */ \
|
||||
0x80a98c80, 0x2036, 0x11d2, \
|
||||
{0xbd, 0x89, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4} }
|
||||
|
||||
class nsIEventStateManager : public nsISupports {
|
||||
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IEVENTSTATEMANAGER_IID; return iid; }
|
||||
|
||||
NS_IMETHOD PreHandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent *aEvent,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsEventStatus* aStatus,
|
||||
nsIView* aView) = 0;
|
||||
|
||||
NS_IMETHOD PostHandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent *aEvent,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsEventStatus* aStatus,
|
||||
nsIView* aView) = 0;
|
||||
|
||||
NS_IMETHOD SetPresContext(nsIPresContext* aPresContext) = 0;
|
||||
NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame) = 0;
|
||||
|
||||
NS_IMETHOD GetEventTarget(nsIFrame **aFrame) = 0;
|
||||
NS_IMETHOD GetEventTargetContent(nsEvent* aEvent, nsIContent** aContent) = 0;
|
||||
NS_IMETHOD GetEventRelatedContent(nsIContent** aContent) = 0;
|
||||
|
||||
NS_IMETHOD GetContentState(nsIContent *aContent, PRInt32& aState) = 0;
|
||||
NS_IMETHOD SetContentState(nsIContent *aContent, PRInt32 aState) = 0;
|
||||
|
||||
NS_IMETHOD GetFocusedContent(nsIContent **aContent) = 0;
|
||||
NS_IMETHOD SetFocusedContent(nsIContent* aContent) = 0;
|
||||
|
||||
// Cross ESM methods, doesn't matter what instance you call it from
|
||||
NS_IMETHOD GetFocusedEventTarget(nsIFrame **aFrame) = 0;
|
||||
|
||||
// This is an experiement and may be temporary
|
||||
NS_IMETHOD ConsumeFocusEvents(PRBool aDoConsume) = 0;
|
||||
};
|
||||
|
||||
#define NS_EVENT_STATE_UNSPECIFIED 0x0000
|
||||
#define NS_EVENT_STATE_ACTIVE 0x0001 // mouse is down on content
|
||||
#define NS_EVENT_STATE_FOCUS 0x0002 // content has focus
|
||||
#define NS_EVENT_STATE_HOVER 0x0004 // mouse is hovering over content
|
||||
#define NS_EVENT_STATE_DRAGOVER 0x0008 // drag is hovering over content
|
||||
|
||||
#endif // nsIEventStateManager_h__
|
||||
43
mozilla/content/events/public/nsIPrivateCompositionEvent.h
Normal file
43
mozilla/content/events/public/nsIPrivateCompositionEvent.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIPrivateCompositionEvent_h__
|
||||
#define nsIPrivateCompositionEvent_h__
|
||||
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
// {ECF6BEF1-5F0C-11d3-9EB3-0060089FE59B}
|
||||
#define NS_IPRIVATECOMPOSITIONEVENT_IID \
|
||||
{ 0xecf6bef1, 0x5f0c, 0x11d3, \
|
||||
{ 0x9e, 0xb3, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b }}
|
||||
|
||||
class nsIPrivateCompositionEvent : public nsISupports {
|
||||
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IPRIVATECOMPOSITIONEVENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetCompositionReply(struct nsTextEventReply** aReply) = 0;
|
||||
};
|
||||
|
||||
#endif // nsIPrivateCompositionEvent_h__
|
||||
|
||||
54
mozilla/content/events/public/nsIPrivateDOMEvent.h
Normal file
54
mozilla/content/events/public/nsIPrivateDOMEvent.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIPrivateDOMEvent_h__
|
||||
#define nsIPrivateDOMEvent_h__
|
||||
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIPresContext;
|
||||
|
||||
/*
|
||||
* Event listener manager interface.
|
||||
*/
|
||||
#define NS_IPRIVATEDOMEVENT_IID \
|
||||
{ /* 80a98c80-2036-11d2-bd89-00805f8ae3f4 */ \
|
||||
0x80a98c80, 0x2036, 0x11d2, \
|
||||
{0xbd, 0x89, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4} }
|
||||
|
||||
class nsIDOMNode;
|
||||
class nsIDOMEvent;
|
||||
|
||||
class nsIPrivateDOMEvent : public nsISupports {
|
||||
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IPRIVATEDOMEVENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD DuplicatePrivateData() = 0;
|
||||
NS_IMETHOD SetTarget(nsIDOMNode* aNode) = 0;
|
||||
};
|
||||
|
||||
extern nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext* aPresContext, nsEvent *aEvent);
|
||||
extern nsresult NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext* aPresContext, nsEvent *aEvent);
|
||||
|
||||
#endif // nsIPrivateDOMEvent_h__
|
||||
46
mozilla/content/events/public/nsIPrivateTextEvent.h
Normal file
46
mozilla/content/events/public/nsIPrivateTextEvent.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIPrivateTextEvent_h__
|
||||
#define nsIPrivateTextEvent_h__
|
||||
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIPrivateTextRange.h"
|
||||
|
||||
#define NS_IPRIVATETEXTEVENT_IID \
|
||||
{ /* 37B69251-4ACE-11d3-9EA6-0060089FE59B */ \
|
||||
0x37b69251, 0x4ace, 0x11d3, \
|
||||
{0x9e, 0xa6, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b} }
|
||||
|
||||
class nsIPrivateTextEvent : public nsISupports {
|
||||
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IPRIVATETEXTEVENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetText(nsString& aText) = 0;
|
||||
NS_IMETHOD GetInputRange(nsIPrivateTextRangeList** aInputRange) = 0;
|
||||
NS_IMETHOD GetEventReply(struct nsTextEventReply** aReply) = 0;
|
||||
};
|
||||
|
||||
#endif // nsIPrivateTextEvent_h__
|
||||
|
||||
66
mozilla/content/events/public/nsIPrivateTextRange.h
Normal file
66
mozilla/content/events/public/nsIPrivateTextRange.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIPrivateTextRange_h__
|
||||
#define nsIPrivateTextRange_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#define NS_IPRIVATETEXTRANGE_IID \
|
||||
{0xb471ab41, 0x2a79, 0x11d3, \
|
||||
{ 0x9e, 0xa4, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b } }
|
||||
|
||||
class nsIPrivateTextRange : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IPRIVATETEXTRANGE_IID; return iid; }
|
||||
enum {
|
||||
TEXTRANGE_CARETPOSITION = 1,
|
||||
TEXTRANGE_RAWINPUT = 2,
|
||||
TEXTRANGE_SELECTEDRAWTEXT = 3,
|
||||
TEXTRANGE_CONVERTEDTEXT = 4,
|
||||
TEXTRANGE_SELECTEDCONVERTEDTEXT = 5
|
||||
};
|
||||
|
||||
NS_IMETHOD GetRangeStart(PRUint16* aRangeStart)=0;
|
||||
NS_IMETHOD SetRangeStart(PRUint16 aRangeStart)=0;
|
||||
|
||||
NS_IMETHOD GetRangeEnd(PRUint16* aRangeEnd)=0;
|
||||
NS_IMETHOD SetRangeEnd(PRUint16 aRangeEnd)=0;
|
||||
|
||||
NS_IMETHOD GetRangeType(PRUint16* aRangeType)=0;
|
||||
NS_IMETHOD SetRangeType(PRUint16 aRangeType)=0;
|
||||
};
|
||||
|
||||
#define NS_IPRIVATETEXTRANGELIST_IID \
|
||||
{ 0x1ee9d531, 0x2a79, 0x11d3, \
|
||||
{ 0x9e, 0xa4, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b} }
|
||||
|
||||
class nsIPrivateTextRangeList : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IPRIVATETEXTRANGELIST_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetLength(PRUint16* aLength)=0;
|
||||
NS_IMETHOD Item(PRUint16 aIndex, nsIPrivateTextRange** aReturn)=0;
|
||||
};
|
||||
|
||||
#endif // nsIPrivateTextRange_h__
|
||||
7
mozilla/content/events/src/MANIFEST
Normal file
7
mozilla/content/events/src/MANIFEST
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist:layout directory
|
||||
#
|
||||
nsEventListenerManager.h
|
||||
nsEventStateManager.h
|
||||
nsDOMEvent.h
|
||||
nsDOMEventsIIDs.h
|
||||
61
mozilla/content/events/src/Makefile.in
Normal file
61
mozilla/content/events/src/Makefile.in
Normal file
@@ -0,0 +1,61 @@
|
||||
#
|
||||
# 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/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = layout
|
||||
LIBRARY_NAME = raptorevents_s
|
||||
|
||||
REQUIRES = xpcom raptor dom js netlib
|
||||
|
||||
CPPSRCS = \
|
||||
nsEventListenerManager.cpp \
|
||||
nsEventStateManager.cpp \
|
||||
nsDOMEvent.cpp \
|
||||
nsDOMEventsIIDs.cpp \
|
||||
nsPrivateTextRange.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsEventListenerManager.h \
|
||||
nsEventStateManager.h \
|
||||
nsDOMEvent.h \
|
||||
nsDOMEventsIIDs.h \
|
||||
nsPrivateTextRange.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_HTML
|
||||
|
||||
INCLUDES += -I$(PUBLIC)/dom -I$(srcdir)/../../html/base/src
|
||||
|
||||
64
mozilla/content/events/src/makefile.win
Normal file
64
mozilla/content/events/src/makefile.win
Normal file
@@ -0,0 +1,64 @@
|
||||
#!nmake
|
||||
#
|
||||
# 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/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
LIBRARY_NAME=raptorevents_s
|
||||
MODULE=raptor
|
||||
REQUIRES=xpcom raptor dom js
|
||||
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
CPPSRCS= nsEventListenerManager.cpp \
|
||||
nsEventStateManager.cpp \
|
||||
nsDOMEvent.cpp \
|
||||
nsDOMEventsIIDs.cpp \
|
||||
nsPrivateTextRange.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= .\$(OBJDIR)\nsEventListenerManager.obj \
|
||||
.\$(OBJDIR)\nsEventStateManager.obj \
|
||||
.\$(OBJDIR)\nsDOMEvent.obj \
|
||||
.\$(OBJDIR)\nsDOMEventsIIDs.obj \
|
||||
.\$(OBJDIR)\nsPrivateTextRange.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
EXPORTS= nsEventListenerManager.h nsEventStateManager.h nsDOMEvent.h nsDOMEventsIIDs.h nsPrivateTextRange.h
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\dom -I$(PUBLIC)\js -I..\..\html\base\src -I$(PUBLIC)\netlib
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
||||
923
mozilla/content/events/src/nsDOMEvent.cpp
Normal file
923
mozilla/content/events/src/nsDOMEvent.cpp
Normal file
@@ -0,0 +1,923 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsDOMEvent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsPrivateTextRange.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIPrivateCompositionEvent.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMEventIID, NS_IDOMEVENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMUIEventIID, NS_IDOMUIEVENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMKeyEventIID, NS_IDOMKEYEVENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMMouseEventIID, NS_IDOMMOUSEEVENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMNSUIEventIID, NS_IDOMNSUIEVENT_IID);
|
||||
static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID);
|
||||
static NS_DEFINE_IID(kIPrivateTextEventIID, NS_IPRIVATETEXTEVENT_IID);
|
||||
static NS_DEFINE_IID(kIPrivateCompositionEventIID,NS_IPRIVATECOMPOSITIONEVENT_IID);
|
||||
|
||||
static char* mEventNames[] = {
|
||||
"mousedown", "mouseup", "click", "dblclick", "mouseover",
|
||||
"mouseout", "mousemove", "keydown", "keyup", "keypress",
|
||||
"focus", "blur", "load", "unload", "abort", "error",
|
||||
"submit", "reset", "change", "select", "input", "paint" ,"text",
|
||||
"create", "close", "destroy", "command", "broadcast", "commandupdate",
|
||||
"dragenter", "dragover", "dragexit", "dragdrop", "draggesture"
|
||||
};
|
||||
|
||||
nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent) {
|
||||
mPresContext = aPresContext;
|
||||
NS_ADDREF(mPresContext);
|
||||
mEvent = aEvent;
|
||||
mTarget = nsnull;
|
||||
mText = nsnull;
|
||||
mTextRange = nsnull;
|
||||
|
||||
if (aEvent->eventStructType ==NS_TEXT_EVENT) {
|
||||
//
|
||||
// extract the IME composition string
|
||||
//
|
||||
mText = new nsString(((nsTextEvent*)aEvent)->theText);
|
||||
//
|
||||
// build the range list -- ranges need to be DOM-ified since the IME transaction
|
||||
// will hold a ref, the widget representation isn't persistent
|
||||
//
|
||||
nsIPrivateTextRange** tempTextRangeList = new nsIPrivateTextRange*[((nsTextEvent*)aEvent)->rangeCount];
|
||||
if (tempTextRangeList!=nsnull) {
|
||||
for(PRUint16 i=0;i<((nsTextEvent*)aEvent)->rangeCount;i++) {
|
||||
nsPrivateTextRange* tempPrivateTextRange = new nsPrivateTextRange((((nsTextEvent*)aEvent)->rangeArray[i]).mStartOffset,
|
||||
(((nsTextEvent*)aEvent)->rangeArray[i]).mEndOffset,
|
||||
(((nsTextEvent*)aEvent)->rangeArray[i]).mRangeType);
|
||||
if (tempPrivateTextRange!=nsnull) {
|
||||
tempPrivateTextRange->AddRef();
|
||||
tempTextRangeList[i] = (nsIPrivateTextRange*)tempPrivateTextRange;
|
||||
}
|
||||
}
|
||||
|
||||
mTextRange = (nsIPrivateTextRangeList*) new nsPrivateTextRangeList(((nsTextEvent*)aEvent)->rangeCount,tempTextRangeList);
|
||||
if (mTextRange!=nsnull) mTextRange->AddRef();
|
||||
}
|
||||
}
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsDOMEvent::~nsDOMEvent() {
|
||||
NS_RELEASE(mPresContext);
|
||||
NS_IF_RELEASE(mTarget);
|
||||
NS_IF_RELEASE(mTextRange);
|
||||
|
||||
if (mText!=nsnull)
|
||||
delete mText;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsDOMEvent)
|
||||
NS_IMPL_RELEASE(nsDOMEvent)
|
||||
|
||||
nsresult nsDOMEvent::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIDOMEventIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIDOMEvent*)(nsIDOMUIEvent*)(nsIDOMMouseEvent*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMUIEventIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIDOMUIEvent*)(nsIDOMMouseEvent*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMMouseEventIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIDOMMouseEvent*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMKeyEventIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIDOMKeyEvent*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMNSUIEventIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIDOMNSUIEvent*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIPrivateDOMEventIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIPrivateDOMEvent*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIPrivateTextEventIID)) {
|
||||
*aInstancePtrResult=(void*)((nsIPrivateTextEvent*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIPrivateCompositionEventIID)) {
|
||||
*aInstancePtrResult = (void*)((nsIPrivateCompositionEvent*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
// nsIDOMEventInterface
|
||||
NS_METHOD nsDOMEvent::GetType(nsString& aType)
|
||||
{
|
||||
const char* mName = GetEventName(mEvent->message);
|
||||
|
||||
if (nsnull != mName) {
|
||||
aType = mName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetTarget(nsIDOMNode** aTarget)
|
||||
{
|
||||
if (nsnull != mTarget) {
|
||||
*aTarget = mTarget;
|
||||
NS_ADDREF(mTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIEventStateManager *manager;
|
||||
nsIContent *targetContent;
|
||||
|
||||
if (NS_OK == mPresContext->GetEventStateManager(&manager)) {
|
||||
manager->GetEventTargetContent(mEvent, &targetContent);
|
||||
NS_RELEASE(manager);
|
||||
}
|
||||
|
||||
if (targetContent) {
|
||||
if (NS_OK == targetContent->QueryInterface(kIDOMNodeIID, (void**)&mTarget)) {
|
||||
*aTarget = mTarget;
|
||||
NS_ADDREF(mTarget);
|
||||
}
|
||||
NS_RELEASE(targetContent);
|
||||
}
|
||||
else {
|
||||
//Always want a target. Use document if nothing else.
|
||||
nsIPresShell* presShell;
|
||||
nsIDocument* doc;
|
||||
if (NS_SUCCEEDED(mPresContext->GetShell(&presShell))) {
|
||||
presShell->GetDocument(&doc);
|
||||
NS_RELEASE(presShell);
|
||||
}
|
||||
|
||||
if (doc) {
|
||||
if (NS_OK == doc->QueryInterface(kIDOMNodeIID, (void**)&mTarget)) {
|
||||
*aTarget = mTarget;
|
||||
NS_ADDREF(mTarget);
|
||||
}
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetCurrentNode(nsIDOMNode** aCurrentNode)
|
||||
{
|
||||
*aCurrentNode = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetEventPhase(PRUint16* aEventPhase)
|
||||
{
|
||||
if (mEvent->flags & NS_EVENT_FLAG_CAPTURE) {
|
||||
*aEventPhase = nsIDOMMouseEvent::CAPTURING_PHASE;
|
||||
}
|
||||
else if (mEvent->flags & NS_EVENT_FLAG_BUBBLE) {
|
||||
*aEventPhase = nsIDOMMouseEvent::BUBBLING_PHASE;
|
||||
}
|
||||
else if (mEvent->flags & NS_EVENT_FLAG_INIT) {
|
||||
*aEventPhase = nsIDOMMouseEvent::AT_TARGET;
|
||||
}
|
||||
else {
|
||||
*aEventPhase = 0;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetBubbles(PRBool* aBubbles)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetCancelable(PRBool* aCancelable)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::PreventBubble()
|
||||
{
|
||||
if (mEvent->flags & NS_EVENT_FLAG_BUBBLE || mEvent->flags & NS_EVENT_FLAG_INIT) {
|
||||
mEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::PreventCapture()
|
||||
{
|
||||
if (mEvent->flags & NS_EVENT_FLAG_CAPTURE) {
|
||||
mEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::PreventDefault()
|
||||
{
|
||||
mEvent->flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetView(nsIDOMAbstractView** aView)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetDetail(PRInt32* aDetail)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetText(nsString& aText)
|
||||
{
|
||||
if (mEvent->message == NS_TEXT_EVENT) {
|
||||
aText = *mText;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetInputRange(nsIPrivateTextRangeList** aInputRange)
|
||||
{
|
||||
if (mEvent->message == NS_TEXT_EVENT) {
|
||||
*aInputRange = mTextRange;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetEventReply(nsTextEventReply** aReply)
|
||||
{
|
||||
if (mEvent->message==NS_TEXT_EVENT) {
|
||||
*aReply = &(((nsTextEvent*)mEvent)->theReply);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetCompositionReply(nsTextEventReply** aReply)
|
||||
{
|
||||
if((mEvent->message==NS_COMPOSITION_START) ||
|
||||
(mEvent->message==NS_COMPOSITION_QUERY)) {
|
||||
*aReply = &(((nsCompositionEvent*)mEvent)->theReply);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetScreenX(PRInt32* aScreenX)
|
||||
{
|
||||
if (!mEvent ||
|
||||
(mEvent->eventStructType != NS_MOUSE_EVENT && mEvent->eventStructType != NS_DRAGDROP_EVENT) ) {
|
||||
*aScreenX = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!((nsGUIEvent*)mEvent)->widget )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsRect bounds, offset;
|
||||
bounds.x = mEvent->refPoint.x;
|
||||
|
||||
((nsGUIEvent*)mEvent)->widget->WidgetToScreen ( bounds, offset );
|
||||
*aScreenX = offset.x;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetScreenY(PRInt32* aScreenY)
|
||||
{
|
||||
if (!mEvent ||
|
||||
(mEvent->eventStructType != NS_MOUSE_EVENT && mEvent->eventStructType != NS_DRAGDROP_EVENT) ) {
|
||||
*aScreenY = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!((nsGUIEvent*)mEvent)->widget )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsRect bounds, offset;
|
||||
bounds.y = mEvent->refPoint.y;
|
||||
|
||||
((nsGUIEvent*)mEvent)->widget->WidgetToScreen ( bounds, offset );
|
||||
*aScreenY = offset.y;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetClientX(PRInt32* aClientX)
|
||||
{
|
||||
if (!mEvent ||
|
||||
(mEvent->eventStructType != NS_MOUSE_EVENT && mEvent->eventStructType != NS_DRAGDROP_EVENT) ) {
|
||||
*aClientX = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//My god, man, there *must* be a better way to do this.
|
||||
nsIPresShell* shell;
|
||||
nsIWidget* rootWidget = nsnull;
|
||||
mPresContext->GetShell(&shell);
|
||||
|
||||
if (shell) {
|
||||
nsIViewManager* vm;
|
||||
shell->GetViewManager(&vm);
|
||||
if (vm) {
|
||||
nsIView* rootView = nsnull;
|
||||
vm->GetRootView(rootView);
|
||||
if (rootView) {
|
||||
rootView->GetWidget(rootWidget);
|
||||
}
|
||||
NS_RELEASE(vm);
|
||||
}
|
||||
NS_RELEASE(shell);
|
||||
}
|
||||
|
||||
|
||||
nsRect bounds, offset;
|
||||
offset.x = 0;
|
||||
|
||||
nsIWidget* parent = ((nsGUIEvent*)mEvent)->widget;
|
||||
//Add extra ref since loop will free one.
|
||||
NS_ADDREF(parent);
|
||||
nsIWidget* tmp;
|
||||
while (rootWidget != parent && nsnull != parent) {
|
||||
parent->GetBounds(bounds);
|
||||
offset.x += bounds.x;
|
||||
tmp = parent;
|
||||
parent = tmp->GetParent();
|
||||
NS_RELEASE(tmp);
|
||||
}
|
||||
NS_IF_RELEASE(parent);
|
||||
NS_IF_RELEASE(rootWidget);
|
||||
|
||||
*aClientX = mEvent->refPoint.x + offset.x;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetClientY(PRInt32* aClientY)
|
||||
{
|
||||
if (!mEvent ||
|
||||
(mEvent->eventStructType != NS_MOUSE_EVENT && mEvent->eventStructType != NS_DRAGDROP_EVENT) ) {
|
||||
*aClientY = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//My god, man, there *must* be a better way to do this.
|
||||
nsIPresShell* shell;
|
||||
nsIWidget* rootWidget = nsnull;
|
||||
mPresContext->GetShell(&shell);
|
||||
|
||||
if (shell) {
|
||||
nsIViewManager* vm;
|
||||
shell->GetViewManager(&vm);
|
||||
if (vm) {
|
||||
nsIView* rootView = nsnull;
|
||||
vm->GetRootView(rootView);
|
||||
if (rootView) {
|
||||
rootView->GetWidget(rootWidget);
|
||||
}
|
||||
NS_RELEASE(vm);
|
||||
}
|
||||
NS_RELEASE(shell);
|
||||
}
|
||||
|
||||
|
||||
nsRect bounds, offset;
|
||||
offset.y = 0;
|
||||
|
||||
nsIWidget* parent = ((nsGUIEvent*)mEvent)->widget;
|
||||
//Add extra ref since loop will free one.
|
||||
NS_ADDREF(parent);
|
||||
nsIWidget* tmp;
|
||||
while (rootWidget != parent && nsnull != parent) {
|
||||
parent->GetBounds(bounds);
|
||||
offset.y += bounds.y;
|
||||
tmp = parent;
|
||||
parent = tmp->GetParent();
|
||||
NS_RELEASE(tmp);
|
||||
}
|
||||
NS_IF_RELEASE(parent);
|
||||
NS_IF_RELEASE(rootWidget);
|
||||
|
||||
*aClientY = mEvent->refPoint.y + offset.y;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetAltKey(PRBool* aIsDown)
|
||||
{
|
||||
*aIsDown = ((nsInputEvent*)mEvent)->isAlt;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetCtrlKey(PRBool* aIsDown)
|
||||
{
|
||||
*aIsDown = ((nsInputEvent*)mEvent)->isControl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetShiftKey(PRBool* aIsDown)
|
||||
{
|
||||
*aIsDown = ((nsInputEvent*)mEvent)->isShift;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetMetaKey(PRBool* aIsDown)
|
||||
{
|
||||
*aIsDown = ((nsInputEvent*)mEvent)->isMeta;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetCharCode(PRUint32* aCharCode)
|
||||
{
|
||||
if (!mEvent || mEvent->eventStructType != NS_KEY_EVENT) {
|
||||
*aCharCode = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
switch (mEvent->message) {
|
||||
case NS_KEY_UP:
|
||||
case NS_KEY_DOWN:
|
||||
#ifdef NS_DEBUG
|
||||
printf("GetCharCode used for wrong key event; should use onkeypress.\n");
|
||||
#endif
|
||||
*aCharCode = 0;
|
||||
break;
|
||||
case NS_KEY_PRESS:
|
||||
*aCharCode = ((nsKeyEvent*)mEvent)->charCode;
|
||||
#if defined(NS_DEBUG) && defined(DEBUG_buster)
|
||||
if (0==*aCharCode)
|
||||
printf("GetCharCode used correctly but no valid key!\n");
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetKeyCode(PRUint32* aKeyCode)
|
||||
{
|
||||
if (!mEvent || mEvent->eventStructType != NS_KEY_EVENT) {
|
||||
*aKeyCode = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
switch (mEvent->message) {
|
||||
case NS_KEY_UP:
|
||||
case NS_KEY_PRESS:
|
||||
case NS_KEY_DOWN:
|
||||
*aKeyCode = ((nsKeyEvent*)mEvent)->keyCode;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetButton(PRUint16* aButton)
|
||||
{
|
||||
if (!mEvent || mEvent->eventStructType != NS_MOUSE_EVENT) {
|
||||
*aButton = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
switch (mEvent->message) {
|
||||
case NS_MOUSE_LEFT_BUTTON_UP:
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
case NS_MOUSE_LEFT_CLICK:
|
||||
case NS_MOUSE_LEFT_DOUBLECLICK:
|
||||
*aButton = 1;
|
||||
break;
|
||||
case NS_MOUSE_MIDDLE_BUTTON_UP:
|
||||
case NS_MOUSE_MIDDLE_BUTTON_DOWN:
|
||||
case NS_MOUSE_MIDDLE_CLICK:
|
||||
case NS_MOUSE_MIDDLE_DOUBLECLICK:
|
||||
*aButton = 2;
|
||||
break;
|
||||
case NS_MOUSE_RIGHT_BUTTON_UP:
|
||||
case NS_MOUSE_RIGHT_BUTTON_DOWN:
|
||||
case NS_MOUSE_RIGHT_CLICK:
|
||||
case NS_MOUSE_RIGHT_DOUBLECLICK:
|
||||
*aButton = 3;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetClickCount(PRUint16* aClickCount)
|
||||
{
|
||||
if (!mEvent || mEvent->eventStructType != NS_MOUSE_EVENT) {
|
||||
*aClickCount = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
switch (mEvent->message) {
|
||||
case NS_MOUSE_LEFT_BUTTON_UP:
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
case NS_MOUSE_LEFT_CLICK:
|
||||
case NS_MOUSE_LEFT_DOUBLECLICK:
|
||||
case NS_MOUSE_MIDDLE_BUTTON_UP:
|
||||
case NS_MOUSE_MIDDLE_BUTTON_DOWN:
|
||||
case NS_MOUSE_MIDDLE_CLICK:
|
||||
case NS_MOUSE_MIDDLE_DOUBLECLICK:
|
||||
case NS_MOUSE_RIGHT_BUTTON_UP:
|
||||
case NS_MOUSE_RIGHT_BUTTON_DOWN:
|
||||
case NS_MOUSE_RIGHT_CLICK:
|
||||
case NS_MOUSE_RIGHT_DOUBLECLICK:
|
||||
*aClickCount = ((nsMouseEvent*)mEvent)->clickCount;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetRelatedNode(nsIDOMNode** aRelatedNode)
|
||||
{
|
||||
nsIEventStateManager *manager;
|
||||
nsIContent *relatedContent;
|
||||
nsresult ret = NS_OK;
|
||||
|
||||
if (NS_OK == mPresContext->GetEventStateManager(&manager)) {
|
||||
manager->GetEventRelatedContent(&relatedContent);
|
||||
NS_RELEASE(manager);
|
||||
}
|
||||
|
||||
if (relatedContent) {
|
||||
ret = relatedContent->QueryInterface(kIDOMNodeIID, (void**)aRelatedNode);
|
||||
NS_RELEASE(relatedContent);
|
||||
}
|
||||
else {
|
||||
*aRelatedNode = nsnull;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// nsINSEventInterface
|
||||
NS_METHOD nsDOMEvent::GetLayerX(PRInt32* aLayerX)
|
||||
{
|
||||
if (!mEvent || mEvent->eventStructType != NS_MOUSE_EVENT) {
|
||||
*aLayerX = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
float t2p;
|
||||
mPresContext->GetTwipsToPixels(&t2p);
|
||||
*aLayerX = NSTwipsToIntPixels(mEvent->point.x, t2p);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetLayerY(PRInt32* aLayerY)
|
||||
{
|
||||
if (!mEvent || mEvent->eventStructType != NS_MOUSE_EVENT) {
|
||||
*aLayerY = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
float t2p;
|
||||
mPresContext->GetTwipsToPixels(&t2p);
|
||||
*aLayerY = NSTwipsToIntPixels(mEvent->point.y, t2p);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetPageX(PRInt32* aPageX)
|
||||
{
|
||||
return GetClientX(aPageX);
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetPageY(PRInt32* aPageY)
|
||||
{
|
||||
return GetClientY(aPageY);
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetWhich(PRUint32* aWhich)
|
||||
{
|
||||
switch (mEvent->eventStructType) {
|
||||
case NS_KEY_EVENT:
|
||||
return GetKeyCode(aWhich);
|
||||
case NS_MOUSE_EVENT:
|
||||
{
|
||||
PRUint16 button;
|
||||
(void) GetButton(&button);
|
||||
*aWhich = button;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
*aWhich = 0;
|
||||
break;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetRangeParent(nsIDOMNode** aRangeParent)
|
||||
{
|
||||
nsIFrame* targetFrame;
|
||||
nsIEventStateManager* manager;
|
||||
|
||||
if (NS_OK == mPresContext->GetEventStateManager(&manager)) {
|
||||
manager->GetEventTarget(&targetFrame);
|
||||
NS_RELEASE(manager);
|
||||
}
|
||||
|
||||
if (targetFrame) {
|
||||
nsIContent* parent = nsnull;
|
||||
PRInt32 offset, endOffset;
|
||||
PRBool beginOfContent;
|
||||
if (NS_SUCCEEDED(targetFrame->GetContentAndOffsetsFromPoint(mPresContext,
|
||||
mEvent->point,
|
||||
&parent,
|
||||
offset,
|
||||
endOffset,
|
||||
beginOfContent))) {
|
||||
if (parent && NS_SUCCEEDED(parent->QueryInterface(kIDOMNodeIID, (void**)aRangeParent))) {
|
||||
NS_RELEASE(parent);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IF_RELEASE(parent);
|
||||
}
|
||||
}
|
||||
*aRangeParent = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetRangeOffset(PRInt32* aRangeOffset)
|
||||
{
|
||||
nsIFrame* targetFrame;
|
||||
nsIEventStateManager* manager;
|
||||
|
||||
if (NS_OK == mPresContext->GetEventStateManager(&manager)) {
|
||||
manager->GetEventTarget(&targetFrame);
|
||||
NS_RELEASE(manager);
|
||||
}
|
||||
|
||||
if (targetFrame) {
|
||||
nsIContent* parent = nsnull;
|
||||
PRInt32 endOffset;
|
||||
PRBool beginOfContent;
|
||||
if (NS_SUCCEEDED(targetFrame->GetContentAndOffsetsFromPoint(mPresContext,
|
||||
mEvent->point,
|
||||
&parent,
|
||||
*aRangeOffset,
|
||||
endOffset,
|
||||
beginOfContent))) {
|
||||
NS_IF_RELEASE(parent);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
*aRangeOffset = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetCancelBubble(PRBool* aCancelBubble)
|
||||
{
|
||||
if (mEvent->flags & NS_EVENT_FLAG_BUBBLE || mEvent->flags & NS_EVENT_FLAG_INIT) {
|
||||
*aCancelBubble = (mEvent->flags &= NS_EVENT_FLAG_STOP_DISPATCH) ? PR_TRUE : PR_FALSE;
|
||||
}
|
||||
else {
|
||||
*aCancelBubble = PR_FALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::SetCancelBubble(PRBool aCancelBubble)
|
||||
{
|
||||
if (mEvent->flags & NS_EVENT_FLAG_BUBBLE || mEvent->flags & NS_EVENT_FLAG_INIT) {
|
||||
if (aCancelBubble) {
|
||||
mEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH;
|
||||
}
|
||||
else {
|
||||
mEvent->flags &= ~NS_EVENT_FLAG_STOP_DISPATCH;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetIsChar(PRBool* aIsChar)
|
||||
{
|
||||
if (!mEvent) {
|
||||
*aIsChar = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
if (mEvent->eventStructType == NS_KEY_EVENT) {
|
||||
*aIsChar = ((nsKeyEvent*)mEvent)->isChar;
|
||||
return NS_OK;
|
||||
}
|
||||
if (mEvent->eventStructType == NS_TEXT_EVENT) {
|
||||
*aIsChar = ((nsTextEvent*)mEvent)->isChar;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aIsChar = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//XXX The following four methods are for custom event dispatch inside the DOM.
|
||||
//They will be implemented post-beta
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::InitEvent(const nsString& aEventTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::InitUIEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, nsIDOMAbstractView* aViewArg, PRInt32 aDetailArg)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::InitMouseEvent(const nsString& aTypeArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRInt32 aScreenXArg, PRInt32 aScreenYArg, PRInt32 aClientXArg, PRInt32 aClientYArg, PRUint16 aButtonArg, PRUint16 aDetailArg)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::InitKeyEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRUint32 aKeyCodeArg, PRUint32 aCharCodeArg, nsIDOMAbstractView* aViewArg)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD nsDOMEvent::DuplicatePrivateData()
|
||||
{
|
||||
//XXX Write me!
|
||||
|
||||
//XXX And when you do, make sure to copy over the event target here, too!
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::SetTarget(nsIDOMNode* aTarget)
|
||||
{
|
||||
if (mTarget != aTarget) {
|
||||
NS_IF_RELEASE(mTarget);
|
||||
NS_IF_ADDREF(aTarget);
|
||||
mTarget = aTarget;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
|
||||
{
|
||||
switch(aEventType) {
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
case NS_MOUSE_MIDDLE_BUTTON_DOWN:
|
||||
case NS_MOUSE_RIGHT_BUTTON_DOWN:
|
||||
return mEventNames[eDOMEvents_mousedown];
|
||||
case NS_MOUSE_LEFT_BUTTON_UP:
|
||||
case NS_MOUSE_MIDDLE_BUTTON_UP:
|
||||
case NS_MOUSE_RIGHT_BUTTON_UP:
|
||||
return mEventNames[eDOMEvents_mouseup];
|
||||
case NS_MOUSE_LEFT_CLICK:
|
||||
case NS_MOUSE_MIDDLE_CLICK:
|
||||
case NS_MOUSE_RIGHT_CLICK:
|
||||
return mEventNames[eDOMEvents_click];
|
||||
case NS_MOUSE_LEFT_DOUBLECLICK:
|
||||
case NS_MOUSE_MIDDLE_DOUBLECLICK:
|
||||
case NS_MOUSE_RIGHT_DOUBLECLICK:
|
||||
return mEventNames[eDOMEvents_dblclick];
|
||||
case NS_MOUSE_ENTER:
|
||||
return mEventNames[eDOMEvents_mouseover];
|
||||
case NS_MOUSE_EXIT:
|
||||
return mEventNames[eDOMEvents_mouseout];
|
||||
case NS_MOUSE_MOVE:
|
||||
return mEventNames[eDOMEvents_mousemove];
|
||||
case NS_KEY_UP:
|
||||
return mEventNames[eDOMEvents_keyup];
|
||||
case NS_KEY_DOWN:
|
||||
return mEventNames[eDOMEvents_keydown];
|
||||
case NS_KEY_PRESS:
|
||||
return mEventNames[eDOMEvents_keypress];
|
||||
case NS_FOCUS_CONTENT:
|
||||
return mEventNames[eDOMEvents_focus];
|
||||
case NS_BLUR_CONTENT:
|
||||
return mEventNames[eDOMEvents_blur];
|
||||
case NS_XUL_CLOSE:
|
||||
return mEventNames[eDOMEvents_close];
|
||||
case NS_PAGE_LOAD:
|
||||
case NS_IMAGE_LOAD:
|
||||
return mEventNames[eDOMEvents_load];
|
||||
case NS_PAGE_UNLOAD:
|
||||
return mEventNames[eDOMEvents_unload];
|
||||
case NS_IMAGE_ABORT:
|
||||
return mEventNames[eDOMEvents_abort];
|
||||
case NS_IMAGE_ERROR:
|
||||
return mEventNames[eDOMEvents_error];
|
||||
case NS_FORM_SUBMIT:
|
||||
return mEventNames[eDOMEvents_submit];
|
||||
case NS_FORM_RESET:
|
||||
return mEventNames[eDOMEvents_reset];
|
||||
case NS_FORM_CHANGE:
|
||||
return mEventNames[eDOMEvents_change];
|
||||
case NS_FORM_SELECTED:
|
||||
return mEventNames[eDOMEvents_select];
|
||||
case NS_FORM_INPUT:
|
||||
return mEventNames[eDOMEvents_input];
|
||||
case NS_PAINT:
|
||||
return mEventNames[eDOMEvents_paint];
|
||||
case NS_TEXT_EVENT:
|
||||
return mEventNames[eDOMEvents_text];
|
||||
case NS_MENU_CREATE:
|
||||
return mEventNames[eDOMEvents_create];
|
||||
case NS_MENU_DESTROY:
|
||||
return mEventNames[eDOMEvents_destroy];
|
||||
case NS_MENU_ACTION:
|
||||
return mEventNames[eDOMEvents_command];
|
||||
case NS_XUL_BROADCAST:
|
||||
return mEventNames[eDOMEvents_broadcast];
|
||||
case NS_XUL_COMMAND_UPDATE:
|
||||
return mEventNames[eDOMEvents_commandupdate];
|
||||
case NS_DRAGDROP_ENTER:
|
||||
return mEventNames[eDOMEvents_dragenter];
|
||||
case NS_DRAGDROP_OVER:
|
||||
return mEventNames[eDOMEvents_dragover];
|
||||
case NS_DRAGDROP_EXIT:
|
||||
return mEventNames[eDOMEvents_dragexit];
|
||||
case NS_DRAGDROP_DROP:
|
||||
return mEventNames[eDOMEvents_dragdrop];
|
||||
case NS_DRAGDROP_GESTURE:
|
||||
return mEventNames[eDOMEvents_draggesture];
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsresult NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext* aPresContext, nsEvent *aEvent)
|
||||
{
|
||||
nsDOMEvent* it = new nsDOMEvent(aPresContext, aEvent);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return it->QueryInterface(kIDOMEventIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
|
||||
nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext* aPresContext, nsEvent *aEvent)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
160
mozilla/content/events/src/nsDOMEvent.h
Normal file
160
mozilla/content/events/src/nsDOMEvent.h
Normal file
@@ -0,0 +1,160 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsDOMEvent_h__
|
||||
#define nsDOMEvent_h__
|
||||
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsIDOMNSUIEvent.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIPrivateCompositionEvent.h"
|
||||
#include "nsIPrivateTextEvent.h"
|
||||
#include "nsIPrivateTextRange.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsPoint.h"
|
||||
#include "nsGUIEvent.h"
|
||||
class nsIContent;
|
||||
|
||||
class nsDOMEvent : public nsIDOMKeyEvent,
|
||||
public nsIDOMMouseEvent,
|
||||
public nsIDOMNSUIEvent,
|
||||
public nsIPrivateDOMEvent,
|
||||
public nsIPrivateTextEvent,
|
||||
public nsIPrivateCompositionEvent {
|
||||
|
||||
public:
|
||||
// Note: this enum must be kept in sync with mEventNames in nsDOMEvent.cpp
|
||||
enum nsDOMEvents {
|
||||
eDOMEvents_mousedown=0,
|
||||
eDOMEvents_mouseup,
|
||||
eDOMEvents_click,
|
||||
eDOMEvents_dblclick,
|
||||
eDOMEvents_mouseover,
|
||||
eDOMEvents_mouseout,
|
||||
eDOMEvents_mousemove,
|
||||
eDOMEvents_keydown,
|
||||
eDOMEvents_keyup,
|
||||
eDOMEvents_keypress,
|
||||
eDOMEvents_focus,
|
||||
eDOMEvents_blur,
|
||||
eDOMEvents_load,
|
||||
eDOMEvents_unload,
|
||||
eDOMEvents_abort,
|
||||
eDOMEvents_error,
|
||||
eDOMEvents_submit,
|
||||
eDOMEvents_reset,
|
||||
eDOMEvents_change,
|
||||
eDOMEvents_select,
|
||||
eDOMEvents_input,
|
||||
eDOMEvents_paint,
|
||||
eDOMEvents_text,
|
||||
eDOMEvents_create,
|
||||
eDOMEvents_close,
|
||||
eDOMEvents_destroy,
|
||||
eDOMEvents_command,
|
||||
eDOMEvents_broadcast,
|
||||
eDOMEvents_commandupdate,
|
||||
eDOMEvents_dragenter,
|
||||
eDOMEvents_dragover,
|
||||
eDOMEvents_dragexit,
|
||||
eDOMEvents_dragdrop,
|
||||
eDOMEvents_draggesture
|
||||
};
|
||||
|
||||
nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent);
|
||||
virtual ~nsDOMEvent();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMEvent Interface
|
||||
NS_IMETHOD GetType(nsString& aType);
|
||||
NS_IMETHOD GetTarget(nsIDOMNode** aTarget);
|
||||
NS_IMETHOD GetCurrentNode(nsIDOMNode** aCurrentNode);
|
||||
NS_IMETHOD GetEventPhase(PRUint16* aEventPhase);
|
||||
NS_IMETHOD GetBubbles(PRBool* aBubbles);
|
||||
NS_IMETHOD GetCancelable(PRBool* aCancelable);
|
||||
NS_IMETHOD PreventBubble();
|
||||
NS_IMETHOD PreventCapture();
|
||||
NS_IMETHOD PreventDefault();
|
||||
NS_IMETHOD InitEvent(const nsString& aEventTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg);
|
||||
|
||||
// nsIDOMUIEvent Interface
|
||||
NS_IMETHOD GetView(nsIDOMAbstractView** aView);
|
||||
NS_IMETHOD GetDetail(PRInt32* aDetail);
|
||||
NS_IMETHOD InitUIEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, nsIDOMAbstractView* aViewArg, PRInt32 aDetailArg);
|
||||
|
||||
// nsIDOMMouseEvent Interface and nsIDOMKeyEvent Interface
|
||||
NS_IMETHOD GetScreenX(PRInt32* aScreenX);
|
||||
NS_IMETHOD GetScreenY(PRInt32* aScreenY);
|
||||
NS_IMETHOD GetClientX(PRInt32* aClientX);
|
||||
NS_IMETHOD GetClientY(PRInt32* aClientY);
|
||||
NS_IMETHOD GetAltKey(PRBool* aAltKey);
|
||||
NS_IMETHOD GetCtrlKey(PRBool* aCtrlKey);
|
||||
NS_IMETHOD GetShiftKey(PRBool* aShiftKey);
|
||||
NS_IMETHOD GetMetaKey(PRBool* aMetaKey);
|
||||
NS_IMETHOD GetButton(PRUint16* aButton);
|
||||
NS_IMETHOD GetClickCount(PRUint16* aClickCount);
|
||||
NS_IMETHOD GetRelatedNode(nsIDOMNode** aRelatedNode);
|
||||
NS_IMETHOD GetCharCode(PRUint32* aCharCode);
|
||||
NS_IMETHOD GetKeyCode(PRUint32* aKeyCode);
|
||||
NS_IMETHOD InitMouseEvent(const nsString& aTypeArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRInt32 aScreenXArg, PRInt32 aScreenYArg, PRInt32 aClientXArg, PRInt32 aClientYArg, PRUint16 aButtonArg, PRUint16 aDetailArg);
|
||||
NS_IMETHOD InitKeyEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRUint32 aKeyCodeArg, PRUint32 aCharCodeArg, nsIDOMAbstractView* aViewArg);
|
||||
|
||||
// nsIDOMNSUIEvent interface
|
||||
NS_IMETHOD GetLayerX(PRInt32* aLayerX);
|
||||
NS_IMETHOD GetLayerY(PRInt32* aLayerY);
|
||||
NS_IMETHOD GetPageX(PRInt32* aClientX);
|
||||
NS_IMETHOD GetPageY(PRInt32* aClientY);
|
||||
NS_IMETHOD GetWhich(PRUint32* aKeyCode);
|
||||
NS_IMETHOD GetRangeParent(nsIDOMNode** aRangeParent);
|
||||
NS_IMETHOD GetRangeOffset(PRInt32* aRangeOffset);
|
||||
NS_IMETHOD GetCancelBubble(PRBool* aCancelBubble);
|
||||
NS_IMETHOD SetCancelBubble(PRBool aCancelBubble);
|
||||
NS_IMETHOD GetIsChar(PRBool* aIsChar);
|
||||
|
||||
// nsIPrivateDOMEvent interface
|
||||
NS_IMETHOD DuplicatePrivateData();
|
||||
NS_IMETHOD SetTarget(nsIDOMNode* aNode);
|
||||
|
||||
// nsIPrivateTextEvent interface
|
||||
NS_IMETHOD GetText(nsString& aText);
|
||||
NS_IMETHOD GetInputRange(nsIPrivateTextRangeList** aInputRange);
|
||||
NS_IMETHOD GetEventReply(nsTextEventReply** aReply);
|
||||
|
||||
// nsIPrivateCompositionEvent interface
|
||||
NS_IMETHOD GetCompositionReply(nsTextEventReply** aReply);
|
||||
|
||||
protected:
|
||||
|
||||
nsEvent* mEvent;
|
||||
nsIPresContext* mPresContext;
|
||||
nsIDOMNode* mTarget;
|
||||
nsString* mText;
|
||||
nsIPrivateTextRangeList* mTextRange;
|
||||
const char* GetEventName(PRUint32 aEventType);
|
||||
};
|
||||
|
||||
#endif // nsDOMEvent_h__
|
||||
45
mozilla/content/events/src/nsDOMEventsIIDs.cpp
Normal file
45
mozilla/content/events/src/nsDOMEventsIIDs.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsDOMEventsIIDs.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
#include "nsIDOMKeyListener.h"
|
||||
#include "nsIDOMMouseMotionListener.h"
|
||||
#include "nsIDOMFocusListener.h"
|
||||
#include "nsIDOMFormListener.h"
|
||||
#include "nsIDOMLoadListener.h"
|
||||
#include "nsIDOMDragListener.h"
|
||||
#include "nsIDOMPaintListener.h"
|
||||
#include "nsIDOMTextListener.h"
|
||||
#include "nsIDOMCompositionListener.h"
|
||||
#include "nsIDOMMenuListener.h"
|
||||
|
||||
NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID);
|
||||
NS_DEFINE_IID(kIDOMKeyListenerIID, NS_IDOMKEYLISTENER_IID);
|
||||
NS_DEFINE_IID(kIDOMMouseMotionListenerIID, NS_IDOMMOUSEMOTIONLISTENER_IID);
|
||||
NS_DEFINE_IID(kIDOMFocusListenerIID, NS_IDOMFOCUSLISTENER_IID);
|
||||
NS_DEFINE_IID(kIDOMFormListenerIID, NS_IDOMFORMLISTENER_IID);
|
||||
NS_DEFINE_IID(kIDOMLoadListenerIID, NS_IDOMLOADLISTENER_IID);
|
||||
NS_DEFINE_IID(kIDOMDragListenerIID, NS_IDOMDRAGLISTENER_IID);
|
||||
NS_DEFINE_IID(kIDOMPaintListenerIID, NS_IDOMPAINTLISTENER_IID);
|
||||
NS_DEFINE_IID(kIDOMTextListenerIID,NS_IDOMTEXTLISTENER_IID);
|
||||
NS_DEFINE_IID(kIDOMCompositionListenerIID,NS_IDOMCOMPOSITIONLISTENER_IID);
|
||||
NS_DEFINE_IID(kIDOMMenuListenerIID, NS_IDOMMENULISTENER_IID);
|
||||
39
mozilla/content/events/src/nsDOMEventsIIDs.h
Normal file
39
mozilla/content/events/src/nsDOMEventsIIDs.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsDOMEVENTSIIDs_h___
|
||||
#define nsDOMEVENTSIIDs_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
extern const nsIID kIDOMMouseListenerIID;
|
||||
extern const nsIID kIDOMKeyListenerIID;
|
||||
extern const nsIID kIDOMMouseMotionListenerIID;
|
||||
extern const nsIID kIDOMFocusListenerIID;
|
||||
extern const nsIID kIDOMFormListenerIID;
|
||||
extern const nsIID kIDOMLoadListenerIID;
|
||||
extern const nsIID kIDOMDragListenerIID;
|
||||
extern const nsIID kIDOMPaintListenerIID;
|
||||
extern const nsIID kIDOMTextListenerIID;
|
||||
extern const nsIID kIDOMCompositionListenerIID;
|
||||
extern const nsIID kIDOMMenuListenerIID;
|
||||
|
||||
#endif /* nsDOMEVENTSIIDs_h___ */
|
||||
1496
mozilla/content/events/src/nsEventListenerManager.cpp
Normal file
1496
mozilla/content/events/src/nsEventListenerManager.cpp
Normal file
File diff suppressed because it is too large
Load Diff
206
mozilla/content/events/src/nsEventListenerManager.h
Normal file
206
mozilla/content/events/src/nsEventListenerManager.h
Normal file
@@ -0,0 +1,206 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsEventListenerManager_h__
|
||||
#define nsEventListenerManager_h__
|
||||
|
||||
#include "nsIEventListenerManager.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPrincipal.h"
|
||||
|
||||
class nsIDOMEvent;
|
||||
class nsIAtom;
|
||||
|
||||
typedef struct {
|
||||
nsIDOMEventListener* mListener;
|
||||
PRUint8 mFlags;
|
||||
PRUint8 mSubType;
|
||||
PRUint32 mHandlerIsString;
|
||||
} nsListenerStruct;
|
||||
|
||||
//Flag must live higher than all event flags in nsGUIEvent.h
|
||||
#define NS_PRIV_EVENT_FLAG_SCRIPT 0x10
|
||||
|
||||
/*
|
||||
* Event listener manager
|
||||
*/
|
||||
|
||||
class nsEventListenerManager : public nsIEventListenerManager {
|
||||
|
||||
public:
|
||||
nsEventListenerManager();
|
||||
virtual ~nsEventListenerManager();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsVoidArray** GetListenersByIID(const nsIID& aIID);
|
||||
|
||||
/**
|
||||
* Retrieves events listeners of all types.
|
||||
* @param
|
||||
*/
|
||||
|
||||
virtual nsresult GetEventListeners(nsVoidArray **aListeners, const nsIID& aIID);
|
||||
|
||||
/**
|
||||
* Sets events listeners of all types.
|
||||
* @param an event listener
|
||||
*/
|
||||
|
||||
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID, PRInt32 aFlags);
|
||||
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID, PRInt32 aFlags);
|
||||
virtual nsresult AddEventListenerByType(nsIDOMEventListener *aListener, const nsString& type, PRInt32 aFlags);
|
||||
virtual nsresult RemoveEventListenerByType(nsIDOMEventListener *aListener, const nsString& type, PRInt32 aFlags) ;
|
||||
|
||||
virtual nsresult AddScriptEventListener(nsIScriptContext*aContext,
|
||||
nsIScriptObjectOwner *aScriptObjectOwner,
|
||||
nsIAtom *aName,
|
||||
const nsString& aFunc,
|
||||
REFNSIID aIID,
|
||||
PRBool aDeferCompilation);
|
||||
virtual nsresult RegisterScriptEventListener(nsIScriptContext *aContext,
|
||||
nsIScriptObjectOwner *aScriptObjectOwner,
|
||||
nsIAtom* aName,
|
||||
const nsIID& aIID);
|
||||
|
||||
|
||||
virtual nsresult CaptureEvent(nsIDOMEventListener *aListener);
|
||||
virtual nsresult ReleaseEvent(nsIDOMEventListener *aListener);
|
||||
|
||||
virtual nsresult HandleEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus);
|
||||
|
||||
virtual nsresult CreateEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent);
|
||||
|
||||
virtual nsresult RemoveAllListeners(PRBool aScriptOnly);
|
||||
|
||||
static nsresult GetIdentifiersForType(nsIAtom* aType, nsIID& aIID, PRInt32* aSubType);
|
||||
|
||||
protected:
|
||||
nsresult HandleEventSubType(nsListenerStruct* aListenerStruct,
|
||||
nsIDOMEvent* aDOMEvent,
|
||||
PRUint32 aSubType);
|
||||
nsListenerStruct* FindJSEventListener(REFNSIID aIID);
|
||||
nsresult SetJSEventListener(nsIScriptContext *aContext, nsIScriptObjectOwner *aOwner, nsIAtom* aName, REFNSIID aIID, PRBool aIsString);
|
||||
nsresult AddEventListener(nsIDOMEventListener *aListener, const nsIID& aIID, PRInt32 aFlags, PRInt32 aSubType);
|
||||
nsresult RemoveEventListener(nsIDOMEventListener *aListener, const nsIID& aIID, PRInt32 aFlags, PRInt32 aSubType);
|
||||
void ReleaseListeners(nsVoidArray** aListeners, PRBool aScriptOnly);
|
||||
|
||||
nsVoidArray* mEventListeners;
|
||||
nsVoidArray* mMouseListeners;
|
||||
nsVoidArray* mMouseMotionListeners;
|
||||
nsVoidArray* mKeyListeners;
|
||||
nsVoidArray* mLoadListeners;
|
||||
nsVoidArray* mFocusListeners;
|
||||
nsVoidArray* mFormListeners;
|
||||
nsVoidArray* mDragListeners;
|
||||
nsVoidArray* mPaintListeners;
|
||||
nsVoidArray* mTextListeners;
|
||||
nsVoidArray* mCompositionListeners;
|
||||
nsVoidArray* mMenuListeners;
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
};
|
||||
|
||||
|
||||
//Set of defines for distinguishing event handlers within listener groupings
|
||||
//XXX Current usage allows no more than 7 types per listener grouping
|
||||
|
||||
#define NS_EVENT_BITS_NONE 0x00
|
||||
|
||||
//nsIDOMMouseListener
|
||||
#define NS_EVENT_BITS_MOUSE_NONE 0x00
|
||||
#define NS_EVENT_BITS_MOUSE_MOUSEDOWN 0x01
|
||||
#define NS_EVENT_BITS_MOUSE_MOUSEUP 0x02
|
||||
#define NS_EVENT_BITS_MOUSE_CLICK 0x04
|
||||
#define NS_EVENT_BITS_MOUSE_DBLCLICK 0x08
|
||||
#define NS_EVENT_BITS_MOUSE_MOUSEOVER 0x10
|
||||
#define NS_EVENT_BITS_MOUSE_MOUSEOUT 0x20
|
||||
|
||||
//nsIDOMMouseMotionListener
|
||||
#define NS_EVENT_BITS_MOUSEMOTION_NONE 0x00
|
||||
#define NS_EVENT_BITS_MOUSEMOTION_MOUSEMOVE 0x01
|
||||
#define NS_EVENT_BITS_MOUSEMOTION_DRAGMOVE 0x02
|
||||
|
||||
//nsIDOMKeyListener
|
||||
#define NS_EVENT_BITS_KEY_NONE 0x00
|
||||
#define NS_EVENT_BITS_KEY_KEYDOWN 0x01
|
||||
#define NS_EVENT_BITS_KEY_KEYUP 0x02
|
||||
#define NS_EVENT_BITS_KEY_KEYPRESS 0x04
|
||||
|
||||
//nsIDOMTextListener
|
||||
#define NS_EVENT_BITS_TEXT_NONE 0x00
|
||||
#define NS_EVENT_BITS_TEXT_TEXT 0x01
|
||||
|
||||
//nsIDOMCompositionListener
|
||||
#define NS_EVENT_BITS_COMPOSITION_NONE 0x00
|
||||
#define NS_EVENT_BITS_COMPOSITION_START 0x01
|
||||
#define NS_EVENT_BITS_COMPOSITION_END 0x02
|
||||
#define NS_EVENT_BITS_COMPOSITION_QUERY 0x04
|
||||
|
||||
//nsIDOMFocusListener
|
||||
#define NS_EVENT_BITS_FOCUS_NONE 0x00
|
||||
#define NS_EVENT_BITS_FOCUS_FOCUS 0x01
|
||||
#define NS_EVENT_BITS_FOCUS_BLUR 0x02
|
||||
|
||||
//nsIDOMFormListener
|
||||
#define NS_EVENT_BITS_FORM_NONE 0x00
|
||||
#define NS_EVENT_BITS_FORM_SUBMIT 0x01
|
||||
#define NS_EVENT_BITS_FORM_RESET 0x02
|
||||
#define NS_EVENT_BITS_FORM_CHANGE 0x04
|
||||
#define NS_EVENT_BITS_FORM_SELECT 0x08
|
||||
#define NS_EVENT_BITS_FORM_INPUT 0x10
|
||||
|
||||
//nsIDOMLoadListener
|
||||
#define NS_EVENT_BITS_LOAD_NONE 0x00
|
||||
#define NS_EVENT_BITS_LOAD_LOAD 0x01
|
||||
#define NS_EVENT_BITS_LOAD_UNLOAD 0x02
|
||||
#define NS_EVENT_BITS_LOAD_ABORT 0x04
|
||||
#define NS_EVENT_BITS_LOAD_ERROR 0x08
|
||||
|
||||
//nsIDOMMenuListener
|
||||
#define NS_EVENT_BITS_MENU_NONE 0x00
|
||||
#define NS_EVENT_BITS_MENU_CREATE 0x01
|
||||
#define NS_EVENT_BITS_XUL_CLOSE 0x02
|
||||
#define NS_EVENT_BITS_MENU_DESTROY 0x04
|
||||
#define NS_EVENT_BITS_MENU_ACTION 0x08
|
||||
#define NS_EVENT_BITS_XUL_BROADCAST 0x10
|
||||
#define NS_EVENT_BITS_XUL_COMMAND_UPDATE 0x20
|
||||
|
||||
//nsIDOMDragListener
|
||||
#define NS_EVENT_BITS_DRAG_NONE 0x00
|
||||
#define NS_EVENT_BITS_DRAG_ENTER 0x01
|
||||
#define NS_EVENT_BITS_DRAG_OVER 0x02
|
||||
#define NS_EVENT_BITS_DRAG_EXIT 0x04
|
||||
#define NS_EVENT_BITS_DRAG_DROP 0x08
|
||||
#define NS_EVENT_BITS_DRAG_GESTURE 0x10
|
||||
|
||||
//nsIDOMPaintListener
|
||||
#define NS_EVENT_BITS_PAINT_NONE 0x00
|
||||
#define NS_EVENT_BITS_PAINT_PAINT 0x01
|
||||
|
||||
#endif // nsEventListenerManager_h__
|
||||
2079
mozilla/content/events/src/nsEventStateManager.cpp
Normal file
2079
mozilla/content/events/src/nsEventStateManager.cpp
Normal file
File diff suppressed because it is too large
Load Diff
147
mozilla/content/events/src/nsEventStateManager.h
Normal file
147
mozilla/content/events/src/nsEventStateManager.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsEventStateManager_h__
|
||||
#define nsEventStateManager_h__
|
||||
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsGUIEvent.h"
|
||||
class nsIDocument;
|
||||
class nsIScrollableView;
|
||||
class nsISelfScrollingFrame;
|
||||
|
||||
/*
|
||||
* Event listener manager
|
||||
*/
|
||||
|
||||
class nsEventStateManager : public nsIEventStateManager {
|
||||
|
||||
public:
|
||||
nsEventStateManager();
|
||||
virtual ~nsEventStateManager();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/* The PreHandleEvent method is called before event dispatch to either
|
||||
* the DOM or frames. Any processing which must not be prevented or
|
||||
* cancelled should occur here. Any processing which is intended to
|
||||
* be conditional based on either DOM or frame processing should occur in
|
||||
* PostHandleEvent. Any centralized event processing which must occur before
|
||||
* DOM or frame event handling should occur here as well.
|
||||
*/
|
||||
NS_IMETHOD PreHandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent *aEvent,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsEventStatus* aStatus,
|
||||
nsIView* aView);
|
||||
|
||||
/* The PostHandleEvent method should contain all system processing which
|
||||
* should occur conditionally based on DOM or frame processing. It should
|
||||
* also contain any centralized event processing which must occur after
|
||||
* DOM and frame processing.
|
||||
*/
|
||||
NS_IMETHOD PostHandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent *aEvent,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsEventStatus* aStatus,
|
||||
nsIView* aView);
|
||||
|
||||
NS_IMETHOD SetPresContext(nsIPresContext* aPresContext);
|
||||
NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame);
|
||||
|
||||
NS_IMETHOD GetEventTarget(nsIFrame **aFrame);
|
||||
NS_IMETHOD GetEventTargetContent(nsEvent* aEvent, nsIContent** aContent);
|
||||
NS_IMETHOD GetEventRelatedContent(nsIContent** aContent);
|
||||
|
||||
NS_IMETHOD GetContentState(nsIContent *aContent, PRInt32& aState);
|
||||
NS_IMETHOD SetContentState(nsIContent *aContent, PRInt32 aState);
|
||||
NS_IMETHOD GetFocusedContent(nsIContent **aContent);
|
||||
NS_IMETHOD SetFocusedContent(nsIContent* aContent);
|
||||
|
||||
// Cross ESM methods
|
||||
NS_IMETHOD GetFocusedEventTarget(nsIFrame **aFrame);
|
||||
|
||||
// This is an experiement and may be temporary
|
||||
NS_IMETHOD ConsumeFocusEvents(PRBool aDoConsume) { mConsumeFocusEvents = aDoConsume; return NS_OK; }
|
||||
|
||||
protected:
|
||||
void UpdateCursor(nsIPresContext* aPresContext, nsPoint& aPoint, nsIFrame* aTargetFrame, nsEventStatus* aStatus);
|
||||
void GenerateMouseEnterExit(nsIPresContext* aPresContext, nsGUIEvent* aEvent);
|
||||
void GenerateDragDropEnterExit(nsIPresContext* aPresContext, nsGUIEvent* aEvent);
|
||||
NS_IMETHOD DispatchKeyPressEvent(nsIPresContext* aPresContext, nsKeyEvent *aEvent, nsEventStatus* aStatus);
|
||||
NS_IMETHOD SetClickCount(nsIPresContext* aPresContext, nsMouseEvent *aEvent, nsEventStatus* aStatus);
|
||||
NS_IMETHOD CheckForAndDispatchClick(nsIPresContext* aPresContext, nsMouseEvent *aEvent, nsEventStatus* aStatus);
|
||||
PRBool ChangeFocus(nsIContent* aFocus, nsIFrame* aFocusFrame, PRBool aSetFocus);
|
||||
void ShiftFocus(PRBool foward);
|
||||
nsIContent* GetNextTabbableContent(nsIContent* aParent, nsIContent* aChild, nsIContent* aTop, PRBool foward);
|
||||
PRInt32 GetNextTabIndex(nsIContent* aParent, PRBool foward);
|
||||
NS_IMETHOD SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aContent);
|
||||
nsIScrollableView* GetNearestScrollingView(nsIView* aView);
|
||||
nsISelfScrollingFrame* GetNearestSelfScrollingFrame(nsIFrame* aFrame);
|
||||
PRBool CheckDisabled(nsIContent* aContent);
|
||||
|
||||
nsIFrame* GetDocumentFrame(nsIPresContext* aPresContext);
|
||||
|
||||
// routines for the d&d gesture tracking state machine
|
||||
void BeginTrackingDragGesture ( nsGUIEvent* inDownEvent, nsIFrame* inDownFrame ) ;
|
||||
void StopTrackingDragGesture ( ) ;
|
||||
void GenerateDragGesture ( nsIPresContext* aPresContext, nsGUIEvent *aEvent ) ;
|
||||
PRBool IsTrackingDragGesture ( ) const { return mIsTrackingDragGesture; }
|
||||
|
||||
//Any frames here must be checked for validity in ClearFrameRefs
|
||||
nsIFrame* mCurrentTarget;
|
||||
nsIContent* mCurrentTargetContent;
|
||||
nsIContent* mCurrentRelatedContent;
|
||||
nsIFrame* mLastMouseOverFrame;
|
||||
nsIFrame* mLastDragOverFrame;
|
||||
|
||||
// member variables for the d&d gesture state machine
|
||||
PRBool mIsTrackingDragGesture;
|
||||
nsPoint mGestureDownPoint;
|
||||
nsIFrame* mGestureDownFrame;
|
||||
|
||||
nsIContent* mLastLeftMouseDownContent;
|
||||
nsIContent* mLastMiddleMouseDownContent;
|
||||
nsIContent* mLastRightMouseDownContent;
|
||||
|
||||
nsIContent* mActiveContent;
|
||||
nsIContent* mHoverContent;
|
||||
nsIContent* mDragOverContent;
|
||||
nsIContent* mCurrentFocus;
|
||||
PRInt32 mCurrentTabIndex;
|
||||
nsIWidget * mLastWindowToHaveFocus; // last native window to get focus via the evs
|
||||
PRBool mConsumeFocusEvents;
|
||||
|
||||
nsIPresContext* mPresContext; // Not refcnted
|
||||
nsIDocument* mDocument; // [OWNER], but doesn't need to be.
|
||||
|
||||
PRUint32 mLClickCount;
|
||||
PRUint32 mMClickCount;
|
||||
PRUint32 mRClickCount;
|
||||
|
||||
static PRUint32 mInstanceCount;
|
||||
|
||||
};
|
||||
|
||||
extern nsresult NS_NewEventStateManager(nsIEventStateManager** aInstancePtrResult);
|
||||
|
||||
#endif // nsEventStateManager_h__
|
||||
153
mozilla/content/events/src/nsPrivateTextRange.cpp
Normal file
153
mozilla/content/events/src/nsPrivateTextRange.cpp
Normal file
@@ -0,0 +1,153 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsPrivateTextRange.h"
|
||||
|
||||
static NS_DEFINE_IID(kIPrivateTextRange, NS_IPRIVATETEXTRANGE_IID);
|
||||
static NS_DEFINE_IID(kIPrivateTextRangeList,NS_IPRIVATETEXTRANGELIST_IID);
|
||||
|
||||
nsPrivateTextRange::nsPrivateTextRange(PRUint16 aRangeStart, PRUint16 aRangeEnd, PRUint16 aRangeType)
|
||||
: mRangeStart(aRangeStart),
|
||||
mRangeEnd(aRangeEnd),
|
||||
mRangeType(aRangeType)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsPrivateTextRange::~nsPrivateTextRange(void)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsPrivateTextRange)
|
||||
NS_IMPL_RELEASE(nsPrivateTextRange)
|
||||
|
||||
nsresult nsPrivateTextRange::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIPrivateTextRange)) {
|
||||
*aInstancePtrResult = (void*) ((nsIPrivateTextRange*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_METHOD nsPrivateTextRange::GetRangeStart(PRUint16* aRangeStart)
|
||||
{
|
||||
*aRangeStart = mRangeStart;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsPrivateTextRange::SetRangeStart(PRUint16 aRangeStart)
|
||||
{
|
||||
mRangeStart = aRangeStart;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsPrivateTextRange::GetRangeEnd(PRUint16* aRangeEnd)
|
||||
{
|
||||
*aRangeEnd = mRangeEnd;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsPrivateTextRange::SetRangeEnd(PRUint16 aRangeEnd)
|
||||
{
|
||||
mRangeEnd = aRangeEnd;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsPrivateTextRange::GetRangeType(PRUint16* aRangeType)
|
||||
{
|
||||
*aRangeType = mRangeType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsPrivateTextRange::SetRangeType(PRUint16 aRangeType)
|
||||
{
|
||||
mRangeType = aRangeType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsPrivateTextRangeList::nsPrivateTextRangeList(PRUint16 aLength,nsIPrivateTextRange** aList)
|
||||
: mLength(aLength),
|
||||
mList(aList)
|
||||
{
|
||||
if (aList==nsnull)
|
||||
aLength = 0;
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsPrivateTextRangeList::~nsPrivateTextRangeList(void)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<mLength;i++)
|
||||
mList[i]->Release();
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsPrivateTextRangeList)
|
||||
NS_IMPL_RELEASE(nsPrivateTextRangeList)
|
||||
|
||||
nsresult nsPrivateTextRangeList::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIPrivateTextRangeList)) {
|
||||
*aInstancePtrResult = (void*) ((nsIPrivateTextRangeList*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_METHOD nsPrivateTextRangeList::GetLength(PRUint16* aLength)
|
||||
{
|
||||
*aLength = mLength;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsPrivateTextRangeList::Item(PRUint16 aIndex, nsIPrivateTextRange** aReturn)
|
||||
{
|
||||
if (aIndex>mLength) {
|
||||
*aReturn = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mList[aIndex]->AddRef();
|
||||
*aReturn = mList[aIndex];
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
71
mozilla/content/events/src/nsPrivateTextRange.h
Normal file
71
mozilla/content/events/src/nsPrivateTextRange.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsPrivateTextRange_h__
|
||||
#define nsPrivateTextRange_h__
|
||||
|
||||
#include "nsIPrivateTextRange.h"
|
||||
|
||||
class nsPrivateTextRange : public nsIPrivateTextRange
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
public:
|
||||
|
||||
nsPrivateTextRange(PRUint16 aRangeStart, PRUint16 aRangeEnd, PRUint16 aRangeType);
|
||||
virtual ~nsPrivateTextRange(void);
|
||||
|
||||
NS_IMETHOD GetRangeStart(PRUint16* aRangeStart);
|
||||
NS_IMETHOD SetRangeStart(PRUint16 aRangeStart);
|
||||
|
||||
NS_IMETHOD GetRangeEnd(PRUint16* aRangeEnd);
|
||||
NS_IMETHOD SetRangeEnd(PRUint16 aRangeEnd);
|
||||
|
||||
NS_IMETHOD GetRangeType(PRUint16* aRangeType);
|
||||
NS_IMETHOD SetRangeType(PRUint16 aRangeType);
|
||||
|
||||
protected:
|
||||
|
||||
PRUint16 mRangeStart;
|
||||
PRUint16 mRangeEnd;
|
||||
PRUint16 mRangeType;
|
||||
};
|
||||
|
||||
class nsPrivateTextRangeList: public nsIPrivateTextRangeList
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
public:
|
||||
|
||||
nsPrivateTextRangeList(PRUint16 aLength,nsIPrivateTextRange** aList);
|
||||
virtual ~nsPrivateTextRangeList(void);
|
||||
|
||||
NS_IMETHOD GetLength(PRUint16* aLength);
|
||||
|
||||
NS_IMETHOD Item(PRUint16 aIndex, nsIPrivateTextRange** aReturn);
|
||||
|
||||
protected:
|
||||
|
||||
PRUint16 mLength;
|
||||
nsIPrivateTextRange** mList;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
32
mozilla/content/html/content/Makefile.in
Normal file
32
mozilla/content/html/content/Makefile.in
Normal file
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# 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/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
26
mozilla/content/html/content/makefile.win
Normal file
26
mozilla/content/html/content/makefile.win
Normal file
@@ -0,0 +1,26 @@
|
||||
#!nmake
|
||||
#
|
||||
# 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/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
DIRS=src public
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
5
mozilla/content/html/content/public/MANIFEST
Normal file
5
mozilla/content/html/content/public/MANIFEST
Normal file
@@ -0,0 +1,5 @@
|
||||
nsIFocusableContent.h
|
||||
nsIForm.h
|
||||
nsIFormControl.h
|
||||
nsISelectElement.h
|
||||
|
||||
41
mozilla/content/html/content/public/Makefile.in
Normal file
41
mozilla/content/html/content/public/Makefile.in
Normal file
@@ -0,0 +1,41 @@
|
||||
#
|
||||
# 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/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = layout
|
||||
|
||||
EXPORTS = \
|
||||
nsIFormControl.h \
|
||||
nsIForm.h \
|
||||
nsIFocusableContent.h \
|
||||
nsISelectElement.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
29
mozilla/content/html/content/public/makefile.win
Normal file
29
mozilla/content/html/content/public/makefile.win
Normal file
@@ -0,0 +1,29 @@
|
||||
#!nmake
|
||||
#
|
||||
# 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/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
EXPORTS=nsIFormControl.h nsIForm.h nsIFocusableContent.h nsISelectElement.h
|
||||
|
||||
MODULE=raptor
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
82
mozilla/content/html/content/public/nsIForm.h
Normal file
82
mozilla/content/html/content/public/nsIForm.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsIForm_h___
|
||||
#define nsIForm_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsIFormControl;
|
||||
class nsISizeOfHandler;
|
||||
|
||||
#define NS_FORM_METHOD_GET 0
|
||||
#define NS_FORM_METHOD_POST 1
|
||||
#define NS_FORM_ENCTYPE_URLENCODED 0
|
||||
#define NS_FORM_ENCTYPE_MULTIPART 1
|
||||
|
||||
// IID for the nsIFormManager interface
|
||||
#define NS_IFORM_IID \
|
||||
{ 0xb7e94510, 0x4c19, 0x11d2, \
|
||||
{ 0x80, 0x3f, 0x0, 0x60, 0x8, 0x15, 0xa7, 0x91 } }
|
||||
|
||||
/**
|
||||
* This interface provides a complete set of methods dealing with
|
||||
* elements which belong to a form element. When nsIDOMHTMLCollection
|
||||
* allows write operations
|
||||
*/
|
||||
class nsIForm : public nsISupports {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Add an element to end of this form's list of elements
|
||||
* @param aElement the element to add
|
||||
* @return NS_OK if the element was successfully added
|
||||
*/
|
||||
NS_IMETHOD AddElement(nsIFormControl* aElement) = 0;
|
||||
|
||||
/**
|
||||
* Get the element at a specified index position
|
||||
* @param aIndex the index
|
||||
* @param aElement the element at that index
|
||||
* @return NS_OK if there was an element at that position, -1 otherwise
|
||||
*/
|
||||
NS_IMETHOD GetElementAt(PRInt32 aIndex, nsIFormControl** aElement) const = 0;
|
||||
|
||||
/**
|
||||
* Get the number of elements in this form
|
||||
* @param aCount the number of elements
|
||||
* @return NS_OK if there was an element at that position, -1 otherwise
|
||||
*/
|
||||
NS_IMETHOD GetElementCount(PRUint32* aCount) const = 0;
|
||||
|
||||
/**
|
||||
* Remove an element from this form's list of elements
|
||||
* @param aElement the element to remove
|
||||
* @param aChildIsRef if PR_TRUE, the elements ref count will be decremented
|
||||
* otherwise not. This is to facilitate circular references.
|
||||
* @return NS_OK if the element was successfully removed.
|
||||
*/
|
||||
NS_IMETHOD RemoveElement(nsIFormControl* aElement,
|
||||
PRBool aChildIsRef = PR_TRUE) = 0;
|
||||
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIForm_h___ */
|
||||
92
mozilla/content/html/content/public/nsIFormControl.h
Normal file
92
mozilla/content/html/content/public/nsIFormControl.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsIFormControl_h___
|
||||
#define nsIFormControl_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsIDOMHTMLFormElement;
|
||||
|
||||
#define NS_FORM_BROWSE 0
|
||||
#define NS_FORM_BUTTON_BUTTON 1
|
||||
#define NS_FORM_BUTTON_RESET 2
|
||||
#define NS_FORM_BUTTON_SUBMIT 3
|
||||
#define NS_FORM_FIELDSET 4
|
||||
#define NS_FORM_INPUT_BUTTON 5
|
||||
#define NS_FORM_INPUT_CHECKBOX 6
|
||||
#define NS_FORM_INPUT_FILE 7
|
||||
#define NS_FORM_INPUT_HIDDEN 8
|
||||
#define NS_FORM_INPUT_RESET 9
|
||||
#define NS_FORM_INPUT_IMAGE 10
|
||||
#define NS_FORM_INPUT_PASSWORD 11
|
||||
#define NS_FORM_INPUT_RADIO 12
|
||||
#define NS_FORM_INPUT_SUBMIT 13
|
||||
#define NS_FORM_INPUT_TEXT 14
|
||||
#define NS_FORM_LABEL 15
|
||||
#define NS_FORM_OPTION 16
|
||||
#define NS_FORM_OPTGROUP 17
|
||||
#define NS_FORM_LEGEND 18
|
||||
#define NS_FORM_SELECT 19
|
||||
#define NS_FORM_TEXTAREA 20
|
||||
|
||||
#define NS_FORM_NOTOK 0xFFFFFFF7
|
||||
#define NS_FORM_NOTSET 0xFFFFFFF7
|
||||
|
||||
#define NS_IFORMCONTROL_IID \
|
||||
{ 0x282ff440, 0xcd7e, 0x11d1, \
|
||||
{0x89, 0xad, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
|
||||
|
||||
|
||||
/**
|
||||
* Interface which all form controls (e.g. buttons, checkboxes, text,
|
||||
* radio buttons, select, etc) implement in addition to their dom specific interface.
|
||||
**/
|
||||
class nsIFormControl : public nsISupports {
|
||||
public:
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IFORMCONTROL_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Get the form for this form control.
|
||||
* @param aForm the form to get
|
||||
* @return NS_OK
|
||||
*/
|
||||
NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm) = 0;
|
||||
|
||||
/**
|
||||
* Set the form for this form control.
|
||||
* @param aForm the form
|
||||
* @return NS_OK
|
||||
*/
|
||||
NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm) = 0;
|
||||
|
||||
/**
|
||||
* Get the type of this control
|
||||
* @param aType the type to be returned
|
||||
* @return NS_OK
|
||||
*/
|
||||
NS_IMETHOD GetType(PRInt32* aType) = 0;
|
||||
|
||||
NS_IMETHOD Init() = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsIFormControl_h___ */
|
||||
102
mozilla/content/html/content/public/nsIHTMLContent.h
Normal file
102
mozilla/content/html/content/public/nsIHTMLContent.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsIHTMLContent_h___
|
||||
#define nsIHTMLContent_h___
|
||||
|
||||
#include "nsIStyledContent.h"
|
||||
#include "nsHTMLValue.h"
|
||||
class nsString;
|
||||
class nsIFrame;
|
||||
class nsIStyleRule;
|
||||
class nsIMutableStyleContext;
|
||||
class nsIPresContext;
|
||||
class nsXIFConverter;
|
||||
class nsIHTMLMappedAttributes;
|
||||
class nsIURI;
|
||||
|
||||
// IID for the nsIHTMLContent class
|
||||
#define NS_IHTMLCONTENT_IID \
|
||||
{ 0xb9e110b0, 0x94d6, 0x11d1, \
|
||||
{0x89, 0x5c, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
|
||||
|
||||
typedef void (*nsMapAttributesFunc)(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext);
|
||||
|
||||
// Abstract interface for all html content
|
||||
class nsIHTMLContent : public nsIStyledContent {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IHTMLCONTENT_IID; return iid; }
|
||||
|
||||
/**
|
||||
* If this html content is a container, then compact asks it to minimize
|
||||
* it's storage usage.
|
||||
*/
|
||||
NS_IMETHOD Compact() = 0;
|
||||
|
||||
NS_IMETHOD SetHTMLAttribute(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
NS_IMETHOD GetHTMLAttribute(nsIAtom* aAttribute,
|
||||
nsHTMLValue& aValue) const = 0;
|
||||
NS_IMETHOD GetAttributeMappingFunctions(nsMapAttributesFunc& aFontMapFunc,
|
||||
nsMapAttributesFunc& aMapFunc) const = 0;
|
||||
|
||||
NS_IMETHOD AttributeToString(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
nsHTMLValue& aResult) = 0;
|
||||
|
||||
/**
|
||||
* Get the base URL for any relative URLs within this piece
|
||||
* of content. Generally, this is the document's base URL,
|
||||
* but certain content carries a local base for backward
|
||||
* compatibility.
|
||||
*/
|
||||
NS_IMETHOD GetBaseURL(nsIURI*& aBaseURL) const = 0;
|
||||
|
||||
/**
|
||||
* Get the base target for any links within this piece
|
||||
* of content. Generally, this is the document's base target,
|
||||
* but certain content carries a local base for backward
|
||||
* compatibility.
|
||||
*/
|
||||
NS_IMETHOD GetBaseTarget(nsString& aBaseTarget) const = 0;
|
||||
|
||||
/**
|
||||
* Translate this piece of content to html. Note that this only
|
||||
* translates this content object, not any children it might
|
||||
* have. The caller is responsible for recursing down the
|
||||
* hierarchy.
|
||||
*/
|
||||
// XXX add in output character set information so that we know how
|
||||
// to encode non 7 bit characters
|
||||
NS_IMETHOD ToHTMLString(nsString& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD ToHTML(FILE* out) const = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIHTMLContent_h___ */
|
||||
71
mozilla/content/html/content/public/nsISelectElement.h
Normal file
71
mozilla/content/html/content/public/nsISelectElement.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsISelectElement_h___
|
||||
#define nsISelectElement_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
// IID for the nsISelect interface
|
||||
#define NS_ISELECTELEMENT_IID \
|
||||
{ 0xa6cf90f6, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
|
||||
/**
|
||||
* This interface is used to notify a SELECT when OPTION
|
||||
* elements are added and removed from its subtree.
|
||||
* Note that the nsIDOMHTMLSelectElement and nsIContent
|
||||
* interfaces are the ones to use to access and enumerate
|
||||
* OPTIONs within a SELECT element.
|
||||
*/
|
||||
class nsISelectElement : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISELECTELEMENT_IID)
|
||||
|
||||
/**
|
||||
* An OPTION element has been added to the SELECT's
|
||||
* subtree.
|
||||
*/
|
||||
NS_IMETHOD AddOption(nsIContent* aContent) = 0;
|
||||
|
||||
/**
|
||||
* An OPTION element has been deleted from the SELECT's
|
||||
* subtree.
|
||||
*/
|
||||
NS_IMETHOD RemoveOption(nsIContent* aContent) = 0;
|
||||
|
||||
/**
|
||||
* Indicates that we're done adding child content
|
||||
* to the select during document loading.
|
||||
*/
|
||||
NS_IMETHOD DoneAddingContent(PRBool aIsDone) = 0;
|
||||
|
||||
/**
|
||||
* Returns whether we're done adding child content
|
||||
* to the select during document loading.
|
||||
*/
|
||||
NS_IMETHOD IsDoneAddingContent(PRBool * aIsDone) = 0;
|
||||
};
|
||||
|
||||
#endif // nsISelectElement_h___
|
||||
|
||||
141
mozilla/content/html/content/src/GenericElementCollection.cpp
Normal file
141
mozilla/content/html/content/src/GenericElementCollection.cpp
Normal file
@@ -0,0 +1,141 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "GenericElementCollection.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
|
||||
GenericElementCollection::GenericElementCollection(nsIContent *aParent,
|
||||
nsIAtom *aTag)
|
||||
: nsGenericDOMHTMLCollection()
|
||||
{
|
||||
mParent = aParent;
|
||||
mTag = aTag;
|
||||
NS_IF_ADDREF(aTag);
|
||||
}
|
||||
|
||||
GenericElementCollection::~GenericElementCollection()
|
||||
{
|
||||
// we do NOT have a ref-counted reference to mParent, so do NOT
|
||||
// release it! this is to avoid circular references. The
|
||||
// instantiator who provided mParent is responsible for managing our
|
||||
// reference for us.
|
||||
|
||||
// Release reference on the tag
|
||||
NS_IF_RELEASE(mTag);
|
||||
}
|
||||
|
||||
// we re-count every call. A better implementation would be to set ourselves up as
|
||||
// an observer of contentAppended, contentInserted, and contentDeleted
|
||||
NS_IMETHODIMP
|
||||
GenericElementCollection::GetLength(PRUint32* aLength)
|
||||
{
|
||||
if (nsnull==aLength)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aLength=0;
|
||||
nsresult result = NS_OK;
|
||||
if (nsnull!=mParent)
|
||||
{
|
||||
nsIContent *child=nsnull;
|
||||
PRUint32 childIndex=0;
|
||||
mParent->ChildAt(childIndex, child);
|
||||
while (nsnull!=child)
|
||||
{
|
||||
nsIAtom *childTag;
|
||||
child->GetTag(childTag);
|
||||
if (mTag==childTag)
|
||||
{
|
||||
(*aLength)++;
|
||||
}
|
||||
NS_RELEASE(childTag);
|
||||
NS_RELEASE(child);
|
||||
childIndex++;
|
||||
mParent->ChildAt(childIndex, child);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GenericElementCollection::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn=nsnull;
|
||||
PRUint32 theIndex = 0;
|
||||
nsresult rv = NS_OK;
|
||||
if (nsnull!=mParent)
|
||||
{
|
||||
nsIContent *child=nsnull;
|
||||
PRUint32 childIndex=0;
|
||||
mParent->ChildAt(childIndex, child);
|
||||
while (nsnull!=child)
|
||||
{
|
||||
nsIAtom *childTag;
|
||||
child->GetTag(childTag);
|
||||
if (mTag==childTag)
|
||||
{
|
||||
if (aIndex==theIndex)
|
||||
{
|
||||
child->QueryInterface(kIDOMNodeIID, (void**)aReturn); // out-param addref
|
||||
NS_ASSERTION(nsnull!=aReturn, "content element must be an nsIDOMNode");
|
||||
NS_RELEASE(childTag);
|
||||
NS_RELEASE(child);
|
||||
break;
|
||||
}
|
||||
theIndex++;
|
||||
}
|
||||
NS_RELEASE(childTag);
|
||||
NS_RELEASE(child);
|
||||
childIndex++;
|
||||
mParent->ChildAt(childIndex, child);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GenericElementCollection::NamedItem(const nsString& aName, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (nsnull!=mParent)
|
||||
{
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GenericElementCollection::ParentDestroyed()
|
||||
{
|
||||
// see comment in destructor, do NOT release mParent!
|
||||
mParent = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
nsresult
|
||||
GenericElementCollection::SizeOf(nsISizeOfHandler* aSizer,
|
||||
PRUint32* aResult) const
|
||||
{
|
||||
if (!aResult) return NS_ERROR_NULL_POINTER;
|
||||
*aResult = sizeof(*this);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
58
mozilla/content/html/content/src/GenericElementCollection.h
Normal file
58
mozilla/content/html/content/src/GenericElementCollection.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef GenericElementCollection_h__
|
||||
#define GenericElementCollection_h__
|
||||
|
||||
#include "nsGenericDOMHTMLCollection.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIAtom;
|
||||
|
||||
/**
|
||||
* This class provides a late-bound collection of elements that are
|
||||
* direct decendents of an element.
|
||||
* mParent is NOT ref-counted to avoid circular references
|
||||
*/
|
||||
class GenericElementCollection : public nsGenericDOMHTMLCollection
|
||||
{
|
||||
public:
|
||||
GenericElementCollection(nsIContent *aParent,
|
||||
nsIAtom *aTag);
|
||||
virtual ~GenericElementCollection();
|
||||
|
||||
NS_IMETHOD GetLength(PRUint32* aLength);
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD NamedItem(const nsString& aName, nsIDOMNode** aReturn);
|
||||
|
||||
NS_IMETHOD ParentDestroyed();
|
||||
|
||||
#ifdef DEBUG
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
nsIContent * mParent;
|
||||
nsIAtom * mTag;
|
||||
};
|
||||
|
||||
#endif
|
||||
115
mozilla/content/html/content/src/Makefile.in
Normal file
115
mozilla/content/html/content/src/Makefile.in
Normal file
@@ -0,0 +1,115 @@
|
||||
#
|
||||
# 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/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = layout
|
||||
LIBRARY_NAME = nglhtmlcon_s
|
||||
|
||||
REQUIRES = xpcom raptor dom js netlib
|
||||
|
||||
CPPSRCS = \
|
||||
nsAttributeContent.cpp \
|
||||
nsGenericHTMLElement.cpp \
|
||||
nsGenericDOMHTMLCollection.cpp \
|
||||
GenericElementCollection.cpp \
|
||||
nsHTMLAnchorElement.cpp \
|
||||
nsHTMLAppletElement.cpp \
|
||||
nsHTMLAreaElement.cpp \
|
||||
nsHTMLBRElement.cpp \
|
||||
nsHTMLBaseElement.cpp \
|
||||
nsHTMLBaseFontElement.cpp \
|
||||
nsHTMLBodyElement.cpp \
|
||||
nsHTMLButtonElement.cpp \
|
||||
nsHTMLDListElement.cpp \
|
||||
nsHTMLDelElement.cpp \
|
||||
nsHTMLDirectoryElement.cpp \
|
||||
nsHTMLDivElement.cpp \
|
||||
nsHTMLEmbedElement.cpp \
|
||||
nsHTMLFieldSetElement.cpp \
|
||||
nsHTMLFontElement.cpp \
|
||||
nsHTMLFormElement.cpp \
|
||||
nsHTMLFrameElement.cpp \
|
||||
nsHTMLFrameSetElement.cpp \
|
||||
nsHTMLHRElement.cpp \
|
||||
nsHTMLHeadElement.cpp \
|
||||
nsHTMLHeadingElement.cpp \
|
||||
nsHTMLHtmlElement.cpp \
|
||||
nsHTMLIFrameElement.cpp \
|
||||
nsHTMLImageElement.cpp \
|
||||
nsHTMLInputElement.cpp \
|
||||
nsHTMLInsElement.cpp \
|
||||
nsHTMLIsIndexElement.cpp \
|
||||
nsHTMLLIElement.cpp \
|
||||
nsHTMLLabelElement.cpp \
|
||||
nsHTMLLayerElement.cpp \
|
||||
nsHTMLLegendElement.cpp \
|
||||
nsHTMLLinkElement.cpp \
|
||||
nsHTMLMapElement.cpp \
|
||||
nsHTMLMenuElement.cpp \
|
||||
nsHTMLMetaElement.cpp \
|
||||
nsHTMLModElement.cpp \
|
||||
nsHTMLOListElement.cpp \
|
||||
nsHTMLObjectElement.cpp \
|
||||
nsHTMLOptionElement.cpp \
|
||||
nsHTMLOptGroupElement.cpp \
|
||||
nsHTMLParagraphElement.cpp \
|
||||
nsHTMLParamElement.cpp \
|
||||
nsHTMLPreElement.cpp \
|
||||
nsHTMLQuoteElement.cpp \
|
||||
nsHTMLScriptElement.cpp \
|
||||
nsHTMLSelectElement.cpp \
|
||||
nsHTMLSpacerElement.cpp \
|
||||
nsHTMLSpanElement.cpp \
|
||||
nsHTMLStyleElement.cpp \
|
||||
nsHTMLTableElement.cpp \
|
||||
nsHTMLTableCaptionElement.cpp \
|
||||
nsHTMLTableCellElement.cpp \
|
||||
nsHTMLTableColElement.cpp \
|
||||
nsHTMLTableColGroupElement.cpp \
|
||||
nsHTMLTableRowElement.cpp \
|
||||
nsHTMLTableSectionElement.cpp \
|
||||
nsHTMLTextAreaElement.cpp \
|
||||
nsHTMLTitleElement.cpp \
|
||||
nsHTMLUListElement.cpp \
|
||||
nsHTMLWBRElement.cpp \
|
||||
nsEditorController.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_HTML
|
||||
|
||||
INCLUDES += \
|
||||
-I$(srcdir)/../../style/src \
|
||||
-I$(srcdir)/../../../base/src \
|
||||
-I$(srcdir)/../../base/src \
|
||||
$(NULL)
|
||||
|
||||
185
mozilla/content/html/content/src/makefile.win
Normal file
185
mozilla/content/html/content/src/makefile.win
Normal file
@@ -0,0 +1,185 @@
|
||||
#!nmake
|
||||
#
|
||||
# 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/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
LIBRARY_NAME = nglhtmlcon_s
|
||||
MODULE=raptor
|
||||
REQUIRES=xpcom raptor js
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
!if defined(XP_NEW_SELECTION)
|
||||
DEFINES = $(DEFINES) -DXP_NEW_SELECTION
|
||||
!endif
|
||||
|
||||
CPPSRCS= \
|
||||
nsAttributeContent.cpp \
|
||||
nsGenericHTMLElement.cpp \
|
||||
nsGenericDOMHTMLCollection.cpp \
|
||||
GenericElementCollection.cpp \
|
||||
nsHTMLAnchorElement.cpp \
|
||||
nsHTMLAppletElement.cpp \
|
||||
nsHTMLAreaElement.cpp \
|
||||
nsHTMLBRElement.cpp \
|
||||
nsHTMLBaseElement.cpp \
|
||||
nsHTMLBaseFontElement.cpp \
|
||||
nsHTMLBodyElement.cpp \
|
||||
nsHTMLButtonElement.cpp \
|
||||
nsHTMLDListElement.cpp \
|
||||
nsHTMLDelElement.cpp \
|
||||
nsHTMLDirectoryElement.cpp \
|
||||
nsHTMLDivElement.cpp \
|
||||
nsHTMLEmbedElement.cpp \
|
||||
nsHTMLFieldSetElement.cpp \
|
||||
nsHTMLFontElement.cpp \
|
||||
nsHTMLFormElement.cpp \
|
||||
nsHTMLFrameElement.cpp \
|
||||
nsHTMLFrameSetElement.cpp \
|
||||
nsHTMLHRElement.cpp \
|
||||
nsHTMLHeadElement.cpp \
|
||||
nsHTMLHeadingElement.cpp \
|
||||
nsHTMLHtmlElement.cpp \
|
||||
nsHTMLIFrameElement.cpp \
|
||||
nsHTMLImageElement.cpp \
|
||||
nsHTMLInputElement.cpp \
|
||||
nsHTMLInsElement.cpp \
|
||||
nsHTMLIsIndexElement.cpp \
|
||||
nsHTMLLIElement.cpp \
|
||||
nsHTMLLabelrElement.cpp \
|
||||
nsHTMLLayerElement.cpp \
|
||||
nsHTMLLegendElement.cpp \
|
||||
nsHTMLLinkElement.cpp \
|
||||
nsHTMLMapElement.cpp \
|
||||
nsHTMLMenuElement.cpp \
|
||||
nsHTMLMetaElement.cpp \
|
||||
nsHTMLModElement.cpp \
|
||||
nsHTMLOListElement.cpp \
|
||||
nsHTMLObjectElement.cpp \
|
||||
nsHTMLOptionElement.cpp \
|
||||
nsHTMLOptGroupElement.cpp \
|
||||
nsHTMLParagraphElement.cpp \
|
||||
nsHTMLParamElement.cpp \
|
||||
nsHTMLPreElement.cpp \
|
||||
nsHTMLQuoteElement.cpp \
|
||||
nsHTMLScriptElement.cpp \
|
||||
nsHTMLSelectElement.cpp \
|
||||
nsHTMLSpacerElement.cpp \
|
||||
nsHTMLSpanElement.cpp \
|
||||
nsHTMLStyleElement.cpp \
|
||||
nsHTMLTableElement.cpp \
|
||||
nsHTMLTableCaptionElement.cpp \
|
||||
nsHTMLTableCellElement.cpp \
|
||||
nsHTMLTableColElement.cpp \
|
||||
nsHTMLTableColGroupElement.cpp \
|
||||
nsHTMLTableRowElement.cpp \
|
||||
nsHTMLTableSectionElement.cpp \
|
||||
nsHTMLTextAreaElement.cpp \
|
||||
nsHTMLTitleElement.cpp \
|
||||
nsHTMLUListElement.cpp \
|
||||
nsHTMLWBRElement.cpp \
|
||||
nsEditorController.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsAttributeContent.obj \
|
||||
.\$(OBJDIR)\nsGenericHTMLElement.obj \
|
||||
.\$(OBJDIR)\nsGenericDOMHTMLCollection.obj \
|
||||
.\$(OBJDIR)\GenericElementCollection.obj \
|
||||
.\$(OBJDIR)\nsHTMLAnchorElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLAppletElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLAreaElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLBRElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLBaseElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLBaseFontElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLBodyElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLButtonElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLDListElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLDelElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLDirectoryElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLDivElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLEmbedElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLFieldSetElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLFontElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLFormElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLFrameElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLFrameSetElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLHRElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLHeadElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLHeadingElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLHtmlElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLIFrameElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLImageElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLInputElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLInsElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLIsIndexElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLLIElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLLabelElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLLayerElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLLegendElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLLinkElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLMapElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLMenuElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLMetaElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLModElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLOListElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLObjectElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLOptionElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLOptGroupElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLParagraphElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLParamElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLPreElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLQuoteElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLScriptElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLSelectElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLSpacerElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLSpanElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLStyleElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLTableElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLTableCaptionElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLTableCellElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLTableColElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLTableColGroupElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLTableRowElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLTableSectionElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLTextAreaElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLTitleElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLUListElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLWBRElement.obj \
|
||||
.\$(OBJDIR)\nsEditorController.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
|
||||
-I$(PUBLIC)\dom -I$(PUBLIC)\netlib \
|
||||
-I..\..\style\src \
|
||||
-I..\..\..\base\src -I..\..\base\src \
|
||||
-I$(PUBLIC)\plugin -I$(PUBLIC)\oji -I$(PUBLIC)\java
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
||||
547
mozilla/content/html/content/src/nsAttributeContent.cpp
Normal file
547
mozilla/content/html/content/src/nsAttributeContent.cpp
Normal file
@@ -0,0 +1,547 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsIAttributeContent.h"
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIEventListenerManager.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsXIFConverter.h"
|
||||
#include "nsRange.h"
|
||||
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIEnumerator.h"
|
||||
|
||||
|
||||
#include "nsCRT.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsISizeOfHandler.h"
|
||||
#include "nsDOMEvent.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "prprf.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsTextFragment.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsITextContent.h"
|
||||
|
||||
class nsIDOMAttr;
|
||||
class nsIDOMEventListener;
|
||||
class nsIDOMNodeList;
|
||||
class nsIEventListenerManager;
|
||||
class nsIFrame;
|
||||
class nsIStyleContext;
|
||||
class nsIStyleRule;
|
||||
class nsISupportsArray;
|
||||
class nsIDOMText;
|
||||
|
||||
|
||||
// XXX share all id's in this dir
|
||||
|
||||
NS_DEFINE_IID(kIDOMCharacterDataIID, NS_IDOMCHARACTERDATA_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID);
|
||||
static NS_DEFINE_IID(kIEnumeratorIID, NS_IENUMERATOR_IID);
|
||||
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
|
||||
static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID);
|
||||
|
||||
|
||||
class nsAttributeContent : public nsIContent, public nsITextContent, public nsIAttributeContent {
|
||||
public:
|
||||
friend nsresult NS_NewAttributeContent(nsAttributeContent** aNewFrame);
|
||||
|
||||
nsAttributeContent();
|
||||
virtual ~nsAttributeContent();
|
||||
|
||||
NS_IMETHOD Init(nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttrName);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// Implementation for nsIContent
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const;
|
||||
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep);
|
||||
NS_IMETHOD GetParent(nsIContent*& aResult) const;
|
||||
NS_IMETHOD SetParent(nsIContent* aParent);
|
||||
|
||||
NS_IMETHOD IsSynthetic(PRBool& aResult) {
|
||||
aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32& aID) const {
|
||||
aID = kNameSpaceID_None;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const {
|
||||
aResult = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHOD ParseAttributeString(const nsString& aStr,
|
||||
nsIAtom*& aName,
|
||||
PRInt32& aNameSpaceID) {
|
||||
aName = nsnull;
|
||||
aNameSpaceID = kNameSpaceID_None;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) {
|
||||
aPrefix = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, const nsString& aValue,
|
||||
PRBool aNotify) { return NS_OK; }
|
||||
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify) { return NS_OK; }
|
||||
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom *aAttribute, nsString &aResult) const {return NS_CONTENT_ATTR_NOT_THERE; }
|
||||
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex, PRInt32& aNameSpaceID, nsIAtom*& aName) const {
|
||||
aName = nsnull;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { aResult = 0; return NS_OK; }
|
||||
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const { return NS_OK; }
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus);
|
||||
|
||||
NS_IMETHOD GetContentID(PRUint32* aID) {
|
||||
*aID = 0;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD SetContentID(PRUint32 aID) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD RangeAdd(nsIDOMRange& aRange);
|
||||
NS_IMETHOD RangeRemove(nsIDOMRange& aRange);
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const;
|
||||
|
||||
// Implementation for nsIContent
|
||||
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const;
|
||||
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const { aResult = PR_FALSE; return NS_OK; }
|
||||
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const { aResult = 0; return NS_OK; }
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { aResult = nsnull; return NS_OK; }
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { aResult = -1; return NS_OK; }
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) { return NS_OK; }
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) { return NS_OK; }
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { return NS_OK; }
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { return NS_OK; }
|
||||
NS_IMETHOD SplitText(PRUint32 aOffset, nsIDOMText** aReturn){ return NS_OK; }
|
||||
|
||||
///////////////////
|
||||
// Implementation for nsITextContent
|
||||
NS_IMETHOD GetText(const nsTextFragment** aFragmentsResult);
|
||||
NS_IMETHOD GetTextLength(PRInt32* aLengthResult);
|
||||
NS_IMETHOD CopyText(nsString& aResult);
|
||||
NS_IMETHOD SetText(const PRUnichar* aBuffer,
|
||||
PRInt32 aLength,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD SetText(const char* aBuffer,
|
||||
PRInt32 aLength,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD IsOnlyWhitespace(PRBool* aResult);
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
void ValidateTextFragment();
|
||||
|
||||
void ToCString(nsString& aBuf, PRInt32 aOffset, PRInt32 aLen) const;
|
||||
|
||||
// Up pointer to the real content object that we are
|
||||
// supporting. Sometimes there is work that we just can't do
|
||||
// ourselves, so this is needed to ask the real object to do the
|
||||
// work.
|
||||
nsIContent* mContent;
|
||||
nsIDocument* mDocument;
|
||||
nsIContent* mParent;
|
||||
|
||||
nsTextFragment mText;
|
||||
PRInt32 mNameSpaceID;
|
||||
nsIAtom* mAttrName;
|
||||
|
||||
};
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsAttributeContent)
|
||||
|
||||
NS_IMPL_RELEASE(nsAttributeContent)
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewAttributeContent(nsIContent** aContent)
|
||||
{
|
||||
NS_PRECONDITION(aContent, "null OUT ptr");
|
||||
if (nsnull == aContent) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsAttributeContent* it = new nsAttributeContent;
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return NS_SUCCEEDED(it->QueryInterface(nsCOMTypeInfo<nsIContent>::GetIID(), (void **)aContent)) ?
|
||||
NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsAttributeContent::nsAttributeContent()
|
||||
: mText()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mDocument = nsnull;
|
||||
mParent = nsnull;
|
||||
mContent = nsnull;
|
||||
mAttrName = nsnull;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
nsAttributeContent::~nsAttributeContent()
|
||||
{
|
||||
NS_IF_RELEASE(mAttrName);
|
||||
//NS_IF_RELEASE(mDocument);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsAttributeContent::Init(nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttrName)
|
||||
{
|
||||
NS_ASSERTION((nsnull == mContent) && (nsnull != aContent), "null ptr");
|
||||
mContent = aContent;
|
||||
|
||||
NS_IF_RELEASE(mAttrName);
|
||||
mNameSpaceID = aNameSpaceID;
|
||||
mAttrName = aAttrName;
|
||||
NS_ADDREF(mAttrName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param aIID The name of the class implementing the method
|
||||
* @param _classiiddef The name of the #define symbol that defines the IID
|
||||
* for the class (e.g. NS_ISUPPORTS_IID)
|
||||
*
|
||||
*/
|
||||
nsresult nsAttributeContent::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsIContent>::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsIContent*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsITextContent>::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsITextContent*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsIAttributeContent>::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsIAttributeContent*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsISupports*)(nsIContent*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Implementation of nsIContent
|
||||
|
||||
|
||||
nsresult
|
||||
nsAttributeContent::BeginConvertToXIF(nsXIFConverter& aConverter) const
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttributeContent::FinishConvertToXIF(nsXIFConverter& aConverter) const
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
nsresult
|
||||
nsAttributeContent::ConvertContentToXIF(nsXIFConverter& aConverter) const
|
||||
{
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsAttributeContent::ToCString(nsString& aBuf, PRInt32 aOffset,
|
||||
PRInt32 aLen) const
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttributeContent::GetDocument(nsIDocument*& aResult) const
|
||||
{
|
||||
aResult = mDocument;
|
||||
NS_IF_ADDREF(mDocument);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsAttributeContent::SetDocument(nsIDocument* aDocument, PRBool aDeep)
|
||||
{
|
||||
mDocument = aDocument;
|
||||
//NS_IF_ADDREF(mDocument);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttributeContent::GetParent(nsIContent*& aResult) const
|
||||
{
|
||||
NS_IF_ADDREF(mParent);
|
||||
aResult = mParent;
|
||||
return NS_OK;;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttributeContent::SetParent(nsIContent* aParent)
|
||||
{
|
||||
mParent = aParent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttributeContent::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsAttributeContent::RangeAdd(nsIDOMRange& aRange)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsAttributeContent::RangeRemove(nsIDOMRange& aRange)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsAttributeContent::GetRangeList(nsVoidArray*& aResult) const
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Implementation of the nsITextContent interface
|
||||
|
||||
void
|
||||
nsAttributeContent::ValidateTextFragment()
|
||||
{
|
||||
if (nsnull != mContent) {
|
||||
nsAutoString result;
|
||||
mContent->GetAttribute(mNameSpaceID, mAttrName, result);
|
||||
|
||||
PRUnichar * text = result.ToNewUnicode();
|
||||
mText.SetTo(text, result.Length());
|
||||
nsCRT::free(text);
|
||||
}
|
||||
else {
|
||||
mText.SetTo("", 0);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttributeContent::GetText(const nsTextFragment** aFragmentsResult)
|
||||
{
|
||||
ValidateTextFragment();
|
||||
if (nsnull != mContent) {
|
||||
*aFragmentsResult = &mText;
|
||||
return NS_OK;
|
||||
}
|
||||
// XXX is this a good idea, or should we just return an empty
|
||||
// fragment with no data in it?
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttributeContent::GetTextLength(PRInt32* aLengthResult)
|
||||
{
|
||||
if (!aLengthResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
ValidateTextFragment();
|
||||
*aLengthResult = mText.GetLength();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttributeContent::CopyText(nsString& aResult)
|
||||
{
|
||||
ValidateTextFragment();
|
||||
if (mText.Is2b()) {
|
||||
aResult.SetString(mText.Get2b(), mText.GetLength());
|
||||
}
|
||||
else {
|
||||
aResult.SetString(mText.Get1b(), mText.GetLength());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXX shouldn't these update mContent's attribute?
|
||||
nsresult
|
||||
nsAttributeContent::SetText(const PRUnichar* aBuffer, PRInt32 aLength,
|
||||
PRBool aNotify)
|
||||
{
|
||||
NS_PRECONDITION((aLength >= 0) && (nsnull != aBuffer), "bad args");
|
||||
if (aLength < 0) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
if (nsnull == aBuffer) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
mText.SetTo(aBuffer, aLength);
|
||||
|
||||
// Trigger a reflow
|
||||
if (aNotify && (nsnull != mDocument)) {
|
||||
mDocument->ContentChanged(mContent, nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXX shouldn't these update mContent's attribute?
|
||||
nsresult
|
||||
nsAttributeContent::SetText(const char* aBuffer,
|
||||
PRInt32 aLength,
|
||||
PRBool aNotify)
|
||||
{
|
||||
NS_PRECONDITION((aLength >= 0) && (nsnull != aBuffer), "bad args");
|
||||
if (aLength < 0) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
if (nsnull == aBuffer) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
mText.SetTo(aBuffer, aLength);
|
||||
|
||||
// Trigger a reflow
|
||||
if (aNotify && (nsnull != mDocument)) {
|
||||
mDocument->ContentChanged(mContent, nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsAttributeContent::IsOnlyWhitespace(PRBool* aResult)
|
||||
{
|
||||
ValidateTextFragment();
|
||||
|
||||
nsTextFragment& frag = mText;
|
||||
if (frag.Is2b()) {
|
||||
const PRUnichar* cp = frag.Get2b();
|
||||
const PRUnichar* end = cp + frag.GetLength();
|
||||
while (cp < end) {
|
||||
PRUnichar ch = *cp++;
|
||||
if (!XP_IS_SPACE(ch)) {
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const char* cp = frag.Get1b();
|
||||
const char* end = cp + frag.GetLength();
|
||||
while (cp < end) {
|
||||
PRUnichar ch = PRUnichar(*(unsigned char*)cp);
|
||||
cp++;
|
||||
if (!XP_IS_SPACE(ch)) {
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*aResult = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAttributeContent::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
||||
{
|
||||
if (!aResult) return NS_ERROR_NULL_POINTER;
|
||||
*aResult = sizeof(*this);
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nslayout.h"
|
||||
#include "nsGenericDOMHTMLCollection.h"
|
||||
|
||||
|
||||
nsGenericDOMHTMLCollection::nsGenericDOMHTMLCollection()
|
||||
{
|
||||
mRefCnt = 0;
|
||||
mScriptObject = nsnull;
|
||||
}
|
||||
|
||||
nsGenericDOMHTMLCollection::~nsGenericDOMHTMLCollection()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMHTMLCollection::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLCollectionIID, NS_IDOMHTMLCOLLECTION_IID);
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
if (aIID.Equals(kIDOMHTMLCollectionIID)) {
|
||||
*aInstancePtr = (void*)(nsIDOMHTMLCollection*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
*aInstancePtr = (void*)(nsIScriptObjectOwner*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*)(nsISupports*)(nsIDOMHTMLCollection*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsGenericDOMHTMLCollection)
|
||||
NS_IMPL_RELEASE(nsGenericDOMHTMLCollection)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericDOMHTMLCollection::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull == mScriptObject) {
|
||||
res = NS_NewScriptHTMLCollection(aContext, (nsISupports *)(nsIDOMHTMLCollection *)this, nsnull, (void**)&mScriptObject);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericDOMHTMLCollection::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsGenericDOMHTMLCollection_h__
|
||||
#define nsGenericDOMHTMLCollection_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
|
||||
/**
|
||||
* This is a base class for a generic HTML collection. The base class
|
||||
* provides implementations for nsISupports and nsIScriptObjectOwner,
|
||||
* but it is up to the subclass to implement the core HTML collection
|
||||
* methods:
|
||||
* GetLength
|
||||
* Item
|
||||
* NamedItem
|
||||
*
|
||||
*/
|
||||
class nsGenericDOMHTMLCollection : public nsIDOMHTMLCollection,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
public:
|
||||
nsGenericDOMHTMLCollection();
|
||||
virtual ~nsGenericDOMHTMLCollection();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
// The following need to be defined in the subclass
|
||||
// nsIDOMHTMLCollection interface
|
||||
NS_IMETHOD GetLength(PRUint32* aLength)=0;
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn)=0;
|
||||
NS_IMETHOD NamedItem(const nsString& aName, nsIDOMNode** aReturn)=0;
|
||||
|
||||
protected:
|
||||
void* mScriptObject;
|
||||
};
|
||||
|
||||
#endif // nsGenericDOMHTMLCollection_h__
|
||||
2985
mozilla/content/html/content/src/nsGenericHTMLElement.cpp
Normal file
2985
mozilla/content/html/content/src/nsGenericHTMLElement.cpp
Normal file
File diff suppressed because it is too large
Load Diff
651
mozilla/content/html/content/src/nsGenericHTMLElement.h
Normal file
651
mozilla/content/html/content/src/nsGenericHTMLElement.h
Normal file
@@ -0,0 +1,651 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsGenericHTMLElement_h___
|
||||
#define nsGenericHTMLElement_h___
|
||||
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsIDOMHTMLElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsHTMLValue.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsINameSpaceManager.h" // for kNameSpaceID_HTML
|
||||
|
||||
extern const nsIID kIDOMHTMLElementIID;
|
||||
extern const nsIID kIHTMLContentIID;
|
||||
|
||||
class nsIDOMAttr;
|
||||
class nsIDOMEventListener;
|
||||
class nsIDOMNodeList;
|
||||
class nsIEventListenerManager;
|
||||
class nsIFrame;
|
||||
class nsIHTMLAttributes;
|
||||
class nsIHTMLMappedAttributes;
|
||||
class nsIHTMLContent;
|
||||
class nsIMutableStyleContext;
|
||||
class nsIStyleRule;
|
||||
class nsISupportsArray;
|
||||
class nsIDOMScriptObjectFactory;
|
||||
class nsChildContentList;
|
||||
class nsDOMCSSDeclaration;
|
||||
class nsIDOMCSSStyleDeclaration;
|
||||
class nsIURI;
|
||||
class nsIFormControlFrame;
|
||||
class nsIFormControl;
|
||||
class nsIForm;
|
||||
|
||||
class nsGenericHTMLElement : public nsGenericElement {
|
||||
public:
|
||||
nsGenericHTMLElement();
|
||||
~nsGenericHTMLElement();
|
||||
|
||||
nsresult CopyInnerTo(nsIContent* aSrcContent,
|
||||
nsGenericHTMLElement* aDest,
|
||||
PRBool aDeep);
|
||||
|
||||
// Implementation for nsIDOMNode
|
||||
nsresult GetNodeName(nsString& aNodeName);
|
||||
|
||||
// Implementation for nsIDOMElement
|
||||
nsresult GetAttribute(const nsString& aName, nsString& aReturn)
|
||||
{
|
||||
return nsGenericElement::GetAttribute(aName, aReturn);
|
||||
}
|
||||
nsresult SetAttribute(const nsString& aName, const nsString& aValue)
|
||||
{
|
||||
return nsGenericElement::SetAttribute(aName, aValue);
|
||||
}
|
||||
nsresult GetTagName(nsString& aTagName);
|
||||
|
||||
// Implementation for nsIDOMHTMLElement
|
||||
nsresult GetId(nsString& aId);
|
||||
nsresult SetId(const nsString& aId);
|
||||
nsresult GetTitle(nsString& aTitle);
|
||||
nsresult SetTitle(const nsString& aTitle);
|
||||
nsresult GetLang(nsString& aLang);
|
||||
nsresult SetLang(const nsString& aLang);
|
||||
nsresult GetDir(nsString& aDir);
|
||||
nsresult SetDir(const nsString& aDir);
|
||||
nsresult GetClassName(nsString& aClassName);
|
||||
nsresult SetClassName(const nsString& aClassName);
|
||||
nsresult GetStyle(nsIDOMCSSStyleDeclaration** aStyle);
|
||||
|
||||
// Implementation for nsIContent
|
||||
nsresult GetNameSpaceID(PRInt32& aNameSpaceID) const;
|
||||
nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep);
|
||||
nsresult ParseAttributeString(const nsString& aStr,
|
||||
nsIAtom*& aName,
|
||||
PRInt32& aNameSpaceID);
|
||||
nsresult GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix);
|
||||
nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue,
|
||||
PRBool aNotify);
|
||||
nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const;
|
||||
nsresult UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify);
|
||||
nsresult GetAttributeNameAt(PRInt32 aIndex,
|
||||
PRInt32& aNameSpaceID,
|
||||
nsIAtom*& aName) const;
|
||||
nsresult GetAttributeCount(PRInt32& aResult) const;
|
||||
nsresult List(FILE* out, PRInt32 aIndent) const;
|
||||
nsresult SetParentForFormControls(nsIContent* aParent,
|
||||
nsIFormControl* aControl,
|
||||
nsIForm* aForm);
|
||||
nsresult SetDocumentForFormControls(nsIDocument* aDocument,
|
||||
PRBool aDeep,
|
||||
nsIFormControl* aControl,
|
||||
nsIForm* aForm);
|
||||
|
||||
// Implementation for nsIHTMLContent
|
||||
nsresult Compact();
|
||||
nsresult SetHTMLAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue,
|
||||
PRBool aNotify);
|
||||
nsresult GetHTMLAttribute(nsIAtom* aAttribute, nsHTMLValue& aValue) const;
|
||||
nsresult GetID(nsIAtom*& aResult) const;
|
||||
nsresult GetClasses(nsVoidArray& aArray) const;
|
||||
nsresult HasClass(nsIAtom* aClass) const;
|
||||
nsresult GetContentStyleRules(nsISupportsArray* aRules);
|
||||
nsresult GetInlineStyleRules(nsISupportsArray* aRules);
|
||||
nsresult GetBaseURL(nsIURI*& aBaseURL) const;
|
||||
nsresult GetBaseTarget(nsString& aBaseTarget) const;
|
||||
nsresult ToHTMLString(nsString& aResult) const;
|
||||
nsresult ToHTML(FILE* out) const;
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const;
|
||||
|
||||
//----------------------------------------
|
||||
nsresult AttributeToString(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult) const;
|
||||
|
||||
void ListAttributes(FILE* out) const;
|
||||
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
// Attribute parsing utilities
|
||||
|
||||
struct EnumTable {
|
||||
const char* tag;
|
||||
PRInt32 value;
|
||||
};
|
||||
|
||||
static PRBool ParseEnumValue(const nsString& aValue,
|
||||
EnumTable* aTable,
|
||||
nsHTMLValue& aResult);
|
||||
|
||||
static PRBool ParseCaseSensitiveEnumValue(const nsString& aValue,
|
||||
EnumTable* aTable,
|
||||
nsHTMLValue& aResult);
|
||||
|
||||
static PRBool EnumValueToString(const nsHTMLValue& aValue,
|
||||
EnumTable* aTable,
|
||||
nsString& aResult);
|
||||
|
||||
static PRBool ParseValueOrPercent(const nsString& aString,
|
||||
nsHTMLValue& aResult,
|
||||
nsHTMLUnit aValueUnit);
|
||||
|
||||
static PRBool ParseValueOrPercentOrProportional(const nsString& aString,
|
||||
nsHTMLValue& aResult,
|
||||
nsHTMLUnit aValueUnit);
|
||||
|
||||
static PRBool ValueOrPercentToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
static PRBool ValueOrPercentOrProportionalToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
static PRBool ParseValue(const nsString& aString, PRInt32 aMin,
|
||||
nsHTMLValue& aResult, nsHTMLUnit aValueUnit);
|
||||
|
||||
static PRBool ParseValue(const nsString& aString, PRInt32 aMin, PRInt32 aMax,
|
||||
nsHTMLValue& aResult, nsHTMLUnit aValueUnit);
|
||||
|
||||
static PRBool ParseColor(const nsString& aString, nsIDocument* aDocument,
|
||||
nsHTMLValue& aResult);
|
||||
|
||||
static PRBool ColorToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
static PRBool ParseCommonAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
nsHTMLValue& aResult);
|
||||
static PRBool ParseAlignValue(const nsString& aString, nsHTMLValue& aResult);
|
||||
|
||||
PRBool ParseDivAlignValue(const nsString& aString,
|
||||
nsHTMLValue& aResult) const;
|
||||
PRBool DivAlignValueToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult) const;
|
||||
|
||||
PRBool ParseTableHAlignValue(const nsString& aString,
|
||||
nsHTMLValue& aResult) const;
|
||||
PRBool TableHAlignValueToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult) const;
|
||||
|
||||
PRBool ParseTableCellHAlignValue(const nsString& aString,
|
||||
nsHTMLValue& aResult) const;
|
||||
PRBool TableCellHAlignValueToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult) const;
|
||||
|
||||
static PRBool ParseTableVAlignValue(const nsString& aString,
|
||||
nsHTMLValue& aResult);
|
||||
|
||||
static PRBool TableVAlignValueToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
static PRBool AlignValueToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
static PRBool ParseImageAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aString,
|
||||
nsHTMLValue& aResult);
|
||||
|
||||
static PRBool ImageAttributeToString(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
static PRBool ParseFrameborderValue(PRBool aStandardMode,
|
||||
const nsString& aString,
|
||||
nsHTMLValue& aResult);
|
||||
|
||||
static PRBool FrameborderValueToString(PRBool aStandardMode,
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
static PRBool ParseScrollingValue(PRBool aStandardMode,
|
||||
const nsString& aString,
|
||||
nsHTMLValue& aResult);
|
||||
|
||||
static PRBool ScrollingValueToString(PRBool aStandardMode,
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
nsresult ReparseStyleAttribute(void);
|
||||
nsresult ParseStyleAttribute(const nsString& aValue, nsHTMLValue& aResult);
|
||||
|
||||
/** Attribute Mapping Helpers
|
||||
*
|
||||
* All attributes that are mapped into style contexts must have a
|
||||
* matched set of mapping function and impact getter
|
||||
*/
|
||||
|
||||
static void MapCommonAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aStyleContext,
|
||||
nsIPresContext* aPresContext);
|
||||
static PRBool GetCommonMappedAttributesImpact(const nsIAtom* aAttribute,
|
||||
PRInt32& aHint);
|
||||
|
||||
static void MapImageAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext);
|
||||
static PRBool GetImageMappedAttributesImpact(const nsIAtom* aAttribute,
|
||||
PRInt32& aHint);
|
||||
|
||||
static void MapImageAlignAttributeInto(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext);
|
||||
static PRBool GetImageAlignAttributeImpact(const nsIAtom* aAttribute,
|
||||
PRInt32& aHint);
|
||||
|
||||
static void MapImageBorderAttributeInto(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext,
|
||||
nscolor aBorderColors[4]);
|
||||
static PRBool GetImageBorderAttributeImpact(const nsIAtom* aAttribute,
|
||||
PRInt32& aHint);
|
||||
|
||||
static void MapBackgroundAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext);
|
||||
static PRBool GetBackgroundAttributesImpact(const nsIAtom* aAttribute,
|
||||
PRInt32& aHint);
|
||||
|
||||
//XXX These two creates a dependency between content and frames
|
||||
static nsresult GetPrimaryFrame(nsIHTMLContent* aContent,
|
||||
nsIFormControlFrame *&aFormControlFrame);
|
||||
static nsresult GetPresContext(nsIHTMLContent* aContent, nsIPresContext** aPresContext);
|
||||
|
||||
static nsresult GetBaseURL(const nsHTMLValue& aBaseHref,
|
||||
nsIDocument* aDocument,
|
||||
nsIURI** aResult);
|
||||
|
||||
// See if the content object is in a document that has nav-quirks
|
||||
// mode enabled.
|
||||
PRBool InNavQuirksMode() const;
|
||||
|
||||
nsIHTMLAttributes* mAttributes;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class nsGenericHTMLLeafElement : public nsGenericHTMLElement {
|
||||
public:
|
||||
nsGenericHTMLLeafElement();
|
||||
~nsGenericHTMLLeafElement();
|
||||
|
||||
nsresult CopyInnerTo(nsIContent* aSrcContent,
|
||||
nsGenericHTMLLeafElement* aDest,
|
||||
PRBool aDeep);
|
||||
|
||||
// Remainder of nsIDOMHTMLElement (and nsIDOMNode)
|
||||
nsresult GetChildNodes(nsIDOMNodeList** aChildNodes);
|
||||
nsresult HasChildNodes(PRBool* aHasChildNodes) {
|
||||
*aHasChildNodes = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetFirstChild(nsIDOMNode** aFirstChild) {
|
||||
*aFirstChild = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetLastChild(nsIDOMNode** aLastChild) {
|
||||
*aLastChild = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Remainder of nsIHTMLContent (and nsIContent)
|
||||
nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult FinishConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult Compact() {
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult CanContainChildren(PRBool& aResult) const {
|
||||
aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult ChildCount(PRInt32& aResult) const {
|
||||
aResult = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult ChildAt(PRInt32 aIndex, nsIContent*& aResult) const {
|
||||
aResult = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const {
|
||||
aResult = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult RemoveChildAt(PRInt32 aIndex, PRBool aNotify) {
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class nsGenericHTMLContainerElement : public nsGenericHTMLElement {
|
||||
public:
|
||||
nsGenericHTMLContainerElement();
|
||||
~nsGenericHTMLContainerElement();
|
||||
|
||||
nsresult CopyInnerTo(nsIContent* aSrcContent,
|
||||
nsGenericHTMLContainerElement* aDest,
|
||||
PRBool aDeep);
|
||||
|
||||
// Remainder of nsIDOMHTMLElement (and nsIDOMNode)
|
||||
nsresult GetChildNodes(nsIDOMNodeList** aChildNodes);
|
||||
nsresult HasChildNodes(PRBool* aHasChildNodes);
|
||||
nsresult GetFirstChild(nsIDOMNode** aFirstChild);
|
||||
nsresult GetLastChild(nsIDOMNode** aLastChild);
|
||||
|
||||
nsresult InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn);
|
||||
nsresult ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn);
|
||||
nsresult RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn);
|
||||
nsresult AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn);
|
||||
|
||||
// Remainder of nsIHTMLContent (and nsIContent)
|
||||
nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult FinishConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult Compact();
|
||||
nsresult CanContainChildren(PRBool& aResult) const;
|
||||
nsresult ChildCount(PRInt32& aResult) const;
|
||||
nsresult ChildAt(PRInt32 aIndex, nsIContent*& aResult) const;
|
||||
nsresult IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const;
|
||||
nsresult InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify);
|
||||
nsresult ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify);
|
||||
nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify);
|
||||
nsresult RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
|
||||
nsVoidArray mChildren;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Implement the nsIDOMHTMLElement API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*/
|
||||
#define NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetId(nsString& aId) { \
|
||||
return _g.GetId(aId); \
|
||||
} \
|
||||
NS_IMETHOD SetId(const nsString& aId) { \
|
||||
return _g.SetId(aId); \
|
||||
} \
|
||||
NS_IMETHOD GetTitle(nsString& aTitle) { \
|
||||
return _g.GetTitle(aTitle); \
|
||||
} \
|
||||
NS_IMETHOD SetTitle(const nsString& aTitle) { \
|
||||
return _g.SetTitle(aTitle); \
|
||||
} \
|
||||
NS_IMETHOD GetLang(nsString& aLang) { \
|
||||
return _g.GetLang(aLang); \
|
||||
} \
|
||||
NS_IMETHOD SetLang(const nsString& aLang) { \
|
||||
return _g.SetLang(aLang); \
|
||||
} \
|
||||
NS_IMETHOD GetDir(nsString& aDir) { \
|
||||
return _g.GetDir(aDir); \
|
||||
} \
|
||||
NS_IMETHOD SetDir(const nsString& aDir) { \
|
||||
return _g.SetDir(aDir); \
|
||||
} \
|
||||
NS_IMETHOD GetClassName(nsString& aClassName) { \
|
||||
return _g.GetClassName(aClassName); \
|
||||
} \
|
||||
NS_IMETHOD SetClassName(const nsString& aClassName) { \
|
||||
return _g.SetClassName(aClassName); \
|
||||
} \
|
||||
NS_IMETHOD GetStyle(nsIDOMCSSStyleDeclaration** aStyle) { \
|
||||
return _g.GetStyle(aStyle); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_IHTMLCONTENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD Compact() { \
|
||||
return _g.Compact(); \
|
||||
} \
|
||||
NS_IMETHOD SetHTMLAttribute(nsIAtom* aAttribute, \
|
||||
const nsHTMLValue& aValue, PRBool aNotify) { \
|
||||
return _g.SetHTMLAttribute(aAttribute, aValue, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetHTMLAttribute(nsIAtom* aAttribute, \
|
||||
nsHTMLValue& aValue) const { \
|
||||
return _g.GetHTMLAttribute(aAttribute, aValue); \
|
||||
} \
|
||||
NS_IMETHOD GetID(nsIAtom*& aResult) const { \
|
||||
return _g.GetID(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetClasses(nsVoidArray& aArray) const { \
|
||||
return _g.GetClasses(aArray); \
|
||||
} \
|
||||
NS_IMETHOD HasClass(nsIAtom* aClass) const { \
|
||||
return _g.HasClass(aClass); \
|
||||
} \
|
||||
NS_IMETHOD GetContentStyleRules(nsISupportsArray* aRules) { \
|
||||
return _g.GetContentStyleRules(aRules); \
|
||||
} \
|
||||
NS_IMETHOD GetInlineStyleRules(nsISupportsArray* aRules) { \
|
||||
return _g.GetInlineStyleRules(aRules); \
|
||||
} \
|
||||
NS_IMETHOD GetBaseURL(nsIURI*& aBaseURL) const { \
|
||||
return _g.GetBaseURL(aBaseURL); \
|
||||
} \
|
||||
NS_IMETHOD GetBaseTarget(nsString& aBaseTarget) const { \
|
||||
return _g.GetBaseTarget(aBaseTarget); \
|
||||
} \
|
||||
NS_IMETHOD ToHTMLString(nsString& aResult) const { \
|
||||
return _g.ToHTMLString(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ToHTML(FILE* out) const { \
|
||||
return _g.ToHTML(out); \
|
||||
} \
|
||||
NS_IMETHOD StringToAttribute(nsIAtom* aAttribute, \
|
||||
const nsString& aValue, \
|
||||
nsHTMLValue& aResult); \
|
||||
NS_IMETHOD AttributeToString(nsIAtom* aAttribute, \
|
||||
const nsHTMLValue& aValue, \
|
||||
nsString& aResult) const; \
|
||||
NS_IMETHOD GetAttributeMappingFunctions(nsMapAttributesFunc& aFontMapFunc, \
|
||||
nsMapAttributesFunc& aMapFunc) const; \
|
||||
NS_IMETHOD GetMappedAttributeImpact(const nsIAtom* aAttribute, \
|
||||
PRInt32& aHint) const;
|
||||
|
||||
#define NS_IMPL_IHTMLCONTENT_USING_GENERIC2(_g) \
|
||||
NS_IMETHOD Compact() { \
|
||||
return _g.Compact(); \
|
||||
} \
|
||||
NS_IMETHOD SetHTMLAttribute(nsIAtom* aAttribute, \
|
||||
const nsHTMLValue& aValue, PRBool aNotify) { \
|
||||
return _g.SetHTMLAttribute(aAttribute, aValue, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetHTMLAttribute(nsIAtom* aAttribute, \
|
||||
nsHTMLValue& aValue) const { \
|
||||
return _g.GetHTMLAttribute(aAttribute, aValue); \
|
||||
} \
|
||||
NS_IMETHOD GetID(nsIAtom*& aResult) const { \
|
||||
return _g.GetID(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetClasses(nsVoidArray& aArray) const { \
|
||||
return _g.GetClasses(aArray); \
|
||||
} \
|
||||
NS_IMETHOD HasClass(nsIAtom* aClass) const { \
|
||||
return _g.HasClass(aClass); \
|
||||
} \
|
||||
NS_IMETHOD GetContentStyleRules(nsISupportsArray* aRules); \
|
||||
NS_IMETHOD GetInlineStyleRules(nsISupportsArray* aRules); \
|
||||
NS_IMETHOD GetBaseURL(nsIURI*& aBaseURL) const { \
|
||||
return _g.GetBaseURL(aBaseURL); \
|
||||
} \
|
||||
NS_IMETHOD GetBaseTarget(nsString& aBaseTarget) const { \
|
||||
return _g.GetBaseTarget(aBaseTarget); \
|
||||
} \
|
||||
NS_IMETHOD ToHTMLString(nsString& aResult) const { \
|
||||
return _g.ToHTMLString(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ToHTML(FILE* out) const { \
|
||||
return _g.ToHTML(out); \
|
||||
} \
|
||||
NS_IMETHOD StringToAttribute(nsIAtom* aAttribute, \
|
||||
const nsString& aValue, \
|
||||
nsHTMLValue& aResult); \
|
||||
NS_IMETHOD AttributeToString(nsIAtom* aAttribute, \
|
||||
const nsHTMLValue& aValue, \
|
||||
nsString& aResult) const; \
|
||||
NS_IMETHOD GetAttributeMappingFunctions(nsMapAttributesFunc& aFontMapFunc, \
|
||||
nsMapAttributesFunc& aMapFunc) const; \
|
||||
NS_IMETHOD GetMappedAttributeImpact(const nsIAtom* aAttribute, \
|
||||
PRInt32& aHint) const;
|
||||
|
||||
/**
|
||||
* This macro implements the portion of query interface that is
|
||||
* generic to all html content objects.
|
||||
*/
|
||||
#define NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(_id, _iptr, _this) \
|
||||
NS_IMPL_CONTENT_QUERY_INTERFACE(_id, _iptr, _this, nsIHTMLContent) \
|
||||
if (_id.Equals(kIDOMHTMLElementIID)) { \
|
||||
nsIDOMHTMLElement* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIHTMLContentIID)) { \
|
||||
nsIHTMLContent* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIStyledContentIID)) { \
|
||||
nsIStyledContent* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given string
|
||||
* valued content property. The method uses the generic SetAttr and
|
||||
* GetAttribute methods.
|
||||
*/
|
||||
#define NS_IMPL_STRING_ATTR(_class, _method, _atom) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(nsString& aValue) \
|
||||
{ \
|
||||
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_atom, aValue); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_method(const nsString& aValue) \
|
||||
{ \
|
||||
return mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_atom, aValue, PR_TRUE); \
|
||||
}
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given boolean
|
||||
* valued content property. The method uses the generic SetAttr and
|
||||
* GetAttribute methods.
|
||||
*/
|
||||
#define NS_IMPL_BOOL_ATTR(_class, _method, _atom) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(PRBool* aValue) \
|
||||
{ \
|
||||
nsHTMLValue val; \
|
||||
nsresult rv = mInner.GetHTMLAttribute(nsHTMLAtoms::_atom, val); \
|
||||
*aValue = NS_CONTENT_ATTR_NOT_THERE != rv; \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_method(PRBool aValue) \
|
||||
{ \
|
||||
nsHTMLValue empty(eHTMLUnit_Empty); \
|
||||
if (aValue) { \
|
||||
return mInner.SetHTMLAttribute(nsHTMLAtoms::_atom, empty, PR_TRUE); \
|
||||
} \
|
||||
else { \
|
||||
mInner.UnsetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_atom, PR_TRUE); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given integer
|
||||
* valued content property. The method uses the generic SetAttr and
|
||||
* GetAttribute methods.
|
||||
*/
|
||||
#define NS_IMPL_INT_ATTR(_class, _method, _atom) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(PRInt32* aValue) \
|
||||
{ \
|
||||
nsHTMLValue value; \
|
||||
*aValue = -1; \
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == \
|
||||
mInner.GetHTMLAttribute(nsHTMLAtoms::_atom, value)) { \
|
||||
if (value.GetUnit() == eHTMLUnit_Integer) { \
|
||||
*aValue = value.GetIntValue(); \
|
||||
} \
|
||||
} \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_method(PRInt32 aValue) \
|
||||
{ \
|
||||
nsHTMLValue value(aValue, eHTMLUnit_Integer); \
|
||||
return mInner.SetHTMLAttribute(nsHTMLAtoms::_atom, value, PR_TRUE); \
|
||||
}
|
||||
|
||||
#endif /* nsGenericHTMLElement_h___ */
|
||||
486
mozilla/content/html/content/src/nsHTMLAnchorElement.cpp
Normal file
486
mozilla/content/html/content/src/nsHTMLAnchorElement.cpp
Normal file
@@ -0,0 +1,486 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsIDOMHTMLAnchorElement.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIMutableStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIFocusableContent.h"
|
||||
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsDOMEvent.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIFrameManager.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
// XXX suppress
|
||||
|
||||
// XXX either suppress is handled in the event code below OR we need a
|
||||
// custom frame
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLAnchorElementIID, NS_IDOMHTMLANCHORELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIFocusableContentIID, NS_IFOCUSABLECONTENT_IID);
|
||||
|
||||
class nsHTMLAnchorElement : public nsIDOMHTMLAnchorElement,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIHTMLContent,
|
||||
public nsIFocusableContent
|
||||
{
|
||||
public:
|
||||
nsHTMLAnchorElement(nsIAtom* aTag);
|
||||
virtual ~nsHTMLAnchorElement();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_IDOMNODE_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMElement
|
||||
NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLElement
|
||||
NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLAnchorElement
|
||||
NS_IMETHOD GetAccessKey(nsString& aAccessKey);
|
||||
NS_IMETHOD SetAccessKey(const nsString& aAccessKey);
|
||||
NS_IMETHOD GetCharset(nsString& aCharset);
|
||||
NS_IMETHOD SetCharset(const nsString& aCharset);
|
||||
NS_IMETHOD GetCoords(nsString& aCoords);
|
||||
NS_IMETHOD SetCoords(const nsString& aCoords);
|
||||
NS_IMETHOD GetHref(nsString& aHref);
|
||||
NS_IMETHOD SetHref(const nsString& aHref);
|
||||
NS_IMETHOD GetHreflang(nsString& aHreflang);
|
||||
NS_IMETHOD SetHreflang(const nsString& aHreflang);
|
||||
NS_IMETHOD GetName(nsString& aName);
|
||||
NS_IMETHOD SetName(const nsString& aName);
|
||||
NS_IMETHOD GetRel(nsString& aRel);
|
||||
NS_IMETHOD SetRel(const nsString& aRel);
|
||||
NS_IMETHOD GetRev(nsString& aRev);
|
||||
NS_IMETHOD SetRev(const nsString& aRev);
|
||||
NS_IMETHOD GetShape(nsString& aShape);
|
||||
NS_IMETHOD SetShape(const nsString& aShape);
|
||||
NS_IMETHOD GetTabIndex(PRInt32* aTabIndex);
|
||||
NS_IMETHOD SetTabIndex(PRInt32 aTabIndex);
|
||||
NS_IMETHOD GetTarget(nsString& aTarget);
|
||||
NS_IMETHOD SetTarget(const nsString& aTarget);
|
||||
NS_IMETHOD GetType(nsString& aType);
|
||||
NS_IMETHOD SetType(const nsString& aType);
|
||||
NS_IMETHOD Blur();
|
||||
NS_IMETHOD Focus();
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIContent
|
||||
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIHTMLContent
|
||||
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIFocusableContent
|
||||
NS_IMETHOD SetFocus(nsIPresContext* aPresContext);
|
||||
NS_IMETHOD RemoveFocus(nsIPresContext* aPresContext);
|
||||
|
||||
protected:
|
||||
nsGenericHTMLContainerElement mInner;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLAnchorElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsIHTMLContent* it = new nsHTMLAnchorElement(aTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
nsHTMLAnchorElement::nsHTMLAnchorElement(nsIAtom* aTag)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInner.Init(this, aTag);
|
||||
}
|
||||
|
||||
nsHTMLAnchorElement::~nsHTMLAnchorElement()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsHTMLAnchorElement)
|
||||
|
||||
NS_IMPL_RELEASE(nsHTMLAnchorElement)
|
||||
|
||||
nsresult
|
||||
nsHTMLAnchorElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this)
|
||||
if (aIID.Equals(kIDOMHTMLAnchorElementIID)) {
|
||||
nsIDOMHTMLAnchorElement* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(kIFocusableContentIID)) {
|
||||
*aInstancePtr = (void*)(nsIFocusableContent*) this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLAnchorElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsHTMLAnchorElement* it = new nsHTMLAnchorElement(mInner.mTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mInner.CopyInnerTo(this, &it->mInner, aDeep);
|
||||
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, AccessKey, accesskey)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Charset, charset)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Coords, coords)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Hreflang, hreflang)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Name, name)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Rel, rel)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Rev, rev)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Shape, shape)
|
||||
NS_IMPL_INT_ATTR(nsHTMLAnchorElement, TabIndex, tabindex)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Target, target)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Type, type)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::Blur()
|
||||
{
|
||||
// XXX write me
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::Focus()
|
||||
{
|
||||
nsIDocument* doc; // Strong
|
||||
nsresult rv = GetDocument(doc);
|
||||
if (NS_FAILED(rv)) { return rv; }
|
||||
if (!doc) { return NS_ERROR_NULL_POINTER; }
|
||||
|
||||
PRInt32 numShells = doc->GetNumberOfShells();
|
||||
nsIPresShell* shell = nsnull; // Strong
|
||||
nsCOMPtr<nsIPresContext> context;
|
||||
for (PRInt32 i=0; i<numShells; i++)
|
||||
{
|
||||
shell = doc->GetShellAt(i);
|
||||
if (!shell) { return NS_ERROR_NULL_POINTER; }
|
||||
|
||||
rv = shell->GetPresContext(getter_AddRefs(context));
|
||||
if (NS_FAILED(rv)) { return rv; }
|
||||
if (!context) { return NS_ERROR_NULL_POINTER; }
|
||||
|
||||
rv = SetFocus(context);
|
||||
if (NS_FAILED(rv)) { return rv; }
|
||||
|
||||
NS_RELEASE(shell);
|
||||
}
|
||||
NS_RELEASE(doc);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::SetFocus(nsIPresContext* aPresContext)
|
||||
{
|
||||
|
||||
// don't make the link grab the focus if there is no link handler
|
||||
nsILinkHandler* handler;
|
||||
nsresult rv = aPresContext->GetLinkHandler(&handler);
|
||||
if (NS_SUCCEEDED(rv) && (nsnull != handler)) {
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_FOCUS);
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||
if (presShell) {
|
||||
nsCOMPtr<nsIFrameManager> frameManager;
|
||||
presShell->GetFrameManager(getter_AddRefs(frameManager));
|
||||
if (frameManager) {
|
||||
|
||||
nsIFrame* frame = nsnull;
|
||||
frameManager->GetPrimaryFrameFor(this, &frame);
|
||||
if (frame) {
|
||||
presShell->ScrollFrameIntoView(frame,
|
||||
NS_PRESSHELL_SCROLL_ANYWHERE,NS_PRESSHELL_SCROLL_ANYWHERE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
NS_RELEASE(handler);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::RemoveFocus(nsIPresContext* aPresContext)
|
||||
{
|
||||
// XXX write me
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::tabindex) {
|
||||
if (nsGenericHTMLElement::ParseValue(aValue, 0, 32767, aResult,
|
||||
eHTMLUnit_Integer)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::suppress) {
|
||||
if (aValue.EqualsIgnoreCase("true")) {
|
||||
aResult.SetEmptyValue(); // XXX? shouldn't just leave "true"
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
return NS_CONTENT_ATTR_NOT_THERE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::AttributeToString(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
{
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
static void
|
||||
MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext)
|
||||
{
|
||||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::GetMappedAttributeImpact(const nsIAtom* aAttribute,
|
||||
PRInt32& aHint) const
|
||||
{
|
||||
if (! nsGenericHTMLElement::GetCommonMappedAttributesImpact(aAttribute, aHint)) {
|
||||
aHint = NS_STYLE_HINT_CONTENT;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::GetAttributeMappingFunctions(nsMapAttributesFunc& aFontMapFunc,
|
||||
nsMapAttributesFunc& aMapFunc) const
|
||||
{
|
||||
aFontMapFunc = nsnull;
|
||||
aMapFunc = &MapAttributesInto;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXX support suppress in here
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
NS_ENSURE_ARG(aPresContext);
|
||||
NS_ENSURE_ARG_POINTER(aEventStatus);
|
||||
// Try script event handlers first
|
||||
nsresult ret = mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
|
||||
if ((NS_OK == ret) && (nsEventStatus_eIgnore == *aEventStatus) &&
|
||||
!(aFlags & NS_EVENT_FLAG_CAPTURE)) {
|
||||
// If this anchor element has an HREF then it is sensitive to
|
||||
// mouse events (otherwise ignore them).
|
||||
nsAutoString href;
|
||||
nsresult result = GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, href);
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
|
||||
switch (aEvent->message) {
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
{
|
||||
// don't make the link grab the focus if there is no link handler
|
||||
nsILinkHandler* handler;
|
||||
nsresult rv = aPresContext->GetLinkHandler(&handler);
|
||||
if (NS_SUCCEEDED(rv) && (nsnull != handler)) {
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
NS_RELEASE(handler);
|
||||
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_MOUSE_LEFT_CLICK:
|
||||
case NS_KEY_PRESS:
|
||||
{
|
||||
if (nsEventStatus_eConsumeNoDefault != *aEventStatus) {
|
||||
|
||||
nsKeyEvent * keyEvent;
|
||||
if (aEvent->eventStructType == NS_KEY_EVENT) {
|
||||
//Handle key commands from keys with char representation here, not on KeyDown
|
||||
keyEvent = (nsKeyEvent *)aEvent;
|
||||
}
|
||||
|
||||
//Click or return key
|
||||
if (aEvent->message == NS_MOUSE_LEFT_CLICK || keyEvent->keyCode == NS_VK_RETURN) {
|
||||
nsAutoString target;
|
||||
nsIURI* baseURL = nsnull;
|
||||
GetBaseURL(baseURL);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
|
||||
if (target.Length() == 0) {
|
||||
GetBaseTarget(target);
|
||||
}
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace,
|
||||
baseURL, href, target, PR_TRUE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
*aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_MOUSE_RIGHT_BUTTON_DOWN:
|
||||
// XXX Bring up a contextual menu provided by the application
|
||||
break;
|
||||
|
||||
case NS_MOUSE_ENTER:
|
||||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_HOVER);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
|
||||
nsAutoString target;
|
||||
nsIURI* baseURL = nsnull;
|
||||
GetBaseURL(baseURL);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
|
||||
if (target.Length() == 0) {
|
||||
GetBaseTarget(target);
|
||||
}
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace,
|
||||
baseURL, href, target, PR_FALSE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_MOUSE_EXIT:
|
||||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(nsnull, NS_EVENT_STATE_HOVER);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
|
||||
nsAutoString empty;
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, nsnull, empty, empty, PR_FALSE);
|
||||
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::GetHref(nsString& aValue)
|
||||
{
|
||||
// Resolve url to an absolute url
|
||||
nsresult rv = NS_OK;
|
||||
nsAutoString relURLSpec;
|
||||
nsIURI* baseURL = nsnull;
|
||||
|
||||
// Get base URL.
|
||||
mInner.GetBaseURL(baseURL);
|
||||
|
||||
// Get href= attribute (relative URL).
|
||||
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, relURLSpec);
|
||||
|
||||
// If there is no href=, then use base target.
|
||||
if (relURLSpec.Length() == 0) {
|
||||
mInner.GetBaseTarget(relURLSpec);
|
||||
}
|
||||
|
||||
if (nsnull != baseURL) {
|
||||
// Get absolute URL.
|
||||
rv = NS_MakeAbsoluteURI(relURLSpec, baseURL, aValue);
|
||||
}
|
||||
else {
|
||||
// Absolute URL is same as relative URL.
|
||||
aValue = relURLSpec;
|
||||
}
|
||||
NS_IF_RELEASE(baseURL);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::SetHref(const nsString& aValue)
|
||||
{
|
||||
return mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, aValue, PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
||||
{
|
||||
return mInner.SizeOf(aSizer, aResult, sizeof(*this));
|
||||
}
|
||||
354
mozilla/content/html/content/src/nsHTMLAppletElement.cpp
Normal file
354
mozilla/content/html/content/src/nsHTMLAppletElement.cpp
Normal file
@@ -0,0 +1,354 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsIDOMHTMLAppletElement.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIMutableStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIFrame.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIJVMManager.h"
|
||||
#include "nsILiveConnectManager.h"
|
||||
#include "nsIPluginInstance.h"
|
||||
#include "nsIJVMPluginInstance.h"
|
||||
|
||||
// XXX this is to get around conflicts with windows.h defines
|
||||
// introduced through jni.h
|
||||
#ifdef XP_PC
|
||||
#undef GetClassName
|
||||
#undef GetObject
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLAppletElementIID, NS_IDOMHTMLAPPLETELEMENT_IID);
|
||||
|
||||
class nsHTMLAppletElement : public nsIDOMHTMLAppletElement,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIHTMLContent
|
||||
{
|
||||
public:
|
||||
nsHTMLAppletElement(nsIAtom* aTag);
|
||||
virtual ~nsHTMLAppletElement();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_IDOMNODE_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMElement
|
||||
NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLElement
|
||||
NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLAppletElement
|
||||
NS_IMETHOD GetAlign(nsString& aAlign);
|
||||
NS_IMETHOD SetAlign(const nsString& aAlign);
|
||||
NS_IMETHOD GetAlt(nsString& aAlt);
|
||||
NS_IMETHOD SetAlt(const nsString& aAlt);
|
||||
NS_IMETHOD GetArchive(nsString& aArchive);
|
||||
NS_IMETHOD SetArchive(const nsString& aArchive);
|
||||
NS_IMETHOD GetCode(nsString& aCode);
|
||||
NS_IMETHOD SetCode(const nsString& aCode);
|
||||
NS_IMETHOD GetCodeBase(nsString& aCodeBase);
|
||||
NS_IMETHOD SetCodeBase(const nsString& aCodeBase);
|
||||
NS_IMETHOD GetHeight(nsString& aHeight);
|
||||
NS_IMETHOD SetHeight(const nsString& aHeight);
|
||||
NS_IMETHOD GetHspace(nsString& aHspace);
|
||||
NS_IMETHOD SetHspace(const nsString& aHspace);
|
||||
NS_IMETHOD GetName(nsString& aName);
|
||||
NS_IMETHOD SetName(const nsString& aName);
|
||||
NS_IMETHOD GetObject(nsString& aObject);
|
||||
NS_IMETHOD SetObject(const nsString& aObject);
|
||||
NS_IMETHOD GetVspace(nsString& aVspace);
|
||||
NS_IMETHOD SetVspace(const nsString& aVspace);
|
||||
NS_IMETHOD GetWidth(nsString& aWidth);
|
||||
NS_IMETHOD SetWidth(const nsString& aWidth);
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext,
|
||||
void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIContent
|
||||
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIHTMLContent
|
||||
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
|
||||
|
||||
protected:
|
||||
nsGenericHTMLContainerElement mInner;
|
||||
PRBool mReflectedApplet;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLAppletElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsIHTMLContent* it = new nsHTMLAppletElement(aTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
nsHTMLAppletElement::nsHTMLAppletElement(nsIAtom* aTag)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInner.Init(this, aTag);
|
||||
mReflectedApplet = PR_FALSE;
|
||||
}
|
||||
|
||||
nsHTMLAppletElement::~nsHTMLAppletElement()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsHTMLAppletElement)
|
||||
|
||||
NS_IMPL_RELEASE(nsHTMLAppletElement)
|
||||
|
||||
nsresult
|
||||
nsHTMLAppletElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this)
|
||||
if (aIID.Equals(kIDOMHTMLAppletElementIID)) {
|
||||
nsIDOMHTMLAppletElement* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLAppletElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsHTMLAppletElement* it = new nsHTMLAppletElement(mInner.mTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mInner.CopyInnerTo(this, &it->mInner, aDeep);
|
||||
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Align, align)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Alt, alt)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Archive, archive)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Code, code)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, CodeBase, codebase)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Height, height)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Hspace, hspace)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Name, name)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Object, object)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Vspace, vspace)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Width, width)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAppletElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (nsGenericHTMLElement::ParseAlignValue(aValue, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
else if (nsGenericHTMLElement::ParseImageAttribute(aAttribute,
|
||||
aValue, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
return NS_CONTENT_ATTR_NOT_THERE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAppletElement::AttributeToString(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
|
||||
nsGenericHTMLElement::AlignValueToString(aValue, aResult);
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
else if (nsGenericHTMLElement::ImageAttributeToString(aAttribute,
|
||||
aValue, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
static void
|
||||
MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext)
|
||||
{
|
||||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
|
||||
nsGenericHTMLElement::MapImageAttributesInto(aAttributes, aContext, aPresContext);
|
||||
nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aContext, aPresContext);
|
||||
nsGenericHTMLElement::MapImageBorderAttributeInto(aAttributes, aContext, aPresContext, nsnull);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAppletElement::GetMappedAttributeImpact(const nsIAtom* aAttribute,
|
||||
PRInt32& aHint) const
|
||||
{
|
||||
if (! nsGenericHTMLElement::GetCommonMappedAttributesImpact(aAttribute, aHint)) {
|
||||
if (! nsGenericHTMLElement::GetImageMappedAttributesImpact(aAttribute, aHint)) {
|
||||
if (! nsGenericHTMLElement::GetImageAlignAttributeImpact(aAttribute, aHint)) {
|
||||
if (! nsGenericHTMLElement::GetImageBorderAttributeImpact(aAttribute, aHint)) {
|
||||
aHint = NS_STYLE_HINT_CONTENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAppletElement::GetAttributeMappingFunctions(nsMapAttributesFunc& aFontMapFunc,
|
||||
nsMapAttributesFunc& aMapFunc) const
|
||||
{
|
||||
aFontMapFunc = nsnull;
|
||||
aMapFunc = &MapAttributesInto;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAppletElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
||||
extern nsresult NS_GetObjectFramePluginInstance(nsIFrame* aFrame, nsIPluginInstance*& aPluginInstance);
|
||||
|
||||
/**
|
||||
* For backwards compatibility an applet element's JavaScript object should expose both the public
|
||||
* fields of the applet, and the attributes of the applet tag. The call to nsGenericElement::GetScriptObject
|
||||
* takes case of the tag attributes. Here we generate a JavaScript reference to the applet object itself,
|
||||
* and set its __proto__ property to the tag object. That way, if the Java applet has public fields that
|
||||
* shadow the tag attributes, the applet's fields take precedence.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAppletElement::GetScriptObject(nsIScriptContext* aContext,
|
||||
void** aScriptObject)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
NS_WITH_SERVICE(nsIJVMManager, jvm, nsIJVMManager::GetCID(), &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// nsresult rv = NS_OK;
|
||||
if (!mReflectedApplet) {
|
||||
// 1. get the script object corresponding to the <APPLET> element itself.
|
||||
JSObject* elementObject = nsnull;
|
||||
rv = mInner.GetScriptObject(aContext, (void**)&elementObject);
|
||||
if (NS_OK != rv)
|
||||
return rv;
|
||||
|
||||
// 2. get the plugin instance corresponding to this element.
|
||||
nsIPresShell* shell = mInner.mDocument->GetShellAt(0);
|
||||
if (nsnull == shell)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(mInner.mContent, &frame);
|
||||
NS_RELEASE(shell);
|
||||
|
||||
// 3. get the Java object corresponding to this applet, and reflect it into
|
||||
// JavaScript using the LiveConnect manager.
|
||||
JSContext* context = (JSContext*)aContext->GetNativeContext();
|
||||
JSObject* wrappedAppletObject = nsnull;
|
||||
nsIPluginInstance* pluginInstance = nsnull;
|
||||
rv = NS_GetObjectFramePluginInstance(frame, pluginInstance);
|
||||
if ((rv == NS_OK) && (nsnull != pluginInstance)) {
|
||||
nsIJVMPluginInstance* javaPluginInstance = nsnull;
|
||||
if (pluginInstance->QueryInterface(nsIJVMPluginInstance::GetIID(), (void**)&javaPluginInstance) == NS_OK) {
|
||||
jobject appletObject = nsnull;
|
||||
rv = javaPluginInstance->GetJavaObject(&appletObject);
|
||||
if (NS_OK == rv) {
|
||||
nsILiveConnectManager* manager = NULL;
|
||||
rv = nsServiceManager::GetService(nsIJVMManager::GetCID(),
|
||||
nsILiveConnectManager::GetIID(),
|
||||
(nsISupports **)&manager);
|
||||
if (rv == NS_OK) {
|
||||
rv = manager->WrapJavaObject(context, appletObject, &wrappedAppletObject);
|
||||
nsServiceManager::ReleaseService(nsIJVMManager::GetCID(), manager);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(javaPluginInstance);
|
||||
}
|
||||
NS_RELEASE(pluginInstance);
|
||||
}
|
||||
|
||||
// 4. set the __proto__ field of the applet object to be the element script object.
|
||||
if (nsnull != wrappedAppletObject) {
|
||||
JS_SetPrototype(context, wrappedAppletObject, elementObject);
|
||||
mInner.SetScriptObject(wrappedAppletObject);
|
||||
mReflectedApplet = PR_TRUE;
|
||||
}
|
||||
*aScriptObject = wrappedAppletObject;
|
||||
} else {
|
||||
rv = mInner.GetScriptObject(aContext, aScriptObject);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
else
|
||||
return mInner.GetScriptObject(aContext, aScriptObject);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO: if this method ever gets called, it will destroy the prototype type chain.
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAppletElement::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
return mInner.SetScriptObject(aScriptObject);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAppletElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
||||
{
|
||||
return mInner.SizeOf(aSizer, aResult, sizeof(*this));
|
||||
}
|
||||
258
mozilla/content/html/content/src/nsHTMLAreaElement.cpp
Normal file
258
mozilla/content/html/content/src/nsHTMLAreaElement.cpp
Normal file
@@ -0,0 +1,258 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsIDOMHTMLAreaElement.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIMutableStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIFocusableContent.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLAreaElementIID, NS_IDOMHTMLAREAELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIFocusableContentIID, NS_IFOCUSABLECONTENT_IID);
|
||||
|
||||
class nsHTMLAreaElement : public nsIDOMHTMLAreaElement,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIHTMLContent,
|
||||
public nsIFocusableContent
|
||||
{
|
||||
public:
|
||||
nsHTMLAreaElement(nsIAtom* aTag);
|
||||
virtual ~nsHTMLAreaElement();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_IDOMNODE_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMElement
|
||||
NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLElement
|
||||
NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLAreaElement
|
||||
NS_IMETHOD GetAccessKey(nsString& aAccessKey);
|
||||
NS_IMETHOD SetAccessKey(const nsString& aAccessKey);
|
||||
NS_IMETHOD GetAlt(nsString& aAlt);
|
||||
NS_IMETHOD SetAlt(const nsString& aAlt);
|
||||
NS_IMETHOD GetCoords(nsString& aCoords);
|
||||
NS_IMETHOD SetCoords(const nsString& aCoords);
|
||||
NS_IMETHOD GetHref(nsString& aHref);
|
||||
NS_IMETHOD SetHref(const nsString& aHref);
|
||||
NS_IMETHOD GetNoHref(PRBool* aNoHref);
|
||||
NS_IMETHOD SetNoHref(PRBool aNoHref);
|
||||
NS_IMETHOD GetShape(nsString& aShape);
|
||||
NS_IMETHOD SetShape(const nsString& aShape);
|
||||
NS_IMETHOD GetTabIndex(PRInt32* aTabIndex);
|
||||
NS_IMETHOD SetTabIndex(PRInt32 aTabIndex);
|
||||
NS_IMETHOD GetTarget(nsString& aTarget);
|
||||
NS_IMETHOD SetTarget(const nsString& aTarget);
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIContent
|
||||
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIHTMLContent
|
||||
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIFocusableContent
|
||||
NS_IMETHOD SetFocus(nsIPresContext* aPresContext);
|
||||
NS_IMETHOD RemoveFocus(nsIPresContext* aPresContext);
|
||||
|
||||
protected:
|
||||
nsGenericHTMLLeafElement mInner;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLAreaElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsIHTMLContent* it = new nsHTMLAreaElement(aTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
nsHTMLAreaElement::nsHTMLAreaElement(nsIAtom* aTag)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInner.Init(this, aTag);
|
||||
}
|
||||
|
||||
nsHTMLAreaElement::~nsHTMLAreaElement()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsHTMLAreaElement)
|
||||
|
||||
NS_IMPL_RELEASE(nsHTMLAreaElement)
|
||||
|
||||
nsresult
|
||||
nsHTMLAreaElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this)
|
||||
if (aIID.Equals(kIDOMHTMLAreaElementIID)) {
|
||||
nsIDOMHTMLAreaElement* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(kIFocusableContentIID)) {
|
||||
*aInstancePtr = (void*)(nsIFocusableContent*) this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLAreaElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsHTMLAreaElement* it = new nsHTMLAreaElement(mInner.mTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mInner.CopyInnerTo(this, &it->mInner, aDeep);
|
||||
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAreaElement, AccessKey, accesskey)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Alt, alt)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Coords, coords)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Href, href)
|
||||
NS_IMPL_BOOL_ATTR(nsHTMLAreaElement, NoHref, nohref)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Shape, shape)
|
||||
NS_IMPL_INT_ATTR(nsHTMLAreaElement, TabIndex, tabindex)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Target, target)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::nohref) {
|
||||
aResult.SetEmptyValue();
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::tabindex) {
|
||||
if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_CONTENT_ATTR_NOT_THERE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::AttributeToString(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
{
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
static void
|
||||
MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext)
|
||||
{
|
||||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::GetMappedAttributeImpact(const nsIAtom* aAttribute,
|
||||
PRInt32& aHint) const
|
||||
|
||||
{
|
||||
if (! nsGenericHTMLElement::GetCommonMappedAttributesImpact(aAttribute, aHint)) {
|
||||
aHint = NS_STYLE_HINT_CONTENT;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::GetAttributeMappingFunctions(nsMapAttributesFunc& aFontMapFunc,
|
||||
nsMapAttributesFunc& aMapFunc) const
|
||||
{
|
||||
aFontMapFunc = nsnull;
|
||||
aMapFunc = &MapAttributesInto;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::SetFocus(nsIPresContext* aPresContext)
|
||||
{
|
||||
nsIEventStateManager* esm;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&esm)) {
|
||||
esm->SetContentState(this, NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(esm);
|
||||
}
|
||||
|
||||
// XXX write me
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::RemoveFocus(nsIPresContext* aPresContext)
|
||||
{
|
||||
// XXX write me
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
||||
{
|
||||
return mInner.SizeOf(aSizer, aResult, sizeof(*this));
|
||||
}
|
||||
225
mozilla/content/html/content/src/nsHTMLBRElement.cpp
Normal file
225
mozilla/content/html/content/src/nsHTMLBRElement.cpp
Normal file
@@ -0,0 +1,225 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsIDOMHTMLBRElement.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIMutableStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLBRElementIID, NS_IDOMHTMLBRELEMENT_IID);
|
||||
|
||||
class nsHTMLBRElement : public nsIDOMHTMLBRElement,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIHTMLContent
|
||||
{
|
||||
public:
|
||||
nsHTMLBRElement(nsIAtom* aTag);
|
||||
virtual ~nsHTMLBRElement();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_IDOMNODE_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMElement
|
||||
NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLElement
|
||||
NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLBRElement
|
||||
NS_IMETHOD GetClear(nsString& aClear);
|
||||
NS_IMETHOD SetClear(const nsString& aClear);
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIContent
|
||||
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIHTMLContent
|
||||
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
|
||||
|
||||
protected:
|
||||
nsGenericHTMLLeafElement mInner;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLBRElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsIHTMLContent* it = new nsHTMLBRElement(aTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
nsHTMLBRElement::nsHTMLBRElement(nsIAtom* aTag)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInner.Init(this, aTag);
|
||||
}
|
||||
|
||||
nsHTMLBRElement::~nsHTMLBRElement()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsHTMLBRElement)
|
||||
|
||||
NS_IMPL_RELEASE(nsHTMLBRElement)
|
||||
|
||||
nsresult
|
||||
nsHTMLBRElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this)
|
||||
if (aIID.Equals(kIDOMHTMLBRElementIID)) {
|
||||
nsIDOMHTMLBRElement* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLBRElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsHTMLBRElement* it = new nsHTMLBRElement(mInner.mTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mInner.CopyInnerTo(this, &it->mInner, aDeep);
|
||||
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLBRElement, Clear, clear)
|
||||
|
||||
static nsGenericHTMLElement::EnumTable kClearTable[] = {
|
||||
{ "left", NS_STYLE_CLEAR_LEFT },
|
||||
{ "right", NS_STYLE_CLEAR_RIGHT },
|
||||
{ "all", NS_STYLE_CLEAR_LEFT_AND_RIGHT },
|
||||
{ "both", NS_STYLE_CLEAR_LEFT_AND_RIGHT },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBRElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::clear) {
|
||||
if (nsGenericHTMLElement::ParseEnumValue(aValue, kClearTable, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
return NS_CONTENT_ATTR_NOT_THERE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBRElement::AttributeToString(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::clear) {
|
||||
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
|
||||
nsGenericHTMLElement::EnumValueToString(aValue, kClearTable, aResult);
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
static void
|
||||
MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext)
|
||||
{
|
||||
nsStyleDisplay* display = (nsStyleDisplay*)
|
||||
aContext->GetMutableStyleData(eStyleStruct_Display);
|
||||
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::clear, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated) {
|
||||
display->mBreakType = value.GetIntValue();
|
||||
}
|
||||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBRElement::GetMappedAttributeImpact(const nsIAtom* aAttribute,
|
||||
PRInt32& aHint) const
|
||||
{
|
||||
if (! nsGenericHTMLElement::GetCommonMappedAttributesImpact(aAttribute, aHint)) {
|
||||
if (nsHTMLAtoms::clear == aAttribute) {
|
||||
aHint = NS_STYLE_HINT_REFLOW;
|
||||
}
|
||||
else {
|
||||
aHint = NS_STYLE_HINT_CONTENT;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBRElement::GetAttributeMappingFunctions(nsMapAttributesFunc& aFontMapFunc,
|
||||
nsMapAttributesFunc& aMapFunc) const
|
||||
{
|
||||
aFontMapFunc = nsnull;
|
||||
aMapFunc = &MapAttributesInto;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBRElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBRElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
||||
{
|
||||
return mInner.SizeOf(aSizer, aResult, sizeof(*this));
|
||||
}
|
||||
195
mozilla/content/html/content/src/nsHTMLBaseElement.cpp
Normal file
195
mozilla/content/html/content/src/nsHTMLBaseElement.cpp
Normal file
@@ -0,0 +1,195 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsIDOMHTMLBaseElement.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIMutableStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLBaseElementIID, NS_IDOMHTMLBASEELEMENT_IID);
|
||||
|
||||
class nsHTMLBaseElement : public nsIDOMHTMLBaseElement,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIHTMLContent
|
||||
{
|
||||
public:
|
||||
nsHTMLBaseElement(nsIAtom* aTag);
|
||||
virtual ~nsHTMLBaseElement();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_IDOMNODE_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMElement
|
||||
NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLElement
|
||||
NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLBaseElement
|
||||
NS_IMETHOD GetHref(nsString& aHref);
|
||||
NS_IMETHOD SetHref(const nsString& aHref);
|
||||
NS_IMETHOD GetTarget(nsString& aTarget);
|
||||
NS_IMETHOD SetTarget(const nsString& aTarget);
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIContent
|
||||
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIHTMLContent
|
||||
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
|
||||
|
||||
protected:
|
||||
nsGenericHTMLLeafElement mInner;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLBaseElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsIHTMLContent* it = new nsHTMLBaseElement(aTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
nsHTMLBaseElement::nsHTMLBaseElement(nsIAtom* aTag)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInner.Init(this, aTag);
|
||||
}
|
||||
|
||||
nsHTMLBaseElement::~nsHTMLBaseElement()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsHTMLBaseElement)
|
||||
|
||||
NS_IMPL_RELEASE(nsHTMLBaseElement)
|
||||
|
||||
nsresult
|
||||
nsHTMLBaseElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this)
|
||||
if (aIID.Equals(kIDOMHTMLBaseElementIID)) {
|
||||
nsIDOMHTMLBaseElement* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLBaseElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsHTMLBaseElement* it = new nsHTMLBaseElement(mInner.mTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mInner.CopyInnerTo(this, &it->mInner, aDeep);
|
||||
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLBaseElement, Href, href)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLBaseElement, Target, target)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBaseElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
return NS_CONTENT_ATTR_NOT_THERE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBaseElement::AttributeToString(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
{
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
static void
|
||||
MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext)
|
||||
{
|
||||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBaseElement::GetMappedAttributeImpact(const nsIAtom* aAttribute,
|
||||
PRInt32& aHint) const
|
||||
{
|
||||
if (! nsGenericHTMLElement::GetCommonMappedAttributesImpact(aAttribute, aHint)) {
|
||||
aHint = NS_STYLE_HINT_CONTENT;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBaseElement::GetAttributeMappingFunctions(nsMapAttributesFunc& aFontMapFunc,
|
||||
nsMapAttributesFunc& aMapFunc) const
|
||||
{
|
||||
aFontMapFunc = nsnull;
|
||||
aMapFunc = &MapAttributesInto;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBaseElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBaseElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
||||
{
|
||||
return mInner.SizeOf(aSizer, aResult, sizeof(*this));
|
||||
}
|
||||
215
mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp
Normal file
215
mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp
Normal file
@@ -0,0 +1,215 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsIDOMHTMLBaseFontElement.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIMutableStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLBaseFontElementIID, NS_IDOMHTMLBASEFONTELEMENT_IID);
|
||||
|
||||
class nsHTMLBaseFontElement : public nsIDOMHTMLBaseFontElement,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIHTMLContent
|
||||
{
|
||||
public:
|
||||
nsHTMLBaseFontElement(nsIAtom* aTag);
|
||||
virtual ~nsHTMLBaseFontElement();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_IDOMNODE_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMElement
|
||||
NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLElement
|
||||
NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLBaseElement
|
||||
NS_IMETHOD GetColor(nsString& aColor);
|
||||
NS_IMETHOD SetColor(const nsString& aColor);
|
||||
NS_IMETHOD GetFace(nsString& aFace);
|
||||
NS_IMETHOD SetFace(const nsString& aFace);
|
||||
NS_IMETHOD GetSize(nsString& aSize);
|
||||
NS_IMETHOD SetSize(const nsString& aSize);
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIContent
|
||||
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIHTMLContent
|
||||
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
|
||||
|
||||
protected:
|
||||
nsGenericHTMLLeafElement mInner;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLBaseFontElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsIHTMLContent* it = new nsHTMLBaseFontElement(aTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
nsHTMLBaseFontElement::nsHTMLBaseFontElement(nsIAtom* aTag)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInner.Init(this, aTag);
|
||||
}
|
||||
|
||||
nsHTMLBaseFontElement::~nsHTMLBaseFontElement()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsHTMLBaseFontElement)
|
||||
|
||||
NS_IMPL_RELEASE(nsHTMLBaseFontElement)
|
||||
|
||||
nsresult
|
||||
nsHTMLBaseFontElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this)
|
||||
if (aIID.Equals(kIDOMHTMLBaseFontElementIID)) {
|
||||
nsIDOMHTMLBaseFontElement* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLBaseFontElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsHTMLBaseFontElement* it = new nsHTMLBaseFontElement(mInner.mTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mInner.CopyInnerTo(this, &it->mInner, aDeep);
|
||||
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLBaseFontElement, Color, color)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLBaseFontElement, Face, face)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLBaseFontElement, Size, size)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBaseFontElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
// XXX write me
|
||||
return NS_CONTENT_ATTR_NOT_THERE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBaseFontElement::AttributeToString(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
{
|
||||
// XXX write me
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
static void
|
||||
MapFontAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext)
|
||||
{
|
||||
// XXX write me
|
||||
}
|
||||
|
||||
static void
|
||||
MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext)
|
||||
{
|
||||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBaseFontElement::GetMappedAttributeImpact(const nsIAtom* aAttribute,
|
||||
PRInt32& aHint) const
|
||||
{
|
||||
if ((nsHTMLAtoms::color == aAttribute) ||
|
||||
(nsHTMLAtoms::face == aAttribute) ||
|
||||
(nsHTMLAtoms::size == aAttribute)) {
|
||||
aHint = NS_STYLE_HINT_RECONSTRUCT_ALL; // XXX this seems a bit harsh, perhaps we need a reflow_all?
|
||||
}
|
||||
else if (! nsGenericHTMLElement::GetCommonMappedAttributesImpact(aAttribute, aHint)) {
|
||||
aHint = NS_STYLE_HINT_CONTENT;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBaseFontElement::GetAttributeMappingFunctions(nsMapAttributesFunc& aFontMapFunc,
|
||||
nsMapAttributesFunc& aMapFunc) const
|
||||
{
|
||||
aFontMapFunc = &MapFontAttributesInto;
|
||||
aMapFunc = &MapAttributesInto;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBaseFontElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBaseFontElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
||||
{
|
||||
return mInner.SizeOf(aSizer, aResult, sizeof(*this));
|
||||
}
|
||||
827
mozilla/content/html/content/src/nsHTMLBodyElement.cpp
Normal file
827
mozilla/content/html/content/src/nsHTMLBodyElement.cpp
Normal file
@@ -0,0 +1,827 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMHTMLBodyElement.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIMutableStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsStyleUtil.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsIHTMLStyleSheet.h"
|
||||
#include "nsIHTMLCSSStyleSheet.h"
|
||||
#include "nsICSSStyleRule.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIMarkupDocumentViewer.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
|
||||
static NS_DEFINE_IID(kICSSStyleRuleIID, NS_ICSS_STYLE_RULE_IID);
|
||||
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLBodyElementIID, NS_IDOMHTMLBODYELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIHTMLContentContainerIID, NS_IHTMLCONTENTCONTAINER_IID);
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class nsHTMLBodyElement;
|
||||
|
||||
class BodyRule: public nsIStyleRule {
|
||||
public:
|
||||
BodyRule(nsHTMLBodyElement* aPart, nsIHTMLStyleSheet* aSheet);
|
||||
virtual ~BodyRule();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Equals(const nsIStyleRule* aRule, PRBool& aResult) const;
|
||||
NS_IMETHOD HashValue(PRUint32& aValue) const;
|
||||
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const;
|
||||
|
||||
// Strength is an out-of-band weighting, always 0 here
|
||||
NS_IMETHOD GetStrength(PRInt32& aStrength) const;
|
||||
|
||||
NS_IMETHOD MapFontStyleInto(nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext);
|
||||
NS_IMETHOD MapStyleInto(nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext);
|
||||
|
||||
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
||||
|
||||
nsHTMLBodyElement* mPart; // not ref-counted, cleared by content
|
||||
nsIHTMLStyleSheet* mSheet; // not ref-counted, cleared by content
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class BodyFixupRule : public nsIStyleRule {
|
||||
public:
|
||||
BodyFixupRule(nsHTMLBodyElement* aPart, nsIHTMLCSSStyleSheet* aSheet);
|
||||
virtual ~BodyFixupRule();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Equals(const nsIStyleRule* aRule, PRBool& aValue) const;
|
||||
NS_IMETHOD HashValue(PRUint32& aValue) const;
|
||||
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const;
|
||||
// Strength is an out-of-band weighting, always maxint here
|
||||
NS_IMETHOD GetStrength(PRInt32& aStrength) const;
|
||||
|
||||
NS_IMETHOD MapFontStyleInto(nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext);
|
||||
NS_IMETHOD MapStyleInto(nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext);
|
||||
|
||||
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
||||
|
||||
nsHTMLBodyElement* mPart; // not ref-counted, cleared by content
|
||||
nsIHTMLCSSStyleSheet* mSheet; // not ref-counted, cleared by content
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// special subclass of inner class to override set document
|
||||
class nsBodyInner: public nsGenericHTMLContainerElement
|
||||
{
|
||||
public:
|
||||
nsBodyInner();
|
||||
virtual ~nsBodyInner();
|
||||
|
||||
nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep);
|
||||
|
||||
BodyRule* mContentStyleRule;
|
||||
BodyFixupRule* mInlineStyleRule;
|
||||
};
|
||||
|
||||
|
||||
nsBodyInner::nsBodyInner()
|
||||
: nsGenericHTMLContainerElement(),
|
||||
mContentStyleRule(nsnull),
|
||||
mInlineStyleRule(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
nsBodyInner::~nsBodyInner()
|
||||
{
|
||||
if (nsnull != mContentStyleRule) {
|
||||
mContentStyleRule->mPart = nsnull;
|
||||
mContentStyleRule->mSheet = nsnull;
|
||||
NS_RELEASE(mContentStyleRule);
|
||||
}
|
||||
if (nsnull != mInlineStyleRule) {
|
||||
mInlineStyleRule->mPart = nsnull;
|
||||
mInlineStyleRule->mSheet = nsnull;
|
||||
NS_RELEASE(mInlineStyleRule);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult nsBodyInner::SetDocument(nsIDocument* aDocument, PRBool aDeep)
|
||||
{
|
||||
if (nsnull != mContentStyleRule) {
|
||||
mContentStyleRule->mPart = nsnull;
|
||||
mContentStyleRule->mSheet = nsnull;
|
||||
NS_RELEASE(mContentStyleRule); // destroy old style rule since the sheet will probably change
|
||||
}
|
||||
if (nsnull != mInlineStyleRule) {
|
||||
mInlineStyleRule->mPart = nsnull;
|
||||
mInlineStyleRule->mSheet = nsnull;
|
||||
NS_RELEASE(mInlineStyleRule); // destroy old style rule since the sheet will probably change
|
||||
}
|
||||
return nsGenericHTMLContainerElement::SetDocument(aDocument, aDeep);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class nsHTMLBodyElement : public nsIDOMHTMLBodyElement,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIHTMLContent
|
||||
{
|
||||
public:
|
||||
nsHTMLBodyElement(nsIAtom* aTag);
|
||||
virtual ~nsHTMLBodyElement();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_IDOMNODE_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMElement
|
||||
NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLElement
|
||||
NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLBodyElement
|
||||
NS_IMETHOD GetALink(nsString& aALink);
|
||||
NS_IMETHOD SetALink(const nsString& aALink);
|
||||
NS_IMETHOD GetBackground(nsString& aBackground);
|
||||
NS_IMETHOD SetBackground(const nsString& aBackground);
|
||||
NS_IMETHOD GetBgColor(nsString& aBgColor);
|
||||
NS_IMETHOD SetBgColor(const nsString& aBgColor);
|
||||
NS_IMETHOD GetLink(nsString& aLink);
|
||||
NS_IMETHOD SetLink(const nsString& aLink);
|
||||
NS_IMETHOD GetText(nsString& aText);
|
||||
NS_IMETHOD SetText(const nsString& aText);
|
||||
NS_IMETHOD GetVLink(nsString& aVLink);
|
||||
NS_IMETHOD SetVLink(const nsString& aVLink);
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIContent
|
||||
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIHTMLContent
|
||||
NS_IMPL_IHTMLCONTENT_USING_GENERIC2(mInner)
|
||||
|
||||
protected:
|
||||
nsBodyInner mInner;
|
||||
|
||||
friend class BodyRule;
|
||||
friend class BodyFixupRule;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
BodyRule::BodyRule(nsHTMLBodyElement* aPart, nsIHTMLStyleSheet* aSheet)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mPart = aPart;
|
||||
mSheet = aSheet;
|
||||
}
|
||||
|
||||
BodyRule::~BodyRule()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(BodyRule, kIStyleRuleIID);
|
||||
|
||||
NS_IMETHODIMP
|
||||
BodyRule::Equals(const nsIStyleRule* aRule, PRBool& aResult) const
|
||||
{
|
||||
aResult = PRBool(this == aRule);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BodyRule::HashValue(PRUint32& aValue) const
|
||||
{
|
||||
aValue = (PRUint32)(mPart);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BodyRule::GetStyleSheet(nsIStyleSheet*& aSheet) const
|
||||
{
|
||||
NS_IF_ADDREF(mSheet);
|
||||
aSheet = mSheet;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Strength is an out-of-band weighting, useful for mapping CSS ! important
|
||||
// always 0 here
|
||||
NS_IMETHODIMP
|
||||
BodyRule::GetStrength(PRInt32& aStrength) const
|
||||
{
|
||||
aStrength = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BodyRule::MapFontStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aPresContext)
|
||||
{
|
||||
// set up the basefont (defaults to 3)
|
||||
nsStyleFont* font = (nsStyleFont*)aContext->GetMutableStyleData(eStyleStruct_Font);
|
||||
PRInt32 scaler;
|
||||
aPresContext->GetFontScaler(&scaler);
|
||||
float scaleFactor = nsStyleUtil::GetScalingFactor(scaler);
|
||||
// apply font scaling to the body
|
||||
font->mFont.size = NSToCoordFloor(float(font->mFont.size) * scaleFactor);
|
||||
if (font->mFont.size < 1) {
|
||||
font->mFont.size = 1;
|
||||
}
|
||||
font->mFixedFont.size = NSToCoordFloor(float(font->mFixedFont.size) * scaleFactor);
|
||||
if (font->mFixedFont.size < 1) {
|
||||
font->mFixedFont.size = 1;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BodyRule::MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aPresContext)
|
||||
{
|
||||
if (nsnull != mPart) {
|
||||
|
||||
nsStyleSpacing* styleSpacing = (nsStyleSpacing*)(aContext->GetMutableStyleData(eStyleStruct_Spacing));
|
||||
|
||||
if (nsnull != styleSpacing) {
|
||||
nsHTMLValue value;
|
||||
PRInt32 attrCount;
|
||||
float p2t;
|
||||
mPart->GetAttributeCount(attrCount);
|
||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
nscoord bodyMarginWidth = -1;
|
||||
nscoord bodyMarginHeight = -1;
|
||||
|
||||
if (0 < attrCount) {
|
||||
// if marginwidth/marginheigth is set reflect them as 'margin'
|
||||
mPart->GetHTMLAttribute(nsHTMLAtoms::marginwidth, value);
|
||||
if (eHTMLUnit_Pixel == value.GetUnit()) {
|
||||
bodyMarginWidth = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
|
||||
if (bodyMarginWidth < 0) {
|
||||
bodyMarginWidth = 0;
|
||||
}
|
||||
nsStyleCoord widthCoord(bodyMarginWidth);
|
||||
styleSpacing->mMargin.SetLeft(widthCoord);
|
||||
styleSpacing->mMargin.SetRight(widthCoord);
|
||||
}
|
||||
|
||||
mPart->GetHTMLAttribute(nsHTMLAtoms::marginheight, value);
|
||||
if (eHTMLUnit_Pixel == value.GetUnit()) {
|
||||
bodyMarginHeight = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
|
||||
if (bodyMarginHeight < 0) {
|
||||
bodyMarginHeight = 0;
|
||||
}
|
||||
|
||||
nsStyleCoord heightCoord(bodyMarginHeight);
|
||||
styleSpacing->mMargin.SetTop(heightCoord);
|
||||
styleSpacing->mMargin.SetBottom(heightCoord);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX This is all pretty hokey...
|
||||
|
||||
// if marginwidth or marginheight is set in the <frame> and not set in the <body>
|
||||
// reflect them as margin in the <body>
|
||||
if ((0 > bodyMarginWidth) || (0 > bodyMarginHeight)) {
|
||||
nsISupports* container;
|
||||
aPresContext->GetContainer(&container);
|
||||
if (nsnull != container) {
|
||||
nsCompatibility mode;
|
||||
aPresContext->GetCompatibilityMode(&mode);
|
||||
nsIWebShell* webShell = nsnull;
|
||||
container->QueryInterface(kIWebShellIID, (void**) &webShell);
|
||||
if (nsnull != webShell) {
|
||||
nscoord pixel = NSIntPixelsToTwips(1, p2t);
|
||||
nscoord frameMarginWidth=-1; // default value
|
||||
nscoord frameMarginHeight=-1; // default value
|
||||
webShell->GetMarginWidth(&frameMarginWidth); // -1 indicates not set
|
||||
webShell->GetMarginHeight(&frameMarginHeight);
|
||||
if ((frameMarginWidth >= 0) && (0 > bodyMarginWidth)) { // set in <frame> & not in <body>
|
||||
if (eCompatibility_NavQuirks == mode) { // allow 0 margins
|
||||
if ((0 > bodyMarginHeight) && (0 > frameMarginHeight)) { // another nav quirk
|
||||
frameMarginHeight = 0;
|
||||
}
|
||||
} else { // margins are at least 1 pixel
|
||||
if (0 == frameMarginWidth) {
|
||||
frameMarginWidth = pixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((frameMarginHeight >= 0) && (0 > bodyMarginHeight)) { // set in <frame> & not in <body>
|
||||
if (eCompatibility_NavQuirks == mode) { // allow 0 margins
|
||||
if ((0 > bodyMarginWidth) && (0 > frameMarginWidth)) { // another nav quirk
|
||||
frameMarginWidth = 0;
|
||||
}
|
||||
} else { // margins are at least 1 pixel
|
||||
if (0 == frameMarginHeight) {
|
||||
frameMarginHeight = pixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((0 > bodyMarginWidth) && (frameMarginWidth >= 0)) {
|
||||
nsStyleCoord widthCoord(frameMarginWidth);
|
||||
styleSpacing->mMargin.SetLeft(widthCoord);
|
||||
styleSpacing->mMargin.SetRight(widthCoord);
|
||||
}
|
||||
|
||||
if ((0 > bodyMarginHeight) && (frameMarginHeight >= 0)) {
|
||||
nsStyleCoord heightCoord(frameMarginHeight);
|
||||
styleSpacing->mMargin.SetTop(heightCoord);
|
||||
styleSpacing->mMargin.SetBottom(heightCoord);
|
||||
}
|
||||
NS_RELEASE(webShell);
|
||||
}
|
||||
NS_RELEASE(container);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BodyRule::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
BodyFixupRule::BodyFixupRule(nsHTMLBodyElement* aPart, nsIHTMLCSSStyleSheet* aSheet)
|
||||
: mPart(aPart),
|
||||
mSheet(aSheet)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
BodyFixupRule::~BodyFixupRule()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(BodyFixupRule);
|
||||
NS_IMPL_RELEASE(BodyFixupRule);
|
||||
|
||||
nsresult BodyFixupRule::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
// static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
if (aIID.Equals(kIStyleRuleIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIStyleRule*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsISupports*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BodyFixupRule::Equals(const nsIStyleRule* aRule, PRBool& aResult) const
|
||||
{
|
||||
aResult = PRBool(this == aRule);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BodyFixupRule::HashValue(PRUint32& aValue) const
|
||||
{
|
||||
aValue = (PRUint32)(mPart);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BodyFixupRule::GetStyleSheet(nsIStyleSheet*& aSheet) const
|
||||
{
|
||||
NS_IF_ADDREF(mSheet);
|
||||
aSheet = mSheet;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Strength is an out-of-band weighting, always MaxInt here
|
||||
NS_IMETHODIMP
|
||||
BodyFixupRule::GetStrength(PRInt32& aStrength) const
|
||||
{
|
||||
aStrength = 2000000000;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BodyFixupRule::MapFontStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aPresContext)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BodyFixupRule::MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aPresContext)
|
||||
{
|
||||
// XXX do any other body processing here
|
||||
|
||||
const nsStyleColor* styleColor;
|
||||
styleColor = (const nsStyleColor*)aContext->GetStyleData(eStyleStruct_Color);
|
||||
|
||||
// Use the CSS precedence rules for dealing with BODY background: if the value
|
||||
// of the 'background' property for the HTML element is different from
|
||||
// 'transparent' then use it, else use the value of the 'background' property
|
||||
// for the BODY element
|
||||
|
||||
// See if the BODY has a background specified
|
||||
if (!styleColor->BackgroundIsTransparent()) {
|
||||
// Get the parent style context
|
||||
nsIStyleContext* parentContext = aContext->GetParent();
|
||||
|
||||
// Look at its 'background' property
|
||||
const nsStyleColor* parentStyleColor;
|
||||
parentStyleColor = (const nsStyleColor*)parentContext->GetStyleData(eStyleStruct_Color);
|
||||
|
||||
// See if it's 'transparent' or set by us
|
||||
if (parentStyleColor->BackgroundIsTransparent() ||
|
||||
(NS_STYLE_BG_PROPOGATED == (parentStyleColor->mBackgroundFlags & NS_STYLE_BG_PROPOGATED))) {
|
||||
// Have the parent (initial containing block) use the BODY's background
|
||||
nsStyleColor* mutableStyleColor;
|
||||
mutableStyleColor = (nsStyleColor*)parentContext->GetMutableStyleData(eStyleStruct_Color);
|
||||
|
||||
mutableStyleColor->mBackgroundAttachment = styleColor->mBackgroundAttachment;
|
||||
mutableStyleColor->mBackgroundFlags = styleColor->mBackgroundFlags | NS_STYLE_BG_PROPOGATED;
|
||||
mutableStyleColor->mBackgroundRepeat = styleColor->mBackgroundRepeat;
|
||||
mutableStyleColor->mBackgroundColor = styleColor->mBackgroundColor;
|
||||
mutableStyleColor->mBackgroundXPosition = styleColor->mBackgroundXPosition;
|
||||
mutableStyleColor->mBackgroundYPosition = styleColor->mBackgroundYPosition;
|
||||
mutableStyleColor->mBackgroundImage = styleColor->mBackgroundImage;
|
||||
|
||||
// Reset the BODY's background to transparent
|
||||
mutableStyleColor = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color);
|
||||
mutableStyleColor->mBackgroundFlags = NS_STYLE_BG_COLOR_TRANSPARENT |
|
||||
NS_STYLE_BG_IMAGE_NONE;
|
||||
mutableStyleColor->mBackgroundImage.SetLength(0);
|
||||
mutableStyleColor->mBackgroundAttachment = NS_STYLE_BG_ATTACHMENT_SCROLL;
|
||||
}
|
||||
NS_RELEASE(parentContext);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||
if (presShell) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
presShell->GetDocument(getter_AddRefs(doc));
|
||||
if (doc) {
|
||||
nsIHTMLContentContainer* htmlContainer;
|
||||
if (NS_OK == doc->QueryInterface(kIHTMLContentContainerIID,
|
||||
(void**)&htmlContainer)) {
|
||||
nsIHTMLStyleSheet* styleSheet;
|
||||
if (NS_OK == htmlContainer->GetAttributeStyleSheet(&styleSheet)) {
|
||||
styleSheet->SetDocumentForegroundColor(styleColor->mColor);
|
||||
if (!(styleColor->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)) {
|
||||
styleSheet->SetDocumentBackgroundColor(styleColor->mBackgroundColor);
|
||||
}
|
||||
NS_RELEASE(styleSheet);
|
||||
}
|
||||
NS_RELEASE(htmlContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BodyFixupRule::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
// Indent
|
||||
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
||||
fputs("Special BODY tag fixup rule\n", out);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLBodyElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsIHTMLContent* it = new nsHTMLBodyElement(aTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
nsHTMLBodyElement::nsHTMLBodyElement(nsIAtom* aTag)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInner.Init(this, aTag);
|
||||
}
|
||||
|
||||
nsHTMLBodyElement::~nsHTMLBodyElement()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsHTMLBodyElement)
|
||||
|
||||
NS_IMPL_RELEASE(nsHTMLBodyElement)
|
||||
|
||||
nsresult
|
||||
nsHTMLBodyElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this)
|
||||
if (aIID.Equals(kIDOMHTMLBodyElementIID)) {
|
||||
nsIDOMHTMLBodyElement* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLBodyElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsHTMLBodyElement* it = new nsHTMLBodyElement(mInner.mTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mInner.CopyInnerTo(this, &it->mInner, aDeep);
|
||||
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLBodyElement, ALink, alink)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLBodyElement, Background, background)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLBodyElement, BgColor, bgcolor)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLBodyElement, Link, link)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLBodyElement, Text, text)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLBodyElement, VLink, vlink)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBodyElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
if ((aAttribute == nsHTMLAtoms::bgcolor) ||
|
||||
(aAttribute == nsHTMLAtoms::text) ||
|
||||
(aAttribute == nsHTMLAtoms::link) ||
|
||||
(aAttribute == nsHTMLAtoms::alink) ||
|
||||
(aAttribute == nsHTMLAtoms::vlink)) {
|
||||
if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
else if ((aAttribute == nsHTMLAtoms::marginwidth) ||
|
||||
(aAttribute == nsHTMLAtoms::marginheight)) {
|
||||
if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
return NS_CONTENT_ATTR_NOT_THERE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBodyElement::AttributeToString(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
{
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
static void
|
||||
MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext)
|
||||
{
|
||||
if (nsnull != aAttributes) {
|
||||
nsHTMLValue value;
|
||||
nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aContext, aPresContext);
|
||||
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::text, value);
|
||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
||||
(eHTMLUnit_ColorName == value.GetUnit())){
|
||||
nsStyleColor* color = (nsStyleColor*)
|
||||
aContext->GetMutableStyleData(eStyleStruct_Color);
|
||||
color->mColor = value.GetColorValue();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||
if (presShell) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
presShell->GetDocument(getter_AddRefs(doc));
|
||||
if (doc) {
|
||||
nsIHTMLContentContainer* htmlContainer;
|
||||
if (NS_OK == doc->QueryInterface(kIHTMLContentContainerIID,
|
||||
(void**)&htmlContainer)) {
|
||||
nsIHTMLStyleSheet* styleSheet;
|
||||
if (NS_OK == htmlContainer->GetAttributeStyleSheet(&styleSheet)) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::link, value);
|
||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
||||
styleSheet->SetLinkColor(value.GetColorValue());
|
||||
}
|
||||
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::alink, value);
|
||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
||||
styleSheet->SetActiveLinkColor(value.GetColorValue());
|
||||
}
|
||||
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::vlink, value);
|
||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
||||
styleSheet->SetVisitedLinkColor(value.GetColorValue());
|
||||
}
|
||||
NS_RELEASE(styleSheet);
|
||||
}
|
||||
NS_RELEASE(htmlContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBodyElement::GetAttributeMappingFunctions(nsMapAttributesFunc& aFontMapFunc,
|
||||
nsMapAttributesFunc& aMapFunc) const
|
||||
{
|
||||
aFontMapFunc = nsnull;
|
||||
aMapFunc = &MapAttributesInto;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBodyElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
||||
|
||||
static nsIHTMLStyleSheet* GetAttrStyleSheet(nsIDocument* aDocument)
|
||||
{
|
||||
nsIHTMLStyleSheet* sheet = nsnull;
|
||||
nsIHTMLContentContainer* htmlContainer;
|
||||
|
||||
if (nsnull != aDocument) {
|
||||
if (NS_OK == aDocument->QueryInterface(kIHTMLContentContainerIID, (void**)&htmlContainer)) {
|
||||
htmlContainer->GetAttributeStyleSheet(&sheet);
|
||||
NS_RELEASE(htmlContainer);
|
||||
}
|
||||
}
|
||||
NS_ASSERTION(nsnull != sheet, "can't get attribute style sheet");
|
||||
return sheet;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBodyElement::GetContentStyleRules(nsISupportsArray* aRules)
|
||||
{
|
||||
mInner.GetContentStyleRules(aRules);
|
||||
|
||||
if (nsnull == mInner.mContentStyleRule) {
|
||||
nsIHTMLStyleSheet* sheet = nsnull;
|
||||
|
||||
if (nsnull != mInner.mDocument) { // find style sheet
|
||||
sheet = GetAttrStyleSheet(mInner.mDocument);
|
||||
}
|
||||
|
||||
mInner.mContentStyleRule = new BodyRule(this, sheet);
|
||||
NS_IF_RELEASE(sheet);
|
||||
NS_IF_ADDREF(mInner.mContentStyleRule);
|
||||
}
|
||||
if (aRules && mInner.mContentStyleRule) {
|
||||
aRules->AppendElement(mInner.mContentStyleRule);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsIHTMLCSSStyleSheet* GetInlineStyleSheet(nsIDocument* aDocument)
|
||||
{
|
||||
nsIHTMLCSSStyleSheet* sheet = nsnull;
|
||||
nsIHTMLContentContainer* htmlContainer;
|
||||
|
||||
if (nsnull != aDocument) {
|
||||
if (NS_OK == aDocument->QueryInterface(kIHTMLContentContainerIID, (void**)&htmlContainer)) {
|
||||
htmlContainer->GetInlineStyleSheet(&sheet);
|
||||
NS_RELEASE(htmlContainer);
|
||||
}
|
||||
}
|
||||
NS_ASSERTION(nsnull != sheet, "can't get inline style sheet");
|
||||
return sheet;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBodyElement::GetInlineStyleRules(nsISupportsArray* aRules)
|
||||
{
|
||||
mInner.GetInlineStyleRules(aRules);
|
||||
|
||||
if (nsnull == mInner.mInlineStyleRule) {
|
||||
nsIHTMLCSSStyleSheet* sheet = nsnull;
|
||||
|
||||
if (nsnull != mInner.mDocument) { // find style sheet
|
||||
sheet = GetInlineStyleSheet(mInner.mDocument);
|
||||
}
|
||||
|
||||
mInner.mInlineStyleRule = new BodyFixupRule(this, sheet);
|
||||
NS_IF_RELEASE(sheet);
|
||||
NS_IF_ADDREF(mInner.mInlineStyleRule);
|
||||
}
|
||||
if (aRules && mInner.mInlineStyleRule) {
|
||||
aRules->AppendElement(mInner.mInlineStyleRule);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBodyElement::GetMappedAttributeImpact(const nsIAtom* aAttribute,
|
||||
PRInt32& aHint) const
|
||||
{
|
||||
if ((aAttribute == nsHTMLAtoms::link) ||
|
||||
(aAttribute == nsHTMLAtoms::vlink) ||
|
||||
(aAttribute == nsHTMLAtoms::alink) ||
|
||||
(aAttribute == nsHTMLAtoms::text)) {
|
||||
aHint = NS_STYLE_HINT_VISUAL;
|
||||
}
|
||||
else if ((aAttribute == nsHTMLAtoms::marginwidth) ||
|
||||
(aAttribute == nsHTMLAtoms::marginheight)) {
|
||||
aHint = NS_STYLE_HINT_REFLOW;
|
||||
}
|
||||
else if (! nsGenericHTMLElement::GetCommonMappedAttributesImpact(aAttribute, aHint)) {
|
||||
if (! nsGenericHTMLElement::GetBackgroundAttributesImpact(aAttribute, aHint)) {
|
||||
aHint = NS_STYLE_HINT_CONTENT;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBodyElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
||||
{
|
||||
return mInner.SizeOf(aSizer, aResult, sizeof(*this));
|
||||
}
|
||||
560
mozilla/content/html/content/src/nsHTMLButtonElement.cpp
Normal file
560
mozilla/content/html/content/src/nsHTMLButtonElement.cpp
Normal file
@@ -0,0 +1,560 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsIDOMHTMLButtonElement.h"
|
||||
#include "nsIDOMNSHTMLButtonElement.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIMutableStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIForm.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIFocusableContent.h"
|
||||
|
||||
#include "nsIFormControlFrame.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsDOMEvent.h"
|
||||
#include "nsISizeOfHandler.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLButtonElementIID, NS_IDOMHTMLBUTTONELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIFocusableContentIID, NS_IFOCUSABLECONTENT_IID);
|
||||
|
||||
class nsHTMLButtonElement : public nsIDOMHTMLButtonElement,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIHTMLContent,
|
||||
public nsIFormControl,
|
||||
public nsIFocusableContent
|
||||
{
|
||||
public:
|
||||
nsHTMLButtonElement(nsIAtom* aTag);
|
||||
virtual ~nsHTMLButtonElement();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_IDOMNODE_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMElement
|
||||
NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLElement
|
||||
NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLButtonElement
|
||||
NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm);
|
||||
NS_IMETHOD GetAccessKey(nsString& aAccessKey);
|
||||
NS_IMETHOD SetAccessKey(const nsString& aAccessKey);
|
||||
NS_IMETHOD GetDisabled(PRBool* aDisabled);
|
||||
NS_IMETHOD SetDisabled(PRBool aDisabled);
|
||||
NS_IMETHOD GetName(nsString& aName);
|
||||
NS_IMETHOD SetName(const nsString& aName);
|
||||
NS_IMETHOD GetTabIndex(PRInt32* aTabIndex);
|
||||
NS_IMETHOD SetTabIndex(PRInt32 aTabIndex);
|
||||
NS_IMETHOD GetType(nsString& aType);
|
||||
NS_IMETHOD GetValue(nsString& aValue);
|
||||
NS_IMETHOD SetValue(const nsString& aValue);
|
||||
|
||||
// nsIDOMHTMLButtonElement
|
||||
NS_IMETHOD Blur();
|
||||
NS_IMETHOD Focus();
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIContent
|
||||
NS_IMPL_ICONTENT_NO_SETPARENT_NO_SETDOCUMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIHTMLContent
|
||||
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIFormControl
|
||||
NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm);
|
||||
NS_IMETHOD GetType(PRInt32* aType);
|
||||
NS_IMETHOD Init() { return NS_OK; }
|
||||
|
||||
// nsIFocusableContent
|
||||
NS_IMETHOD SetFocus(nsIPresContext* aPresContext);
|
||||
NS_IMETHOD RemoveFocus(nsIPresContext* aPresContext);
|
||||
|
||||
protected:
|
||||
nsGenericHTMLContainerElement mInner;
|
||||
nsIForm* mForm;
|
||||
PRInt32 mType;
|
||||
};
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIFormIID, NS_IFORM_IID);
|
||||
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
|
||||
|
||||
// Construction, destruction
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLButtonElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsIHTMLContent* it = new nsHTMLButtonElement(aTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
nsHTMLButtonElement::nsHTMLButtonElement(nsIAtom* aTag)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInner.Init(this, aTag);
|
||||
mForm = nsnull;
|
||||
mType = NS_FORM_BUTTON_BUTTON; // default
|
||||
}
|
||||
|
||||
nsHTMLButtonElement::~nsHTMLButtonElement()
|
||||
{
|
||||
if (nsnull != mForm) {
|
||||
// prevent mForm from decrementing its ref count on us
|
||||
mForm->RemoveElement(this, PR_FALSE);
|
||||
NS_RELEASE(mForm);
|
||||
}
|
||||
}
|
||||
|
||||
// nsISupports
|
||||
|
||||
NS_IMPL_ADDREF(nsHTMLButtonElement);
|
||||
|
||||
nsresult
|
||||
nsHTMLButtonElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this)
|
||||
if (aIID.Equals(kIDOMHTMLButtonElementIID)) {
|
||||
*aInstancePtr = (void*)(nsIDOMHTMLButtonElement*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(kIFormControlIID)) {
|
||||
*aInstancePtr = (void*)(nsIFormControl*) this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(kIFocusableContentIID)) {
|
||||
*aInstancePtr = (void*)(nsIFocusableContent*) this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsHTMLButtonElement::Release()
|
||||
{
|
||||
--mRefCnt;
|
||||
NS_LOG_RELEASE(this, mRefCnt, "nsHTMLButtonElement");
|
||||
if (mRefCnt <= 0) {
|
||||
delete this;
|
||||
return 0;
|
||||
} else if ((1 == mRefCnt) && mForm) {
|
||||
mRefCnt = 0;
|
||||
delete this;
|
||||
return 0;
|
||||
} else {
|
||||
return mRefCnt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// nsIDOMHTMLButtonElement
|
||||
|
||||
nsresult
|
||||
nsHTMLButtonElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsHTMLButtonElement* it = new nsHTMLButtonElement(mInner.mTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mInner.CopyInnerTo(this, &it->mInner, aDeep);
|
||||
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
}
|
||||
|
||||
// nsIContent
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::SetParent(nsIContent* aParent)
|
||||
{
|
||||
return mInner.SetParentForFormControls(aParent, this, mForm);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::SetDocument(nsIDocument* aDocument, PRBool aDeep)
|
||||
{
|
||||
return mInner.SetDocumentForFormControls(aDocument, aDeep, this, mForm);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::GetForm(nsIDOMHTMLFormElement** aForm)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
*aForm = nsnull;
|
||||
if (nsnull != mForm) {
|
||||
nsIDOMHTMLFormElement* formElem = nsnull;
|
||||
result = mForm->QueryInterface(kIDOMHTMLFormElementIID, (void**)&formElem);
|
||||
if (NS_OK == result) {
|
||||
*aForm = formElem;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::GetType(nsString& aType)
|
||||
{
|
||||
aType.SetString("button");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLButtonElement, AccessKey, accesskey)
|
||||
//NS_IMPL_BOOL_ATTR(nsHTMLButtonElement, Disabled, disabled)
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::GetDisabled(PRBool* aValue)
|
||||
{
|
||||
nsHTMLValue val;
|
||||
nsresult rv = mInner.GetHTMLAttribute(nsHTMLAtoms::disabled, val);
|
||||
*aValue = NS_CONTENT_ATTR_NOT_THERE != rv;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::SetDisabled(PRBool aValue)
|
||||
{
|
||||
nsHTMLValue empty(eHTMLUnit_Empty);
|
||||
if (aValue) {
|
||||
nsresult status = mInner.SetHTMLAttribute(nsHTMLAtoms::disabled, empty, PR_TRUE);
|
||||
mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, "DISABLED", PR_TRUE);
|
||||
return status;
|
||||
|
||||
}
|
||||
else {
|
||||
mInner.UnsetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::disabled, PR_TRUE);
|
||||
mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, "", PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLButtonElement, Name, name)
|
||||
NS_IMPL_INT_ATTR(nsHTMLButtonElement, TabIndex, tabindex)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLButtonElement, Value, value)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::Blur()
|
||||
{
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
nsresult rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Ask the frame to Deselect focus (i.e Blur).
|
||||
formControlFrame->SetFocus(PR_FALSE, PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::Focus()
|
||||
{
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
nsresult rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
formControlFrame->SetFocus(PR_TRUE, PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::SetFocus(nsIPresContext* aPresContext)
|
||||
{
|
||||
// first see if we are disabled or not. If disabled then do nothing.
|
||||
nsAutoString disabled;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::disabled, disabled))
|
||||
return NS_OK;
|
||||
|
||||
nsIEventStateManager* esm;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&esm)) {
|
||||
esm->SetContentState(this, NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(esm);
|
||||
}
|
||||
|
||||
Focus();
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
nsresult rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
formControlFrame->ScrollIntoView(aPresContext);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::RemoveFocus(nsIPresContext* aPresContext)
|
||||
{
|
||||
Blur();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsGenericHTMLElement::EnumTable kButtonTypeTable[] = {
|
||||
{ "button", NS_FORM_BUTTON_BUTTON },
|
||||
{ "reset", NS_FORM_BUTTON_RESET },
|
||||
{ "submit", NS_FORM_BUTTON_SUBMIT },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::tabindex) {
|
||||
if (nsGenericHTMLElement::ParseValue(aValue, 0, 32767, aResult,
|
||||
eHTMLUnit_Integer)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::type) {
|
||||
nsGenericHTMLElement::EnumTable *table = kButtonTypeTable;
|
||||
while (nsnull != table->tag) {
|
||||
if (aValue.EqualsIgnoreCase(table->tag)) {
|
||||
aResult.SetIntValue(table->value, eHTMLUnit_Enumerated);
|
||||
mType = table->value;
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
table++;
|
||||
}
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::disabled) {
|
||||
aResult.SetEmptyValue();
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
return NS_CONTENT_ATTR_NOT_THERE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::AttributeToString(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::type) {
|
||||
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
|
||||
nsGenericHTMLElement::EnumValueToString(aValue, kButtonTypeTable, aResult);
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
static void
|
||||
MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext)
|
||||
{
|
||||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::GetMappedAttributeImpact(const nsIAtom* aAttribute,
|
||||
PRInt32& aHint) const
|
||||
{
|
||||
if (! nsGenericHTMLElement::GetCommonMappedAttributesImpact(aAttribute, aHint)) {
|
||||
aHint = NS_STYLE_HINT_CONTENT;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::GetAttributeMappingFunctions(nsMapAttributesFunc& aFontMapFunc,
|
||||
nsMapAttributesFunc& aMapFunc) const
|
||||
{
|
||||
aFontMapFunc = nsnull;
|
||||
aMapFunc = &MapAttributesInto;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
NS_ENSURE_ARG(aPresContext);
|
||||
NS_ENSURE_ARG_POINTER(aEventStatus);
|
||||
|
||||
// Do not process any DOM events if the element is disabled
|
||||
PRBool disabled;
|
||||
nsresult rv = GetDisabled(&disabled);
|
||||
if (NS_FAILED(rv) || disabled) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Try script event handlers first
|
||||
nsresult ret = mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
|
||||
if ((NS_OK == ret) && (nsEventStatus_eIgnore == *aEventStatus) &&
|
||||
!(aFlags & NS_EVENT_FLAG_CAPTURE)) {
|
||||
switch (aEvent->message) {
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_MOUSE_LEFT_BUTTON_UP:
|
||||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
nsIContent *activeLink = nsnull;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&stateManager)) {
|
||||
//stateManager->GetActiveLink(&activeLink);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
|
||||
if (activeLink == this) {
|
||||
if (nsEventStatus_eConsumeNoDefault != *aEventStatus) {
|
||||
nsAutoString href, target, disabled;
|
||||
nsIURI* baseURL = nsnull;
|
||||
GetBaseURL(baseURL);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, href);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::disabled, disabled);
|
||||
|
||||
if (target.Length() == 0) {
|
||||
GetBaseTarget(target);
|
||||
}
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, baseURL, href, target, PR_TRUE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_MOUSE_RIGHT_BUTTON_DOWN:
|
||||
// XXX Bring up a contextual menu provided by the application
|
||||
break;
|
||||
|
||||
case NS_MOUSE_ENTER:
|
||||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_HOVER);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
// XXX this doesn't seem to do anything yet
|
||||
case NS_MOUSE_EXIT:
|
||||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(nsnull, NS_EVENT_STATE_HOVER);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::GetType(PRInt32* aType)
|
||||
{
|
||||
if (aType) {
|
||||
*aType = mType;
|
||||
return NS_OK;
|
||||
} else {
|
||||
return NS_FORM_NOTOK;
|
||||
}
|
||||
}
|
||||
|
||||
// An important assumption is that if aForm is null, the previous mForm will not be released
|
||||
// This allows nsHTMLFormElement to deal with circular references.
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::SetForm(nsIDOMHTMLFormElement* aForm)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
if (nsnull == aForm) {
|
||||
mForm = nsnull;
|
||||
return NS_OK;
|
||||
} else {
|
||||
NS_IF_RELEASE(mForm);
|
||||
nsIFormControl* formControl = nsnull;
|
||||
result = QueryInterface(kIFormControlIID, (void**)&formControl);
|
||||
if ((NS_OK == result) && formControl) {
|
||||
result = aForm->QueryInterface(kIFormIID, (void**)&mForm); // keep the ref
|
||||
if ((NS_OK == result) && mForm) {
|
||||
mForm->AddElement(formControl);
|
||||
}
|
||||
NS_RELEASE(formControl);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
||||
{
|
||||
if (!aResult) return NS_ERROR_NULL_POINTER;
|
||||
#ifdef DEBUG
|
||||
mInner.SizeOf(aSizer, aResult, sizeof(*this));
|
||||
if (mForm) {
|
||||
PRBool recorded;
|
||||
aSizer->RecordObject(mForm, &recorded);
|
||||
if (!recorded) {
|
||||
PRUint32 formSize;
|
||||
mForm->SizeOf(aSizer, &formSize);
|
||||
aSizer->AddSize(nsHTMLAtoms::iform, formSize);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
209
mozilla/content/html/content/src/nsHTMLDListElement.cpp
Normal file
209
mozilla/content/html/content/src/nsHTMLDListElement.cpp
Normal file
@@ -0,0 +1,209 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsIDOMHTMLDListElement.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIMutableStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLDListElementIID, NS_IDOMHTMLDLISTELEMENT_IID);
|
||||
|
||||
class nsHTMLDListElement : public nsIDOMHTMLDListElement,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIHTMLContent
|
||||
{
|
||||
public:
|
||||
nsHTMLDListElement(nsIAtom* aTag);
|
||||
virtual ~nsHTMLDListElement();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_IDOMNODE_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMElement
|
||||
NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLElement
|
||||
NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLDListElement
|
||||
NS_IMETHOD GetCompact(PRBool* aCompact);
|
||||
NS_IMETHOD SetCompact(PRBool aCompact);
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIContent
|
||||
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIHTMLContent
|
||||
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
|
||||
|
||||
protected:
|
||||
nsGenericHTMLContainerElement mInner;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLDListElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsIHTMLContent* it = new nsHTMLDListElement(aTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
nsHTMLDListElement::nsHTMLDListElement(nsIAtom* aTag)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInner.Init(this, aTag);
|
||||
}
|
||||
|
||||
nsHTMLDListElement::~nsHTMLDListElement()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsHTMLDListElement)
|
||||
|
||||
NS_IMPL_RELEASE(nsHTMLDListElement)
|
||||
|
||||
nsresult
|
||||
nsHTMLDListElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this)
|
||||
if (aIID.Equals(kIDOMHTMLDListElementIID)) {
|
||||
nsIDOMHTMLDListElement* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLDListElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsHTMLDListElement* it = new nsHTMLDListElement(mInner.mTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mInner.CopyInnerTo(this, &it->mInner, aDeep);
|
||||
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
}
|
||||
|
||||
NS_IMPL_BOOL_ATTR(nsHTMLDListElement, Compact, compact)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDListElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::compact) {
|
||||
aResult.SetEmptyValue();
|
||||
return NS_CONTENT_ATTR_NO_VALUE;
|
||||
}
|
||||
return NS_CONTENT_ATTR_NOT_THERE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDListElement::AttributeToString(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
{
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
static void
|
||||
MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext)
|
||||
{
|
||||
if (nsnull != aAttributes) {
|
||||
nsHTMLValue value;
|
||||
// compact: empty
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::compact, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Empty) {
|
||||
// XXX set
|
||||
}
|
||||
}
|
||||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDListElement::GetMappedAttributeImpact(const nsIAtom* aAttribute,
|
||||
PRInt32& aHint) const
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::compact) {
|
||||
aHint = NS_STYLE_HINT_CONTENT; // handled by ua.css?
|
||||
}
|
||||
else if (! nsGenericHTMLElement::GetCommonMappedAttributesImpact(aAttribute, aHint)) {
|
||||
aHint = NS_STYLE_HINT_CONTENT;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDListElement::GetAttributeMappingFunctions(nsMapAttributesFunc& aFontMapFunc,
|
||||
nsMapAttributesFunc& aMapFunc) const
|
||||
{
|
||||
aFontMapFunc = nsnull;
|
||||
aMapFunc = &MapAttributesInto;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDListElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDListElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
||||
{
|
||||
return mInner.SizeOf(aSizer, aResult, sizeof(*this));
|
||||
}
|
||||
199
mozilla/content/html/content/src/nsHTMLDelElement.cpp
Normal file
199
mozilla/content/html/content/src/nsHTMLDelElement.cpp
Normal file
@@ -0,0 +1,199 @@
|
||||
/* -*- 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.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/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsIDOMHTMLModElement.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIMutableStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLModElementIID, NS_IDOMHTMLMODELEMENT_IID);
|
||||
|
||||
class nsHTMLDelElement : public nsIDOMHTMLModElement,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIHTMLContent
|
||||
{
|
||||
public:
|
||||
nsHTMLDelElement(nsIAtom* aTag);
|
||||
virtual ~nsHTMLDelElement();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_IDOMNODE_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMElement
|
||||
NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLElement
|
||||
NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMHTMLModElement
|
||||
NS_IMETHOD GetCite(nsString& aCite);
|
||||
NS_IMETHOD SetCite(const nsString& aCite);
|
||||
NS_IMETHOD GetDateTime(nsString& aDateTime);
|
||||
NS_IMETHOD SetDateTime(const nsString& aDateTime);
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIContent
|
||||
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIHTMLContent
|
||||
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
|
||||
|
||||
protected:
|
||||
nsGenericHTMLContainerElement mInner;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLDelElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsIHTMLContent* it = new nsHTMLDelElement(aTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
nsHTMLDelElement::nsHTMLDelElement(nsIAtom* aTag)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInner.Init(this, aTag);
|
||||
}
|
||||
|
||||
nsHTMLDelElement::~nsHTMLDelElement()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsHTMLDelElement)
|
||||
|
||||
NS_IMPL_RELEASE(nsHTMLDelElement)
|
||||
|
||||
nsresult
|
||||
nsHTMLDelElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this)
|
||||
if (aIID.Equals(kIDOMHTMLModElementIID)) {
|
||||
nsIDOMHTMLModElement* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLDelElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsHTMLDelElement* it = new nsHTMLDelElement(mInner.mTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mInner.CopyInnerTo(this, &it->mInner, aDeep);
|
||||
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLDelElement, Cite, cite)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLDelElement, DateTime, datetime)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDelElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
// XXX write me
|
||||
return NS_CONTENT_ATTR_NOT_THERE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDelElement::AttributeToString(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
{
|
||||
// XXX write me
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
static void
|
||||
MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext)
|
||||
{
|
||||
// XXX write me
|
||||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDelElement::GetMappedAttributeImpact(const nsIAtom* aAttribute,
|
||||
PRInt32& aHint) const
|
||||
{
|
||||
if (! nsGenericHTMLElement::GetCommonMappedAttributesImpact(aAttribute, aHint)) {
|
||||
aHint = NS_STYLE_HINT_CONTENT;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDelElement::GetAttributeMappingFunctions(nsMapAttributesFunc& aFontMapFunc,
|
||||
nsMapAttributesFunc& aMapFunc) const
|
||||
{
|
||||
aFontMapFunc = nsnull;
|
||||
aMapFunc = &MapAttributesInto;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDelElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDelElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
||||
{
|
||||
return mInner.SizeOf(aSizer, aResult, sizeof(*this));
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user