21 KiB
CSS
_Auto generated documentation for WebKit inspector
This domain exposes CSS read/write operations. All CSS objects, like stylesheets, rules, and styles, have an associated id used in subsequent operations on the related object. Each object type has a specific id structure, and those are not interchangeable between objects of different kinds. CSS objects can be loaded using the get*ForNode() calls (which accept a DOM node id). Alternatively, a client can discover all the existing stylesheets with the getAllStyleSheets() method and subsequently load the required stylesheet contents using the getStyleSheetText methods.
- Commands
- enable
- disable
- getMatchedStylesForNode
- getInlineStylesForNode
- getComputedStyleForNode
- getAllStyleSheets
- getStyleSheet
- getStyleSheetText
- setStyleSheetText
- setStyleText
- setRuleSelector
- addRule
- getSupportedCSSProperties
- forcePseudoState
- getNamedFlowCollection
- Events
- mediaQueryResultChanged
- styleSheetChanged
- namedFlowCreated
- namedFlowRemoved
- regionOversetChanged
- registeredNamedFlowContentElement
- unregisteredNamedFlowContentElement
- Types
- StyleSheetId
- CSSStyleId
- StyleSheetOrigin
- CSSRuleId
- PseudoIdMatches
- InheritedStyleEntry
- RuleMatch
- CSSSelector
- SelectorList
- CSSStyleAttribute
- CSSStyleSheetHeader
- CSSStyleSheetBody
- CSSRule
- SourceRange
- ShorthandEntry
- CSSPropertyInfo
- CSSComputedStyleProperty
- CSSStyle
- CSSPropertyStatus
- CSSProperty
- CSSMedia
- Region
- NamedFlow
Commands
CSS.enable(callback)
Enables the CSS agent for the given page. Clients should not assume that the CSS agent has been enabled until the result of this command is received.
Parameters
callback ( function )
Results
error ( error )
CSS.disable(callback)
Disables the CSS agent for the given page.
Parameters
callback ( function )
Results
error ( error )
CSS.getMatchedStylesForNode(DOM.NodeId, [includePseudo], [includeInherited], callback)
Returns requested styles for a DOM node identified by nodeId.
Parameters
nodeId ( DOM.NodeId )
includePseudo ( optional boolean )
Whether to include pseudo styles (default: true).
includeInherited ( optional boolean )
Whether to include inherited styles (default: true).
callback ( function )
Results
error ( error )
matchedCSSRules ( optional array of RuleMatch )
CSS rules matching this node, from all applicable stylesheets.
pseudoElements ( optional array of PseudoIdMatches )
Pseudo style matches for this node.
inherited ( optional array of InheritedStyleEntry )
A chain of inherited styles (from the immediate node parent up to the DOM tree root).
CSS.getInlineStylesForNode(DOM.NodeId, callback)
Returns the styles defined inline (explicitly in the "style" attribute and implicitly, using DOM attributes) for a DOM node identified by nodeId.
Parameters
nodeId ( DOM.NodeId )
callback ( function )
Results
error ( error )
inlineStyle ( optional CSSStyle )
Inline style for the specified DOM node.
attributesStyle ( optional CSSStyle )
Attribute-defined element style (e.g. resulting from "width=20 height=100%").
CSS.getComputedStyleForNode(DOM.NodeId, callback)
Returns the computed style for a DOM node identified by nodeId.
Parameters
nodeId ( DOM.NodeId )
callback ( function )
Results
error ( error )
computedStyle ( array of CSSComputedStyleProperty )
Computed style for the specified DOM node.
CSS.getAllStyleSheets(callback)
Returns metainfo entries for all known stylesheets.
Parameters
callback ( function )
Results
error ( error )
headers ( array of CSSStyleSheetHeader )
Descriptor entries for all available stylesheets.
CSS.getStyleSheet(StyleSheetId, callback)
Returns stylesheet data for the specified styleSheetId.
Parameters
styleSheetId ( StyleSheetId )
callback ( function )
Results
error ( error )
styleSheet ( CSSStyleSheetBody )
Stylesheet contents for the specified
styleSheetId.
CSS.getStyleSheetText(StyleSheetId, callback)
Returns the current textual content and the URL for a stylesheet.
Parameters
styleSheetId ( StyleSheetId )
callback ( function )
Results
error ( error )
text ( string )
The stylesheet text.
CSS.setStyleSheetText(StyleSheetId, text, callback)
Sets the new stylesheet text, thereby invalidating all existing CSSStyleId's and CSSRuleId's contained by this stylesheet.
Parameters
styleSheetId ( StyleSheetId )
text ( string )
callback ( function )
Results
error ( error )
CSS.setStyleText(CSSStyleId, text, callback)
Sets the new text for the respective style.
Parameters
styleId ( CSSStyleId )
text ( string )
callback ( function )
Results
error ( error )
style ( CSSStyle )
The resulting style after the text modification.
CSS.setRuleSelector(CSSRuleId, selector, callback)
Modifies the rule selector.
Parameters
ruleId ( CSSRuleId )
selector ( string )
callback ( function )
Results
error ( error )
rule ( CSSRule )
The resulting rule after the selector modification.
CSS.addRule(DOM.NodeId, selector, callback)
Creates a new empty rule with the given selector in a special "inspector" stylesheet in the owner document of the context node.
Parameters
contextNodeId ( DOM.NodeId )
selector ( string )
callback ( function )
Results
error ( error )
rule ( CSSRule )
The newly created rule.
CSS.getSupportedCSSProperties(callback)
Returns all supported CSS property names.
Parameters
callback ( function )
Results
error ( error )
cssProperties ( array of CSSPropertyInfo )
Supported property metainfo.
CSS.forcePseudoState(DOM.NodeId, forcedPseudoClasses, callback)
Ensures that the given node will have specified pseudo-classes whenever its style is computed by the browser.
Parameters
nodeId ( DOM.NodeId )
The element id for which to force the pseudo state.
forcedPseudoClasses ( array enumerated ["active","focus","hover","visited"] )
Element pseudo classes to force when computing the element's style.
callback ( function )
Results
error ( error )
CSS.getNamedFlowCollection(DOM.NodeId, callback)
Returns the Named Flows from the document.
Parameters
documentNodeId ( DOM.NodeId )
The document node id for which to get the Named Flow Collection.
callback ( function )
Results
error ( error )
namedFlows ( array of NamedFlow )
An array containing the Named Flows in the document.
Events
Event: mediaQueryResultChanged
Fires whenever a MediaQuery result changes (for example, after a browser window has been resized.) The current implementation considers only viewport-dependent media features.
Event: styleSheetChanged
Fired whenever a stylesheet is changed as a result of the client operation.
Results
styleSheetId ( StyleSheetId )
Event: namedFlowCreated
Fires when a Named Flow is created.
Results
namedFlow ( NamedFlow )
The new Named Flow.
Event: namedFlowRemoved
Fires when a Named Flow is removed: has no associated content nodes and regions.
Results
documentNodeId ( DOM.NodeId )
The document node id.
flowName ( string )
Identifier of the removed Named Flow.
Event: regionOversetChanged
Fires if any of the regionOverset values changed in a Named Flow's region chain.
Results
namedFlow ( NamedFlow )
The Named Flow containing the regions whose regionOverset values changed.
Event: registeredNamedFlowContentElement
Fires when a Named Flow's has been registered with a new content node.
Results
documentNodeId ( DOM.NodeId )
The document node id.
flowName ( string )
Named Flow identifier for which the new content element was registered.
contentNodeId ( DOM.NodeId )
The node id of the registered content node.
nextContentNodeId ( DOM.NodeId )
The node id of the element following the registered content node.
Event: unregisteredNamedFlowContentElement
Fires when a Named Flow's has been registered with a new content node.
Results
documentNodeId ( DOM.NodeId )
The document node id.
flowName ( string )
Named Flow identifier for which the new content element was unregistered.
contentNodeId ( DOM.NodeId )
The node id of the unregistered content node.
Types
Class: StyleSheetId
Type: string
Class: CSSStyleId
Type: object
This object identifies a CSS style in a unique way.
Properties
styleSheetId ( StyleSheetId )
Enclosing stylesheet identifier.
ordinal ( integer )
The style ordinal within the stylesheet.
Class: StyleSheetOrigin
Type: string
Stylesheet type: "user" for user stylesheets, "user-agent" for user-agent stylesheets, "inspector" for stylesheets created by the inspector (i.e. those holding the "via inspector" rules), "regular" for regular stylesheets.
Class: CSSRuleId
Type: object
This object identifies a CSS rule in a unique way.
Properties
styleSheetId ( StyleSheetId )
Enclosing stylesheet identifier.
ordinal ( integer )
The rule ordinal within the stylesheet.
Class: PseudoIdMatches
Type: object
CSS rule collection for a single pseudo style.
Properties
pseudoId ( integer )
Pseudo style identifier (see
enum PseudoIdinRenderStyleConstants.h).
matches ( array of RuleMatch )
Matches of CSS rules applicable to the pseudo style.
Class: InheritedStyleEntry
Type: object
CSS rule collection for a single pseudo style.
Properties
inlineStyle ( optional CSSStyle )
The ancestor node's inline style, if any, in the style inheritance chain.
matchedCSSRules ( array of RuleMatch )
Matches of CSS rules matching the ancestor node in the style inheritance chain.
Class: RuleMatch
Type: object
Match data for a CSS rule.
Properties
rule ( CSSRule )
CSS rule in the match.
matchingSelectors ( array )
Matching selector indices in the rule's selectorList selectors (0-based).
Class: CSSSelector
Type: object
CSS selector.
Properties
text ( string )
Canonicalized selector text.
specificity ( optional array )
Specificity (a, b, c) tuple. Included if the selector is sent in response to CSS.getMatchedStylesForNode which provides a context element.
dynamic ( optional boolean )
Whether or not the specificity can be dynamic. Included if the selector is sent in response to CSS.getMatchedStylesForNode which provides a context element.
Class: SelectorList
Type: object
Selector list data.
Properties
selectors ( array of CSSSelector )
Selectors in the list.
text ( string )
Rule selector text.
range ( optional SourceRange )
Rule selector range in the underlying resource (if available).
Class: CSSStyleAttribute
Type: object
CSS style information for a DOM style attribute.
Properties
name ( string )
DOM attribute name (e.g. "width").
style ( CSSStyle )
CSS style generated by the respective DOM attribute.
Class: CSSStyleSheetHeader
Type: object
CSS stylesheet metainformation.
Properties
styleSheetId ( StyleSheetId )
The stylesheet identifier.
frameId ( Network.FrameId )
Owner frame identifier.
sourceURL ( string )
Stylesheet resource URL.
origin ( StyleSheetOrigin )
Stylesheet origin.
title ( string )
Stylesheet title.
disabled ( boolean )
Denotes whether the stylesheet is disabled.
Class: CSSStyleSheetBody
Type: object
CSS stylesheet contents.
Properties
styleSheetId ( StyleSheetId )
The stylesheet identifier.
rules ( array of CSSRule )
Stylesheet resource URL.
text ( optional string )
Stylesheet resource contents (if available).
Class: CSSRule
Type: object
CSS rule representation.
Properties
ruleId ( optional CSSRuleId )
The CSS rule identifier (absent for user agent stylesheet and user-specified stylesheet rules).
selectorList ( SelectorList )
Rule selector data.
sourceURL ( optional string )
Parent stylesheet resource URL (for regular rules).
sourceLine ( integer )
Line ordinal of the rule selector start character in the resource.
origin ( StyleSheetOrigin )
Parent stylesheet's origin.
style ( CSSStyle )
Associated style declaration.
media ( optional array of CSSMedia )
Media list array (for rules involving media queries). The array enumerates media queries starting with the innermost one, going outwards.
Class: SourceRange
Type: object
Text range within a resource.
Properties
startLine ( integer )
Start line of range.
startColumn ( integer )
Start column of range (inclusive).
endLine ( integer )
End line of range
endColumn ( integer )
End column of range (exclusive).
Class: ShorthandEntry
Type: object
Properties
name ( string )
Shorthand name.
value ( string )
Shorthand value.
Class: CSSPropertyInfo
Type: object
Properties
name ( string )
Property name.
longhands ( optional array )
Longhand property names.
values ( optional array )
Supported values for this property.
Class: CSSComputedStyleProperty
Type: object
Properties
name ( string )
Computed style property name.
value ( string )
Computed style property value.
Class: CSSStyle
Type: object
CSS style representation.
Properties
styleId ( optional CSSStyleId )
The CSS style identifier (absent for attribute styles).
cssProperties ( array of CSSProperty )
CSS properties in the style.
shorthandEntries ( array of ShorthandEntry )
Computed values for all shorthands found in the style.
cssText ( optional string )
Style declaration text (if available).
range ( optional SourceRange )
Style declaration range in the enclosing stylesheet (if available).
width ( optional string )
The effective "width" property value from this style.
height ( optional string )
The effective "height" property value from this style.
Class: CSSPropertyStatus
Type: string
The property status: "active" if the property is effective in the style, "inactive" if the property is overridden by a same-named property in this style later on, "disabled" if the property is disabled by the user, "style" (implied if absent) if the property is reported by the browser rather than by the CSS source parser.
Class: CSSProperty
Type: object
CSS style effective visual dimensions and source offsets.
Properties
name ( string )
The property name.
value ( string )
The property value.
priority ( optional string )
The property priority (implies "" if absent).
implicit ( optional boolean )
Whether the property is implicit (implies
falseif absent).
text ( optional string )
The full property text as specified in the style.
parsedOk ( optional boolean )
Whether the property is understood by the browser (implies
trueif absent).
status ( optional CSSPropertyStatus )
Whether the property is active or disabled.
range ( optional SourceRange )
The entire property range in the enclosing style declaration (if available).
Class: CSSMedia
Type: object
CSS media query descriptor.
Properties
text ( string )
Media query text.
source ( string enumerated ["mediaRule","importRule","linkedSheet","inlineSheet"] )
Source of the media query: "mediaRule" if specified by a @media rule, "importRule" if specified by an @import rule, "linkedSheet" if specified by a "media" attribute in a linked stylesheet's LINK tag, "inlineSheet" if specified by a "media" attribute in an inline stylesheet's STYLE tag.
sourceURL ( optional string )
URL of the document containing the media query description.
sourceLine ( optional integer )
Line in the document containing the media query (not defined for the "stylesheet" source).
Class: Region
Type: object
This object represents a region that flows from a Named Flow.
Properties
regionOverset ( string enumerated ["overset","fit","empty"] )
The "overset" attribute of a Named Flow.
nodeId ( DOM.NodeId )
The corresponding DOM node id.
Class: NamedFlow
Type: object
This object represents a Named Flow.
Properties
documentNodeId ( DOM.NodeId )
The document node id.
name ( string )
Named Flow identifier.
overset ( boolean )
The "overset" attribute of a Named Flow.
content ( array of DOM.NodeId )
An array of nodes that flow into the Named Flow.
regions ( array of Region )
An array of regions associated with the Named Flow.