--- a/editor/libeditor/CSSEditUtils.cpp
+++ b/editor/libeditor/CSSEditUtils.cpp
@@ -1246,31 +1246,16 @@ CSSEditUtils::IsCSSPrefChecked() const
}
// ElementsSameStyle compares two elements and checks if they have the same
// specified CSS declarations in the STYLE attribute
// The answer is always negative if at least one of them carries an ID or a class
// static
bool
-CSSEditUtils::ElementsSameStyle(nsIDOMNode* aFirstNode,
- nsIDOMNode* aSecondNode)
-{
- nsCOMPtr<Element> firstElement = do_QueryInterface(aFirstNode);
- nsCOMPtr<Element> secondElement = do_QueryInterface(aSecondNode);
-
- NS_ASSERTION((firstElement && secondElement), "Non element nodes passed to ElementsSameStyle.");
- NS_ENSURE_TRUE(firstElement, false);
- NS_ENSURE_TRUE(secondElement, false);
-
- return ElementsSameStyle(firstElement, secondElement);
-}
-
-// static
-bool
CSSEditUtils::ElementsSameStyle(Element* aFirstElement,
Element* aSecondElement)
{
MOZ_ASSERT(aFirstElement);
MOZ_ASSERT(aSecondElement);
if (aFirstElement->HasAttr(kNameSpaceID_None, nsGkAtoms::id) ||
aSecondElement->HasAttr(kNameSpaceID_None, nsGkAtoms::id)) {
--- a/editor/libeditor/CSSEditUtils.h
+++ b/editor/libeditor/CSSEditUtils.h
@@ -309,18 +309,16 @@ public:
*
* @param aFirstNode [IN] A DOM node.
* @param aSecondNode [IN] A DOM node.
* @return true if the two elements are considered to
* have same styles.
*/
static bool ElementsSameStyle(dom::Element* aFirstNode,
dom::Element* aSecondNode);
- static bool ElementsSameStyle(nsIDOMNode* aFirstNode,
- nsIDOMNode* aSecondNode);
/**
* 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 attribute.
* @param aLength [OUT] The number of declarations in aCssDecl.
--- a/editor/libeditor/HTMLAbsPositionEditor.cpp
+++ b/editor/libeditor/HTMLAbsPositionEditor.cpp
@@ -96,18 +96,18 @@ HTMLEditor::GetAbsolutelyPositionedSelec
already_AddRefed<Element>
HTMLEditor::GetAbsolutelyPositionedSelectionContainer()
{
nsAutoString positionStr;
RefPtr<Element> element = GetSelectionContainer();
while (element && !element->IsHTMLElement(nsGkAtoms::html)) {
nsresult rv =
- mCSSEditUtils->GetComputedProperty(*element, *nsGkAtoms::position,
- positionStr);
+ CSSEditUtils::GetComputedProperty(*element, *nsGkAtoms::position,
+ positionStr);
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
}
if (positionStr.EqualsLiteral("absolute")) {
return element.forget();
}
element = element->GetParentElement();
}
@@ -212,34 +212,34 @@ HTMLEditor::GetElementZIndex(Element* aE
if (NS_WARN_IF(!aElement)) {
return NS_ERROR_INVALID_ARG;
}
nsAutoString zIndexStr;
*aZindex = 0;
nsresult rv =
- mCSSEditUtils->GetSpecifiedProperty(*aElement, *nsGkAtoms::z_index,
- zIndexStr);
+ CSSEditUtils::GetSpecifiedProperty(*aElement, *nsGkAtoms::z_index,
+ zIndexStr);
NS_ENSURE_SUCCESS(rv, rv);
if (zIndexStr.EqualsLiteral("auto")) {
// we have to look at the positioned ancestors
// cf. CSS 2 spec section 9.9.1
nsCOMPtr<nsINode> node = aElement->GetParentNode();
nsAutoString positionStr;
while (node && zIndexStr.EqualsLiteral("auto") &&
!node->IsHTMLElement(nsGkAtoms::body)) {
- rv = mCSSEditUtils->GetComputedProperty(*node, *nsGkAtoms::position,
- positionStr);
+ rv = CSSEditUtils::GetComputedProperty(*node, *nsGkAtoms::position,
+ positionStr);
NS_ENSURE_SUCCESS(rv, rv);
if (positionStr.EqualsLiteral("absolute")) {
// ah, we found one, what's its z-index ? If its z-index is auto,
// we have to continue climbing the document's tree
- rv = mCSSEditUtils->GetComputedProperty(*node, *nsGkAtoms::z_index,
- zIndexStr);
+ rv = CSSEditUtils::GetComputedProperty(*node, *nsGkAtoms::z_index,
+ zIndexStr);
NS_ENSURE_SUCCESS(rv, rv);
}
node = node->GetParentNode();
}
}
if (!zIndexStr.EqualsLiteral("auto")) {
nsresult errorCode;
@@ -501,18 +501,18 @@ HTMLEditor::AddPositioningOffset(int32_t
NS_IMETHODIMP
HTMLEditor::AbsolutelyPositionElement(nsIDOMElement* aElement,
bool aEnabled)
{
nsCOMPtr<Element> element = do_QueryInterface(aElement);
NS_ENSURE_ARG_POINTER(element);
nsAutoString positionStr;
- mCSSEditUtils->GetComputedProperty(*element, *nsGkAtoms::position,
- positionStr);
+ CSSEditUtils::GetComputedProperty(*element, *nsGkAtoms::position,
+ positionStr);
bool isPositioned = (positionStr.EqualsLiteral("absolute"));
// nothing to do if the element is already in the state we want
if (isPositioned == aEnabled)
return NS_OK;
AutoPlaceholderBatch batchIt(this);
@@ -651,34 +651,34 @@ HTMLEditor::GetTemporaryStyleForFocusedP
// each above #d0, use a black background
// If the background color is 'auto' and at least one of R G B values of
// the foreground is below #d0, use a white background
// Otherwise don't change background/foreground
aReturn.Truncate();
nsAutoString bgImageStr;
nsresult rv =
- mCSSEditUtils->GetComputedProperty(aElement, *nsGkAtoms::background_image,
- bgImageStr);
+ CSSEditUtils::GetComputedProperty(aElement, *nsGkAtoms::background_image,
+ bgImageStr);
NS_ENSURE_SUCCESS(rv, rv);
if (!bgImageStr.EqualsLiteral("none")) {
return NS_OK;
}
nsAutoString bgColorStr;
rv =
- mCSSEditUtils->GetComputedProperty(aElement, *nsGkAtoms::backgroundColor,
- bgColorStr);
+ CSSEditUtils::GetComputedProperty(aElement, *nsGkAtoms::backgroundColor,
+ bgColorStr);
NS_ENSURE_SUCCESS(rv, rv);
if (!bgColorStr.EqualsLiteral("transparent")) {
return NS_OK;
}
RefPtr<nsComputedDOMStyle> cssDecl =
- mCSSEditUtils->GetComputedStyle(&aElement);
+ CSSEditUtils::GetComputedStyle(&aElement);
NS_ENSURE_STATE(cssDecl);
// from these declarations, get the one we want and that one only
ErrorResult error;
RefPtr<dom::CSSValue> cssVal =
cssDecl->GetPropertyCSSValue(NS_LITERAL_STRING("color"), error);
NS_ENSURE_TRUE(!error.Failed(), error.StealNSResult());
--- a/editor/libeditor/HTMLAnonymousNodeEditor.cpp
+++ b/editor/libeditor/HTMLAnonymousNodeEditor.cpp
@@ -483,28 +483,28 @@ HTMLEditor::GetPositionAndDimensions(Ele
int32_t& aMarginTop)
{
// Is the element positioned ? let's check the cheap way first...
bool isPositioned =
aElement.HasAttr(kNameSpaceID_None, nsGkAtoms::_moz_abspos);
if (!isPositioned) {
// hmmm... the expensive way now...
nsAutoString positionStr;
- mCSSEditUtils->GetComputedProperty(aElement, *nsGkAtoms::position,
+ CSSEditUtils::GetComputedProperty(aElement, *nsGkAtoms::position,
positionStr);
isPositioned = positionStr.EqualsLiteral("absolute");
}
if (isPositioned) {
// Yes, it is absolutely positioned
mResizedObjectIsAbsolutelyPositioned = true;
// Get the all the computed css styles attached to the element node
RefPtr<nsComputedDOMStyle> cssDecl =
- mCSSEditUtils->GetComputedStyle(&aElement);
+ CSSEditUtils::GetComputedStyle(&aElement);
NS_ENSURE_STATE(cssDecl);
aBorderLeft = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("border-left-width"));
aBorderTop = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("border-top-width"));
aMarginLeft = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("margin-left"));
aMarginTop = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("margin-top"));
aX = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("left")) +
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -873,23 +873,23 @@ HTMLEditRules::GetAlignment(bool* aMixed
NS_ENSURE_TRUE(nodeToExamine, NS_ERROR_NULL_POINTER);
nsCOMPtr<Element> blockParent = htmlEditor->GetBlock(*nodeToExamine);
NS_ENSURE_TRUE(blockParent, NS_ERROR_FAILURE);
if (htmlEditor->IsCSSEnabled() &&
- htmlEditor->mCSSEditUtils->IsCSSEditableProperty(blockParent, nullptr,
- nsGkAtoms::align)) {
+ CSSEditUtils::IsCSSEditableProperty(blockParent, nullptr,
+ nsGkAtoms::align)) {
// We are in CSS mode and we know how to align this element with CSS
nsAutoString value;
// Let's get the value(s) of text-align or margin-left/margin-right
- htmlEditor->mCSSEditUtils->GetCSSEquivalentToHTMLInlineStyleSet(
- blockParent, nullptr, nsGkAtoms::align, value, CSSEditUtils::eComputed);
+ CSSEditUtils::GetCSSEquivalentToHTMLInlineStyleSet(
+ blockParent, nullptr, nsGkAtoms::align, value, CSSEditUtils::eComputed);
if (value.EqualsLiteral("center") ||
value.EqualsLiteral("-moz-center") ||
value.EqualsLiteral("auto auto")) {
*aAlign = nsIHTMLEditor::eCenter;
return NS_OK;
}
if (value.EqualsLiteral("right") ||
value.EqualsLiteral("-moz-right") ||
@@ -911,22 +911,22 @@ HTMLEditRules::GetAlignment(bool* aMixed
if (!isFirstNodeToExamine &&
nodeToExamine->IsHTMLElement(nsGkAtoms::table)) {
// The node to examine is a table and this is not the first node we
// examine; let's break here to materialize the 'inline-block' behaviour
// of html tables regarding to text alignment
return NS_OK;
}
- if (htmlEditor->mCSSEditUtils->IsCSSEditableProperty(nodeToExamine, nullptr,
- nsGkAtoms::align)) {
+ if (CSSEditUtils::IsCSSEditableProperty(nodeToExamine, nullptr,
+ nsGkAtoms::align)) {
nsAutoString value;
- htmlEditor->mCSSEditUtils->GetSpecifiedProperty(*nodeToExamine,
- *nsGkAtoms::textAlign,
- value);
+ CSSEditUtils::GetSpecifiedProperty(*nodeToExamine,
+ *nsGkAtoms::textAlign,
+ value);
if (!value.IsEmpty()) {
if (value.EqualsLiteral("center")) {
*aAlign = nsIHTMLEditor::eCenter;
return NS_OK;
}
if (value.EqualsLiteral("right")) {
*aAlign = nsIHTMLEditor::eRight;
return NS_OK;
@@ -963,21 +963,21 @@ HTMLEditRules::GetAlignment(bool* aMixed
return NS_OK;
}
}
isFirstNodeToExamine = false;
}
return NS_OK;
}
-static nsAtom& MarginPropertyAtomForIndent(CSSEditUtils& aHTMLCSSUtils,
- nsINode& aNode)
+static nsAtom&
+MarginPropertyAtomForIndent(nsINode& aNode)
{
nsAutoString direction;
- aHTMLCSSUtils.GetComputedProperty(aNode, *nsGkAtoms::direction, direction);
+ CSSEditUtils::GetComputedProperty(aNode, *nsGkAtoms::direction, direction);
return direction.EqualsLiteral("rtl") ?
*nsGkAtoms::marginRight : *nsGkAtoms::marginLeft;
}
nsresult
HTMLEditRules::GetIndentState(bool* aCanIndent,
bool* aCanOutdent)
{
@@ -1004,29 +1004,24 @@ HTMLEditRules::GetIndentState(bool* aCan
NS_ENSURE_STATE(mHTMLEditor);
bool useCSS = mHTMLEditor->IsCSSEnabled();
for (auto& curNode : Reversed(arrayOfNodes)) {
if (HTMLEditUtils::IsNodeThatCanOutdent(curNode)) {
*aCanOutdent = true;
break;
} else if (useCSS) {
// we are in CSS mode, indentation is done using the margin-left (or margin-right) property
- NS_ENSURE_STATE(mHTMLEditor);
- nsAtom& marginProperty =
- MarginPropertyAtomForIndent(*mHTMLEditor->mCSSEditUtils, curNode);
+ nsAtom& marginProperty = MarginPropertyAtomForIndent(curNode);
nsAutoString value;
// retrieve its specified value
- NS_ENSURE_STATE(mHTMLEditor);
- mHTMLEditor->mCSSEditUtils->GetSpecifiedProperty(*curNode,
- marginProperty, value);
+ CSSEditUtils::GetSpecifiedProperty(*curNode, marginProperty, value);
float f;
RefPtr<nsAtom> unit;
// get its number part and its unit
- NS_ENSURE_STATE(mHTMLEditor);
- mHTMLEditor->mCSSEditUtils->ParseLength(value, &f, getter_AddRefs(unit));
+ CSSEditUtils::ParseLength(value, &f, getter_AddRefs(unit));
// if the number part is strictly positive, outdent is possible
if (0 < f) {
*aCanOutdent = true;
break;
}
}
}
@@ -4543,27 +4538,22 @@ HTMLEditRules::WillOutdent(Selection& aS
curBlockQuoteIsIndentedWithCSS = false;
}
rv = htmlEditor->RemoveBlockContainer(curNode);
NS_ENSURE_SUCCESS(rv, rv);
continue;
}
// Is it a block with a 'margin' property?
if (useCSS && IsBlockNode(curNode)) {
- nsAtom& marginProperty =
- MarginPropertyAtomForIndent(*htmlEditor->mCSSEditUtils, curNode);
+ nsAtom& marginProperty = MarginPropertyAtomForIndent(curNode);
nsAutoString value;
- htmlEditor->mCSSEditUtils->GetSpecifiedProperty(curNode,
- marginProperty,
- value);
+ CSSEditUtils::GetSpecifiedProperty(curNode, marginProperty, value);
float f;
RefPtr<nsAtom> unit;
- NS_ENSURE_STATE(htmlEditor);
- htmlEditor->mCSSEditUtils->ParseLength(value, &f,
- getter_AddRefs(unit));
+ CSSEditUtils::ParseLength(value, &f, getter_AddRefs(unit));
if (f > 0) {
ChangeIndentation(*curNode->AsElement(), Change::minus);
continue;
}
}
// Is it a list item?
if (HTMLEditUtils::IsListItem(curNode)) {
// If it is a list item, that means we are not outdenting whole list.
@@ -4622,24 +4612,22 @@ HTMLEditRules::WillOutdent(Selection& aS
n = *n->GetParentNode();
if (n->IsHTMLElement(nsGkAtoms::blockquote)) {
// If so, remember it and the first node we are taking out of it.
curBlockQuote = n->AsElement();
firstBQChild = curNode;
lastBQChild = curNode;
break;
} else if (useCSS) {
- nsAtom& marginProperty =
- MarginPropertyAtomForIndent(*htmlEditor->mCSSEditUtils, curNode);
+ nsAtom& marginProperty = MarginPropertyAtomForIndent(curNode);
nsAutoString value;
- htmlEditor->mCSSEditUtils->GetSpecifiedProperty(*n, marginProperty,
- value);
+ CSSEditUtils::GetSpecifiedProperty(*n, marginProperty, value);
float f;
RefPtr<nsAtom> unit;
- htmlEditor->mCSSEditUtils->ParseLength(value, &f, getter_AddRefs(unit));
+ CSSEditUtils::ParseLength(value, &f, getter_AddRefs(unit));
if (f > 0 && !(HTMLEditUtils::IsList(curParent) &&
HTMLEditUtils::IsList(curNode))) {
curBlockQuote = n->AsElement();
firstBQChild = curNode;
lastBQChild = curNode;
curBlockQuoteIsIndentedWithCSS = true;
break;
}
@@ -7762,18 +7750,18 @@ HTMLEditRules::JoinNodesSmart(nsIContent
if (NS_WARN_IF(NS_FAILED(rv))) {
return EditorDOMPoint();
}
if (lastLeft && firstRight && mHTMLEditor &&
mHTMLEditor->AreNodesSameType(lastLeft, firstRight) &&
(lastLeft->GetAsText() || !mHTMLEditor ||
(lastLeft->IsElement() && firstRight->IsElement() &&
- mHTMLEditor->mCSSEditUtils->ElementsSameStyle(lastLeft->AsElement(),
- firstRight->AsElement())))) {
+ CSSEditUtils::ElementsSameStyle(lastLeft->AsElement(),
+ firstRight->AsElement())))) {
if (NS_WARN_IF(!mHTMLEditor)) {
return EditorDOMPoint();
}
return JoinNodesSmart(*lastLeft, *firstRight);
}
return ret;
}
@@ -7836,18 +7824,17 @@ HTMLEditRules::GetInlineStyles(nsINode*
if (!useCSS || (aStyleCache[j].tag == nsGkAtoms::font &&
aStyleCache[j].attr == nsGkAtoms::size)) {
NS_ENSURE_STATE(mHTMLEditor);
isSet = mHTMLEditor->IsTextPropertySetByContent(aNode, aStyleCache[j].tag,
aStyleCache[j].attr,
nullptr,
&outValue);
} else {
- NS_ENSURE_STATE(mHTMLEditor);
- isSet = mHTMLEditor->mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(
+ isSet = CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet(
aNode, aStyleCache[j].tag, aStyleCache[j].attr, outValue,
CSSEditUtils::eComputed);
}
if (isSet) {
aStyleCache[j].mPresent = true;
aStyleCache[j].value.Assign(outValue);
}
}
@@ -7895,20 +7882,19 @@ HTMLEditRules::ReapplyCachedStyles()
for (size_t i = 0; i < SIZE_STYLE_TABLE; ++i) {
if (mCachedStyles[i].mPresent) {
bool bFirst, bAny, bAll;
bFirst = bAny = bAll = false;
nsAutoString curValue;
if (useCSS) {
// check computed style first in css case
- NS_ENSURE_STATE(mHTMLEditor);
- bAny = mHTMLEditor->mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(
- selNode, mCachedStyles[i].tag, mCachedStyles[i].attr, curValue,
- CSSEditUtils::eComputed);
+ bAny = CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet(
+ selNode, mCachedStyles[i].tag, mCachedStyles[i].attr, curValue,
+ CSSEditUtils::eComputed);
}
if (!bAny) {
// then check typeinstate and html style
NS_ENSURE_STATE(mHTMLEditor);
nsresult rv =
mHTMLEditor->GetInlinePropertyBase(*mCachedStyles[i].tag,
mCachedStyles[i].attr,
&(mCachedStyles[i].value),
@@ -9176,27 +9162,25 @@ HTMLEditRules::AlignBlock(Element& aElem
nsresult
HTMLEditRules::ChangeIndentation(Element& aElement,
Change aChange)
{
NS_ENSURE_STATE(mHTMLEditor);
RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
- nsAtom& marginProperty =
- MarginPropertyAtomForIndent(*htmlEditor->mCSSEditUtils, aElement);
+ nsAtom& marginProperty = MarginPropertyAtomForIndent(aElement);
nsAutoString value;
- htmlEditor->mCSSEditUtils->GetSpecifiedProperty(aElement, marginProperty,
- value);
+ CSSEditUtils::GetSpecifiedProperty(aElement, marginProperty, value);
float f;
RefPtr<nsAtom> unit;
- htmlEditor->mCSSEditUtils->ParseLength(value, &f, getter_AddRefs(unit));
+ CSSEditUtils::ParseLength(value, &f, getter_AddRefs(unit));
if (!f) {
nsAutoString defaultLengthUnit;
- htmlEditor->mCSSEditUtils->GetDefaultLengthUnit(defaultLengthUnit);
+ CSSEditUtils::GetDefaultLengthUnit(defaultLengthUnit);
unit = NS_Atomize(defaultLengthUnit);
}
int8_t multiplier = aChange == Change::plus ? +1 : -1;
if (nsGkAtoms::in == unit) {
f += NS_EDITOR_INDENT_INCREMENT_IN * multiplier;
} else if (nsGkAtoms::cm == unit) {
f += NS_EDITOR_INDENT_INCREMENT_CM * multiplier;
} else if (nsGkAtoms::mm == unit) {
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -1719,28 +1719,28 @@ HTMLEditor::GetCSSBackgroundColorState(b
// we are querying the block background (and not the text background), let's
// climb to the block container
nsCOMPtr<Element> blockParent = GetBlock(*nodeToExamine);
NS_ENSURE_TRUE(blockParent, NS_OK);
// Make sure to not walk off onto the Document node
do {
// retrieve the computed style of background-color for blockParent
- mCSSEditUtils->GetComputedProperty(*blockParent,
- *nsGkAtoms::backgroundColor,
- aOutColor);
+ CSSEditUtils::GetComputedProperty(*blockParent,
+ *nsGkAtoms::backgroundColor,
+ aOutColor);
blockParent = blockParent->GetParentElement();
// look at parent if the queried color is transparent and if the node to
// examine is not the root of the document
} while (aOutColor.EqualsLiteral("transparent") && blockParent);
if (aOutColor.EqualsLiteral("transparent")) {
// we have hit the root of the document and the color is still transparent !
// Grumble... Let's look at the default background color because that's the
// color we are looking for
- mCSSEditUtils->GetDefaultBackgroundColor(aOutColor);
+ CSSEditUtils::GetDefaultBackgroundColor(aOutColor);
}
}
else {
// no, we are querying the text background for the Text Highlight button
if (IsTextNode(nodeToExamine)) {
// if the node of interest is a text node, let's climb a level
nodeToExamine = nodeToExamine->GetParentNode();
}
@@ -1752,19 +1752,19 @@ HTMLEditor::GetCSSBackgroundColorState(b
// is the node to examine a block ?
if (NodeIsBlockStatic(nodeToExamine)) {
// yes it is a block; in that case, the text background color is transparent
aOutColor.AssignLiteral("transparent");
break;
} else {
// no, it's not; let's retrieve the computed style of background-color for the
// node to examine
- mCSSEditUtils->GetComputedProperty(*nodeToExamine,
- *nsGkAtoms::backgroundColor,
- aOutColor);
+ CSSEditUtils::GetComputedProperty(*nodeToExamine,
+ *nsGkAtoms::backgroundColor,
+ aOutColor);
if (!aOutColor.EqualsLiteral("transparent")) {
break;
}
}
nodeToExamine = nodeToExamine->GetParentNode();
} while ( aOutColor.EqualsLiteral("transparent") && nodeToExamine );
}
return NS_OK;
@@ -4308,19 +4308,23 @@ HTMLEditor::AreNodesSameType(nsIContent*
if (aNode1->NodeInfo()->NameAtom() != aNode2->NodeInfo()->NameAtom()) {
return false;
}
if (!IsCSSEnabled() || !aNode1->IsHTMLElement(nsGkAtoms::span)) {
return true;
}
+ if (!aNode1->IsElement() || !aNode2->IsElement()) {
+ return false;
+ }
+
// If CSS is enabled, we are stricter about span nodes.
- return mCSSEditUtils->ElementsSameStyle(aNode1->AsDOMNode(),
- aNode2->AsDOMNode());
+ return CSSEditUtils::ElementsSameStyle(aNode1->AsElement(),
+ aNode2->AsElement());
}
nsresult
HTMLEditor::CopyLastEditableChildStyles(nsINode* aPreviousBlock,
nsINode* aNewBlock,
Element** aOutBrNode)
{
nsCOMPtr<nsINode> newBlock = do_QueryInterface(aNewBlock);
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -436,17 +436,17 @@ public:
/**
* Add a url + known style sheet to the internal lists.
*/
nsresult AddNewStyleSheetToList(const nsAString &aURL,
StyleSheet* aStyleSheet);
nsresult RemoveStyleSheetFromList(const nsAString &aURL);
- bool IsCSSEnabled()
+ bool IsCSSEnabled() const
{
// TODO: removal of mCSSAware and use only the presence of mCSSEditUtils
return mCSSAware && mCSSEditUtils && mCSSEditUtils->IsCSSPrefChecked();
}
static bool HasAttributes(Element* aElement)
{
MOZ_ASSERT(aElement);
--- a/editor/libeditor/HTMLEditorObjectResizer.cpp
+++ b/editor/libeditor/HTMLEditorObjectResizer.cpp
@@ -190,22 +190,22 @@ HTMLEditor::SetAllResizersPosition()
int32_t h = mResizedObjectHeight;
// now let's place all the resizers around the image
// get the size of resizers
nsAutoString value;
float resizerWidth, resizerHeight;
RefPtr<nsAtom> dummyUnit;
- mCSSEditUtils->GetComputedProperty(*mTopLeftHandle, *nsGkAtoms::width,
- value);
- mCSSEditUtils->ParseLength(value, &resizerWidth, getter_AddRefs(dummyUnit));
- mCSSEditUtils->GetComputedProperty(*mTopLeftHandle, *nsGkAtoms::height,
- value);
- mCSSEditUtils->ParseLength(value, &resizerHeight, getter_AddRefs(dummyUnit));
+ CSSEditUtils::GetComputedProperty(*mTopLeftHandle, *nsGkAtoms::width,
+ value);
+ CSSEditUtils::ParseLength(value, &resizerWidth, getter_AddRefs(dummyUnit));
+ CSSEditUtils::GetComputedProperty(*mTopLeftHandle, *nsGkAtoms::height,
+ value);
+ CSSEditUtils::ParseLength(value, &resizerHeight, getter_AddRefs(dummyUnit));
int32_t rw = (int32_t)((resizerWidth + 1) / 2);
int32_t rh = (int32_t)((resizerHeight+ 1) / 2);
SetAnonymousElementPosition(x-rw, y-rh, mTopLeftHandle);
SetAnonymousElementPosition(x+w/2-rw, y-rh, mTopHandle);
SetAnonymousElementPosition(x+w-rw-1, y-rh, mTopRightHandle);
--- a/editor/libeditor/HTMLStyleEditor.cpp
+++ b/editor/libeditor/HTMLStyleEditor.cpp
@@ -227,17 +227,17 @@ HTMLEditor::IsSimpleModifiableNode(nsICo
// Property-specific handling is needed (bug 760211).
return true;
}
}
// No luck so far. Now we check for a <span> with a single style=""
// attribute that sets only the style we're looking for, if this type of
// style supports it
- if (!mCSSEditUtils->IsCSSEditableProperty(element, aProperty, aAttribute) ||
+ if (!CSSEditUtils::IsCSSEditableProperty(element, aProperty, aAttribute) ||
!element->IsHTMLElement(nsGkAtoms::span) ||
element->GetAttrCount() != 1 ||
!element->HasAttr(kNameSpaceID_None, nsGkAtoms::style)) {
return false;
}
// Some CSS styles are not so simple. For instance, underline is
// "text-decoration: underline", which decomposes into four different text-*
@@ -245,17 +245,17 @@ HTMLEditor::IsSimpleModifiableNode(nsICo
// see if it matches.
nsCOMPtr<Element> newSpan = CreateHTMLContent(nsGkAtoms::span);
NS_ASSERTION(newSpan, "CreateHTMLContent failed");
NS_ENSURE_TRUE(newSpan, false);
mCSSEditUtils->SetCSSEquivalentToHTMLStyle(newSpan, aProperty,
aAttribute, aValue,
/*suppress transaction*/ true);
- return mCSSEditUtils->ElementsSameStyle(newSpan, element);
+ return CSSEditUtils::ElementsSameStyle(newSpan, element);
}
nsresult
HTMLEditor::SetInlinePropertyOnTextNode(Text& aText,
int32_t aStartOffset,
int32_t aEndOffset,
nsAtom& aProperty,
nsAtom* aAttribute,
@@ -267,20 +267,20 @@ HTMLEditor::SetInlinePropertyOnTextNode(
}
// Don't need to do anything if no characters actually selected
if (aStartOffset == aEndOffset) {
return NS_OK;
}
// Don't need to do anything if property already set on node
- if (mCSSEditUtils->IsCSSEditableProperty(&aText, &aProperty, aAttribute)) {
+ if (CSSEditUtils::IsCSSEditableProperty(&aText, &aProperty, aAttribute)) {
// The HTML styles defined by aProperty/aAttribute have a CSS equivalence
// for node; let's check if it carries those CSS styles
- if (mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(&aText, &aProperty,
+ if (CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet(&aText, &aProperty,
aAttribute, aValue, CSSEditUtils::eComputed)) {
return NS_OK;
}
} else if (IsTextPropertySetByContent(&aText, &aProperty, aAttribute,
&aValue)) {
return NS_OK;
}
@@ -374,29 +374,29 @@ HTMLEditor::SetInlinePropertyOnNodeImpl(
}
if (IsSimpleModifiableNode(nextSibling, &aProperty, aAttribute, &aValue)) {
nsresult rv = MoveNode(&aNode, nextSibling, 0);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
// Don't need to do anything if property already set on node
- if (mCSSEditUtils->IsCSSEditableProperty(&aNode, &aProperty, aAttribute)) {
- if (mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(
+ if (CSSEditUtils::IsCSSEditableProperty(&aNode, &aProperty, aAttribute)) {
+ if (CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet(
&aNode, &aProperty, aAttribute, aValue, CSSEditUtils::eComputed)) {
return NS_OK;
}
} else if (IsTextPropertySetByContent(&aNode, &aProperty,
aAttribute, &aValue)) {
return NS_OK;
}
bool useCSS = (IsCSSEnabled() &&
- mCSSEditUtils->IsCSSEditableProperty(&aNode, &aProperty,
- aAttribute)) ||
+ CSSEditUtils::IsCSSEditableProperty(&aNode, &aProperty,
+ aAttribute)) ||
// bgcolor is always done using CSS
aAttribute == nsGkAtoms::bgcolor;
if (useCSS) {
nsCOMPtr<dom::Element> tmp;
// We only add style="" to <span>s with no attributes (bug 746515). If we
// don't have one, we need to make one.
if (aNode.IsHTMLElement(nsGkAtoms::span) &&
@@ -532,23 +532,23 @@ HTMLEditor::SplitStyleAbovePoint(nsCOMPt
OwningNonNull<nsIContent> node = *(*aNode)->AsContent();
bool useCSS = IsCSSEnabled();
bool isSet;
while (!IsBlockNode(node) && node->GetParent() &&
IsEditable(node->GetParent())) {
isSet = false;
- if (useCSS && mCSSEditUtils->IsCSSEditableProperty(node, aProperty,
- aAttribute)) {
+ if (useCSS && CSSEditUtils::IsCSSEditableProperty(node, aProperty,
+ aAttribute)) {
// The HTML style defined by aProperty/aAttribute has a CSS equivalence
// in this implementation for the node; let's check if it carries those
// CSS styles
nsAutoString firstValue;
- isSet = mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(
+ isSet = CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet(
node, aProperty, aAttribute, firstValue,
CSSEditUtils::eSpecified);
}
if (// node is the correct inline prop
(aProperty && node->IsHTMLElement(aProperty)) ||
// node is href - test if really <a href=...
(aProperty == nsGkAtoms::href && HTMLEditUtils::IsLink(node)) ||
// or node is any prop, and we asked to split them all
@@ -747,25 +747,25 @@ HTMLEditor::RemoveStyleInside(nsIContent
return rv;
}
}
}
}
}
if (!aChildrenOnly &&
- mCSSEditUtils->IsCSSEditableProperty(&aNode, aProperty, aAttribute)) {
+ CSSEditUtils::IsCSSEditableProperty(&aNode, aProperty, aAttribute)) {
// the HTML style defined by aProperty/aAttribute has a CSS equivalence in
// this implementation for the node aNode; let's check if it carries those
// css styles
if (aNode.IsElement()) {
bool hasAttribute =
- mCSSEditUtils->HaveCSSEquivalentStyles(
- aNode, aProperty, aAttribute,
- CSSEditUtils::eSpecified);
+ CSSEditUtils::HaveCSSEquivalentStyles(
+ aNode, aProperty, aAttribute,
+ CSSEditUtils::eSpecified);
if (hasAttribute) {
// yes, tmp has the corresponding css declarations in its style
// attribute
// let's remove them
mCSSEditUtils->RemoveCSSEquivalentToHTMLStyle(aNode.AsElement(),
aProperty,
aAttribute,
nullptr,
@@ -976,24 +976,25 @@ HTMLEditor::GetInlinePropertyBase(nsAtom
} else {
mTypeInState->GetTypingState(isSet, theSetting, &aProperty);
}
if (isSet) {
*aFirst = *aAny = *aAll = theSetting;
return NS_OK;
}
- if (mCSSEditUtils->IsCSSEditableProperty(collapsedNode, &aProperty,
- aAttribute)) {
+ if (CSSEditUtils::IsCSSEditableProperty(collapsedNode, &aProperty,
+ aAttribute)) {
if (aValue) {
tOutString.Assign(*aValue);
}
*aFirst = *aAny = *aAll =
- mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(collapsedNode,
- &aProperty, aAttribute, tOutString, CSSEditUtils::eComputed);
+ CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet(
+ collapsedNode, &aProperty, aAttribute, tOutString,
+ CSSEditUtils::eComputed);
if (outValue) {
outValue->Assign(tOutString);
}
return NS_OK;
}
isSet = IsTextPropertySetByContent(collapsedNode, &aProperty,
aAttribute, aValue, outValue);
@@ -1035,46 +1036,47 @@ HTMLEditor::GetInlinePropertyBase(nsAtom
}
} else if (content->IsElement()) {
// handle non-text leaf nodes here
continue;
}
bool isSet = false;
if (first) {
- if (mCSSEditUtils->IsCSSEditableProperty(content, &aProperty,
- aAttribute)) {
+ if (CSSEditUtils::IsCSSEditableProperty(content, &aProperty,
+ aAttribute)) {
// The HTML styles defined by aProperty/aAttribute have a CSS
// equivalence in this implementation for node; let's check if it
// carries those CSS styles
if (aValue) {
firstValue.Assign(*aValue);
}
- isSet = mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(content,
- &aProperty, aAttribute, firstValue, CSSEditUtils::eComputed);
+ isSet = CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet(
+ content, &aProperty, aAttribute, firstValue,
+ CSSEditUtils::eComputed);
} else {
isSet = IsTextPropertySetByContent(content, &aProperty, aAttribute,
aValue, &firstValue);
}
*aFirst = isSet;
first = false;
if (outValue) {
*outValue = firstValue;
}
} else {
- if (mCSSEditUtils->IsCSSEditableProperty(content, &aProperty,
- aAttribute)) {
+ if (CSSEditUtils::IsCSSEditableProperty(content, &aProperty,
+ aAttribute)) {
// The HTML styles defined by aProperty/aAttribute have a CSS
// equivalence in this implementation for node; let's check if it
// carries those CSS styles
if (aValue) {
theValue.Assign(*aValue);
}
- isSet = mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(content,
- &aProperty, aAttribute, theValue, CSSEditUtils::eComputed);
+ isSet = CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet(
+ content, &aProperty, aAttribute, theValue, CSSEditUtils::eComputed);
} else {
isSet = IsTextPropertySetByContent(content, &aProperty, aAttribute,
aValue, &theValue);
}
if (firstValue != theValue) {
*aAll = false;
}
}
@@ -1242,28 +1244,28 @@ HTMLEditor::RemoveInlineProperty(nsAtom*
NS_ENSURE_SUCCESS(rv, rv);
// Check for easy case: both range endpoints in same text node
nsCOMPtr<nsINode> startNode = range->GetStartContainer();
nsCOMPtr<nsINode> endNode = range->GetEndContainer();
if (startNode && startNode == endNode && startNode->GetAsText()) {
// We're done with this range!
if (IsCSSEnabled() &&
- mCSSEditUtils->IsCSSEditableProperty(startNode, aProperty,
- aAttribute)) {
+ CSSEditUtils::IsCSSEditableProperty(startNode, aProperty,
+ aAttribute)) {
// The HTML style defined by aProperty/aAttribute has a CSS
// equivalence in this implementation for startNode
- if (mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(startNode,
- aProperty, aAttribute, EmptyString(),
- CSSEditUtils::eComputed)) {
+ if (CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet(
+ startNode, aProperty, aAttribute, EmptyString(),
+ CSSEditUtils::eComputed)) {
// startNode's computed style indicates the CSS equivalence to the
// HTML style to remove is applied; but we found no element in the
// ancestors of startNode carrying specified styles; assume it
// comes from a rule and try to insert a span "inverting" the style
- if (mCSSEditUtils->IsCSSInvertible(*aProperty, aAttribute)) {
+ if (CSSEditUtils::IsCSSInvertible(*aProperty, aAttribute)) {
NS_NAMED_LITERAL_STRING(value, "-moz-editor-invert-value");
SetInlinePropertyOnTextNode(*startNode->GetAsText(),
range->StartOffset(),
range->EndOffset(), *aProperty,
aAttribute, value);
}
}
}
@@ -1283,27 +1285,27 @@ HTMLEditor::RemoveInlineProperty(nsAtom*
}
}
// Loop through the list, remove the property on each node
for (auto& node : arrayOfNodes) {
rv = RemoveStyleInside(node, aProperty, aAttribute);
NS_ENSURE_SUCCESS(rv, rv);
if (IsCSSEnabled() &&
- mCSSEditUtils->IsCSSEditableProperty(node, aProperty,
- aAttribute) &&
- mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(node,
- aProperty, aAttribute, EmptyString(),
- CSSEditUtils::eComputed) &&
+ CSSEditUtils::IsCSSEditableProperty(node, aProperty,
+ aAttribute) &&
+ CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet(
+ node, aProperty, aAttribute, EmptyString(),
+ CSSEditUtils::eComputed) &&
// startNode's computed style indicates the CSS equivalence to
// the HTML style to remove is applied; but we found no element
// in the ancestors of startNode carrying specified styles;
// assume it comes from a rule and let's try to insert a span
// "inverting" the style
- mCSSEditUtils->IsCSSInvertible(*aProperty, aAttribute)) {
+ CSSEditUtils::IsCSSInvertible(*aProperty, aAttribute)) {
NS_NAMED_LITERAL_STRING(value, "-moz-editor-invert-value");
SetInlinePropertyOnNode(node, *aProperty, aAttribute, value);
}
}
}
}
}
if (!cancel) {