diff --git a/editor/libeditor/CSSEditUtils.cpp b/editor/libeditor/CSSEditUtils.cpp index adec802cb30a..27edb01d04fb 100644 --- a/editor/libeditor/CSSEditUtils.cpp +++ b/editor/libeditor/CSSEditUtils.cpp @@ -24,7 +24,6 @@ #include "nsAtom.h" #include "nsIContent.h" #include "nsIDOMCSSStyleDeclaration.h" -#include "nsIDOMElement.h" #include "nsIDOMNode.h" #include "nsIDOMWindow.h" #include "nsIDocument.h" @@ -872,36 +871,6 @@ CSSEditUtils::GenerateCSSDeclarationsFromHTMLStyle( // Add to aNode the CSS inline style equivalent to HTMLProperty/aAttribute/ // aValue for the node, and return in aCount the number of CSS properties set // by the call. The Element version returns aCount instead. -int32_t -CSSEditUtils::SetCSSEquivalentToHTMLStyle(nsIDOMNode* aNode, - nsAtom* aProperty, - const nsAString* aAttribute, - const nsAString* aValue, - bool aSuppressTransaction) -{ - MOZ_ASSERT_IF(aAttribute, aValue); - // This can only fail if SetCSSProperty fails, which should only happen if - // something is pretty badly wrong. In this case we assert so that hopefully - // someone will notice, but there's nothing more sensible to do than just - // return the count and carry on. - nsCOMPtr element = do_QueryInterface(aNode); - return SetCSSEquivalentToHTMLStyle(element, - aProperty, aAttribute, - aValue, aSuppressTransaction); -} - -int32_t -CSSEditUtils::SetCSSEquivalentToHTMLStyle(Element* aElement, - nsAtom* aHTMLProperty, - const nsAString* aAttribute, - const nsAString* aValue, - bool aSuppressTransaction) -{ - RefPtr attribute = aAttribute ? NS_Atomize(*aAttribute) : nullptr; - return SetCSSEquivalentToHTMLStyle(aElement, aHTMLProperty, attribute, - aValue, aSuppressTransaction); -} - int32_t CSSEditUtils::SetCSSEquivalentToHTMLStyle(Element* aElement, nsAtom* aHTMLProperty, @@ -937,21 +906,8 @@ CSSEditUtils::SetCSSEquivalentToHTMLStyle(Element* aElement, return count; } -// Remove from aNode the CSS inline style equivalent to HTMLProperty/aAttribute/aValue for the node -nsresult -CSSEditUtils::RemoveCSSEquivalentToHTMLStyle(nsIDOMNode* aNode, - nsAtom* aHTMLProperty, - const nsAString* aAttribute, - const nsAString* aValue, - bool aSuppressTransaction) -{ - nsCOMPtr element = do_QueryInterface(aNode); - RefPtr attribute = aAttribute ? NS_Atomize(*aAttribute) : nullptr; - - return RemoveCSSEquivalentToHTMLStyle(element, aHTMLProperty, attribute, - aValue, aSuppressTransaction); -} - +// Remove from aNode the CSS inline style equivalent to +// HTMLProperty/aAttribute/aValue for the node nsresult CSSEditUtils::RemoveCSSEquivalentToHTMLStyle(Element* aElement, nsAtom* aHTMLProperty, @@ -1066,20 +1022,6 @@ CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode, aValue, aStyleType); } -bool -CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode* aNode, - nsAtom* aProperty, - const nsAString* aAttribute, - nsAString& aValue, - StyleType aStyleType) -{ - MOZ_ASSERT(aNode && aProperty); - nsCOMPtr node = do_QueryInterface(aNode); - RefPtr attribute = aAttribute ? NS_Atomize(*aAttribute) : nullptr; - return IsCSSEquivalentToHTMLInlineStyleSet(node, aProperty, attribute, - aValue, aStyleType); -} - bool CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet( nsINode* aNode, @@ -1373,22 +1315,6 @@ nsresult CSSEditUtils::GetInlineStyles(Element* aElement, nsIDOMCSSStyleDeclaration** aCssDecl, uint32_t* aLength) -{ - return GetInlineStyles(static_cast(aElement), aCssDecl, aLength); -} - -nsresult -CSSEditUtils::GetInlineStyles(nsIDOMElement* aElement, - nsIDOMCSSStyleDeclaration** aCssDecl, - uint32_t* aLength) -{ - return GetInlineStyles(static_cast(aElement), aCssDecl, aLength); -} - -nsresult -CSSEditUtils::GetInlineStyles(nsISupports* aElement, - nsIDOMCSSStyleDeclaration** aCssDecl, - uint32_t* aLength) { NS_ENSURE_TRUE(aElement && aLength, NS_ERROR_NULL_POINTER); *aLength = 0; @@ -1404,16 +1330,6 @@ CSSEditUtils::GetInlineStyles(nsISupports* aElement, return NS_OK; } -already_AddRefed -CSSEditUtils::GetElementContainerOrSelf(nsIDOMNode* aNode) -{ - nsCOMPtr node = do_QueryInterface(aNode); - NS_ENSURE_TRUE(node, nullptr); - nsCOMPtr element = - do_QueryInterface(GetElementContainerOrSelf(node)); - return element.forget(); -} - Element* CSSEditUtils::GetElementContainerOrSelf(nsINode* aNode) { @@ -1432,31 +1348,4 @@ CSSEditUtils::GetElementContainerOrSelf(nsINode* aNode) return node->AsElement(); } -nsresult -CSSEditUtils::SetCSSProperty(nsIDOMElement* aElement, - const nsAString& aProperty, - const nsAString& aValue) -{ - nsCOMPtr cssDecl; - uint32_t length; - nsresult rv = GetInlineStyles(aElement, getter_AddRefs(cssDecl), &length); - if (NS_FAILED(rv) || !cssDecl) { - return rv; - } - - return cssDecl->SetProperty(aProperty, - aValue, - EmptyString()); -} - -nsresult -CSSEditUtils::SetCSSPropertyPixels(nsIDOMElement* aElement, - const nsAString& aProperty, - int32_t aIntValue) -{ - nsAutoString s; - s.AppendInt(aIntValue); - return SetCSSProperty(aElement, aProperty, s + NS_LITERAL_STRING("px")); -} - } // namespace mozilla diff --git a/editor/libeditor/CSSEditUtils.h b/editor/libeditor/CSSEditUtils.h index 54f8fe0eefc5..eb1e938d5a87 100644 --- a/editor/libeditor/CSSEditUtils.h +++ b/editor/libeditor/CSSEditUtils.h @@ -16,7 +16,6 @@ class nsComputedDOMStyle; class nsAtom; class nsIContent; class nsIDOMCSSStyleDeclaration; -class nsIDOMElement; class nsIDOMNode; class nsINode; @@ -111,23 +110,6 @@ public: const nsAString& aPropertyValue, bool aSuppressTxn = false); - /** - * Directly adds/remove a CSS declaration to the STYLE atrribute carried by - * a given element without going through the transaction 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); - nsresult SetCSSPropertyPixels(nsIDOMElement* aElement, - const nsAString& aProperty, - int32_t aIntValue); - /** * Gets the specified/computed style value of a CSS property for a given * node (or its element ancestor if it is not an element). @@ -231,12 +213,6 @@ public: nsAString& aValue, StyleType aStyleType); - bool IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode* aNode, - nsAtom* aProperty, - const nsAString* aAttribute, - nsAString& aValue, - StyleType aStyleType); - /** * This is a kind of IsCSSEquivalentToHTMLInlineStyleSet. * IsCSSEquivalentToHTMLInlineStyleSet returns whether the properties @@ -266,7 +242,7 @@ public: * * @param aNode [IN] A DOM node. * @param aHTMLProperty [IN] An atom containing an HTML property. - * @param aAttribute [IN] A pointer/atom to an attribute name or nullptr + * @param aAttribute [IN] An atom to an attribute name or nullptr * if irrelevant. * @param aValue [IN] The attribute value. * @param aSuppressTransaction [IN] A boolean indicating, when true, @@ -279,33 +255,6 @@ public: nsAtom* aAttribute, const nsAString* aValue, bool aSuppressTransaction); - int32_t SetCSSEquivalentToHTMLStyle(dom::Element* aElement, - nsAtom* aProperty, - const nsAString* aAttribute, - const nsAString* aValue, - bool aSuppressTransaction); - int32_t SetCSSEquivalentToHTMLStyle(nsIDOMNode* aNode, - nsAtom* aHTMLProperty, - const nsAString* aAttribute, - const nsAString* aValue, - bool aSuppressTransaction); - - /** - * 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. - * @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(nsIDOMNode* aNode, - nsAtom* aHTMLProperty, - const nsAString* aAttribute, - const nsAString* aValue, - bool aSuppressTransaction); /** * Removes from the node the CSS inline styles equivalent to the HTML style. @@ -377,13 +326,6 @@ public: nsresult GetInlineStyles(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); public: /** @@ -395,7 +337,6 @@ public: * (possibly aNode itself) */ dom::Element* GetElementContainerOrSelf(nsINode* aNode); - already_AddRefed GetElementContainerOrSelf(nsIDOMNode* aNode); /** * Gets the computed style for a given element. Can return null.