inIDOMUtils 编辑

layout/inspector/inIDOMUtils.idlScriptable DOM utility functions. Inherits from: nsISupports Last changed in Gecko 22.0 (Firefox 22.0 / Thunderbird 22.0 / SeaMonkey 2.19)

Implemented by: @mozilla.org/inspector/dom-utils;1 as a service:

var inIDOMUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"]
                  .getService(Components.interfaces.inIDOMUtils);

Method overview

void addPseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass);
void clearPseudoClassLocks(in nsIDOMElement aElement);
[implicit_jscontext] jsval colorNameToRGB(in DOMString aColorName);
nsIArray getBindingURLs(in nsIDOMElement aElement);
nsIDOMNodeList getChildrenForNode(in nsIDOMNode aNode, in boolean aShowingAnonymousContent);
unsigned long long getContentState(in nsIDOMElement aElement);
void getCSSPropertyNames([optional] in unsigned long aFlags, [optional] out unsigned long aCount, [retval, array, size_is(aCount)] out wstring aProps);
nsISupportsArray getCSSStyleRules(in nsIDOMElement aElement, [optional] in DOMString aPseudo);
nsIDOMNode getParentForNode(in nsIDOMNode aNode, in boolean aShowingAnonymousContent);
unsigned long getRuleLine(in nsIDOMCSSStyleRule aRule);
unsigned long getRuleColumn(in nsIDOMCSSStyleRule aRule);
unsigned long getSelectorCount(in nsIDOMCSSStyleRule aRule);
AString getSelectorText(in nsIDOMCSSStyleRule aRule, in unsigned long aSelectorIndex);
unsigned long long getSpecificity(in nsIDOMCSSStyleRule aRule, in unsigned long aSelectorIndex);
nsIDOMFontFaceList getUsedFontFaces(in nsIDOMRange aRange);
bool hasPseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass);
boolean isIgnorableWhitespace(in nsIDOMCharacterData aDataNode);
bool isInheritedProperty(in AString aPropertyName);
void parseStyleSheet(in nsIDOMCSSStyleSheet aSheet, in DOMString aInput);
void removePseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass);
AString rgbToColorName(in octet aR, in octet aG, in octet aB);
bool selectorMatchesElement(in nsIDOMElement aElement, in nsIDOMCSSStyleRule aRule, in unsigned long aSelectorIndex, [optional] in DOMString aPseudo);
void setContentState(in nsIDOMElement aElement, in unsigned long long aState);

Constants

ConstantValueDescription
EXCLUDE_SHORTHANDS(1<<0)
INCLUDE_ALIASES(1<<1)

Content state flags

The content state flags are used in a bitmask.

ValueState
1:active
2:focus
4:hover
8:-moz-drag-over
16:target
1<<29:-moz-focusring

Methods

getBindingURLs()

Returns an array of nsIURI objects representing the current XML binding for the specified element.

nsIArray getBindingURLs(
  in nsIDOMElement aElement
);
Parameters
aElement
A DOM Element to retrieve the bindings of.
Return value

An array of nsIURI objects representing the current XBL binding (if any) for the element and its hierarchy of base bindings.

getChildrenForNode()

Returns a list of DOM nodes that are children of the specified node.

nsIDOMNodeList getChildrenForNode(
  in nsIDOMNode aNode,
  in boolean aShowingAnonymousContent
);
Parameters
aNode
A DOM Node for which to retrieve the style nodes.
aShowingAnonymousContent
Whether you are interested in the XBL flattened tree.
Return value

A DOM NodeList of the child nodes. If you have requested anonymous content, then if the element has an XBL binding then this will be the binding's anonymous nodes, otherwise if the element is itself an anonymous node containing an insertion point then this will be a list combining the element's explicit children from its binding parent's anonymous nodes and any children inserted as a result of the insertion point.

getContentState()

A bit mask of the supported content state flags, which are listed in Content state flags.

unsigned long long getContentState(
  in nsIDOMElement aElement
);
Parameters
aElement
A DOM Element to retrieve the content states of.
Return value

A bitmask of one of the 6 supported content state flags specified in Content state flags.

getCSSPropertyNames()

Get a list of all our supported property names

void getCSSPropertyNames(
  in unsigned long aFlags, Optional
  out unsigned long aCount, Optional
  [retval, array, size_is(aCount)] out wstring aProps
);
Parameters
aFlags Optional
Shorthands can be excluded or property aliases included. See constants.
aCount Optional
Count
aProps
Properties

getCSSStyleRules()

Returns an array of the CSS style rules on the specified element.

nsISupportsArray getCSSStyleRules(
  in nsIDOMElement aElement,
  in DOMString aPseudo Optional
);
Parameters
aElement
A DOM element to retrieve the style rules of.
aPseudo Optional
A pseudo element, such as before.
Return value

An nsISupportsArray containing all the style rules that currently apply to the element, in ascending order of weight.

getParentForNode()

Returns the parent of the specified node.

nsIDOMNode getParentForNode(
  in nsIDOMNode aNode,
  in boolean aShowingAnonymousContent
);
Parameters
aNode
The node to return the parent of.
aShowingAnonymousContent
Whether you are interested in the XBL flattened tree.
Return value

Returns the parent of a node. The parent of a document node is the frame/iframe containing that document. If you have requested anonymous content and the element's parent has an XBL binding then the element containing the insertion point is returned instead.

getRuleLine()

Returns the line number of the specified CSS style rule in its source file.

unsigned long getRuleLine(
  in nsIDOMCSSStyleRule aRule
);
Parameters
aRule
The style rule to retrieve the line number of.
Return value

The line number of the style rule; the URL of the rule can be obtained from its parent style sheet object.

getRuleColumn()

Returns the column number of the specified CSS style rule in its source file.

unsigned long getRuleColumn(
  in nsIDOMCSSStyleRule aRule
);
Parameters
aRule
The style rule to retrieve the column number of.
Return value

The column number of the style rule; the URL of the rule can be obtained from its parent style sheet object.

getUsedFontFaces()

Returns a list of the fonts specified using @font-face in the specified portion of the document.

nsIDOMFontFaceList getUsedFontFaces(
  in nsIDOMRange aRange
);
Parameters
aRange
The DOM range to retrieve the font faces of.
Return value

An nsIDOMFontFaceList object listing all the font faces used by the text in the range.

isIgnorableWhitespace()

Determines if the specified text node contains only ignorable whitespace characters.

boolean isIgnorableWhitespace(
  in nsIDOMCharacterData aDataNode
);
Parameters
aDataNode
A DOM CharacterData node; that is, a text node.
Return value

true if the node only contains insignificant whitespace. In particular, this will be false if certain CSS white-space styles are in effect.

isInheritedProperty()

Determines if the specified string names a CSS property that is inherited by default.

boolean isInheritedProperty(
  in AString aPropertyName
);
Parameters
aPropertyName
The name of the CSS property.
Return value

true if the property is inherited, otherwise false.

parseStyleSheet()

Parse CSS and update the style sheet in place.

void parseStyleSheet(
  in nsIDOMCSSStyleSheet aSheet,
  in DOMString aInput
);
Parameters
aSheet
A DOMCSSStyleSheet.
aInput
A DOMString. The new source string for the style sheet.
Return value

void

setContentState()

Sets the given element as the current owner of the specified state, and removes that state from the previous owner.

void setContentState(
  in nsIDOMElement aElement,
  in unsigned long long aState
);
Parameters
aElement
The element to set the content state of.
aState
The content state to set. This must be one (and only one) of the values listed in Content state flags.

selectorMatchesElement()

Checks if a given selector from a style rule matches an element.

bool selectorMatchesElement (
  in nsIDOMElement aElement,
  in nsIDOMCSSStyleRule aRule,
  in unsigned long aSelectorIndex,
  in DOMString aPseudo Optional
)
Parameters
aElement
The element to check the selector against.
aRule
The style rule containing the selector.
aSelectorIndex
The index of the selector.
aPseudo Optional
A string specifying the pseudo-element to match. May be omitted when checking the regular elements.

addPseudoClassLock()

Makes the element take on style properties that would apply if the element had the given pseudo-classes.

void addPseudoClassLock(
  in nsIDOMElement aElement,
  in DOMString aPseudoClass
);
Parameters
aElement
The element to set the pseudo-class lock on.
aPseudoClass
The pseudo-class to set. e.g. ":hover".

removePseudoClassLock()

Removes a pseudo-class lock from the element.

void removePseudoClassLock(
  in nsIDOMElement aElement,
  in DOMString aPseudoClass
);
Parameters
aElement
The element to remove the pseudo-class lock from.
aPseudoClass
The pseudo-class to remove the lock of. e.g. ":hover".

hasPseudoClassLock()

Checks whether the element element has a particular pseudo-class lock applied.

boolean hasPseudoClassLock(
  in nsIDOMElement aElement,
  in DOMString aPseudoClass
);
Parameters
aElement
The element to test.
aPseudoClass
The pseudo-class lock to test for existence, e.g. ":hover".
Return value

true if lock exists, false otherwise

clearPseudoClassLocks()

Removes any pseudo-class locks from the element.

void clearPseudoClassLocks(
  in nsIDOMElement aElement
);
Parameters
aElement
The element to remove the pseudo-class locks from.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:134 次

字数:23678

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文