2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-05-17 06:22:14 +04:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
2006-05-17 06:38:48 +04:00
|
|
|
interface nsIArray;
|
2016-10-24 23:24:28 +03:00
|
|
|
interface nsIArrayExtensions;
|
2006-05-17 06:37:41 +04:00
|
|
|
interface nsIDOMCharacterData;
|
2006-05-17 06:22:14 +04:00
|
|
|
interface nsIDOMElement;
|
|
|
|
interface nsIDOMDocument;
|
2014-07-15 02:57:46 +04:00
|
|
|
interface nsIDOMCSSRule;
|
2006-05-17 06:22:14 +04:00
|
|
|
interface nsIDOMCSSStyleRule;
|
2006-05-17 06:38:00 +04:00
|
|
|
interface nsIDOMNode;
|
2011-05-31 01:51:09 +04:00
|
|
|
interface nsIDOMNodeList;
|
2011-06-16 10:31:36 +04:00
|
|
|
interface nsIDOMFontFaceList;
|
|
|
|
interface nsIDOMRange;
|
2012-06-03 20:54:38 +04:00
|
|
|
interface nsIDOMCSSStyleSheet;
|
2006-05-17 06:22:14 +04:00
|
|
|
|
2016-03-30 12:54:27 +03:00
|
|
|
[scriptable, uuid(362e98c3-82c2-4ad8-8dcb-00e8e4eab497)]
|
2006-05-17 06:22:14 +04:00
|
|
|
interface inIDOMUtils : nsISupports
|
|
|
|
{
|
|
|
|
// CSS utilities
|
2013-07-25 17:31:14 +04:00
|
|
|
void getAllStyleSheets (in nsIDOMDocument aDoc,
|
|
|
|
[optional] out unsigned long aLength,
|
|
|
|
[array, size_is (aLength), retval] out nsISupports aSheets);
|
2016-10-24 23:24:28 +03:00
|
|
|
nsIArrayExtensions getCSSStyleRules(in nsIDOMElement aElement, [optional] in DOMString aPseudo);
|
2015-08-24 18:43:00 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the line number of a rule.
|
|
|
|
*
|
|
|
|
* @param nsIDOMCSSRule aRule The rule.
|
|
|
|
* @return The rule's line number. Line numbers are 1-based.
|
|
|
|
*/
|
2014-07-15 02:57:46 +04:00
|
|
|
unsigned long getRuleLine(in nsIDOMCSSRule aRule);
|
2015-08-24 18:43:00 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the column number of a rule.
|
|
|
|
*
|
|
|
|
* @param nsIDOMCSSRule aRule The rule.
|
|
|
|
* @return The rule's column number. Column numbers are 1-based.
|
|
|
|
*/
|
2014-07-15 02:57:46 +04:00
|
|
|
unsigned long getRuleColumn(in nsIDOMCSSRule aRule);
|
2006-05-17 06:37:41 +04:00
|
|
|
|
2015-08-18 01:19:21 +03:00
|
|
|
/**
|
|
|
|
* Like getRuleLine, but if the rule is in a <style> element,
|
|
|
|
* returns a line number relative to the start of the element.
|
|
|
|
*
|
|
|
|
* @param nsIDOMCSSRule aRule the rule to examine
|
|
|
|
* @return the line number of the rule, possibly relative to the
|
|
|
|
* <style> element
|
|
|
|
*/
|
|
|
|
unsigned long getRelativeRuleLine(in nsIDOMCSSRule aRule);
|
|
|
|
|
2015-05-04 17:28:00 +03:00
|
|
|
[implicit_jscontext]
|
|
|
|
jsval getCSSLexer(in DOMString aText);
|
|
|
|
|
2013-02-13 19:11:53 +04:00
|
|
|
// Utilities for working with selectors. We don't have a JS OM representation
|
|
|
|
// of a single selector or a selector list yet, but given a rule we can index
|
|
|
|
// into the selector list.
|
|
|
|
//
|
|
|
|
// This is a somewhat backwards API; once we move StyleRule to WebIDL we
|
|
|
|
// should consider using [ChromeOnly] APIs on that.
|
|
|
|
unsigned long getSelectorCount(in nsIDOMCSSStyleRule aRule);
|
|
|
|
// For all three functions below, aSelectorIndex is 0-based
|
|
|
|
AString getSelectorText(in nsIDOMCSSStyleRule aRule,
|
|
|
|
in unsigned long aSelectorIndex);
|
|
|
|
unsigned long long getSpecificity(in nsIDOMCSSStyleRule aRule,
|
|
|
|
in unsigned long aSelectorIndex);
|
|
|
|
// Note: This does not handle scoped selectors correctly, because it has no
|
|
|
|
// idea what the right scope is.
|
|
|
|
bool selectorMatchesElement(in nsIDOMElement aElement,
|
|
|
|
in nsIDOMCSSStyleRule aRule,
|
2014-07-18 22:30:00 +04:00
|
|
|
in unsigned long aSelectorIndex,
|
|
|
|
[optional] in DOMString aPseudo);
|
2013-02-13 19:11:53 +04:00
|
|
|
|
2013-03-14 23:42:59 +04:00
|
|
|
// Utilities for working with CSS properties
|
|
|
|
//
|
2011-11-05 19:41:10 +04:00
|
|
|
// Returns true if the string names a property that is inherited by default.
|
|
|
|
bool isInheritedProperty(in AString aPropertyName);
|
|
|
|
|
2013-03-14 23:42:59 +04:00
|
|
|
// Get a list of all our supported property names. Optionally
|
|
|
|
// shorthands can be excluded or property aliases included.
|
|
|
|
const unsigned long EXCLUDE_SHORTHANDS = (1<<0);
|
|
|
|
const unsigned long INCLUDE_ALIASES = (1<<1);
|
|
|
|
void getCSSPropertyNames([optional] in unsigned long aFlags,
|
|
|
|
[optional] out unsigned long aCount,
|
|
|
|
[retval, array, size_is(aCount)] out wstring aProps);
|
|
|
|
|
2013-07-16 01:28:49 +04:00
|
|
|
// Get a list of all valid keywords and colors for aProperty.
|
|
|
|
void getCSSValuesForProperty(in AString aProperty,
|
|
|
|
[optional] out unsigned long aLength,
|
|
|
|
[array, size_is(aLength), retval] out wstring aValues);
|
|
|
|
|
2013-03-14 23:43:00 +04:00
|
|
|
// Utilities for working with CSS colors
|
|
|
|
[implicit_jscontext]
|
|
|
|
jsval colorNameToRGB(in DOMString aColorName);
|
2013-03-14 23:43:00 +04:00
|
|
|
AString rgbToColorName(in octet aR, in octet aG, in octet aB);
|
2013-03-14 23:43:00 +04:00
|
|
|
|
2014-07-17 18:08:07 +04:00
|
|
|
// Convert a given CSS color string to rgba. Returns null on failure or an
|
|
|
|
// InspectorRGBATuple on success.
|
|
|
|
//
|
|
|
|
// NOTE: Converting a color to RGBA may be lossy when converting from some
|
|
|
|
// formats e.g. CMYK.
|
|
|
|
[implicit_jscontext]
|
|
|
|
jsval colorToRGBA(in DOMString aColorString);
|
|
|
|
|
|
|
|
// Check whether a given color is a valid CSS color.
|
|
|
|
bool isValidCSSColor(in AString aColorString);
|
|
|
|
|
2014-05-06 19:46:34 +04:00
|
|
|
// Utilities for obtaining information about a CSS property.
|
|
|
|
|
2014-07-17 18:08:07 +04:00
|
|
|
// Check whether a CSS property and value are a valid combination. If the
|
|
|
|
// property is pref-disabled it will still be processed.
|
|
|
|
// aPropertyName: A property name e.g. "color"
|
|
|
|
// aPropertyValue: A property value e.g. "red" or "red !important"
|
|
|
|
bool cssPropertyIsValid(in AString aPropertyName, in AString aPropertyValue);
|
|
|
|
|
2014-05-06 19:46:34 +04:00
|
|
|
// Get a list of the longhands corresponding to the given CSS property. If
|
|
|
|
// the property is a longhand already, just returns the property itself.
|
|
|
|
// Throws on unsupported property names.
|
|
|
|
void getSubpropertiesForCSSProperty(in AString aProperty,
|
|
|
|
[optional] out unsigned long aLength,
|
|
|
|
[array, size_is(aLength), retval] out wstring aValues);
|
|
|
|
// Check whether a given CSS property is a shorthand. Throws on unsupported
|
|
|
|
// property names.
|
|
|
|
bool cssPropertyIsShorthand(in AString aProperty);
|
|
|
|
|
|
|
|
// Check whether values of the given type are valid values for the property.
|
|
|
|
// For shorthands, checks whether there's a corresponding longhand property
|
|
|
|
// that accepts values of this type. Throws on unsupported properties or
|
|
|
|
// unknown types.
|
|
|
|
const unsigned long TYPE_LENGTH = 0;
|
|
|
|
const unsigned long TYPE_PERCENTAGE = 1;
|
|
|
|
const unsigned long TYPE_COLOR = 2;
|
|
|
|
const unsigned long TYPE_URL = 3;
|
|
|
|
const unsigned long TYPE_ANGLE = 4;
|
|
|
|
const unsigned long TYPE_FREQUENCY = 5;
|
|
|
|
const unsigned long TYPE_TIME = 6;
|
|
|
|
const unsigned long TYPE_GRADIENT = 7;
|
|
|
|
const unsigned long TYPE_TIMING_FUNCTION = 8;
|
|
|
|
const unsigned long TYPE_IMAGE_RECT = 9;
|
|
|
|
const unsigned long TYPE_NUMBER = 10;
|
|
|
|
bool cssPropertySupportsType(in AString aProperty, in unsigned long type);
|
|
|
|
|
2006-05-17 06:37:41 +04:00
|
|
|
// DOM Node utilities
|
|
|
|
boolean isIgnorableWhitespace(in nsIDOMCharacterData aDataNode);
|
2006-05-17 06:38:00 +04:00
|
|
|
// Returns the "parent" of a node. The parent of a document node is the
|
|
|
|
// frame/iframe containing that document. aShowingAnonymousContent says
|
|
|
|
// whether we are showing anonymous content.
|
|
|
|
nsIDOMNode getParentForNode(in nsIDOMNode aNode,
|
|
|
|
in boolean aShowingAnonymousContent);
|
2011-05-31 01:51:09 +04:00
|
|
|
nsIDOMNodeList getChildrenForNode(in nsIDOMNode aNode,
|
|
|
|
in boolean aShowingAnonymousContent);
|
2006-05-17 06:22:14 +04:00
|
|
|
|
|
|
|
// XBL utilities
|
2006-05-17 06:38:48 +04:00
|
|
|
nsIArray getBindingURLs(in nsIDOMElement aElement);
|
2006-05-17 06:22:14 +04:00
|
|
|
|
|
|
|
// content state utilities
|
2010-10-20 11:41:35 +04:00
|
|
|
unsigned long long getContentState(in nsIDOMElement aElement);
|
2016-03-30 12:54:27 +03:00
|
|
|
/**
|
|
|
|
* Setting and removing content state on an element. Both these functions
|
|
|
|
* calling EventStateManager::SetContentState internally, the difference is
|
|
|
|
* that for the remove case we simply pass in nullptr for the element.
|
|
|
|
* Use them accordingly.
|
|
|
|
*
|
|
|
|
* @return Returns true if the state was set successfully. See more details
|
|
|
|
* in EventStateManager.h SetContentState.
|
|
|
|
*/
|
|
|
|
bool setContentState(in nsIDOMElement aElement, in unsigned long long aState);
|
|
|
|
bool removeContentState(in nsIDOMElement aElement, in unsigned long long aState);
|
2011-06-16 10:31:36 +04:00
|
|
|
|
|
|
|
nsIDOMFontFaceList getUsedFontFaces(in nsIDOMRange aRange);
|
2012-02-08 22:42:38 +04:00
|
|
|
|
2015-11-02 18:55:26 +03:00
|
|
|
/**
|
|
|
|
* Get the names of all the supported pseudo-elements.
|
|
|
|
* Pseudo-elements which are only accepted in UA style sheets are
|
|
|
|
* not included.
|
|
|
|
*
|
|
|
|
* @param {unsigned long} aCount the number of items returned
|
|
|
|
* @param {wstring[]} aNames the names
|
|
|
|
*/
|
|
|
|
void getCSSPseudoElementNames([optional] out unsigned long aCount,
|
|
|
|
[retval, array, size_is(aCount)] out wstring aNames);
|
|
|
|
|
2012-02-08 22:42:38 +04:00
|
|
|
// pseudo-class style locking methods. aPseudoClass must be a valid pseudo-class
|
2016-07-20 06:13:13 +03:00
|
|
|
// selector string, e.g. ":hover". ":any-link" and non-event-state
|
2017-01-12 20:10:07 +03:00
|
|
|
// pseudo-classes are ignored. aEnabled sets whether the psuedo-class
|
|
|
|
// should be locked to on or off.
|
|
|
|
[optional_argc] void addPseudoClassLock(in nsIDOMElement aElement,
|
|
|
|
in DOMString aPseudoClass,
|
|
|
|
[optional] in boolean aEnabled);
|
2012-02-08 22:42:38 +04:00
|
|
|
void removePseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass);
|
|
|
|
bool hasPseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass);
|
|
|
|
void clearPseudoClassLocks(in nsIDOMElement aElement);
|
2012-06-03 20:54:38 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse CSS and update the style sheet in place.
|
|
|
|
*
|
|
|
|
* @param DOMCSSStyleSheet aSheet
|
|
|
|
* @param DOMString aInput
|
|
|
|
* The new source string for the style sheet.
|
|
|
|
*/
|
|
|
|
void parseStyleSheet(in nsIDOMCSSStyleSheet aSheet, in DOMString aInput);
|
2014-06-09 11:35:13 +04:00
|
|
|
/**
|
|
|
|
* Scroll an element completely into view, if possible.
|
|
|
|
* This is similar to ensureElementIsVisible but for all ancestors.
|
|
|
|
*
|
|
|
|
* @param DOMElement aElement
|
|
|
|
*/
|
|
|
|
void scrollElementIntoView(in nsIDOMElement aElement);
|
2006-05-17 06:22:14 +04:00
|
|
|
};
|
2014-04-12 01:39:58 +04:00
|
|
|
|
|
|
|
%{ C++
|
|
|
|
#define IN_DOMUTILS_CONTRACTID "@mozilla.org/inspector/dom-utils;1"
|
|
|
|
%}
|