Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
nsXPathResult Class Reference

A class for evaluating an XPath expression string. More...

#include <nsXPathResult.h>

Inheritance diagram for nsXPathResult:
Inheritance graph
[legend]
Collaboration diagram for nsXPathResult:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsXPathResult ()
virtual ~nsXPathResult ()
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMXPATHRESULT
NS_DECL_NSIDOCUMENTOBSERVER
nsresult 
SetExprResult (txAExprResult *aExprResult, PRUint16 aResultType)
nsresult GetExprResult (txAExprResult **aExprResult)
nsresult Clone (nsIXPathResult **aResult)
nsIDOMNode iterateNext () raises (XPathException, DOMException)
nsIDOMNode snapshotItem (in unsigned long index) raises (XPathException)
virtual void BeginUpdate (nsIDocument *aDocument, nsUpdateType aUpdateType)=0
 Notify that a content model update is beginning.
virtual void EndUpdate (nsIDocument *aDocument, nsUpdateType aUpdateType)=0
 Notify that a content model update is finished.
virtual void BeginLoad (nsIDocument *aDocument)=0
 Notify the observer that a document load is beginning.
virtual void EndLoad (nsIDocument *aDocument)=0
 Notify the observer that a document load has finished.
virtual void BeginReflow (nsIDocument *aDocument, nsIPresShell *aShell)=0
 Notify the observer that the document is being reflowed in the given presentation shell.
virtual void EndReflow (nsIDocument *aDocument, nsIPresShell *aShell)=0
 Notify the observer that the document is done being reflowed in the given presentation shell.
virtual void CharacterDataChanged (nsIDocument *aDocument, nsIContent *aContent, PRBool aAppend)=0
 Notification that the content model has changed.
virtual void ContentStatesChanged (nsIDocument *aDocument, nsIContent *aContent1, nsIContent *aContent2, PRInt32 aStateMask)=0
 Notification that the state of a content node has changed.
virtual void AttributeChanged (nsIDocument *aDocument, nsIContent *aContent, PRInt32 aNameSpaceID, nsIAtom *aAttribute, PRInt32 aModType)=0
 Notification that the content model has changed.
virtual void ContentAppended (nsIDocument *aDocument, nsIContent *aContainer, PRInt32 aNewIndexInContainer)=0
 Notifcation that the content model has had data appended to the given content object.
virtual void ContentInserted (nsIDocument *aDocument, nsIContent *aContainer, nsIContent *aChild, PRInt32 aIndexInContainer)=0
 Notification that content has been inserted.
virtual void ContentRemoved (nsIDocument *aDocument, nsIContent *aContainer, nsIContent *aChild, PRInt32 aIndexInContainer)=0
 Content has just been removed.
virtual void StyleSheetAdded (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, PRBool aDocumentSheet)=0
 A StyleSheet has just been added to the document.
virtual void StyleSheetRemoved (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, PRBool aDocumentSheet)=0
 A StyleSheet has just been removed from the document.
virtual void StyleSheetApplicableStateChanged (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, PRBool aApplicable)=0
 A StyleSheet has just changed its applicable state.
virtual void StyleRuleChanged (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, nsIStyleRule *aOldStyleRule, nsIStyleRule *aNewStyleRule)=0
 A StyleRule has just been modified within a style sheet.
virtual void StyleRuleAdded (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, nsIStyleRule *aStyleRule)=0
 A StyleRule has just been added to a style sheet.
virtual void StyleRuleRemoved (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, nsIStyleRule *aStyleRule)=0
 A StyleRule has just been removed from a style sheet.
virtual void DocumentWillBeDestroyed (nsIDocument *aDocument)=0
 The document is in the process of being destroyed.

Public Attributes

const unsigned short ANY_TYPE = 0
const unsigned short NUMBER_TYPE = 1
const unsigned short STRING_TYPE = 2
const unsigned short BOOLEAN_TYPE = 3
const unsigned short UNORDERED_NODE_ITERATOR_TYPE = 4
const unsigned short ORDERED_NODE_ITERATOR_TYPE = 5
const unsigned short UNORDERED_NODE_SNAPSHOT_TYPE = 6
const unsigned short ORDERED_NODE_SNAPSHOT_TYPE = 7
const unsigned short ANY_UNORDERED_NODE_TYPE = 8
const unsigned short FIRST_ORDERED_NODE_TYPE = 9
readonly attribute unsigned short resultType
readonly attribute double numberValue
readonly attribute DOMString stringValue
readonly attribute boolean booleanValue
readonly attribute nsIDOMNode singleNodeValue
readonly attribute boolean invalidIteratorState
readonly attribute unsigned long snapshotLength

Private Member Functions

PRBool isSnapshot () const
PRBool isIterator () const
PRBool isNode () const
void Invalidate ()

Private Attributes

txResultHolder mResult
nsCOMPtr< nsIDocumentmDocument
PRUint32 mCurrentPos
PRUint16 mResultType
PRPackedBool mInvalidIteratorState

Detailed Description

A class for evaluating an XPath expression string.

Definition at line 90 of file nsXPathResult.h.


Constructor & Destructor Documentation

Definition at line 50 of file nsXPathResult.cpp.

Here is the caller graph for this function:

Definition at line 57 of file nsXPathResult.cpp.

{
    if (mDocument) {
        mDocument->RemoveObserver(this);
    }
}

Member Function Documentation

virtual void nsIDocumentObserver::AttributeChanged ( nsIDocument aDocument,
nsIContent aContent,
PRInt32  aNameSpaceID,
nsIAtom aAttribute,
PRInt32  aModType 
) [pure virtual, inherited]

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.

Parameters:
aDocumentThe document being observed
aContentthe piece of content whose attribute changed
aAttributethe atom name of the attribute
aModTypeWhether or not the attribute was added, changed, or removed. The constants are defined in nsIDOMMutationEvent.h.

Implemented in PresShell, nsContentList, nsXULContentBuilder, nsXULTemplateBuilder, nsImageMap, nsTreeContentView, and nsXMLPrettyPrinter.

virtual void nsIDocumentObserver::BeginLoad ( nsIDocument aDocument) [pure virtual, inherited]

Notify the observer that a document load is beginning.

Implemented in PresShell.

virtual void nsIDocumentObserver::BeginReflow ( nsIDocument aDocument,
nsIPresShell aShell 
) [pure virtual, inherited]

Notify the observer that the document is being reflowed in the given presentation shell.

virtual void nsIDocumentObserver::BeginUpdate ( nsIDocument aDocument,
nsUpdateType  aUpdateType 
) [pure virtual, inherited]

Notify that a content model update is beginning.

This call can be nested.

Implemented in nsFragmentObserver, PresShell, HTMLContentSink, and nsXMLPrettyPrinter.

virtual void nsIDocumentObserver::CharacterDataChanged ( nsIDocument aDocument,
nsIContent aContent,
PRBool  aAppend 
) [pure virtual, inherited]

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.

This notification is not sent when a piece of content is added/removed from the document (the other notifications are used for that).

Parameters:
aDocumentThe document being observed
aContentthe piece of content that changed
aAppendWhether the change was an append

Implemented in PresShell.

nsresult nsXPathResult::Clone ( nsIXPathResult **  aResult) [virtual]

Implements nsIXPathResult.

Definition at line 327 of file nsXPathResult.cpp.

{
    *aResult = nsnull;

    if (isIterator() && mInvalidIteratorState) {
        return NS_ERROR_DOM_INVALID_STATE_ERR;
    }

    nsCOMPtr<nsIXPathResult> result = new nsXPathResult();
    if (!result) {
        return NS_ERROR_OUT_OF_MEMORY;
    }

    nsresult rv = result->SetExprResult(mResult.get(), mResultType);
    NS_ENSURE_SUCCESS(rv, rv);

    result.swap(*aResult);

    return NS_OK;
}

Here is the call graph for this function:

virtual void nsIDocumentObserver::ContentAppended ( nsIDocument aDocument,
nsIContent aContainer,
PRInt32  aNewIndexInContainer 
) [pure virtual, inherited]

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.

Parameters:
aDocumentThe document being observed
aContainerthe container that had a new child appended
aNewIndexInContainerthe index in the container of the first new child

Implemented in PresShell, nsContentList, nsBindingManager, nsImageMap, nsTreeContentView, and nsXMLPrettyPrinter.

virtual void nsIDocumentObserver::ContentInserted ( nsIDocument aDocument,
nsIContent aContainer,
nsIContent aChild,
PRInt32  aIndexInContainer 
) [pure virtual, inherited]

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.

Parameters:
aDocumentThe document being observed
aContainerthe container that now contains aChild
aChildthe child that was inserted
aIndexInContainerthe index of the child in the container

Implemented in PresShell, nsContentList, nsBindingManager, nsImageMap, nsTreeContentView, and nsXMLPrettyPrinter.

virtual void nsIDocumentObserver::ContentRemoved ( nsIDocument aDocument,
nsIContent aContainer,
nsIContent aChild,
PRInt32  aIndexInContainer 
) [pure virtual, inherited]

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.

Parameters:
aDocumentThe document being observed
aContainerthe container that had a child removed
aChildthe child that was just removed
aIndexInContainerthe index of the child in the container before it was removed

Implemented in PresShell, nsContentList, nsBindingManager, nsImageMap, nsTreeContentView, and nsXMLPrettyPrinter.

virtual void nsIDocumentObserver::ContentStatesChanged ( nsIDocument aDocument,
nsIContent aContent1,
nsIContent aContent2,
PRInt32  aStateMask 
) [pure virtual, inherited]

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.

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

Parameters:
aDocumentThe document being observed
aContent1the piece of content that changed
aContent2optional second piece of content that changed

Implemented in PresShell, and nsTreeContentView.

virtual void nsIDocumentObserver::DocumentWillBeDestroyed ( nsIDocument aDocument) [pure virtual, inherited]

The document is in the process of being destroyed.

This method is called automatically during document destruction.

Parameters:
aDocumentThe document being observed

Implemented in nsFragmentObserver, nsDOMStyleSheetList, nsContentList, nsBindingManager, nsXULContentBuilder, nsXULTreeBuilder, nsXULTemplateBuilder, nsTreeContentView, and nsXMLPrettyPrinter.

virtual void nsIDocumentObserver::EndLoad ( nsIDocument aDocument) [pure virtual, inherited]

Notify the observer that a document load has finished.

Note that the associated reflow of the document will be done before EndLoad is invoked, not after.

Implemented in PresShell.

virtual void nsIDocumentObserver::EndReflow ( nsIDocument aDocument,
nsIPresShell aShell 
) [pure virtual, inherited]

Notify the observer that the document is done being reflowed in the given presentation shell.

virtual void nsIDocumentObserver::EndUpdate ( nsIDocument aDocument,
nsUpdateType  aUpdateType 
) [pure virtual, inherited]

Notify that a content model update is finished.

This call can be nested.

Implemented in PresShell, HTMLContentSink, and nsXMLPrettyPrinter.

nsresult nsXPathResult::GetExprResult ( txAExprResult **  aExprResult) [virtual]

Implements nsIXPathResult.

Definition at line 310 of file nsXPathResult.cpp.

{
    if (isIterator() && mInvalidIteratorState) {
        return NS_ERROR_DOM_INVALID_STATE_ERR;
    }

    *aExprResult = mResult.get();
    if (!*aExprResult) {
        return NS_ERROR_DOM_INVALID_STATE_ERR;
    }

    NS_ADDREF(*aExprResult);

    return NS_OK;
}

Here is the call graph for this function:

Definition at line 300 of file nsXPathResult.cpp.

{
    if (mDocument) {
        mDocument->RemoveObserver(this);
        mDocument = nsnull;
    }
    mInvalidIteratorState = PR_TRUE;
}
PRBool nsXPathResult::isIterator ( ) const [inline, private]

Definition at line 118 of file nsXPathResult.h.

Here is the caller graph for this function:

PRBool nsXPathResult::isNode ( ) const [inline, private]

Definition at line 123 of file nsXPathResult.h.

Here is the caller graph for this function:

PRBool nsXPathResult::isSnapshot ( ) const [inline, private]

Definition at line 113 of file nsXPathResult.h.

Here is the caller graph for this function:

nsIDOMNode nsIDOMXPathResult::iterateNext ( ) raises (XPathException, DOMException) [inherited]
nsresult nsXPathResult::SetExprResult ( txAExprResult aExprResult,
PRUint16  aResultType 
) [virtual]

Implements nsIXPathResult.

Definition at line 250 of file nsXPathResult.cpp.

{
    mResultType = aResultType;

    if ((isSnapshot() || isIterator() || isNode()) &&
        aExprResult->getResultType() != txAExprResult::NODESET) {
        return NS_ERROR_DOM_TYPE_ERR;
    }

    if (mDocument) {
        mDocument->RemoveObserver(this);
        mDocument = nsnull;
    }
 
    mResult.set(aExprResult);

    if (!isIterator()) {
        return NS_OK;
    }

    mInvalidIteratorState = PR_FALSE;

    txNodeSet* nodeSet = NS_STATIC_CAST(txNodeSet*, aExprResult);
    nsCOMPtr<nsIDOMNode> node;
    if (nodeSet->size() > 0) {
        nsresult rv = txXPathNativeNode::getNode(nodeSet->get(0),
                                                 getter_AddRefs(node));
        NS_ENSURE_SUCCESS(rv, rv);

        // If we support the document() function in DOM-XPath we need to
        // observe all documents that we have resultnodes in.
        nsCOMPtr<nsIDOMDocument> document;
        node->GetOwnerDocument(getter_AddRefs(document));
        if (document) {
            mDocument = do_QueryInterface(document);
        }
        else {
            mDocument = do_QueryInterface(node);
        }

        NS_ASSERTION(mDocument, "We need a document!");
        if (mDocument) {
            mDocument->AddObserver(this);
        }
    }

    return NS_OK;
}

Here is the call graph for this function:

nsIDOMNode nsIDOMXPathResult::snapshotItem ( in unsigned long  index) raises (XPathException) [inherited]
virtual void nsIDocumentObserver::StyleRuleAdded ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
nsIStyleRule aStyleRule 
) [pure virtual, inherited]

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.

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that has been modified
aStyleRulethe rule that was added

Implemented in PresShell.

virtual void nsIDocumentObserver::StyleRuleChanged ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
nsIStyleRule aOldStyleRule,
nsIStyleRule aNewStyleRule 
) [pure virtual, inherited]

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.

Since nsIStyleRule objects are immutable, there is a new object replacing the old one. However, the use of this method (rather than StyleRuleAdded and StyleRuleRemoved) implies that the new rule matches the same elements and has the same priority (weight, origin, specificity) as the old one. (However, if it is a CSS style rule, there may be a change in whether it has an important rule.)

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that contians the rule
aOldStyleRuleThe rule being removed. This rule may not be fully valid anymore -- however, it can still be used for pointer comparison and |QueryInterface|.
aNewStyleRuleThe rule being added.

Implemented in PresShell.

virtual void nsIDocumentObserver::StyleRuleRemoved ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
nsIStyleRule aStyleRule 
) [pure virtual, inherited]

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.

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that has been modified
aStyleRulethe rule that was removed

Implemented in PresShell.

virtual void nsIDocumentObserver::StyleSheetAdded ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
PRBool  aDocumentSheet 
) [pure virtual, inherited]

A StyleSheet has just been added to the document.

This method is called automatically when a StyleSheet gets added to the document, even if the stylesheet is not applicable. The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that has been added
aDocumentSheetTrue if sheet is in document's style sheet list, false if sheet is not (i.e., UA or user sheet)

Implemented in PresShell, and nsDOMStyleSheetList.

virtual void nsIDocumentObserver::StyleSheetApplicableStateChanged ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
PRBool  aApplicable 
) [pure virtual, inherited]

A StyleSheet has just changed its applicable state.

This method is called automatically when the applicable 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.

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that has changed state
aApplicablePR_TRUE if the sheet is applicable, PR_FALSE if it is not applicable

Implemented in PresShell.

virtual void nsIDocumentObserver::StyleSheetRemoved ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
PRBool  aDocumentSheet 
) [pure virtual, inherited]

A StyleSheet has just been removed from the document.

This method is called automatically when a StyleSheet gets removed from the document, even if the stylesheet is not applicable. The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that has been removed
aDocumentSheetTrue if sheet is in document's style sheet list, false if sheet is not (i.e., UA or user sheet)

Implemented in PresShell, and nsDOMStyleSheetList.


Member Data Documentation

const unsigned short nsIDOMXPathResult::ANY_TYPE = 0 [inherited]

Definition at line 51 of file nsIDOMXPathResult.idl.

const unsigned short nsIDOMXPathResult::ANY_UNORDERED_NODE_TYPE = 8 [inherited]

Definition at line 59 of file nsIDOMXPathResult.idl.

const unsigned short nsIDOMXPathResult::BOOLEAN_TYPE = 3 [inherited]

Definition at line 54 of file nsIDOMXPathResult.idl.

Definition at line 69 of file nsIDOMXPathResult.idl.

const unsigned short nsIDOMXPathResult::FIRST_ORDERED_NODE_TYPE = 9 [inherited]

Definition at line 60 of file nsIDOMXPathResult.idl.

Definition at line 75 of file nsIDOMXPathResult.idl.

Definition at line 133 of file nsXPathResult.h.

Definition at line 132 of file nsXPathResult.h.

Definition at line 135 of file nsXPathResult.h.

Definition at line 131 of file nsXPathResult.h.

Definition at line 134 of file nsXPathResult.h.

const unsigned short nsIDOMXPathResult::NUMBER_TYPE = 1 [inherited]

Definition at line 52 of file nsIDOMXPathResult.idl.

readonly attribute double nsIDOMXPathResult::numberValue [inherited]

Definition at line 63 of file nsIDOMXPathResult.idl.

const unsigned short nsIDOMXPathResult::ORDERED_NODE_ITERATOR_TYPE = 5 [inherited]

Definition at line 56 of file nsIDOMXPathResult.idl.

const unsigned short nsIDOMXPathResult::ORDERED_NODE_SNAPSHOT_TYPE = 7 [inherited]

Definition at line 58 of file nsIDOMXPathResult.idl.

readonly attribute unsigned short nsIDOMXPathResult::resultType [inherited]

Definition at line 62 of file nsIDOMXPathResult.idl.

Definition at line 72 of file nsIDOMXPathResult.idl.

readonly attribute unsigned long nsIDOMXPathResult::snapshotLength [inherited]

Definition at line 76 of file nsIDOMXPathResult.idl.

const unsigned short nsIDOMXPathResult::STRING_TYPE = 2 [inherited]

Definition at line 53 of file nsIDOMXPathResult.idl.

readonly attribute DOMString nsIDOMXPathResult::stringValue [inherited]

Definition at line 66 of file nsIDOMXPathResult.idl.

Definition at line 55 of file nsIDOMXPathResult.idl.

Definition at line 57 of file nsIDOMXPathResult.idl.


The documentation for this class was generated from the following files: