Public Types | Static Public Member Functions

nsContentUtils Class Reference

#include <nsContentUtils.h>

Collaboration diagram for nsContentUtils:

List of all members.

Public Types

enum  PropertiesFile {
  eCSS_PROPERTIES, eXBL_PROPERTIES, eXUL_PROPERTIES, eLAYOUT_PROPERTIES,
  eFORMS_PROPERTIES, ePRINTING_PROPERTIES, eDOM_PROPERTIES, eBRAND_PROPERTIES,
  eCOMMON_DIALOG_PROPERTIES, PropertiesFile_COUNT
}
 

Report a localized error message to the error console.

More...

Static Public Member Functions

static nsresult Init ()
static nsresult ReparentContentWrapper (nsIContent *aNode, nsIContent *aNewParent, nsIDocument *aNewDocument, nsIDocument *aOldDocument)
static nsresult GetContextAndScopes (nsIDocument *aOldDocument, nsIDocument *aNewDocument, JSContext **aCx, JSObject **aOldScope, JSObject **aNewScope)
 Get a scope from aOldDocument and one from aNewDocument.
static nsresult ReparentContentWrappersInScope (nsIScriptGlobalObject *aOldScope, nsIScriptGlobalObject *aNewScope)
 When a document's scope changes (e.g., from document.open(), call this function to move all content wrappers from the old scope to the new one.
static PRBool IsCallerChrome ()
static PRBool IsCallerTrustedForRead ()
static PRBool IsCallerTrustedForWrite ()
static PRBool IsCallerTrustedForCapability (const char *aCapability)
 Check whether a caller is trusted to have aCapability.
static PRBool ContentIsDescendantOf (nsINode *aPossibleDescendant, nsINode *aPossibleAncestor)
 Do not ever pass null pointers to this method.
static PRBool ContentIsCrossDocDescendantOf (nsINode *aPossibleDescendant, nsINode *aPossibleAncestor)
 Similar to ContentIsDescendantOf except it crosses document boundaries.
static nsresult GetAncestors (nsIDOMNode *aNode, nsTArray< nsIDOMNode * > *aArray)
static nsresult GetAncestorsAndOffsets (nsIDOMNode *aNode, PRInt32 aOffset, nsTArray< nsIContent * > *aAncestorNodes, nsTArray< PRInt32 > *aAncestorOffsets)
static nsresult GetCommonAncestor (nsIDOMNode *aNode, nsIDOMNode *aOther, nsIDOMNode **aCommonAncestor)
static nsINode * GetCommonAncestor (nsINode *aNode1, nsINode *aNode2)
 Returns the common ancestor, if any, for two nodes.
static PRUint16 ComparePosition (nsINode *aNode1, nsINode *aNode2)
 Compares the document position of nodes.
static PRBool PositionIsBefore (nsINode *aNode1, nsINode *aNode2)
 Returns true if aNode1 is before aNode2 in the same connected tree.
static PRInt32 ComparePoints (nsINode *aParent1, PRInt32 aOffset1, nsINode *aParent2, PRInt32 aOffset2, PRBool *aDisconnected=0)
 Utility routine to compare two "points", where a point is a node/offset pair Returns -1 if point1 < point2, 1, if point1 > point2, 0 if error or if point1 == point2.
static nsIContent * FindFirstChildWithResolvedTag (nsIContent *aParent, PRInt32 aNamespace, nsIAtom *aTag)
 Find the first child of aParent with a resolved tag matching aNamespace and aTag.
static nsIContent * MatchElementId (nsIContent *aContent, const nsAString &aId)
 Brute-force search of the element subtree rooted at aContent for an element with the given id.
static nsIContent * MatchElementId (nsIContent *aContent, nsIAtom *aId)
 Similar to above, but to be used if one already has an atom for the ID.
static nsIContent * GetReferencedElement (nsIURI *aURI, nsIContent *aFromContent)
 Given a URI containing an element reference (whatever), resolve it to the target content element with the given ID.
static PRUint16 ReverseDocumentPosition (PRUint16 aDocumentPosition)
 Reverses the document position flags passed in.
static PRUint32 CopyNewlineNormalizedUnicodeTo (const nsAString &aSource, PRUint32 aSrcOffset, PRUnichar *aDest, PRUint32 aLength, PRBool &aLastCharCR)
static PRUint32 CopyNewlineNormalizedUnicodeTo (nsReadingIterator< PRUnichar > &aSrcStart, const nsReadingIterator< PRUnichar > &aSrcEnd, nsAString &aDest)
static nsISupportsGetClassInfoInstance (nsDOMClassInfoID aID)
static const
nsDependentSubstring_external 
TrimCharsInSet (const char *aSet, const nsAString &aValue)
static const
nsDependentSubstring_external 
TrimWhitespace (const nsAString &aStr, PRBool aTrimTrailing=1)
static PRBool IsPunctuationMark (PRUint32 aChar)
 Returns true if aChar is of class Ps, Pi, Po, Pf, or Pe.
static PRBool IsPunctuationMarkAt (const nsTextFragment *aFrag, PRUint32 aOffset)
static PRBool IsAlphanumeric (PRUint32 aChar)
 Returns true if aChar is of class Lu, Ll, Lt, Lm, Lo, Nd, Nl or No.
static PRBool IsAlphanumericAt (const nsTextFragment *aFrag, PRUint32 aOffset)
static PRBool IsHTMLWhitespace (PRUnichar aChar)
static void Shutdown ()
static nsresult CheckSameOrigin (nsIDOMNode *aTrustedNode, nsIDOMNode *aUnTrustedNode)
 Checks whether two nodes come from the same origin.
static PRBool CanCallerAccess (nsIDOMNode *aNode)
static PRBool CanCallerAccess (nsPIDOMWindow *aWindow)
static nsIDocShellGetDocShellFromCaller ()
 Get the docshell through the JS context that's currently on the stack.
static nsIDOMDocumentGetDocumentFromCaller ()
 The two GetDocumentFrom* functions below allow a caller to get at a document that is relevant to the currently executing script.
static nsIDOMDocumentGetDocumentFromContext ()
 Get the document through the JS context that's currently on the stack.
static PRBool InProlog (nsINode *aNode)
static nsIParserService * GetParserService ()
static nsINameSpaceManager * NameSpaceManager ()
static nsIIOServiceGetIOService ()
static imgILoaderGetImgLoader ()
static nsIScriptSecurityManagerGetSecurityManager ()
 Get the cache security manager service.
static nsresult GenerateStateKey (nsIContent *aContent, nsIDocument *aDocument, nsIStatefulFrame::SpecialStateID aID, nsACString &aKey)
static nsresult NewURIWithDocumentCharset (nsIURI **aResult, const nsAString &aSpec, nsIDocument *aDocument, nsIURI *aBaseURI)
 Create a new nsIURI from aSpec, using aBaseURI as the base.
static nsresult ConvertStringFromCharset (const nsACString &aCharset, const nsACString &aInput, nsAString &aOutput)
 Convert aInput (in charset aCharset) to UTF16 in aOutput.
static PRBool CheckForBOM (const unsigned char *aBuffer, PRUint32 aLength, nsACString &aCharset, PRBool *bigEndian=0)
 Determine whether a buffer begins with a BOM for UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE.
static PRBool BelongsInForm (nsIDOMHTMLFormElement *aForm, nsIContent *aContent)
 Determine whether aContent is in some way associated with aForm.
static nsresult CheckQName (const nsAString &aQualifiedName, PRBool aNamespaceAware=1)
static nsresult SplitQName (nsIContent *aNamespaceResolver, const nsAFlatString &aQName, PRInt32 *aNamespace, nsIAtom **aLocalName)
static nsresult LookupNamespaceURI (nsIContent *aNamespaceResolver, const nsAString &aNamespacePrefix, nsAString &aNamespaceURI)
static nsresult GetNodeInfoFromQName (const nsAString &aNamespaceURI, const nsAString &aQualifiedName, nsNodeInfoManager *aNodeInfoManager, nsINodeInfo **aNodeInfo)
static void SplitExpatName (const PRUnichar *aExpatName, nsIAtom **aPrefix, nsIAtom **aTagName, PRInt32 *aNameSpaceID)
static nsAdoptingCString GetCharPref (const char *aPref)
static PRPackedBool GetBoolPref (const char *aPref, PRBool aDefault=0)
static PRInt32 GetIntPref (const char *aPref, PRInt32 aDefault=0)
static nsAdoptingString GetLocalizedStringPref (const char *aPref)
static nsAdoptingString GetStringPref (const char *aPref)
static void RegisterPrefCallback (const char *aPref, PrefChangedFunc aCallback, void *aClosure)
static void UnregisterPrefCallback (const char *aPref, PrefChangedFunc aCallback, void *aClosure)
static void AddBoolPrefVarCache (const char *aPref, PRBool *aVariable)
static void AddIntPrefVarCache (const char *aPref, PRInt32 *aVariable)
static nsIPrefBranchGetPrefBranch ()
static nsILineBreaker * LineBreaker ()
static nsIWordBreaker * WordBreaker ()
static nsICaseConversion * GetCaseConv ()
static nsIUGenCategory * GetGenCat ()
static PRBool HasNonEmptyAttr (nsIContent *aContent, PRInt32 aNameSpaceID, nsIAtom *aName)
static nsPresContextGetContextForContent (nsIContent *aContent)
 Method that gets the primary presContext for the node.
static PRBool CanLoadImage (nsIURI *aURI, nsISupports *aContext, nsIDocument *aLoadingDocument, nsIPrincipal *aLoadingPrincipal, PRInt16 *aImageBlockingStatus=0)
 Method to do security and content policy checks on the image URI.
static nsresult LoadImage (nsIURI *aURI, nsIDocument *aLoadingDocument, nsIPrincipal *aLoadingPrincipal, nsIURI *aReferrer, imgIDecoderObserver *aObserver, PRInt32 aLoadFlags, imgIRequest **aRequest)
 Method to start an image load.
static PRBool IsImageInCache (nsIURI *aURI)
 Returns whether the given URI is in the image cache.
static already_AddRefed
< imgIContainer
GetImageFromContent (nsIImageLoadingContent *aContent, imgIRequest **aRequest=0)
 Method to get an imgIContainer from an image loading content.
static already_AddRefed
< imgIRequest
GetStaticRequest (imgIRequest *aRequest)
 Helper method to call imgIRequest::GetStaticRequest.
static PRBool ContentIsDraggable (nsIContent *aContent)
 Method that decides whether a content node is draggable.
static PRBool IsDraggableImage (nsIContent *aContent)
 Method that decides whether a content node is a draggable image.
static PRBool IsDraggableLink (nsIContent *aContent)
 Method that decides whether a content node is a draggable link.
static nsresult NameChanged (nsINodeInfo *aNodeInfo, nsIAtom *aName, nsINodeInfo **aResult)
 Convenience method to create a new nodeinfo that differs only by name from aNodeInfo.
static nsresult PrefixChanged (nsINodeInfo *aNodeInfo, nsIAtom *aPrefix, nsINodeInfo **aResult)
 Convenience method to create a new nodeinfo that differs only by prefix from aNodeInfo.
static void GetEventArgNames (PRInt32 aNameSpaceID, nsIAtom *aEventName, PRUint32 *aArgCount, const char ***aArgNames)
 Returns the appropriate event argument names for the specified namespace and event name.
static PRBool IsInSameAnonymousTree (nsINode *aNode, nsIContent *aContent)
 If aNode is not an element, return true exactly when aContent's binding parent is null.
static nsIXPConnectXPConnect ()
 Return the nsIXPConnect service.
static nsresult ReportToConsole (PropertiesFile aFile, const char *aMessageName, const PRUnichar **aParams, PRUint32 aParamsLength, nsIURI *aURI, const nsAFlatString &aSourceLine, PRUint32 aLineNumber, PRUint32 aColumnNumber, PRUint32 aErrorFlags, const char *aCategory)
static nsresult GetLocalizedString (PropertiesFile aFile, const char *aKey, nsXPIDLString &aResult)
 Get the localized string named |aKey| in properties file |aFile|.
static nsresult FormatLocalizedString (PropertiesFile aFile, const char *aKey, const PRUnichar **aParams, PRUint32 aParamsLength, nsXPIDLString &aResult)
 Fill (with the parameters given) the localized string named |aKey| in properties file |aFile|.
static PRBool IsChromeDoc (nsIDocument *aDocument)
 Returns true if aDocument is a chrome document.
static PRBool IsChildOfSameType (nsIDocument *aDoc)
 Returns true if aDocument is in a docshell whose parent is the same type.
static PRBool GetWrapperSafeScriptFilename (nsIDocument *aDocument, nsIURI *aURI, nsACString &aScriptURI)
 Get the script file name to use when compiling the script referenced by aURI.
static PRBool IsInChromeDocshell (nsIDocument *aDocument)
 Returns true if aDocument belongs to a chrome docshell for display purposes.
static nsresult ReleasePtrOnShutdown (nsISupports **aSupportsPtr)
 Release *aSupportsPtr when the shutdown notification is received.
static nsIContentPolicyGetContentPolicy ()
 Return the content policy service.
static PRBool HasMutationListeners (nsINode *aNode, PRUint32 aType, nsINode *aTargetForSubtreeModified)
 Quick helper to determine whether there are any mutation listeners of a given type that apply to this content or any of its ancestors.
static nsresult DispatchTrustedEvent (nsIDocument *aDoc, nsISupports *aTarget, const nsAString &aEventName, PRBool aCanBubble, PRBool aCancelable, PRBool *aDefaultAction=0)
 This method creates and dispatches a trusted event.
static nsresult DispatchChromeEvent (nsIDocument *aDoc, nsISupports *aTarget, const nsAString &aEventName, PRBool aCanBubble, PRBool aCancelable, PRBool *aDefaultAction=0)
 This method creates and dispatches a trusted event to the chrome event handler.
static PRBool IsEventAttributeName (nsIAtom *aName, PRInt32 aType)
 Determines if an event attribute name (such as onclick) is valid for a given element type.
static PRUint32 GetEventId (nsIAtom *aName)
 Return the event id for the event with the given name.
static void TraverseListenerManager (nsINode *aNode, nsCycleCollectionTraversalCallback &cb)
 Used only during traversal of the XPCOM graph by the cycle collector: push a pointer to the listener manager onto the children deque, if it exists.
static nsIEventListenerManager * GetListenerManager (nsINode *aNode, PRBool aCreateIfNotFound)
 Get the eventlistener manager for aNode.
static void RemoveListenerManager (nsINode *aNode)
 Remove the eventlistener manager for aNode.
static PRBool IsInitialized ()
static PRBool IsValidNodeName (nsIAtom *aLocalName, nsIAtom *aPrefix, PRInt32 aNamespaceID)
 Checks if the localname/prefix/namespace triple is valid wrt prefix and namespace according to the Namespaces in XML and DOM Code specfications.
static nsresult CreateContextualFragment (nsIDOMNode *aContextNode, const nsAString &aFragment, PRBool aWillOwnFragment, nsIDOMDocumentFragment **aReturn)
 Creates a DocumentFragment from text using a context node to resolve namespaces.
static nsresult CreateDocument (const nsAString &aNamespaceURI, const nsAString &aQualifiedName, nsIDOMDocumentType *aDoctype, nsIURI *aDocumentURI, nsIURI *aBaseURI, nsIPrincipal *aPrincipal, nsIScriptGlobalObject *aScriptObject, nsIDOMDocument **aResult)
 Creates a new XML document, which is marked to be loaded as data.
static nsresult SetNodeTextContent (nsIContent *aContent, const nsAString &aValue, PRBool aTryReuse)
 Sets the text contents of a node by replacing all existing children with a single text child.
static void GetNodeTextContent (nsINode *aNode, PRBool aDeep, nsAString &aResult)
 Get the textual contents of a node.
static void AppendNodeTextContent (nsINode *aNode, PRBool aDeep, nsAString &aResult)
 Same as GetNodeTextContents but appends the result rather than sets it.
static PRBool HasNonEmptyTextContent (nsINode *aNode)
 Utility method that checks if a given node has any non-empty children.
static void DestroyMatchString (void *aData)
 Delete strings allocated for nsContentList matches.
static void DestroyAnonymousContent (nsCOMPtr< nsIContent > *aContent)
 Unbinds the content from the tree and nulls it out if it's not null.
static nsresult HoldScriptObject (PRUint32 aLangID, void *aScriptObjectHolder, nsScriptObjectTracer *aTracer, void *aNewObject, PRBool aWasHoldingObjects)
 Keep script object aNewObject, held by aScriptObjectHolder, alive.
static nsresult DropScriptObjects (PRUint32 aLangID, void *aScriptObjectHolder, nsScriptObjectTracer *aTracer)
 Drop any script objects that aScriptObjectHolder is holding.
static nsresult HoldJSObjects (void *aScriptObjectHolder, nsScriptObjectTracer *aTracer)
 Keep the JS objects held by aScriptObjectHolder alive.
static nsresult DropJSObjects (void *aScriptObjectHolder)
 Drop the JS objects held by aScriptObjectHolder.
static void PreserveWrapper (nsISupports *aScriptObjectHolder, nsWrapperCache *aCache)
static void ReleaseWrapper (nsISupports *aScriptObjectHolder, nsWrapperCache *aCache)
static void TraceWrapper (nsWrapperCache *aCache, TraceCallback aCallback, void *aClosure)
static PRUint32 GetWidgetStatusFromIMEStatus (PRUint32 aState)
 Convert nsIContent::IME_STATUS_* to nsIWidget::IME_STATUS_*.
static void NotifyInstalledMenuKeyboardListener (PRBool aInstalling)
static nsresult CheckSecurityBeforeLoad (nsIURI *aURIToLoad, nsIPrincipal *aLoadingPrincipal, PRUint32 aCheckLoadFlags, PRBool aAllowData, PRUint32 aContentPolicyType, nsISupports *aContext, const nsACString &aMimeGuess=nsCString_external(), nsISupports *aExtra=0)
 Do security checks before loading a resource.
static void TriggerLink (nsIContent *aContent, nsPresContext *aPresContext, nsIURI *aLinkURI, const nsString_external &aTargetSpec, PRBool aClick, PRBool aIsUserTriggered)
 Trigger a link with uri aLinkURI.
static nsIWidget * GetTopLevelWidget (nsIWidget *aWidget)
 Return top-level widget in the parent chain.
static const
nsDependentString_external 
GetLocalizedEllipsis ()
 Return the localized ellipsis for UI.
static nsEventGetNativeEvent (nsIDOMEvent *aDOMEvent)
 The routine GetNativeEvent is used to fill nsNativeKeyEvent.
static PRBool DOMEventToNativeKeyEvent (nsIDOMKeyEvent *aKeyEvent, nsNativeKeyEvent *aNativeEvent, PRBool aGetCharCode)
static void GetAccelKeyCandidates (nsIDOMKeyEvent *aDOMKeyEvent, nsTArray< nsShortcutCandidate > &aCandidates)
 Get the candidates for accelkeys for aDOMKeyEvent.
static void GetAccessKeyCandidates (nsKeyEvent *aNativeKeyEvent, nsTArray< PRUint32 > &aCandidates)
 Get the candidates for accesskeys for aNativeKeyEvent.
static void HidePopupsInDocument (nsIDocument *aDocument)
 Hide any XUL popups associated with aDocument, including any documents displayed in child frames.
static already_AddRefed
< nsIDragSession
GetDragSession ()
 Retrieve the current drag session, or null if no drag is currently occuring.
static nsresult SetDataTransferInEvent (nsDragEvent *aDragEvent)
static PRUint32 FilterDropEffect (PRUint32 aAction, PRUint32 aEffectAllowed)
static PRBool URIIsLocalFile (nsIURI *aURI)
 Return true if aURI is a local file URI (i.e.
static nsIAtomIsNamedItem (nsIContent *aContent)
 If aContent is an HTML element with a DOM level 0 'name', then return the name.
static void GetOfflineAppManifest (nsIDocument *aDocument, nsIURI **aURI)
 Get the application manifest URI for this document.
static PRBool OfflineAppAllowed (nsIURI *aURI)
 Check whether an application should be allowed to use offline APIs.
static PRBool OfflineAppAllowed (nsIPrincipal *aPrincipal)
 Check whether an application should be allowed to use offline APIs.
static void AddScriptBlocker ()
 Increases the count of blockers preventing scripts from running.
static void AddScriptBlockerAndPreventAddingRunners ()
 Increases the count of blockers preventing scripts from running.
static void RemoveScriptBlocker ()
 Decreases the count of blockers preventing scripts from running.
static PRBool AddScriptRunner (nsIRunnable *aRunnable)
 Add a runnable that is to be executed as soon as it's safe to execute scripts.
static PRBool IsSafeToRunScript ()
 Returns true if it's safe to execute content script and false otherwise.
static void AddRemovableScriptBlocker ()
 Get/Set the current number of removable updates.
static void RemoveRemovableScriptBlocker ()
static PRUint32 GetRemovableScriptBlockerLevel ()
static nsresult ProcessViewportInfo (nsIDocument *aDocument, const nsAString &viewportInfo)
static nsIScriptContext * GetContextForEventHandlers (nsINode *aNode, nsresult *aRv)
static JSContextGetCurrentJSContext ()
static nsIInterfaceRequestorGetSameOriginChecker ()
static nsIThreadJSContextStackThreadJSContextStack ()
static nsresult GetASCIIOrigin (nsIPrincipal *aPrincipal, nsCString_external &aOrigin)
 Get the Origin of the passed in nsIPrincipal or nsIURI.
static nsresult GetASCIIOrigin (nsIURI *aURI, nsCString_external &aOrigin)
static nsresult GetUTFOrigin (nsIPrincipal *aPrincipal, nsString_external &aOrigin)
static nsresult GetUTFOrigin (nsIURI *aURI, nsString_external &aOrigin)
static nsresult DispatchXULCommand (nsIContent *aTarget, PRBool aTrusted, nsIDOMEvent *aSourceEvent=0, nsIPresShell *aShell=0, PRBool aCtrl=0, PRBool aAlt=0, PRBool aShift=0, PRBool aMeta=0)
 This method creates and dispatches "command" event, which implements nsIDOMXULCommandEvent.
static already_AddRefed
< nsIDocument > 
GetDocumentFromScriptContext (nsIScriptContext *aScriptContext)
 Gets the nsIDocument given the script context.
static PRBool CanAccessNativeAnon ()
 The method checks whether the caller can access native anonymous content.
static nsresult WrapNative (JSContext *cx, JSObject *scope, nsISupports *native, const nsIID *aIID, jsval *vp, nsIXPConnectJSObjectHolder **aHolder=0, PRBool aAllowWrapping=0)
static nsresult WrapNative (JSContext *cx, JSObject *scope, nsISupports *native, jsval *vp, nsIXPConnectJSObjectHolder **aHolder=0, PRBool aAllowWrapping=0)

Member Enumeration Documentation

Report a localized error message to the error console.

Parameters:
aFile Properties file containing localized message.
aMessageName Name of localized message.
aParams Parameters to be substituted into localized message.
aParamsLength Length of aParams.
aURI URI of resource containing error (may be null).
aSourceLine The text of the line that contains the error (may be empty).
aLineNumber Line number within resource containing error.
aColumnNumber Column number within resource containing error.
aErrorFlags See nsIScriptError.
aCategory Name of module reporting error.
Enumerator:
eCSS_PROPERTIES 
eXBL_PROPERTIES 
eXUL_PROPERTIES 
eLAYOUT_PROPERTIES 
eFORMS_PROPERTIES 
ePRINTING_PROPERTIES 
eDOM_PROPERTIES 
eBRAND_PROPERTIES 
eCOMMON_DIALOG_PROPERTIES 
PropertiesFile_COUNT 

Member Function Documentation

static void nsContentUtils::AddBoolPrefVarCache ( const char *  aPref,
PRBool aVariable 
) [static]
static void nsContentUtils::AddIntPrefVarCache ( const char *  aPref,
PRInt32 *  aVariable 
) [static]
static void nsContentUtils::AddRemovableScriptBlocker (  )  [inline, static]

Get/Set the current number of removable updates.

Currently only UPDATE_CONTENT_MODEL updates are removable, and only when firing mutation events. These functions should only be called by mozAutoDocUpdateRemover. The count is also adjusted by the normal calls to BeginUpdate/EndUpdate.

static void nsContentUtils::AddScriptBlocker (  )  [static]

Increases the count of blockers preventing scripts from running.

NOTE: You might want to use nsAutoScriptBlocker rather than calling this directly

static void nsContentUtils::AddScriptBlockerAndPreventAddingRunners (  )  [static]

Increases the count of blockers preventing scripts from running.

Also, while this script blocker is active, script runners must not be added --- we'll assert if one is, and ignore it.

static PRBool nsContentUtils::AddScriptRunner ( nsIRunnable aRunnable  )  [static]

Add a runnable that is to be executed as soon as it's safe to execute scripts.

NOTE: If it's currently safe to execute scripts, aRunnable will be run synchronously before the function returns.

Parameters:
aRunnable The nsIRunnable to run as soon as it's safe to execute scripts. Passing null is allowed and results in nothing happening. It is also allowed to pass an object that has not yet been AddRefed.
Returns:
false on out of memory, true otherwise.
static void nsContentUtils::AppendNodeTextContent ( nsINode *  aNode,
PRBool  aDeep,
nsAString aResult 
) [static]

Same as GetNodeTextContents but appends the result rather than sets it.

static PRBool nsContentUtils::BelongsInForm ( nsIDOMHTMLFormElement aForm,
nsIContent *  aContent 
) [static]

Determine whether aContent is in some way associated with aForm.

If the form is a container the only elements that are considered to be associated with a form are the elements that are contained within the form. If the form is a leaf element then all elements will be accepted into this list, since this can happen due to content fixup when a form spans table rows or table cells.

static PRBool nsContentUtils::CanAccessNativeAnon (  )  [static]

The method checks whether the caller can access native anonymous content.

If there is no JS in the stack or privileged JS is running, this method returns PR_TRUE, otherwise PR_FALSE.

static PRBool nsContentUtils::CanCallerAccess ( nsPIDOMWindow aWindow  )  [static]
static PRBool nsContentUtils::CanCallerAccess ( nsIDOMNode aNode  )  [static]
static PRBool nsContentUtils::CanLoadImage ( nsIURI aURI,
nsISupports aContext,
nsIDocument *  aLoadingDocument,
nsIPrincipal aLoadingPrincipal,
PRInt16 *  aImageBlockingStatus = 0 
) [static]

Method to do security and content policy checks on the image URI.

Parameters:
aURI uri of the image to be loaded
aContext the context the image is loaded in (eg an element)
aLoadingDocument the document we belong to
aLoadingPrincipal the principal doing the load
aImageBlockingStatus the nsIContentPolicy blocking status for this image. This will be set even if a security check fails for the image, to some reasonable REJECT_* value. This out param will only be set if it's non-null.
Returns:
PR_TRUE if the load can proceed, or PR_FALSE if it is blocked. Note that aImageBlockingStatus, if set will always be an ACCEPT status if PR_TRUE is returned and always be a REJECT_* status if PR_FALSE is returned.
static PRBool nsContentUtils::CheckForBOM ( const unsigned char *  aBuffer,
PRUint32  aLength,
nsACString aCharset,
PRBool bigEndian = 0 
) [static]

Determine whether a buffer begins with a BOM for UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE.

Parameters:
aBuffer the buffer to check
aLength the length of the buffer
aCharset empty if not found
Returns:
boolean indicating whether a BOM was detected.
static nsresult nsContentUtils::CheckQName ( const nsAString aQualifiedName,
PRBool  aNamespaceAware = 1 
) [static]
static nsresult nsContentUtils::CheckSameOrigin ( nsIDOMNode aTrustedNode,
nsIDOMNode aUnTrustedNode 
) [static]

Checks whether two nodes come from the same origin.

aTrustedNode is considered 'safe' in that a user can operate on it and that it isn't a js-object that implements nsIDOMNode. Never call this function with the first node provided by script, it must always be known to be a 'real' node!

static nsresult nsContentUtils::CheckSecurityBeforeLoad ( nsIURI aURIToLoad,
nsIPrincipal aLoadingPrincipal,
PRUint32  aCheckLoadFlags,
PRBool  aAllowData,
PRUint32  aContentPolicyType,
nsISupports aContext,
const nsACString aMimeGuess = nsCString_external(),
nsISupports aExtra = 0 
) [static]

Do security checks before loading a resource.

Does the following checks: nsIScriptSecurityManager::CheckLoadURIWithPrincipal NS_CheckContentLoadPolicy nsIScriptSecurityManager::CheckSameOriginURI

You will still need to do at least SameOrigin checks before on redirects.

Parameters:
aURIToLoad URI that is getting loaded.
aLoadingPrincipal Principal of the resource that is initiating the load
aCheckLoadFlags Flags to be passed to nsIScriptSecurityManager::CheckLoadURIWithPrincipal NOTE: If this contains ALLOW_CHROME the CheckSameOriginURI check will be skipped if aURIToLoad is a chrome uri.
aAllowData Set to true to skip CheckSameOriginURI check when aURIToLoad is a data uri.
aContentPolicyType Type \
aContext Context |- to be passed to
aMimeGuess Mimetype | NS_CheckContentLoadPolicy
aExtra Extra /
static PRInt32 nsContentUtils::ComparePoints ( nsINode *  aParent1,
PRInt32  aOffset1,
nsINode *  aParent2,
PRInt32  aOffset2,
PRBool aDisconnected = 0 
) [static]

Utility routine to compare two "points", where a point is a node/offset pair Returns -1 if point1 < point2, 1, if point1 > point2, 0 if error or if point1 == point2.

NOTE! If the two nodes aren't in the same connected subtree, the result is undefined, but the optional aDisconnected parameter is set to PR_TRUE.

static PRUint16 nsContentUtils::ComparePosition ( nsINode *  aNode1,
nsINode *  aNode2 
) [static]

Compares the document position of nodes.

Parameters:
aNode1 The node whose position is being compared to the reference node
aNode2 The reference node
Returns:
The document position flags of the nodes. aNode1 is compared to aNode2, i.e. if aNode1 is before aNode2 then DOCUMENT_POSITION_PRECEDING will be set.
See also:
nsIDOMNode
nsIDOM3Node
static PRBool nsContentUtils::ContentIsCrossDocDescendantOf ( nsINode *  aPossibleDescendant,
nsINode *  aPossibleAncestor 
) [static]

Similar to ContentIsDescendantOf except it crosses document boundaries.

static PRBool nsContentUtils::ContentIsDescendantOf ( nsINode *  aPossibleDescendant,
nsINode *  aPossibleAncestor 
) [static]

Do not ever pass null pointers to this method.

If one of your nsIContents is null, you have to decide for yourself what "IsDescendantOf" really means.

Parameters:
aPossibleDescendant node to test for being a descendant of aPossibleAncestor
aPossibleAncestor node to test for being an ancestor of aPossibleDescendant
Returns:
PR_TRUE if aPossibleDescendant is a descendant of aPossibleAncestor (or is aPossibleAncestor). PR_FALSE otherwise.
static PRBool nsContentUtils::ContentIsDraggable ( nsIContent *  aContent  )  [static]

Method that decides whether a content node is draggable.

Parameters:
aContent The content node to test.
Returns:
whether it's draggable
static nsresult nsContentUtils::ConvertStringFromCharset ( const nsACString aCharset,
const nsACString aInput,
nsAString aOutput 
) [static]

Convert aInput (in charset aCharset) to UTF16 in aOutput.

Parameters:
aCharset the name of the charset; if empty, we assume UTF8
static PRUint32 nsContentUtils::CopyNewlineNormalizedUnicodeTo ( const nsAString aSource,
PRUint32  aSrcOffset,
PRUnichar aDest,
PRUint32  aLength,
PRBool aLastCharCR 
) [static]
static PRUint32 nsContentUtils::CopyNewlineNormalizedUnicodeTo ( nsReadingIterator< PRUnichar > &  aSrcStart,
const nsReadingIterator< PRUnichar > &  aSrcEnd,
nsAString aDest 
) [static]
static nsresult nsContentUtils::CreateContextualFragment ( nsIDOMNode aContextNode,
const nsAString aFragment,
PRBool  aWillOwnFragment,
nsIDOMDocumentFragment **  aReturn 
) [static]

Creates a DocumentFragment from text using a context node to resolve namespaces.

Parameters:
aContextNode the node which is used to resolve namespaces
aFragment the string which is parsed to a DocumentFragment
aWillOwnFragment is PR_TRUE if ownership of the fragment should be transferred to the caller.
aReturn [out] the created DocumentFragment
static nsresult nsContentUtils::CreateDocument ( const nsAString aNamespaceURI,
const nsAString aQualifiedName,
nsIDOMDocumentType aDoctype,
nsIURI aDocumentURI,
nsIURI aBaseURI,
nsIPrincipal aPrincipal,
nsIScriptGlobalObject *  aScriptObject,
nsIDOMDocument **  aResult 
) [static]

Creates a new XML document, which is marked to be loaded as data.

Parameters:
aNamespaceURI Namespace for the root element to create and insert in the document. Only used if aQualifiedName is not empty.
aQualifiedName Qualified name for the root element to create and insert in the document. If empty no root element will be created.
aDoctype Doctype node to insert in the document.
aDocumentURI URI of the document. Must not be null.
aBaseURI Base URI of the document. Must not be null.
aPrincipal Prinicpal of the document. Must not be null.
aScriptObject The object from which the context for event handling can be got.
aResult [out] The document that was created.
static void nsContentUtils::DestroyAnonymousContent ( nsCOMPtr< nsIContent > *  aContent  )  [static]

Unbinds the content from the tree and nulls it out if it's not null.

static void nsContentUtils::DestroyMatchString ( void *  aData  )  [inline, static]

Delete strings allocated for nsContentList matches.

static nsresult nsContentUtils::DispatchChromeEvent ( nsIDocument *  aDoc,
nsISupports aTarget,
const nsAString aEventName,
PRBool  aCanBubble,
PRBool  aCancelable,
PRBool aDefaultAction = 0 
) [static]

This method creates and dispatches a trusted event to the chrome event handler.

Works only with events which can be created by calling nsIDOMDocumentEvent::CreateEvent() with parameter "Events".

Parameters:
aDocument The document which will be used to create the event, and whose window's chrome handler will be used to dispatch the event.
aTarget The target of the event, used for event->SetTarget()
aEventName The name of the event.
aCanBubble Whether the event can bubble.
aCancelable Is the event cancelable.
aDefaultAction Set to true if default action should be taken, see nsIDOMEventTarget::DispatchEvent.
static nsresult nsContentUtils::DispatchTrustedEvent ( nsIDocument *  aDoc,
nsISupports aTarget,
const nsAString aEventName,
PRBool  aCanBubble,
PRBool  aCancelable,
PRBool aDefaultAction = 0 
) [static]

This method creates and dispatches a trusted event.

Works only with events which can be created by calling nsIDOMDocumentEvent::CreateEvent() with parameter "Events".

Parameters:
aDoc The document which will be used to create the event.
aTarget The target of the event, should be QIable to nsIDOMEventTarget.
aEventName The name of the event.
aCanBubble Whether the event can bubble.
aCancelable Is the event cancelable.
aDefaultAction Set to true if default action should be taken, see nsIDOMEventTarget::DispatchEvent.
static nsresult nsContentUtils::DispatchXULCommand ( nsIContent *  aTarget,
PRBool  aTrusted,
nsIDOMEvent aSourceEvent = 0,
nsIPresShell *  aShell = 0,
PRBool  aCtrl = 0,
PRBool  aAlt = 0,
PRBool  aShift = 0,
PRBool  aMeta = 0 
) [static]

This method creates and dispatches "command" event, which implements nsIDOMXULCommandEvent.

If aShell is not null, dispatching goes via nsIPresShell::HandleDOMEventWithTarget.

static PRBool nsContentUtils::DOMEventToNativeKeyEvent ( nsIDOMKeyEvent aKeyEvent,
nsNativeKeyEvent *  aNativeEvent,
PRBool  aGetCharCode 
) [static]
static nsresult nsContentUtils::DropJSObjects ( void *  aScriptObjectHolder  )  [static]

Drop the JS objects held by aScriptObjectHolder.

Parameters:
aScriptObjectHolder the object that holds JS objects that we want to drop
static nsresult nsContentUtils::DropScriptObjects ( PRUint32  aLangID,
void *  aScriptObjectHolder,
nsScriptObjectTracer aTracer 
) [inline, static]

Drop any script objects that aScriptObjectHolder is holding.

NOTE: This currently only supports objects that hold script objects of one scripting language.

Parameters:
aLangID script language ID of the objects that
aScriptObjectHolder the object that holds script object that we want to drop
aTracer the tracer for aScriptObject
static PRUint32 nsContentUtils::FilterDropEffect ( PRUint32  aAction,
PRUint32  aEffectAllowed 
) [static]
static nsIContent* nsContentUtils::FindFirstChildWithResolvedTag ( nsIContent *  aParent,
PRInt32  aNamespace,
nsIAtom aTag 
) [static]

Find the first child of aParent with a resolved tag matching aNamespace and aTag.

Both the explicit and anonymous children of aParent are examined. The return value is not addrefed.

XXXndeakin this should return the first child whether in anonymous or explicit children, but currently XBL doesn't tell us the relative ordering of anonymous vs explicit children, so instead it searches the explicit children first then the anonymous children.

static nsresult nsContentUtils::FormatLocalizedString ( PropertiesFile  aFile,
const char *  aKey,
const PRUnichar **  aParams,
PRUint32  aParamsLength,
nsXPIDLString &  aResult 
) [static]

Fill (with the parameters given) the localized string named |aKey| in properties file |aFile|.

static nsresult nsContentUtils::GenerateStateKey ( nsIContent *  aContent,
nsIDocument *  aDocument,
nsIStatefulFrame::SpecialStateID  aID,
nsACString aKey 
) [static]
static void nsContentUtils::GetAccelKeyCandidates ( nsIDOMKeyEvent aDOMKeyEvent,
nsTArray< nsShortcutCandidate > &  aCandidates 
) [static]

Get the candidates for accelkeys for aDOMKeyEvent.

Parameters:
aDOMKeyEvent [in] the key event for accelkey handling.
aCandidates [out] the candidate shortcut key combination list. the first item is most preferred.
static void nsContentUtils::GetAccessKeyCandidates ( nsKeyEvent aNativeKeyEvent,
nsTArray< PRUint32 > &  aCandidates 
) [static]

Get the candidates for accesskeys for aNativeKeyEvent.

Parameters:
aNativeKeyEvent [in] the key event for accesskey handling.
aCandidates [out] the candidate access key list. the first item is most preferred.
static nsresult nsContentUtils::GetAncestors ( nsIDOMNode aNode,
nsTArray< nsIDOMNode * > *  aArray 
) [static]
static nsresult nsContentUtils::GetAncestorsAndOffsets ( nsIDOMNode aNode,
PRInt32  aOffset,
nsTArray< nsIContent * > *  aAncestorNodes,
nsTArray< PRInt32 > *  aAncestorOffsets 
) [static]
static nsresult nsContentUtils::GetASCIIOrigin ( nsIPrincipal aPrincipal,
nsCString_external aOrigin 
) [static]

Get the Origin of the passed in nsIPrincipal or nsIURI.

If the passed in nsIURI or the URI of the passed in nsIPrincipal does not have a host, the origin is set to 'null'.

The ASCII versions return a ASCII strings that are puny-code encoded, suitable for for example header values. The UTF versions return strings containing international characters.

aPrincipal/aOrigin must not be null.

static nsresult nsContentUtils::GetASCIIOrigin ( nsIURI aURI,
nsCString_external aOrigin 
) [static]
static PRPackedBool nsContentUtils::GetBoolPref ( const char *  aPref,
PRBool  aDefault = 0 
) [static]
static nsICaseConversion* nsContentUtils::GetCaseConv (  )  [inline, static]
static nsAdoptingCString nsContentUtils::GetCharPref ( const char *  aPref  )  [static]
static nsISupports* nsContentUtils::GetClassInfoInstance ( nsDOMClassInfoID  aID  )  [static]
static nsresult nsContentUtils::GetCommonAncestor ( nsIDOMNode aNode,
nsIDOMNode aOther,
nsIDOMNode **  aCommonAncestor 
) [static]
static nsINode* nsContentUtils::GetCommonAncestor ( nsINode *  aNode1,
nsINode *  aNode2 
) [static]

Returns the common ancestor, if any, for two nodes.

Returns null if the nodes are disconnected.

static nsIContentPolicy* nsContentUtils::GetContentPolicy (  )  [static]

Return the content policy service.

static nsresult nsContentUtils::GetContextAndScopes ( nsIDocument *  aOldDocument,
nsIDocument *  aNewDocument,
JSContext **  aCx,
JSObject **  aOldScope,
JSObject **  aNewScope 
) [static]

Get a scope from aOldDocument and one from aNewDocument.

Also get a context through one of the scopes, from the stack or the safe context.

Parameters:
aOldDocument The document to get aOldScope from.
aNewDocument The document to get aNewScope from.
aCx [out] Context gotten through one of the scopes, from the stack or the safe context.
aOldScope [out] Scope gotten from aOldDocument.
aNewScope [out] Scope gotten from aNewDocument.
static nsPresContext* nsContentUtils::GetContextForContent ( nsIContent *  aContent  )  [static]

Method that gets the primary presContext for the node.

Parameters:
aContent The content node.
Returns:
the presContext, or nsnull if the content is not in a document (if GetCurrentDoc returns nsnull)
static nsIScriptContext* nsContentUtils::GetContextForEventHandlers ( nsINode *  aNode,
nsresult aRv 
) [static]
static JSContext* nsContentUtils::GetCurrentJSContext (  )  [static]
static nsIDocShell* nsContentUtils::GetDocShellFromCaller (  )  [static]

Get the docshell through the JS context that's currently on the stack.

If there's no JS context currently on the stack aDocShell will be null.

Parameters:
aDocShell The docshell or null if no JS context
static nsIDOMDocument* nsContentUtils::GetDocumentFromCaller (  )  [static]

The two GetDocumentFrom* functions below allow a caller to get at a document that is relevant to the currently executing script.

GetDocumentFromCaller gets its document by looking at the last called function and finding the document that the function itself relates to. For example, consider two windows A and B in the same origin. B has a function which does something that ends up needing the current document. If a script in window A were to call B's function, GetDocumentFromCaller would find that function (in B) and return B's document.

GetDocumentFromContext gets its document by looking at the currently executing context's global object and returning its document. Thus, given the example above, GetDocumentFromCaller would see that the currently executing script was in window A, and return A's document. Get the document from the currently executing function. This will return the document that the currently executing function is in/from.

Returns:
The document or null if no JS Context.
static nsIDOMDocument* nsContentUtils::GetDocumentFromContext (  )  [static]

Get the document through the JS context that's currently on the stack.

If there's no JS context currently on the stack it will return null. This will return the document of the calling script.

Returns:
The document or null if no JS context
static already_AddRefed<nsIDocument> nsContentUtils::GetDocumentFromScriptContext ( nsIScriptContext *  aScriptContext  )  [static]

Gets the nsIDocument given the script context.

Will return nsnull on failure.

Parameters:
aScriptContext the script context to get the document for; can be null
Returns:
the document associated with the script context
static already_AddRefed<nsIDragSession> nsContentUtils::GetDragSession (  )  [static]

Retrieve the current drag session, or null if no drag is currently occuring.

static void nsContentUtils::GetEventArgNames ( PRInt32  aNameSpaceID,
nsIAtom aEventName,
PRUint32 *  aArgCount,
const char ***  aArgNames 
) [static]

Returns the appropriate event argument names for the specified namespace and event name.

Added because we need to switch between SVG's "evt" and the rest of the world's "event", and because onerror takes 3 args.

static PRUint32 nsContentUtils::GetEventId ( nsIAtom aName  )  [static]

Return the event id for the event with the given name.

The name is the event name with the 'on' prefix. Returns NS_USER_DEFINED_EVENT if the event doesn't match a known event name.

Parameters:
aName the event name to look up
static nsIUGenCategory* nsContentUtils::GetGenCat (  )  [inline, static]
static already_AddRefed<imgIContainer> nsContentUtils::GetImageFromContent ( nsIImageLoadingContent aContent,
imgIRequest **  aRequest = 0 
) [static]

Method to get an imgIContainer from an image loading content.

Parameters:
aContent The image loading content. Must not be null.
aRequest The image request [out]
Returns:
the imgIContainer corresponding to the first frame of the image
static imgILoader* nsContentUtils::GetImgLoader (  )  [inline, static]
static PRInt32 nsContentUtils::GetIntPref ( const char *  aPref,
PRInt32  aDefault = 0 
) [static]
static nsIIOService* nsContentUtils::GetIOService (  )  [inline, static]
static nsIEventListenerManager* nsContentUtils::GetListenerManager ( nsINode *  aNode,
PRBool  aCreateIfNotFound 
) [static]

Get the eventlistener manager for aNode.

If a new eventlistener manager was created, aCreated is set to PR_TRUE.

Parameters:
aNode The node for which to get the eventlistener manager.
aCreateIfNotFound If PR_FALSE, returns a listener manager only if one already exists.
static const nsDependentString_external nsContentUtils::GetLocalizedEllipsis (  )  [static]

Return the localized ellipsis for UI.

static nsresult nsContentUtils::GetLocalizedString ( PropertiesFile  aFile,
const char *  aKey,
nsXPIDLString &  aResult 
) [static]

Get the localized string named |aKey| in properties file |aFile|.

static nsAdoptingString nsContentUtils::GetLocalizedStringPref ( const char *  aPref  )  [static]
static nsEvent* nsContentUtils::GetNativeEvent ( nsIDOMEvent aDOMEvent  )  [static]

The routine GetNativeEvent is used to fill nsNativeKeyEvent.

It's also used in DOMEventToNativeKeyEvent. See bug 406407 for details.

static nsresult nsContentUtils::GetNodeInfoFromQName ( const nsAString aNamespaceURI,
const nsAString aQualifiedName,
nsNodeInfoManager aNodeInfoManager,
nsINodeInfo **  aNodeInfo 
) [static]
static void nsContentUtils::GetNodeTextContent ( nsINode *  aNode,
PRBool  aDeep,
nsAString aResult 
) [inline, static]

Get the textual contents of a node.

This is a concatenation of all textnodes that are direct or (depending on aDeep) indirect children of the node.

NOTE! No serialization takes place and
elements are not converted into newlines. Only textnodes and cdata nodes are added to the result.

Parameters:
aNode Node to get textual contents of.
aDeep If true child elements of aNode are recursivly descended into to find text children.
aResult the result. Out param.
static void nsContentUtils::GetOfflineAppManifest ( nsIDocument *  aDocument,
nsIURI **  aURI 
) [static]

Get the application manifest URI for this document.

The manifest URI is specified in the manifest= attribute of the root element of the document.

Parameters:
aDocument The document that lists the manifest.
aURI The manifest URI.
static nsIParserService* nsContentUtils::GetParserService (  )  [static]
static nsIPrefBranch* nsContentUtils::GetPrefBranch (  )  [inline, static]
static nsIContent* nsContentUtils::GetReferencedElement ( nsIURI aURI,
nsIContent *  aFromContent 
) [static]

Given a URI containing an element reference (whatever), resolve it to the target content element with the given ID.

If aFromContent is anonymous XBL content then the URI must refer to its binding document and we will return a node in the same anonymous content subtree as aFromContent, if one exists with the correct ID.

Parameters:
aFromContent the context of the reference; currently we only support references to elements in the same document as the context, so this must be non-null
Returns:
the element, or nsnull on failure
static PRUint32 nsContentUtils::GetRemovableScriptBlockerLevel (  )  [inline, static]
static nsIInterfaceRequestor* nsContentUtils::GetSameOriginChecker (  )  [static]
static nsIScriptSecurityManager* nsContentUtils::GetSecurityManager (  )  [inline, static]

Get the cache security manager service.

Can return null if the layout module has been shut down.

static already_AddRefed<imgIRequest> nsContentUtils::GetStaticRequest ( imgIRequest aRequest  )  [static]

Helper method to call imgIRequest::GetStaticRequest.

static nsAdoptingString nsContentUtils::GetStringPref ( const char *  aPref  )  [static]
static nsIWidget* nsContentUtils::GetTopLevelWidget ( nsIWidget *  aWidget  )  [static]

Return top-level widget in the parent chain.

static nsresult nsContentUtils::GetUTFOrigin ( nsIURI aURI,
nsString_external aOrigin 
) [static]
static nsresult nsContentUtils::GetUTFOrigin ( nsIPrincipal aPrincipal,
nsString_external aOrigin 
) [static]
static PRUint32 nsContentUtils::GetWidgetStatusFromIMEStatus ( PRUint32  aState  )  [static]

Convert nsIContent::IME_STATUS_* to nsIWidget::IME_STATUS_*.

static PRBool nsContentUtils::GetWrapperSafeScriptFilename ( nsIDocument *  aDocument,
nsIURI aURI,
nsACString aScriptURI 
) [static]

Get the script file name to use when compiling the script referenced by aURI.

In cases where there's no need for any extra security wrapper automation the script file name that's returned will be the spec in aURI, else it will be the spec in aDocument's URI followed by aURI's spec, separated by " -> ". Returns PR_TRUE if the script file name was modified, PR_FALSE if it's aURI's spec.

static PRBool nsContentUtils::HasMutationListeners ( nsINode *  aNode,
PRUint32  aType,
nsINode *  aTargetForSubtreeModified 
) [static]

Quick helper to determine whether there are any mutation listeners of a given type that apply to this content or any of its ancestors.

The method has the side effect to call document's MayDispatchMutationEvent using aTargetForSubtreeModified as the parameter.

Parameters:
aNode The node to search for listeners
aType The type of listener (NS_EVENT_BITS_MUTATION_*)
aTargetForSubtreeModified The node which is the target of the possible DOMSubtreeModified event.
Returns:
true if there are mutation listeners of the specified type
static PRBool nsContentUtils::HasNonEmptyAttr ( nsIContent *  aContent,
PRInt32  aNameSpaceID,
nsIAtom aName 
) [static]
Returns:
PR_TRUE if aContent has an attribute aName in namespace aNameSpaceID, and the attribute value is non-empty.
static PRBool nsContentUtils::HasNonEmptyTextContent ( nsINode *  aNode  )  [static]

Utility method that checks if a given node has any non-empty children.

NOTE! This method does not descend recursivly into elements. Though it would be easy to make it so if needed

static void nsContentUtils::HidePopupsInDocument ( nsIDocument *  aDocument  )  [static]

Hide any XUL popups associated with aDocument, including any documents displayed in child frames.

Does nothing if aDocument is null.

static nsresult nsContentUtils::HoldJSObjects ( void *  aScriptObjectHolder,
nsScriptObjectTracer aTracer 
) [static]

Keep the JS objects held by aScriptObjectHolder alive.

Parameters:
aScriptObjectHolder the object that holds JS objects that we want to keep alive
aTracer the tracer for aScriptObject
static nsresult nsContentUtils::HoldScriptObject ( PRUint32  aLangID,
void *  aScriptObjectHolder,
nsScriptObjectTracer aTracer,
void *  aNewObject,
PRBool  aWasHoldingObjects 
) [inline, static]

Keep script object aNewObject, held by aScriptObjectHolder, alive.

NOTE: This currently only supports objects that hold script objects of one scripting language.

Parameters:
aLangID script language ID of aNewObject
aScriptObjectHolder the object that holds aNewObject
aTracer the tracer for aScriptObject
aNewObject the script object to hold
aWasHoldingObjects whether aScriptObjectHolder was already holding script objects (ie. HoldScriptObject was called on it before, without a corresponding call to DropScriptObjects)
static nsresult nsContentUtils::Init (  )  [static]
static PRBool nsContentUtils::InProlog ( nsINode *  aNode  )  [static]
static PRBool nsContentUtils::IsAlphanumeric ( PRUint32  aChar  )  [static]

Returns true if aChar is of class Lu, Ll, Lt, Lm, Lo, Nd, Nl or No.

static PRBool nsContentUtils::IsAlphanumericAt ( const nsTextFragment aFrag,
PRUint32  aOffset 
) [static]
static PRBool nsContentUtils::IsCallerChrome (  )  [static]
static PRBool nsContentUtils::IsCallerTrustedForCapability ( const char *  aCapability  )  [static]

Check whether a caller is trusted to have aCapability.

This also checks for UniversalXPConnect in addition to aCapability.

static PRBool nsContentUtils::IsCallerTrustedForRead (  )  [static]
static PRBool nsContentUtils::IsCallerTrustedForWrite (  )  [static]
static PRBool nsContentUtils::IsChildOfSameType ( nsIDocument *  aDoc  )  [static]

Returns true if aDocument is in a docshell whose parent is the same type.

static PRBool nsContentUtils::IsChromeDoc ( nsIDocument *  aDocument  )  [static]

Returns true if aDocument is a chrome document.

static PRBool nsContentUtils::IsDraggableImage ( nsIContent *  aContent  )  [static]

Method that decides whether a content node is a draggable image.

Parameters:
aContent The content node to test.
Returns:
whether it's a draggable image
static PRBool nsContentUtils::IsDraggableLink ( nsIContent *  aContent  )  [static]

Method that decides whether a content node is a draggable link.

Parameters:
aContent The content node to test.
Returns:
whether it's a draggable link
static PRBool nsContentUtils::IsEventAttributeName ( nsIAtom aName,
PRInt32  aType 
) [static]

Determines if an event attribute name (such as onclick) is valid for a given element type.

Types are from the EventNameType enumeration defined above.

Parameters:
aName the event name to look up
aType the type of content
static PRBool nsContentUtils::IsHTMLWhitespace ( PRUnichar  aChar  )  [static]
static PRBool nsContentUtils::IsImageInCache ( nsIURI aURI  )  [static]

Returns whether the given URI is in the image cache.

static PRBool nsContentUtils::IsInChromeDocshell ( nsIDocument *  aDocument  )  [static]

Returns true if aDocument belongs to a chrome docshell for display purposes.

Returns false for null documents or documents which do not belong to a docshell.

static PRBool nsContentUtils::IsInitialized (  )  [inline, static]
static PRBool nsContentUtils::IsInSameAnonymousTree ( nsINode *  aNode,
nsIContent *  aContent 
) [static]

If aNode is not an element, return true exactly when aContent's binding parent is null.

If aNode is an element, return true exactly when aContent's binding parent is the same as aNode's.

This method is particularly useful for callers who are trying to ensure that they are working with a non-anonymous descendant of a given node. If aContent is a descendant of aNode, a return value of PR_FALSE from this method means that it's an anonymous descendant from aNode's point of view.

Both arguments to this method must be non-null.

static nsIAtom* nsContentUtils::IsNamedItem ( nsIContent *  aContent  )  [static]

If aContent is an HTML element with a DOM level 0 'name', then return the name.

Otherwise return null.

static PRBool nsContentUtils::IsPunctuationMark ( PRUint32  aChar  )  [static]

Returns true if aChar is of class Ps, Pi, Po, Pf, or Pe.

static PRBool nsContentUtils::IsPunctuationMarkAt ( const nsTextFragment aFrag,
PRUint32  aOffset 
) [static]
static PRBool nsContentUtils::IsSafeToRunScript (  )  [inline, static]

Returns true if it's safe to execute content script and false otherwise.

The only known case where this lies is mutation events. They run, and can run anything else, when this function returns false, but this is ok.

static PRBool nsContentUtils::IsValidNodeName ( nsIAtom aLocalName,
nsIAtom aPrefix,
PRInt32  aNamespaceID 
) [static]

Checks if the localname/prefix/namespace triple is valid wrt prefix and namespace according to the Namespaces in XML and DOM Code specfications.

Parameters:
aLocalname localname of the node
aPrefix prefix of the node
aNamespaceID namespace of the node
static nsILineBreaker* nsContentUtils::LineBreaker (  )  [inline, static]
static nsresult nsContentUtils::LoadImage ( nsIURI aURI,
nsIDocument *  aLoadingDocument,
nsIPrincipal aLoadingPrincipal,
nsIURI aReferrer,
imgIDecoderObserver aObserver,
PRInt32  aLoadFlags,
imgIRequest **  aRequest 
) [static]

Method to start an image load.

This does not do any security checks. This method will attempt to make aURI immutable; a caller that wants to keep a mutable version around should pass in a clone.

Parameters:
aURI uri of the image to be loaded
aLoadingDocument the document we belong to
aLoadingPrincipal the principal doing the load
aReferrer the referrer URI
aObserver the observer for the image load
aLoadFlags the load flags to use. See nsIRequest
Returns:
the imgIRequest for the image load
static nsresult nsContentUtils::LookupNamespaceURI ( nsIContent *  aNamespaceResolver,
const nsAString aNamespacePrefix,
nsAString aNamespaceURI 
) [static]
static nsIContent* nsContentUtils::MatchElementId ( nsIContent *  aContent,
nsIAtom aId 
) [static]

Similar to above, but to be used if one already has an atom for the ID.

static nsIContent* nsContentUtils::MatchElementId ( nsIContent *  aContent,
const nsAString aId 
) [static]

Brute-force search of the element subtree rooted at aContent for an element with the given id.

aId must be nonempty, otherwise this method may return nodes even if they have no id!

static nsresult nsContentUtils::NameChanged ( nsINodeInfo *  aNodeInfo,
nsIAtom aName,
nsINodeInfo **  aResult 
) [inline, static]

Convenience method to create a new nodeinfo that differs only by name from aNodeInfo.

static nsINameSpaceManager* nsContentUtils::NameSpaceManager (  )  [inline, static]
static nsresult nsContentUtils::NewURIWithDocumentCharset ( nsIURI **  aResult,
const nsAString aSpec,
nsIDocument *  aDocument,
nsIURI aBaseURI 
) [static]

Create a new nsIURI from aSpec, using aBaseURI as the base.

The origin charset of the new nsIURI will be the document charset of aDocument.

static void nsContentUtils::NotifyInstalledMenuKeyboardListener ( PRBool  aInstalling  )  [static]
static PRBool nsContentUtils::OfflineAppAllowed ( nsIURI aURI  )  [static]

Check whether an application should be allowed to use offline APIs.

static PRBool nsContentUtils::OfflineAppAllowed ( nsIPrincipal aPrincipal  )  [static]

Check whether an application should be allowed to use offline APIs.

static PRBool nsContentUtils::PositionIsBefore ( nsINode *  aNode1,
nsINode *  aNode2 
) [inline, static]

Returns true if aNode1 is before aNode2 in the same connected tree.

static nsresult nsContentUtils::PrefixChanged ( nsINodeInfo *  aNodeInfo,
nsIAtom aPrefix,
nsINodeInfo **  aResult 
) [inline, static]

Convenience method to create a new nodeinfo that differs only by prefix from aNodeInfo.

static void nsContentUtils::PreserveWrapper ( nsISupports aScriptObjectHolder,
nsWrapperCache aCache 
) [inline, static]
static nsresult nsContentUtils::ProcessViewportInfo ( nsIDocument *  aDocument,
const nsAString viewportInfo 
) [static]
static void nsContentUtils::RegisterPrefCallback ( const char *  aPref,
PrefChangedFunc  aCallback,
void *  aClosure 
) [static]
static nsresult nsContentUtils::ReleasePtrOnShutdown ( nsISupports **  aSupportsPtr  )  [inline, static]

Release *aSupportsPtr when the shutdown notification is received.

static void nsContentUtils::ReleaseWrapper ( nsISupports aScriptObjectHolder,
nsWrapperCache aCache 
) [inline, static]
static void nsContentUtils::RemoveListenerManager ( nsINode *  aNode  )  [static]

Remove the eventlistener manager for aNode.

Parameters:
aNode The node for which to remove the eventlistener manager.
static void nsContentUtils::RemoveRemovableScriptBlocker (  )  [inline, static]
static void nsContentUtils::RemoveScriptBlocker (  )  [static]

Decreases the count of blockers preventing scripts from running.

NOTE: You might want to use nsAutoScriptBlocker rather than calling this directly

WARNING! Calling this function could synchronously execute scripts.

static nsresult nsContentUtils::ReparentContentWrapper ( nsIContent *  aNode,
nsIContent *  aNewParent,
nsIDocument *  aNewDocument,
nsIDocument *  aOldDocument 
) [static]
static nsresult nsContentUtils::ReparentContentWrappersInScope ( nsIScriptGlobalObject *  aOldScope,
nsIScriptGlobalObject *  aNewScope 
) [static]

When a document's scope changes (e.g., from document.open(), call this function to move all content wrappers from the old scope to the new one.

static nsresult nsContentUtils::ReportToConsole ( PropertiesFile  aFile,
const char *  aMessageName,
const PRUnichar **  aParams,
PRUint32  aParamsLength,
nsIURI aURI,
const nsAFlatString aSourceLine,
PRUint32  aLineNumber,
PRUint32  aColumnNumber,
PRUint32  aErrorFlags,
const char *  aCategory 
) [static]
static PRUint16 nsContentUtils::ReverseDocumentPosition ( PRUint16  aDocumentPosition  )  [static]

Reverses the document position flags passed in.

Parameters:
aDocumentPosition The document position flags to be reversed.
Returns:
The reversed document position flags.
See also:
nsIDOMNode
nsIDOM3Node
static nsresult nsContentUtils::SetDataTransferInEvent ( nsDragEvent aDragEvent  )  [static]
static nsresult nsContentUtils::SetNodeTextContent ( nsIContent *  aContent,
const nsAString aValue,
PRBool  aTryReuse 
) [static]

Sets the text contents of a node by replacing all existing children with a single text child.

The function always notifies.

Will reuse the first text child if one is available. Will not reuse existing cdata children.

Parameters:
aContent Node to set contents of.
aValue Value to set contents to.
aTryReuse When true, the function will try to reuse an existing textnodes rather than always creating a new one.
static void nsContentUtils::Shutdown (  )  [static]
static void nsContentUtils::SplitExpatName ( const PRUnichar aExpatName,
nsIAtom **  aPrefix,
nsIAtom **  aTagName,
PRInt32 *  aNameSpaceID 
) [static]
static nsresult nsContentUtils::SplitQName ( nsIContent *  aNamespaceResolver,
const nsAFlatString aQName,
PRInt32 *  aNamespace,
nsIAtom **  aLocalName 
) [static]
static nsIThreadJSContextStack* nsContentUtils::ThreadJSContextStack (  )  [inline, static]
static void nsContentUtils::TraceWrapper ( nsWrapperCache aCache,
TraceCallback  aCallback,
void *  aClosure 
) [inline, static]
static void nsContentUtils::TraverseListenerManager ( nsINode *  aNode,
nsCycleCollectionTraversalCallback cb 
) [static]

Used only during traversal of the XPCOM graph by the cycle collector: push a pointer to the listener manager onto the children deque, if it exists.

Do nothing if there is no listener manager.

Crucially: does not perform any refcounting operations.

Parameters:
aNode The node to traverse.
children The buffer to push a listener manager pointer into.
static void nsContentUtils::TriggerLink ( nsIContent *  aContent,
nsPresContext aPresContext,
nsIURI aLinkURI,
const nsString_external aTargetSpec,
PRBool  aClick,
PRBool  aIsUserTriggered 
) [static]

Trigger a link with uri aLinkURI.

If aClick is false, this triggers a mouseover on the link, otherwise it triggers a load after doing a security check using aContent's principal.

Parameters:
aContent the node on which a link was triggered.
aPresContext the pres context, must be non-null.
aLinkURI the URI of the link, must be non-null.
aTargetSpec the target (like target=, may be empty).
aClick whether this was a click or not (if false, this method assumes you just hovered over the link).
aIsUserTriggered whether the user triggered the link. This would be false for loads from auto XLinks or from the click() method if we ever implement it.
static const nsDependentSubstring_external nsContentUtils::TrimCharsInSet ( const char *  aSet,
const nsAString aValue 
) [static]
static const nsDependentSubstring_external nsContentUtils::TrimWhitespace ( const nsAString aStr,
PRBool  aTrimTrailing = 1 
) [static]
static void nsContentUtils::UnregisterPrefCallback ( const char *  aPref,
PrefChangedFunc  aCallback,
void *  aClosure 
) [static]
static PRBool nsContentUtils::URIIsLocalFile ( nsIURI aURI  )  [static]

Return true if aURI is a local file URI (i.e.

file://).

static nsIWordBreaker* nsContentUtils::WordBreaker (  )  [inline, static]
static nsresult nsContentUtils::WrapNative ( JSContext cx,
JSObject scope,
nsISupports native,
const nsIID *  aIID,
jsval vp,
nsIXPConnectJSObjectHolder **  aHolder = 0,
PRBool  aAllowWrapping = 0 
) [static]
static nsresult nsContentUtils::WrapNative ( JSContext cx,
JSObject scope,
nsISupports native,
jsval vp,
nsIXPConnectJSObjectHolder **  aHolder = 0,
PRBool  aAllowWrapping = 0 
) [inline, static]
static nsIXPConnect* nsContentUtils::XPConnect (  )  [inline, static]

Return the nsIXPConnect service.


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