inIDOMUtils.idl 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #include "nsISupports.idl"
  5. interface nsIArray;
  6. interface nsIArrayExtensions;
  7. interface nsIDOMCharacterData;
  8. interface nsIDOMElement;
  9. interface nsIDOMDocument;
  10. interface nsIDOMCSSRule;
  11. interface nsIDOMCSSStyleRule;
  12. interface nsIDOMNode;
  13. interface nsIDOMNodeList;
  14. interface nsIDOMFontFaceList;
  15. interface nsIDOMRange;
  16. interface nsIDOMCSSStyleSheet;
  17. [scriptable, uuid(362e98c3-82c2-4ad8-8dcb-00e8e4eab497)]
  18. interface inIDOMUtils : nsISupports
  19. {
  20. // CSS utilities
  21. void getAllStyleSheets (in nsIDOMDocument aDoc,
  22. [optional] out unsigned long aLength,
  23. [array, size_is (aLength), retval] out nsISupports aSheets);
  24. nsIArrayExtensions getCSSStyleRules(in nsIDOMElement aElement, [optional] in DOMString aPseudo);
  25. /**
  26. * Get the line number of a rule.
  27. *
  28. * @param nsIDOMCSSRule aRule The rule.
  29. * @return The rule's line number. Line numbers are 1-based.
  30. */
  31. unsigned long getRuleLine(in nsIDOMCSSRule aRule);
  32. /**
  33. * Get the column number of a rule.
  34. *
  35. * @param nsIDOMCSSRule aRule The rule.
  36. * @return The rule's column number. Column numbers are 1-based.
  37. */
  38. unsigned long getRuleColumn(in nsIDOMCSSRule aRule);
  39. /**
  40. * Like getRuleLine, but if the rule is in a <style> element,
  41. * returns a line number relative to the start of the element.
  42. *
  43. * @param nsIDOMCSSRule aRule the rule to examine
  44. * @return the line number of the rule, possibly relative to the
  45. * <style> element
  46. */
  47. unsigned long getRelativeRuleLine(in nsIDOMCSSRule aRule);
  48. [implicit_jscontext]
  49. jsval getCSSLexer(in DOMString aText);
  50. // Utilities for working with selectors. We don't have a JS OM representation
  51. // of a single selector or a selector list yet, but given a rule we can index
  52. // into the selector list.
  53. //
  54. // This is a somewhat backwards API; once we move StyleRule to WebIDL we
  55. // should consider using [ChromeOnly] APIs on that.
  56. unsigned long getSelectorCount(in nsIDOMCSSStyleRule aRule);
  57. // For all three functions below, aSelectorIndex is 0-based
  58. AString getSelectorText(in nsIDOMCSSStyleRule aRule,
  59. in unsigned long aSelectorIndex);
  60. unsigned long long getSpecificity(in nsIDOMCSSStyleRule aRule,
  61. in unsigned long aSelectorIndex);
  62. // Note: This does not handle scoped selectors correctly, because it has no
  63. // idea what the right scope is.
  64. bool selectorMatchesElement(in nsIDOMElement aElement,
  65. in nsIDOMCSSStyleRule aRule,
  66. in unsigned long aSelectorIndex,
  67. [optional] in DOMString aPseudo);
  68. // Utilities for working with CSS properties
  69. //
  70. // Returns true if the string names a property that is inherited by default.
  71. bool isInheritedProperty(in AString aPropertyName);
  72. // Get a list of all our supported property names. Optionally
  73. // shorthands can be excluded or property aliases included.
  74. const unsigned long EXCLUDE_SHORTHANDS = (1<<0);
  75. const unsigned long INCLUDE_ALIASES = (1<<1);
  76. void getCSSPropertyNames([optional] in unsigned long aFlags,
  77. [optional] out unsigned long aCount,
  78. [retval, array, size_is(aCount)] out wstring aProps);
  79. // Get a list of all valid keywords and colors for aProperty.
  80. void getCSSValuesForProperty(in AString aProperty,
  81. [optional] out unsigned long aLength,
  82. [array, size_is(aLength), retval] out wstring aValues);
  83. // Utilities for working with CSS colors
  84. [implicit_jscontext]
  85. jsval colorNameToRGB(in DOMString aColorName);
  86. AString rgbToColorName(in octet aR, in octet aG, in octet aB);
  87. // Convert a given CSS color string to rgba. Returns null on failure or an
  88. // InspectorRGBATuple on success.
  89. //
  90. // NOTE: Converting a color to RGBA may be lossy when converting from some
  91. // formats e.g. CMYK.
  92. [implicit_jscontext]
  93. jsval colorToRGBA(in DOMString aColorString);
  94. // Check whether a given color is a valid CSS color.
  95. bool isValidCSSColor(in AString aColorString);
  96. // Utilities for obtaining information about a CSS property.
  97. // Check whether a CSS property and value are a valid combination. If the
  98. // property is pref-disabled it will still be processed.
  99. // aPropertyName: A property name e.g. "color"
  100. // aPropertyValue: A property value e.g. "red" or "red !important"
  101. bool cssPropertyIsValid(in AString aPropertyName, in AString aPropertyValue);
  102. // Get a list of the longhands corresponding to the given CSS property. If
  103. // the property is a longhand already, just returns the property itself.
  104. // Throws on unsupported property names.
  105. void getSubpropertiesForCSSProperty(in AString aProperty,
  106. [optional] out unsigned long aLength,
  107. [array, size_is(aLength), retval] out wstring aValues);
  108. // Check whether a given CSS property is a shorthand. Throws on unsupported
  109. // property names.
  110. bool cssPropertyIsShorthand(in AString aProperty);
  111. // Check whether values of the given type are valid values for the property.
  112. // For shorthands, checks whether there's a corresponding longhand property
  113. // that accepts values of this type. Throws on unsupported properties or
  114. // unknown types.
  115. const unsigned long TYPE_LENGTH = 0;
  116. const unsigned long TYPE_PERCENTAGE = 1;
  117. const unsigned long TYPE_COLOR = 2;
  118. const unsigned long TYPE_URL = 3;
  119. const unsigned long TYPE_ANGLE = 4;
  120. const unsigned long TYPE_FREQUENCY = 5;
  121. const unsigned long TYPE_TIME = 6;
  122. const unsigned long TYPE_GRADIENT = 7;
  123. const unsigned long TYPE_TIMING_FUNCTION = 8;
  124. const unsigned long TYPE_IMAGE_RECT = 9;
  125. const unsigned long TYPE_NUMBER = 10;
  126. bool cssPropertySupportsType(in AString aProperty, in unsigned long type);
  127. // DOM Node utilities
  128. boolean isIgnorableWhitespace(in nsIDOMCharacterData aDataNode);
  129. // Returns the "parent" of a node. The parent of a document node is the
  130. // frame/iframe containing that document. aShowingAnonymousContent says
  131. // whether we are showing anonymous content.
  132. nsIDOMNode getParentForNode(in nsIDOMNode aNode,
  133. in boolean aShowingAnonymousContent);
  134. nsIDOMNodeList getChildrenForNode(in nsIDOMNode aNode,
  135. in boolean aShowingAnonymousContent);
  136. // XBL utilities
  137. nsIArray getBindingURLs(in nsIDOMElement aElement);
  138. // content state utilities
  139. unsigned long long getContentState(in nsIDOMElement aElement);
  140. /**
  141. * Setting and removing content state on an element. Both these functions
  142. * calling EventStateManager::SetContentState internally, the difference is
  143. * that for the remove case we simply pass in nullptr for the element.
  144. * Use them accordingly.
  145. *
  146. * @return Returns true if the state was set successfully. See more details
  147. * in EventStateManager.h SetContentState.
  148. */
  149. bool setContentState(in nsIDOMElement aElement, in unsigned long long aState);
  150. bool removeContentState(in nsIDOMElement aElement, in unsigned long long aState);
  151. nsIDOMFontFaceList getUsedFontFaces(in nsIDOMRange aRange);
  152. /**
  153. * Get the names of all the supported pseudo-elements.
  154. * Pseudo-elements which are only accepted in UA style sheets are
  155. * not included.
  156. *
  157. * @param {unsigned long} aCount the number of items returned
  158. * @param {wstring[]} aNames the names
  159. */
  160. void getCSSPseudoElementNames([optional] out unsigned long aCount,
  161. [retval, array, size_is(aCount)] out wstring aNames);
  162. // pseudo-class style locking methods. aPseudoClass must be a valid pseudo-class
  163. // selector string, e.g. ":hover". ":any-link" and non-event-state
  164. // pseudo-classes are ignored.
  165. void addPseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass);
  166. void removePseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass);
  167. bool hasPseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass);
  168. void clearPseudoClassLocks(in nsIDOMElement aElement);
  169. /**
  170. * Parse CSS and update the style sheet in place.
  171. *
  172. * @param DOMCSSStyleSheet aSheet
  173. * @param DOMString aInput
  174. * The new source string for the style sheet.
  175. */
  176. void parseStyleSheet(in nsIDOMCSSStyleSheet aSheet, in DOMString aInput);
  177. /**
  178. * Scroll an element completely into view, if possible.
  179. * This is similar to ensureElementIsVisible but for all ancestors.
  180. *
  181. * @param DOMElement aElement
  182. */
  183. void scrollElementIntoView(in nsIDOMElement aElement);
  184. };
  185. %{ C++
  186. #define IN_DOMUTILS_CONTRACTID "@mozilla.org/inspector/dom-utils;1"
  187. %}