CSSStyleRule.webidl (2297B)
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. 5 * 6 * The origin of this IDL file is 7 * https://drafts.csswg.org/cssom/#the-cssstylerule-interface 8 */ 9 10 // https://drafts.csswg.org/cssom/#the-cssstylerule-interface 11 [Exposed=Window] 12 interface CSSStyleRule : CSSGroupingRule { 13 attribute UTF8String selectorText; 14 [SameObject, PutForwards=cssText] readonly attribute CSSStyleProperties style; 15 16 [ChromeOnly] readonly attribute unsigned long selectorCount; 17 [ChromeOnly] UTF8String selectorTextAt(unsigned long index, optional boolean desugared = false); 18 [ChromeOnly] unsigned long long selectorSpecificityAt(unsigned long index, optional boolean desugared = false); 19 [ChromeOnly] boolean selectorMatchesElement( 20 unsigned long selectorIndex, 21 Element element, 22 optional [LegacyNullToEmptyString] DOMString pseudo = "", 23 optional boolean includeVisitedStyle = false); 24 // Get scope root of this style rule's selector. Returns null if the rule is not within a scope rule, 25 // or if this selector does not match this style rule (Whether by not matching the selector, or it 26 // not having a no viable scope root). 27 [ChromeOnly] Element? getScopeRootFor( 28 unsigned long selectorIndex, 29 Element element, 30 optional [LegacyNullToEmptyString] DOMString pseudo = "", 31 optional boolean includeVisitedStyle = false); 32 [ChromeOnly] sequence<SelectorWarning> getSelectorWarnings(); 33 // Get elements on the page matching the rule's selectors. This is helpful for DevTools 34 // so we can avoid computing a desugared selector, which can be very expensive on deeply 35 // nested rules. 36 [ChromeOnly] NodeList querySelectorAll(Node root); 37 }; 38 39 enum SelectorWarningKind { 40 "UnconstrainedHas", 41 "SiblingCombinatorAfterScope", 42 }; 43 44 dictionary SelectorWarning { 45 required unsigned long index; 46 required SelectorWarningKind kind; 47 }; 48 49 // https://drafts.css-houdini.org/css-typed-om-1/#declared-stylepropertymap-objects 50 partial interface CSSStyleRule { 51 [SameObject, Pref="layout.css.typed-om.enabled"] readonly attribute StylePropertyMap styleMap; 52 };