2002-01-09 13:51:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
#ifndef nsHTMLCSSUtils_h__
|
|
|
|
#define nsHTMLCSSUtils_h__
|
|
|
|
|
2014-08-29 11:43:24 +00:00
|
|
|
#include "ChangeStyleTxn.h" // for ChangeStyleTxn::EChangeType
|
2012-07-13 06:33:42 +00:00
|
|
|
#include "nsCOMPtr.h" // for already_AddRefed
|
|
|
|
#include "nsTArray.h" // for nsTArray
|
2012-07-30 14:20:58 +00:00
|
|
|
#include "nscore.h" // for nsAString, nsresult, nullptr
|
2012-07-13 06:33:42 +00:00
|
|
|
|
2012-07-08 09:50:31 +00:00
|
|
|
class nsComputedDOMStyle;
|
2012-07-13 06:33:42 +00:00
|
|
|
class nsIAtom;
|
|
|
|
class nsIContent;
|
|
|
|
class nsIDOMCSSStyleDeclaration;
|
|
|
|
class nsIDOMElement;
|
|
|
|
class nsIDOMNode;
|
|
|
|
class nsINode;
|
|
|
|
class nsString;
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class Element;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
class nsHTMLEditor;
|
|
|
|
|
2002-03-23 22:08:20 +00:00
|
|
|
typedef void (*nsProcessValueFunc)(const nsAString * aInputString, nsAString & aOutputString,
|
2002-01-09 13:51:37 +00:00
|
|
|
const char * aDefaultValueString,
|
|
|
|
const char * aPrependString, const char* aAppendString);
|
|
|
|
|
|
|
|
class nsHTMLCSSUtils
|
|
|
|
{
|
|
|
|
public:
|
2011-05-15 10:07:30 +00:00
|
|
|
explicit nsHTMLCSSUtils(nsHTMLEditor* aEditor);
|
2002-01-09 13:51:37 +00:00
|
|
|
~nsHTMLCSSUtils();
|
|
|
|
|
|
|
|
enum nsCSSEditableProperty {
|
|
|
|
eCSSEditableProperty_NONE=0,
|
|
|
|
eCSSEditableProperty_background_color,
|
|
|
|
eCSSEditableProperty_background_image,
|
|
|
|
eCSSEditableProperty_border,
|
|
|
|
eCSSEditableProperty_caption_side,
|
|
|
|
eCSSEditableProperty_color,
|
|
|
|
eCSSEditableProperty_float,
|
|
|
|
eCSSEditableProperty_font_family,
|
|
|
|
eCSSEditableProperty_font_size,
|
|
|
|
eCSSEditableProperty_font_style,
|
|
|
|
eCSSEditableProperty_font_weight,
|
|
|
|
eCSSEditableProperty_height,
|
|
|
|
eCSSEditableProperty_list_style_type,
|
|
|
|
eCSSEditableProperty_margin_left,
|
|
|
|
eCSSEditableProperty_margin_right,
|
|
|
|
eCSSEditableProperty_text_align,
|
|
|
|
eCSSEditableProperty_text_decoration,
|
|
|
|
eCSSEditableProperty_vertical_align,
|
|
|
|
eCSSEditableProperty_whitespace,
|
|
|
|
eCSSEditableProperty_width
|
|
|
|
};
|
|
|
|
|
2012-07-06 11:50:07 +00:00
|
|
|
enum StyleType { eSpecified, eComputed };
|
|
|
|
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
struct CSSEquivTable {
|
|
|
|
nsCSSEditableProperty cssProperty;
|
|
|
|
nsProcessValueFunc processValueFunctor;
|
|
|
|
const char * defaultValue;
|
|
|
|
const char * prependValue;
|
|
|
|
const char * appendValue;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool gettable;
|
|
|
|
bool caseSensitiveValue;
|
2002-01-09 13:51:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/** answers true if the given combination element_name/attribute_name
|
|
|
|
* has a CSS equivalence in this implementation
|
|
|
|
*
|
|
|
|
* @return a boolean saying if the tag/attribute has a css equiv
|
|
|
|
* @param aNode [IN] a DOM node
|
|
|
|
* @param aProperty [IN] an atom containing a HTML tag name
|
2012-04-24 10:57:49 +00:00
|
|
|
* @param aAttribute [IN] a string containing the name of a HTML
|
|
|
|
* attribute carried by the element above
|
2002-01-09 13:51:37 +00:00
|
|
|
*/
|
2015-04-19 12:28:50 +00:00
|
|
|
bool IsCSSEditableProperty(nsINode* aNode, nsIAtom* aProperty,
|
|
|
|
const nsAString* aAttribute);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
/** adds/remove a CSS declaration to the STYLE atrribute carried by a given element
|
|
|
|
*
|
|
|
|
* @param aElement [IN] a DOM element
|
|
|
|
* @param aProperty [IN] an atom containing the CSS property to set
|
|
|
|
* @param aValue [IN] a string containing the value of the CSS property
|
2002-09-17 12:04:59 +00:00
|
|
|
* @param aSuppressTransaction [IN] a boolean indicating, when true,
|
|
|
|
* that no transaction should be recorded
|
2002-01-09 13:51:37 +00:00
|
|
|
*/
|
2014-08-29 11:43:24 +00:00
|
|
|
nsresult SetCSSProperty(mozilla::dom::Element& aElement, nsIAtom& aProperty,
|
|
|
|
const nsAString& aValue, bool aSuppressTxn = false);
|
|
|
|
nsresult SetCSSPropertyPixels(mozilla::dom::Element& aElement,
|
|
|
|
nsIAtom& aProperty, int32_t aIntValue);
|
|
|
|
nsresult RemoveCSSProperty(mozilla::dom::Element& aElement,
|
|
|
|
nsIAtom& aProperty,
|
|
|
|
const nsAString& aPropertyValue,
|
|
|
|
bool aSuppressTxn = false);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
2003-06-25 08:50:48 +00:00
|
|
|
/** directly adds/remove a CSS declaration to the STYLE atrribute carried by
|
|
|
|
* a given element without going through the txn manager
|
|
|
|
*
|
|
|
|
* @param aElement [IN] a DOM element
|
|
|
|
* @param aProperty [IN] a string containing the CSS property to set/remove
|
|
|
|
* @param aValue [IN] a string containing the new value of the CSS property
|
|
|
|
*/
|
|
|
|
nsresult SetCSSProperty(nsIDOMElement * aElement,
|
|
|
|
const nsAString & aProperty,
|
|
|
|
const nsAString & aValue);
|
2003-09-03 13:54:36 +00:00
|
|
|
nsresult SetCSSPropertyPixels(nsIDOMElement * aElement,
|
|
|
|
const nsAString & aProperty,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aIntValue);
|
2003-06-25 08:50:48 +00:00
|
|
|
|
2015-04-19 12:28:50 +00:00
|
|
|
/** Gets the specified/computed style value of a CSS property for a given
|
|
|
|
* node (or its element ancestor if it is not an element)
|
2002-01-09 13:51:37 +00:00
|
|
|
*
|
|
|
|
* @param aNode [IN] a DOM node
|
|
|
|
* @param aProperty [IN] an atom containing the CSS property to get
|
|
|
|
* @param aPropertyValue [OUT] the retrieved value of the property
|
|
|
|
*/
|
2015-04-19 12:28:50 +00:00
|
|
|
nsresult GetSpecifiedProperty(nsINode& aNode, nsIAtom& aProperty,
|
|
|
|
nsAString& aValue);
|
|
|
|
nsresult GetComputedProperty(nsINode& aNode, nsIAtom& aProperty,
|
|
|
|
nsAString& aValue);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
/** Removes a CSS property from the specified declarations in STYLE attribute
|
|
|
|
** and removes the node if it is an useless span
|
|
|
|
*
|
|
|
|
* @param aNode [IN] the specific node we want to remove a style from
|
|
|
|
* @param aProperty [IN] the CSS property atom to remove
|
|
|
|
* @param aPropertyValue [IN] the value of the property we have to rremove if the property
|
|
|
|
* accepts more than one value
|
|
|
|
*/
|
2002-03-23 22:08:20 +00:00
|
|
|
nsresult RemoveCSSInlineStyle(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString & aPropertyValue);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
/** Answers true is the property can be removed by setting a "none" CSS value
|
|
|
|
* on a node
|
|
|
|
*
|
|
|
|
* @return a boolean saying if the property can be remove by setting a "none" value
|
|
|
|
* @param aProperty [IN] an atom containing a CSS property
|
|
|
|
* @param aAttribute [IN] pointer to an attribute name or null if this information is irrelevant
|
|
|
|
*/
|
2015-04-19 12:28:50 +00:00
|
|
|
bool IsCSSInvertible(nsIAtom& aProperty, const nsAString* aAttribute);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
/** Get the default browser background color if we need it for GetCSSBackgroundColorState
|
|
|
|
*
|
|
|
|
* @param aColor [OUT] the default color as it is defined in prefs
|
|
|
|
*/
|
2011-06-17 00:59:29 +00:00
|
|
|
void GetDefaultBackgroundColor(nsAString & aColor);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
/** Get the default length unit used for CSS Indent/Outdent
|
|
|
|
*
|
|
|
|
* @param aLengthUnit [OUT] the default length unit as it is defined in prefs
|
|
|
|
*/
|
2011-06-17 00:59:29 +00:00
|
|
|
void GetDefaultLengthUnit(nsAString & aLengthUnit);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
/** returns the list of values for the CSS equivalences to
|
|
|
|
* the passed HTML style for the passed node
|
|
|
|
*
|
|
|
|
* @param aNode [IN] a DOM node
|
|
|
|
* @param aHTMLProperty [IN] an atom containing an HTML property
|
2012-07-30 14:20:58 +00:00
|
|
|
* @param aAttribute [IN] a pointer to an attribute name or nullptr if irrelevant
|
2002-01-09 13:51:37 +00:00
|
|
|
* @param aValueString [OUT] the list of css values
|
2012-07-06 11:50:07 +00:00
|
|
|
* @param aStyleType [IN] eSpecified or eComputed
|
2002-01-09 13:51:37 +00:00
|
|
|
*/
|
2012-02-10 10:04:47 +00:00
|
|
|
nsresult GetCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
2002-01-09 13:51:37 +00:00
|
|
|
nsIAtom * aHTMLProperty,
|
2002-03-23 22:08:20 +00:00
|
|
|
const nsAString * aAttribute,
|
|
|
|
nsAString & aValueString,
|
2012-07-06 11:50:07 +00:00
|
|
|
StyleType aStyleType);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
/** Does the node aNode (or his parent if it is not an element node) carries
|
|
|
|
* the CSS equivalent styles to the HTML style for this node ?
|
|
|
|
*
|
|
|
|
* @param aNode [IN] a DOM node
|
|
|
|
* @param aHTMLProperty [IN] an atom containing an HTML property
|
2012-07-30 14:20:58 +00:00
|
|
|
* @param aAttribute [IN] a pointer to an attribute name or nullptr if irrelevant
|
2002-01-09 13:51:37 +00:00
|
|
|
* @param aIsSet [OUT] a boolean being true if the css properties are set
|
|
|
|
* @param aValueString [IN/OUT] the attribute value (in) the list of css values (out)
|
2012-07-06 11:50:07 +00:00
|
|
|
* @param aStyleType [IN] eSpecified or eComputed
|
2012-05-22 10:15:09 +00:00
|
|
|
*
|
|
|
|
* The nsIContent variant returns aIsSet instead of using an out parameter.
|
2002-01-09 13:51:37 +00:00
|
|
|
*/
|
2015-04-19 12:28:50 +00:00
|
|
|
bool IsCSSEquivalentToHTMLInlineStyleSet(nsINode* aContent,
|
2012-05-22 10:15:09 +00:00
|
|
|
nsIAtom* aProperty,
|
|
|
|
const nsAString* aAttribute,
|
|
|
|
const nsAString& aValue,
|
2012-07-06 11:50:07 +00:00
|
|
|
StyleType aStyleType);
|
2012-05-22 10:15:09 +00:00
|
|
|
|
2015-04-19 12:28:50 +00:00
|
|
|
bool IsCSSEquivalentToHTMLInlineStyleSet(nsINode* aContent,
|
|
|
|
nsIAtom* aProperty,
|
|
|
|
const nsAString* aAttribute,
|
|
|
|
nsAString& aValue,
|
|
|
|
StyleType aStyleType);
|
|
|
|
|
2002-01-09 13:51:37 +00:00
|
|
|
nsresult IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
|
|
|
|
nsIAtom * aHTMLProperty,
|
2002-03-23 22:08:20 +00:00
|
|
|
const nsAString * aAttribute,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool & aIsSet,
|
2002-03-23 22:08:20 +00:00
|
|
|
nsAString & aValueString,
|
2012-07-06 11:50:07 +00:00
|
|
|
StyleType aStyleType);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
/** Adds to the node the CSS inline styles equivalent to the HTML style
|
|
|
|
* and return the number of CSS properties set by the call
|
|
|
|
*
|
|
|
|
* @param aNode [IN] a DOM node
|
|
|
|
* @param aHTMLProperty [IN] an atom containing an HTML property
|
2012-07-30 14:20:58 +00:00
|
|
|
* @param aAttribute [IN] a pointer to an attribute name or nullptr if irrelevant
|
2002-01-09 13:51:37 +00:00
|
|
|
* @param aValue [IN] the attribute value
|
|
|
|
* @param aCount [OUT] the number of CSS properties set by the call
|
2002-09-17 12:04:59 +00:00
|
|
|
* @param aSuppressTransaction [IN] a boolean indicating, when true,
|
|
|
|
* that no transaction should be recorded
|
2012-05-29 07:12:51 +00:00
|
|
|
*
|
|
|
|
* aCount is returned by the dom::Element variant instead of being an out
|
|
|
|
* parameter.
|
2002-01-09 13:51:37 +00:00
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t SetCSSEquivalentToHTMLStyle(mozilla::dom::Element* aElement,
|
2012-05-29 07:12:51 +00:00
|
|
|
nsIAtom* aProperty,
|
|
|
|
const nsAString* aAttribute,
|
|
|
|
const nsAString* aValue,
|
|
|
|
bool aSuppressTransaction);
|
2002-01-09 13:51:37 +00:00
|
|
|
nsresult SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
|
|
|
nsIAtom * aHTMLProperty,
|
2002-03-23 22:08:20 +00:00
|
|
|
const nsAString * aAttribute,
|
|
|
|
const nsAString * aValue,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t * aCount,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aSuppressTransaction);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
/** removes from the node the CSS inline styles equivalent to the HTML style
|
|
|
|
*
|
|
|
|
* @param aNode [IN] a DOM node
|
|
|
|
* @param aHTMLProperty [IN] an atom containing an HTML property
|
2012-07-30 14:20:58 +00:00
|
|
|
* @param aAttribute [IN] a pointer to an attribute name or nullptr if irrelevant
|
2002-01-09 13:51:37 +00:00
|
|
|
* @param aValue [IN] the attribute value
|
2002-09-17 12:04:59 +00:00
|
|
|
* @param aSuppressTransaction [IN] a boolean indicating, when true,
|
|
|
|
* that no transaction should be recorded
|
2002-01-09 13:51:37 +00:00
|
|
|
*/
|
|
|
|
nsresult RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
|
|
|
nsIAtom *aHTMLProperty,
|
2002-03-23 22:08:20 +00:00
|
|
|
const nsAString *aAttribute,
|
2002-09-17 12:04:59 +00:00
|
|
|
const nsAString *aValue,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aSuppressTransaction);
|
2013-03-10 07:58:34 +00:00
|
|
|
/** removes from the node the CSS inline styles equivalent to the HTML style
|
|
|
|
*
|
|
|
|
* @param aElement [IN] a DOM Element (must not be null)
|
|
|
|
* @param aHTMLProperty [IN] an atom containing an HTML property
|
|
|
|
* @param aAttribute [IN] a pointer to an attribute name or nullptr if irrelevant
|
|
|
|
* @param aValue [IN] the attribute value
|
|
|
|
* @param aSuppressTransaction [IN] a boolean indicating, when true,
|
|
|
|
* that no transaction should be recorded
|
|
|
|
*/
|
|
|
|
nsresult RemoveCSSEquivalentToHTMLStyle(mozilla::dom::Element* aElement,
|
|
|
|
nsIAtom* aHTMLProperty,
|
|
|
|
const nsAString* aAttribute,
|
|
|
|
const nsAString* aValue,
|
|
|
|
bool aSuppressTransaction);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
/** parses a "xxxx.xxxxxuuu" string where x is a digit and u an alpha char
|
|
|
|
* we need such a parser because nsIDOMCSSStyleDeclaration::GetPropertyCSSValue() is not
|
|
|
|
* implemented
|
|
|
|
*
|
|
|
|
* @param aString [IN] input string to parse
|
|
|
|
* @param aValue [OUT] numeric part
|
|
|
|
* @param aUnit [OUT] unit part
|
|
|
|
*/
|
2002-03-23 22:08:20 +00:00
|
|
|
void ParseLength(const nsAString & aString, float * aValue, nsIAtom ** aUnit);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
/** sets the mIsCSSPrefChecked private member ; used as callback from observer when
|
|
|
|
* the css pref state is changed
|
|
|
|
*
|
|
|
|
* @param aIsCSSPrefChecked [IN] the new boolean state for the pref
|
|
|
|
*/
|
2012-06-01 11:03:17 +00:00
|
|
|
void SetCSSEnabled(bool aIsCSSPrefChecked);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
/** retrieves the mIsCSSPrefChecked private member, true if the css pref is checked,
|
|
|
|
* false if it is not
|
|
|
|
*
|
|
|
|
* @return the boolean value of the css pref
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsCSSPrefChecked();
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
/** ElementsSameStyle compares two elements and checks if they have the same
|
|
|
|
* specified CSS declarations in the STYLE attribute
|
|
|
|
* The answer is always false if at least one of them carries an ID or a class
|
|
|
|
*
|
|
|
|
* @return true if the two elements are considered to have same styles
|
|
|
|
* @param aFirstNode [IN] a DOM node
|
|
|
|
* @param aSecondNode [IN] a DOM node
|
|
|
|
*/
|
2012-05-29 07:12:51 +00:00
|
|
|
bool ElementsSameStyle(mozilla::dom::Element* aFirstNode,
|
|
|
|
mozilla::dom::Element* aSecondNode);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool ElementsSameStyle(nsIDOMNode *aFirstNode, nsIDOMNode *aSecondNode);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
/** get the specified inline styles (style attribute) for an element
|
|
|
|
*
|
|
|
|
* @param aElement [IN] the element node
|
|
|
|
* @param aCssDecl [OUT] the CSS declaration corresponding to the style attr
|
|
|
|
* @param aLength [OUT] the number of declarations in aCssDecl
|
|
|
|
*/
|
2013-01-11 08:43:01 +00:00
|
|
|
nsresult GetInlineStyles(mozilla::dom::Element* aElement,
|
|
|
|
nsIDOMCSSStyleDeclaration** aCssDecl,
|
|
|
|
uint32_t* aLength);
|
|
|
|
nsresult GetInlineStyles(nsIDOMElement* aElement,
|
|
|
|
nsIDOMCSSStyleDeclaration** aCssDecl,
|
|
|
|
uint32_t* aLength);
|
|
|
|
private:
|
|
|
|
nsresult GetInlineStyles(nsISupports* aElement,
|
|
|
|
nsIDOMCSSStyleDeclaration** aCssDecl,
|
|
|
|
uint32_t* aLength);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
2013-01-11 08:43:01 +00:00
|
|
|
public:
|
2002-01-09 13:51:37 +00:00
|
|
|
/** returns aNode itself if it is an element node, or the first ancestors being an element
|
|
|
|
* node if aNode is not one itself
|
|
|
|
*
|
|
|
|
* @param aNode [IN] a node
|
|
|
|
* @param aElement [OUT] the deepest element node containing aNode (possibly aNode itself)
|
|
|
|
*/
|
2012-02-10 10:04:46 +00:00
|
|
|
mozilla::dom::Element* GetElementContainerOrSelf(nsINode* aNode);
|
2012-02-01 10:54:22 +00:00
|
|
|
already_AddRefed<nsIDOMElement> GetElementContainerOrSelf(nsIDOMNode* aNode);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
2011-04-24 06:54:25 +00:00
|
|
|
/**
|
2012-07-08 09:50:31 +00:00
|
|
|
* Gets the computed style for a given element. Can return null.
|
2003-06-25 08:50:48 +00:00
|
|
|
*/
|
2012-07-08 09:50:31 +00:00
|
|
|
already_AddRefed<nsComputedDOMStyle>
|
|
|
|
GetComputedStyle(mozilla::dom::Element* aElement);
|
2003-06-25 08:50:48 +00:00
|
|
|
|
|
|
|
|
2002-01-09 13:51:37 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
/** retrieves the css property atom from an enum
|
|
|
|
*
|
|
|
|
* @param aProperty [IN] the enum value for the property
|
|
|
|
* @param aAtom [OUT] the corresponding atom
|
|
|
|
*/
|
|
|
|
void GetCSSPropertyAtom(nsCSSEditableProperty aProperty, nsIAtom ** aAtom);
|
|
|
|
|
|
|
|
/** retrieves the CSS declarations equivalent to a HTML style value for
|
|
|
|
* a given equivalence table
|
|
|
|
*
|
|
|
|
* @param aPropertyArray [OUT] the array of css properties
|
|
|
|
* @param aValueArray [OUT] the array of values for the css properties above
|
|
|
|
* @param aEquivTable [IN] the equivalence table
|
|
|
|
* @param aValue [IN] the HTML style value
|
|
|
|
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
|
|
|
|
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
|
|
|
|
* RemoveCSSEquivalentToHTMLInlineStyleSet
|
|
|
|
*/
|
|
|
|
|
2009-04-22 08:43:15 +00:00
|
|
|
void BuildCSSDeclarations(nsTArray<nsIAtom*> & aPropertyArray,
|
2009-01-18 20:14:14 +00:00
|
|
|
nsTArray<nsString> & cssValueArray,
|
2002-01-09 13:51:37 +00:00
|
|
|
const CSSEquivTable * aEquivTable,
|
2002-03-23 22:08:20 +00:00
|
|
|
const nsAString * aValue,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aGetOrRemoveRequest);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
/** retrieves the CSS declarations equivalent to the given HTML property/attribute/value
|
|
|
|
* for a given node
|
|
|
|
*
|
|
|
|
* @param aNode [IN] the DOM node
|
|
|
|
* @param aHTMLProperty [IN] an atom containing an HTML property
|
2012-07-30 14:20:58 +00:00
|
|
|
* @param aAttribute [IN] a pointer to an attribute name or nullptr if irrelevant
|
2002-01-09 13:51:37 +00:00
|
|
|
* @param aValue [IN] the attribute value
|
|
|
|
* @param aPropertyArray [OUT] the array of css properties
|
|
|
|
* @param aValueArray [OUT] the array of values for the css properties above
|
|
|
|
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
|
|
|
|
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
|
|
|
|
* RemoveCSSEquivalentToHTMLInlineStyleSet
|
|
|
|
*/
|
2012-02-10 10:04:47 +00:00
|
|
|
void GenerateCSSDeclarationsFromHTMLStyle(mozilla::dom::Element* aNode,
|
|
|
|
nsIAtom* aHTMLProperty,
|
|
|
|
const nsAString* aAttribute,
|
|
|
|
const nsAString* aValue,
|
|
|
|
nsTArray<nsIAtom*>& aPropertyArray,
|
|
|
|
nsTArray<nsString>& aValueArray,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aGetOrRemoveRequest);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
2014-08-29 11:43:24 +00:00
|
|
|
/** Creates a Transaction for setting or removing a CSS property. Never
|
|
|
|
* returns null.
|
2002-01-09 13:51:37 +00:00
|
|
|
*
|
|
|
|
* @param aElement [IN] a DOM element
|
|
|
|
* @param aProperty [IN] a CSS property
|
2014-08-29 11:43:24 +00:00
|
|
|
* @param aValue [IN] the value to set for this CSS property
|
|
|
|
* @param aChangeType [IN] eSet to set, eRemove to remove
|
2002-01-09 13:51:37 +00:00
|
|
|
*/
|
2014-08-29 11:43:24 +00:00
|
|
|
already_AddRefed<mozilla::dom::ChangeStyleTxn>
|
|
|
|
CreateCSSPropertyTxn(mozilla::dom::Element& aElement,
|
|
|
|
nsIAtom& aProperty, const nsAString& aValue,
|
|
|
|
mozilla::dom::ChangeStyleTxn::EChangeType aChangeType);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
/** back-end for GetSpecifiedProperty and GetComputedProperty
|
2011-04-24 06:54:25 +00:00
|
|
|
*
|
|
|
|
* @param aNode [IN] a DOM node
|
|
|
|
* @param aProperty [IN] a CSS property
|
|
|
|
* @param aValue [OUT] the retrieved value for this property
|
2012-07-06 11:50:07 +00:00
|
|
|
* @param aStyleType [IN] eSpecified or eComputed
|
2011-04-24 06:54:25 +00:00
|
|
|
*/
|
2012-02-10 10:04:47 +00:00
|
|
|
nsresult GetCSSInlinePropertyBase(nsINode* aNode, nsIAtom* aProperty,
|
2012-07-08 09:50:31 +00:00
|
|
|
nsAString& aValue, StyleType aStyleType);
|
2002-01-09 13:51:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsHTMLEditor *mHTMLEditor;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mIsCSSPrefChecked;
|
2002-01-09 13:51:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define NS_EDITOR_INDENT_INCREMENT_IN 0.4134f
|
|
|
|
#define NS_EDITOR_INDENT_INCREMENT_CM 1.05f
|
|
|
|
#define NS_EDITOR_INDENT_INCREMENT_MM 10.5f
|
|
|
|
#define NS_EDITOR_INDENT_INCREMENT_PT 29.76f
|
|
|
|
#define NS_EDITOR_INDENT_INCREMENT_PC 2.48f
|
|
|
|
#define NS_EDITOR_INDENT_INCREMENT_EM 3
|
|
|
|
#define NS_EDITOR_INDENT_INCREMENT_EX 6
|
|
|
|
#define NS_EDITOR_INDENT_INCREMENT_PX 40
|
|
|
|
#define NS_EDITOR_INDENT_INCREMENT_PERCENT 4
|
|
|
|
|
|
|
|
#endif /* nsHTMLCSSUtils_h__ */
|