tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

InspectorUtils.webidl (14962B)


      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 
      7 /**
      8 * A collection of utility methods for use by devtools.
      9 *
     10 * See InspectorUtils.h for documentation on these methods.
     11 */
     12 [Func="nsContentUtils::IsCallerChromeOrFuzzingEnabled",
     13 Exposed=Window]
     14 namespace InspectorUtils {
     15  // documentOnly tells whether user and UA sheets should get included.
     16  sequence<StyleSheet> getAllStyleSheets(Document document, optional boolean documentOnly = false);
     17  sequence<(CSSRule or InspectorDeclaration)> getMatchingCSSRules(
     18    Element element,
     19    optional [LegacyNullToEmptyString] DOMString pseudo = "",
     20    optional boolean relevantLinkVisited = false,
     21    optional boolean withStartingStyle = false);
     22  unsigned long getRuleLine(CSSRule rule);
     23  unsigned long getRuleColumn(CSSRule rule);
     24  unsigned long getRelativeRuleLine(CSSRule rule);
     25  sequence<unsigned long> getRuleIndex(CSSRule rule);
     26  boolean hasRulesModifiedByCSSOM(CSSStyleSheet sheet);
     27  // Get a flat list of specific at-rules (including nested ones) of a given stylesheet.
     28  // Useful for DevTools (StyleEditor at-rules sidebar) as this is faster than in JS
     29  // where we'd have a lot of proxy access overhead building the same list.
     30  InspectorStyleSheetRuleCountAndAtRulesResult getStyleSheetRuleCountAndAtRules(CSSStyleSheet sheet);
     31  boolean isInheritedProperty(Document document, UTF8String property);
     32  sequence<DOMString> getCSSPropertyNames(optional PropertyNamesOptions options = {});
     33  sequence<PropertyPref> getCSSPropertyPrefs();
     34  [Throws] sequence<DOMString> getCSSValuesForProperty(UTF8String property);
     35  UTF8String rgbToColorName(octet r, octet g, octet b);
     36  InspectorNearestColor rgbToNearestColorName(float r, float g, float b);
     37  sequence<float> rgbToHsv(float r, float g, float b);
     38  sequence<float> hsvToRgb(float h, float s, float v);
     39  float relativeLuminance(float r, float g, float b);
     40  InspectorRGBATuple? colorToRGBA(UTF8String colorString);
     41  InspectorColorToResult? colorTo(UTF8String fromColor, UTF8String toColorSpace);
     42  boolean isValidCSSColor(UTF8String colorString);
     43  [Throws] sequence<DOMString> getSubpropertiesForCSSProperty(UTF8String property);
     44  [Throws] boolean cssPropertyIsShorthand(UTF8String property);
     45 
     46  [Throws] boolean cssPropertySupportsType(UTF8String property, InspectorPropertyType type);
     47 
     48  // A version of CSS.supports that allows you to set UA or chrome context.
     49  boolean supports(UTF8String conditionText, optional SupportsOptions options = {});
     50 
     51  boolean isIgnorableWhitespace(CharacterData dataNode);
     52  Node? getParentForNode(Node node, boolean showingAnonymousContent);
     53  sequence<Node> getChildrenForNode(Node node,
     54                                    boolean showingAnonymousContent,
     55                                    boolean includeAssignedNodes);
     56  [Throws] boolean setContentState(Element element, unsigned long long state);
     57  [Throws] boolean removeContentState(
     58      Element element,
     59      unsigned long long state,
     60      optional boolean clearActiveDocument = false);
     61  unsigned long long getContentState(Element element);
     62 
     63  // Get the font face(s) actually used to render the text in /range/,
     64  // as a collection of InspectorFontFace objects (below).
     65  // If /maxRanges/ is greater than zero, each InspectorFontFace will record
     66  // up to /maxRanges/ fragments of content that used the face, for the caller
     67  // to access via its .ranges attribute.
     68  [NewObject, Throws] sequence<InspectorFontFace> getUsedFontFaces(
     69      Range range,
     70      optional unsigned long maxRanges = 0,
     71      optional boolean skipCollapsedWhitespace = true);
     72 
     73  sequence<DOMString> getCSSPseudoElementNames();
     74  undefined addPseudoClassLock(Element element,
     75                               DOMString pseudoClass,
     76                               optional boolean enabled = true);
     77  undefined removePseudoClassLock(Element element, DOMString pseudoClass);
     78  boolean hasPseudoClassLock(Element element, DOMString pseudoClass);
     79  undefined clearPseudoClassLocks(Element element);
     80  [Throws] undefined parseStyleSheet(CSSStyleSheet sheet, UTF8String input);
     81  boolean isCustomElementName([LegacyNullToEmptyString] DOMString name,
     82                              DOMString? namespaceURI);
     83 
     84  boolean isElementThemed(Element element);
     85 
     86  boolean isUsedColorSchemeDark(Element element);
     87 
     88  Element? containingBlockOf(Element element);
     89 
     90  boolean isBlockContainer(Element element);
     91 
     92  // If the element is styled as display:block, returns an array of numbers giving
     93  // the number of lines in each fragment.
     94  // Returns null if the element is not a block.
     95  [NewObject] sequence<unsigned long>? getBlockLineCounts(Element element);
     96 
     97  [NewObject] NodeList getOverflowingChildrenOfElement(Element element);
     98  sequence<DOMString> getRegisteredCssHighlights(Document document, optional boolean activeOnly = false);
     99  sequence<InspectorCSSPropertyDefinition> getCSSRegisteredProperties(Document document);
    100  InspectorCSSPropertyDefinition? getCSSRegisteredProperty(Document document, UTF8String name);
    101  boolean valueMatchesSyntax(Document document, UTF8String value, UTF8String syntax);
    102 
    103  // Get the first rule body text within initialText
    104  // Consider the following example:
    105  // p {
    106  //  line-height: 2em;
    107  //  color: blue;
    108  // }
    109  // Calling the function with the whole text above would return:
    110  // "line-height: 2em; color: blue;"
    111  // Returns null when opening curly bracket wasn't found in initialText
    112  UTF8String? getRuleBodyText(UTF8String initialText);
    113 
    114  // Returns string where the rule body text at passed line and column in styleSheetText
    115  // is replaced by newBodyText.
    116  UTF8String? replaceBlockRuleBodyTextInStylesheet(
    117    UTF8String styleSheetText,
    118    unsigned long line,
    119    unsigned long column,
    120    UTF8String newBodyText);
    121 
    122  // Update the amount of vertical space that is clipped or visibly obscured in
    123  // the bottom portion of the view. Tells gecko where to put bottom fixed
    124  // elements so they are fully visible. aOffset must be offset from the bottom
    125  // edge of the ICB and it's negative.
    126  // Examples for aOffset:
    127  // 0: Toolbar fully visible
    128  // -dynamicToolbarMaxHeight: Toolbar fully hidden (e.g. -40 for a 40px toolbar)
    129  //
    130  // Note: These functions must be called from the parent process.
    131  //
    132  // This interface may not be the clearest, but we want to match
    133  // what has been established by the GeckoView API
    134  [ChromeOnly] undefined setVerticalClipping(BrowsingContext? aContext,
    135                                             float aOffset);
    136  [ChromeOnly] undefined setDynamicToolbarMaxHeight(BrowsingContext? aContext,
    137                                             float aHeight);
    138 
    139  // This element is not a grid container.
    140  const unsigned short GRID_NONE = 0;
    141  // This element is a grid container, and might additionally be a subgrid.
    142  const unsigned short GRID_CONTAINER = 1;
    143  // This element is a subgrid in the row direction.
    144  const unsigned short GRID_SUBGRID_ROW = 2;
    145  // This element is a subgrid in the col direction.
    146  const unsigned short GRID_SUBGRID_COL = 4;
    147  // Returns a set of GRID_* flags based on whether the element is a grid
    148  // container or not.
    149  unsigned short getGridContainerType(Element aElement);
    150 };
    151 
    152 enum DeclarationOrigin {
    153  "user",
    154  "user-agent",
    155  "pres-hints",
    156  "style-attribute",
    157  "position-fallback",
    158  "animations",
    159  "transitions",
    160  "smil",
    161 };
    162 
    163 dictionary InspectorDeclaration {
    164  required CSSStyleDeclaration style;
    165  required DeclarationOrigin declarationOrigin;
    166 };
    167 
    168 dictionary SupportsOptions {
    169  boolean userAgent = false;
    170  boolean chrome = false;
    171  boolean quirks = false;
    172 };
    173 
    174 dictionary PropertyNamesOptions {
    175  boolean includeAliases = false;
    176  boolean includeShorthands = true;
    177  boolean includeExperimentals = false;
    178 };
    179 
    180 dictionary PropertyPref {
    181  required DOMString name;
    182  required DOMString pref;
    183 };
    184 
    185 dictionary InspectorRGBATuple {
    186  /*
    187   * NOTE: This tuple is in the normal 0-255-sized RGB space but can be
    188   * fractional and may extend outside the 0-255 range.
    189   *
    190   * a is in the range 0 - 1.
    191   */
    192  double r = 0;
    193  double g = 0;
    194  double b = 0;
    195  double a = 1;
    196 };
    197 
    198 dictionary InspectorNearestColor {
    199  required UTF8String colorName;
    200  required boolean exact;
    201 };
    202 
    203 dictionary InspectorColorToResult {
    204  required DOMString color;
    205  required sequence<float> components;
    206  required boolean adjusted;
    207 };
    208 
    209 // Any update to this enum should probably also update
    210 // devtools/shared/css/constants.js
    211 enum InspectorPropertyType {
    212  "color",
    213  "gradient",
    214  "timing-function",
    215 };
    216 
    217 dictionary InspectorVariationAxis {
    218  required DOMString tag;
    219  required DOMString name;
    220  required float minValue;
    221  required float maxValue;
    222  required float defaultValue;
    223 };
    224 
    225 dictionary InspectorVariationValue {
    226  required DOMString axis;
    227  required float value;
    228 };
    229 
    230 dictionary InspectorVariationInstance {
    231  required DOMString name;
    232  required sequence<InspectorVariationValue> values;
    233 };
    234 
    235 dictionary InspectorFontFeature {
    236  required DOMString tag;
    237  required DOMString script;
    238  required DOMString languageSystem;
    239 };
    240 
    241 dictionary InspectorCSSPropertyDefinition {
    242  required UTF8String name;
    243  required UTF8String syntax;
    244  required boolean inherits;
    245  required UTF8String? initialValue;
    246  required boolean fromJS;
    247 };
    248 
    249 dictionary InspectorStyleSheetRuleCountAndAtRulesResult {
    250  required sequence<CSSRule> atRules;
    251  required unsigned long ruleCount;
    252 };
    253 
    254 [Func="nsContentUtils::IsCallerChromeOrFuzzingEnabled",
    255 Exposed=Window]
    256 interface InspectorFontFace {
    257  // OpenType IDs for some common name strings; see OpenType spec for details.
    258  // (These may not always be present; and fonts may also contain names with
    259  // other arbitrary 16-bit IDs, e.g. for variation axes, feature names, etc.)
    260  const unsigned short NAME_ID_COPYRIGHT = 0;
    261  const unsigned short NAME_ID_FAMILY = 1;
    262  const unsigned short NAME_ID_SUBFAMILY = 2;
    263  const unsigned short NAME_ID_UNIQUE = 3;
    264  const unsigned short NAME_ID_FULL = 4;
    265  const unsigned short NAME_ID_VERSION = 5;
    266  const unsigned short NAME_ID_POSTSCRIPT = 6;
    267  const unsigned short NAME_ID_TRADEMARK = 7;
    268  const unsigned short NAME_ID_MANUFACTURER = 8;
    269  const unsigned short NAME_ID_DESIGNER = 9;
    270  const unsigned short NAME_ID_DESCRIPTION = 10;
    271  const unsigned short NAME_ID_VENDOR_URL = 11;
    272  const unsigned short NAME_ID_DESIGNER_URL = 12;
    273  const unsigned short NAME_ID_LICENSE = 13;
    274  const unsigned short NAME_ID_LICENSE_URL = 14;
    275  const unsigned short NAME_ID_TYPOGRAPHIC_FAMILY = 16;
    276  const unsigned short NAME_ID_TYPOGRAPHIC_SUBFAMILY = 17;
    277  const unsigned short NAME_ID_COMPATIBLE_FULL = 18;
    278  const unsigned short NAME_ID_SAMPLE_TEXT = 19;
    279 
    280  // An indication of how we found this font during font-matching.
    281  // Note that the same physical font may have been found in multiple ways within a range.
    282  readonly attribute boolean fromFontGroup;
    283  readonly attribute boolean fromLanguagePrefs;
    284  readonly attribute boolean fromSystemFallback;
    285 
    286  // available for all fonts
    287  readonly attribute DOMString name; // full font name as obtained from the font resource
    288  readonly attribute DOMString CSSFamilyName; // a family name that could be used in CSS font-family
    289                                              // (not necessarily the actual name that was used,
    290                                              // due to aliases, generics, localized names, etc)
    291  readonly attribute DOMString CSSGeneric; // CSS generic (serif, sans-serif, etc) that was mapped
    292                                           // to this font, if any (frequently empty!)
    293 
    294  DOMString getNameString(unsigned short id);  // Specified string from OpenType 'name' table.
    295 
    296  [NewObject,Throws] sequence<InspectorVariationAxis> getVariationAxes();
    297  [NewObject,Throws] sequence<InspectorVariationInstance> getVariationInstances();
    298  [NewObject,Throws] sequence<InspectorFontFeature> getFeatures();
    299 
    300  // A list of Ranges of text rendered with this face.
    301  // This will list the first /maxRanges/ ranges found when InspectorUtils.getUsedFontFaces
    302  // was called (so it will be empty unless a non-zero maxRanges argument was passed).
    303  // Note that this indicates how the document was rendered at the time of calling
    304  // getUsedFontFaces; it does not reflect any subsequent modifications, so if styles
    305  // have been modified since calling getUsedFontFaces, it may no longer be accurate.
    306  [Constant,Cached]  readonly attribute sequence<Range> ranges;
    307 
    308  // meaningful only when the font is a user font defined using @font-face
    309  readonly attribute CSSFontFaceRule? rule; // null if no associated @font-face rule
    310  readonly attribute long srcIndex; // index in the rule's src list, -1 if no @font-face rule
    311  readonly attribute DOMString URI; // empty string if not a downloaded font, i.e. local
    312  readonly attribute DOMString localName; // empty string  if not a src:local(...) rule
    313  readonly attribute DOMString format; // as per http://www.w3.org/TR/css3-webfonts/#referencing
    314  readonly attribute DOMString metadata; // XML metadata from WOFF file (if any)
    315 };
    316 
    317 dictionary InspectorCSSToken {
    318  // The token type.
    319  required UTF8String tokenType;
    320 
    321  // Text associated with the token.
    322  required UTF8String text;
    323 
    324  // Value of the token. Might differ from `text`:
    325  // - for `Function` tokens, text contains the opening paren, `value` does not (e.g. `var(` vs `var`)
    326  // - for `AtKeyword` tokens, text contains the leading `@`, `value` does not (e.g. `@media` vs `media`)
    327  // - for `Hash` and `IDHash` tokens, text contains the leading `#`, `value` does not (e.g. `#myid` vs `myid`)
    328  // - for `UnquotedUrl` tokens, text contains the `url(` parts, `value` only holds the url (e.g. `url(test.jpg)` vs `test.jpg`)
    329  // - for `QuotedString` tokens, text contains the wrapping quotes, `value` does not (e.g. `"hello"` vs `hello`)
    330  // - for `Comment` tokens, text contains leading `/*` and trailing `*/`, `value` does not (e.g. `/* yo */` vs ` yo `)
    331  required UTF8String? value;
    332 
    333  // Unit for Dimension tokens
    334  required UTF8String? unit;
    335 
    336  // Float value for Dimension, Number and Percentage tokens
    337  double? number = null;
    338 };
    339 
    340 /**
    341 * InspectorCSSParser is an interface to the CSS lexer. It tokenizes an
    342 * input stream and returns CSS tokens.
    343 */
    344 [Func="nsContentUtils::IsCallerChromeOrFuzzingEnabled",
    345 Exposed=Window]
    346 interface InspectorCSSParser {
    347  constructor(UTF8String text);
    348 
    349  /**
    350   * The line number of the most recently returned token.  Line
    351   * numbers are 0-based.
    352   */
    353  readonly attribute unsigned long lineNumber;
    354 
    355  /**
    356   * The column number of the most recently returned token.  Column
    357   * numbers are 1-based.
    358   */
    359  readonly attribute unsigned long columnNumber;
    360 
    361  /**
    362   * Return the next token, or null at EOF.
    363   */
    364  InspectorCSSToken? nextToken();
    365 };