Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include "nsISupports.idl" |
michael@0 | 6 | |
michael@0 | 7 | interface nsIArray; |
michael@0 | 8 | interface nsISupportsArray; |
michael@0 | 9 | interface nsIDOMCharacterData; |
michael@0 | 10 | interface nsIDOMElement; |
michael@0 | 11 | interface nsIDOMDocument; |
michael@0 | 12 | interface nsIDOMCSSStyleRule; |
michael@0 | 13 | interface nsIDOMNode; |
michael@0 | 14 | interface nsIDOMNodeList; |
michael@0 | 15 | interface nsIDOMFontFaceList; |
michael@0 | 16 | interface nsIDOMRange; |
michael@0 | 17 | interface nsIDOMCSSStyleSheet; |
michael@0 | 18 | |
michael@0 | 19 | [scriptable, uuid(ceae6c68-f5d4-4597-a3d9-ca5646c25f1a)] |
michael@0 | 20 | interface inIDOMUtils : nsISupports |
michael@0 | 21 | { |
michael@0 | 22 | // CSS utilities |
michael@0 | 23 | void getAllStyleSheets (in nsIDOMDocument aDoc, |
michael@0 | 24 | [optional] out unsigned long aLength, |
michael@0 | 25 | [array, size_is (aLength), retval] out nsISupports aSheets); |
michael@0 | 26 | nsISupportsArray getCSSStyleRules(in nsIDOMElement aElement, [optional] in DOMString aPseudo); |
michael@0 | 27 | unsigned long getRuleLine(in nsIDOMCSSStyleRule aRule); |
michael@0 | 28 | unsigned long getRuleColumn(in nsIDOMCSSStyleRule aRule); |
michael@0 | 29 | |
michael@0 | 30 | // Utilities for working with selectors. We don't have a JS OM representation |
michael@0 | 31 | // of a single selector or a selector list yet, but given a rule we can index |
michael@0 | 32 | // into the selector list. |
michael@0 | 33 | // |
michael@0 | 34 | // This is a somewhat backwards API; once we move StyleRule to WebIDL we |
michael@0 | 35 | // should consider using [ChromeOnly] APIs on that. |
michael@0 | 36 | unsigned long getSelectorCount(in nsIDOMCSSStyleRule aRule); |
michael@0 | 37 | // For all three functions below, aSelectorIndex is 0-based |
michael@0 | 38 | AString getSelectorText(in nsIDOMCSSStyleRule aRule, |
michael@0 | 39 | in unsigned long aSelectorIndex); |
michael@0 | 40 | unsigned long long getSpecificity(in nsIDOMCSSStyleRule aRule, |
michael@0 | 41 | in unsigned long aSelectorIndex); |
michael@0 | 42 | // Note: This does not handle scoped selectors correctly, because it has no |
michael@0 | 43 | // idea what the right scope is. |
michael@0 | 44 | bool selectorMatchesElement(in nsIDOMElement aElement, |
michael@0 | 45 | in nsIDOMCSSStyleRule aRule, |
michael@0 | 46 | in unsigned long aSelectorIndex); |
michael@0 | 47 | |
michael@0 | 48 | // Utilities for working with CSS properties |
michael@0 | 49 | // |
michael@0 | 50 | // Returns true if the string names a property that is inherited by default. |
michael@0 | 51 | bool isInheritedProperty(in AString aPropertyName); |
michael@0 | 52 | |
michael@0 | 53 | // Get a list of all our supported property names. Optionally |
michael@0 | 54 | // shorthands can be excluded or property aliases included. |
michael@0 | 55 | const unsigned long EXCLUDE_SHORTHANDS = (1<<0); |
michael@0 | 56 | const unsigned long INCLUDE_ALIASES = (1<<1); |
michael@0 | 57 | void getCSSPropertyNames([optional] in unsigned long aFlags, |
michael@0 | 58 | [optional] out unsigned long aCount, |
michael@0 | 59 | [retval, array, size_is(aCount)] out wstring aProps); |
michael@0 | 60 | |
michael@0 | 61 | // Get a list of all valid keywords and colors for aProperty. |
michael@0 | 62 | void getCSSValuesForProperty(in AString aProperty, |
michael@0 | 63 | [optional] out unsigned long aLength, |
michael@0 | 64 | [array, size_is(aLength), retval] out wstring aValues); |
michael@0 | 65 | |
michael@0 | 66 | // Utilities for working with CSS colors |
michael@0 | 67 | [implicit_jscontext] |
michael@0 | 68 | jsval colorNameToRGB(in DOMString aColorName); |
michael@0 | 69 | AString rgbToColorName(in octet aR, in octet aG, in octet aB); |
michael@0 | 70 | |
michael@0 | 71 | // DOM Node utilities |
michael@0 | 72 | boolean isIgnorableWhitespace(in nsIDOMCharacterData aDataNode); |
michael@0 | 73 | // Returns the "parent" of a node. The parent of a document node is the |
michael@0 | 74 | // frame/iframe containing that document. aShowingAnonymousContent says |
michael@0 | 75 | // whether we are showing anonymous content. |
michael@0 | 76 | nsIDOMNode getParentForNode(in nsIDOMNode aNode, |
michael@0 | 77 | in boolean aShowingAnonymousContent); |
michael@0 | 78 | nsIDOMNodeList getChildrenForNode(in nsIDOMNode aNode, |
michael@0 | 79 | in boolean aShowingAnonymousContent); |
michael@0 | 80 | |
michael@0 | 81 | // XBL utilities |
michael@0 | 82 | nsIArray getBindingURLs(in nsIDOMElement aElement); |
michael@0 | 83 | |
michael@0 | 84 | // content state utilities |
michael@0 | 85 | unsigned long long getContentState(in nsIDOMElement aElement); |
michael@0 | 86 | void setContentState(in nsIDOMElement aElement, in unsigned long long aState); |
michael@0 | 87 | |
michael@0 | 88 | nsIDOMFontFaceList getUsedFontFaces(in nsIDOMRange aRange); |
michael@0 | 89 | |
michael@0 | 90 | // pseudo-class style locking methods. aPseudoClass must be a valid pseudo-class |
michael@0 | 91 | // selector string, e.g. ":hover". ":-moz-any-link" and non-event-state |
michael@0 | 92 | // pseudo-classes are ignored. |
michael@0 | 93 | void addPseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass); |
michael@0 | 94 | void removePseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass); |
michael@0 | 95 | bool hasPseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass); |
michael@0 | 96 | void clearPseudoClassLocks(in nsIDOMElement aElement); |
michael@0 | 97 | |
michael@0 | 98 | /** |
michael@0 | 99 | * Parse CSS and update the style sheet in place. |
michael@0 | 100 | * |
michael@0 | 101 | * @param DOMCSSStyleSheet aSheet |
michael@0 | 102 | * @param DOMString aInput |
michael@0 | 103 | * The new source string for the style sheet. |
michael@0 | 104 | */ |
michael@0 | 105 | void parseStyleSheet(in nsIDOMCSSStyleSheet aSheet, in DOMString aInput); |
michael@0 | 106 | }; |
michael@0 | 107 | |
michael@0 | 108 | %{ C++ |
michael@0 | 109 | #define IN_DOMUTILS_CONTRACTID "@mozilla.org/inspector/dom-utils;1" |
michael@0 | 110 | %} |