Bug 1156062 - Back out for now, requested by Masayuki at bug 1191356 comment 23

This commit is contained in:
Aryeh Gregor 2016-04-20 20:44:59 +03:00
parent 81d03b3b1d
commit ed26b75d9e

View File

@ -944,13 +944,14 @@ nsHTMLEditRules::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
return NS_OK;
}
static nsIAtom& MarginPropertyAtomForIndent(nsHTMLCSSUtils& aHTMLCSSUtils,
nsINode& aNode)
{
static nsIAtom* MarginPropertyAtomForIndent(nsHTMLCSSUtils* aHTMLCSSUtils,
nsIDOMNode* aNode) {
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
NS_ENSURE_TRUE(node || !aNode, nsGkAtoms::marginLeft);
nsAutoString direction;
aHTMLCSSUtils.GetComputedProperty(aNode, *nsGkAtoms::direction, direction);
aHTMLCSSUtils->GetComputedProperty(*node, *nsGkAtoms::direction, direction);
return direction.EqualsLiteral("rtl") ?
*nsGkAtoms::marginRight : *nsGkAtoms::marginLeft;
nsGkAtoms::marginRight : nsGkAtoms::marginLeft;
}
nsresult
@ -983,13 +984,14 @@ nsHTMLEditRules::GetIndentState(bool *aCanIndent, bool *aCanOutdent)
else if (useCSS) {
// we are in CSS mode, indentation is done using the margin-left (or margin-right) property
NS_ENSURE_STATE(mHTMLEditor);
nsIAtom& marginProperty =
MarginPropertyAtomForIndent(*mHTMLEditor->mHTMLCSSUtils, curNode);
nsIAtom* marginProperty =
MarginPropertyAtomForIndent(mHTMLEditor->mHTMLCSSUtils,
GetAsDOMNode(curNode));
nsAutoString value;
// retrieve its specified value
NS_ENSURE_STATE(mHTMLEditor);
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(*curNode,
marginProperty, value);
*marginProperty, value);
float f;
nsCOMPtr<nsIAtom> unit;
// get its number part and its unit
@ -4020,12 +4022,13 @@ nsHTMLEditRules::WillOutdent(Selection* aSelection,
// is it a block with a 'margin' property?
if (useCSS && IsBlockNode(GetAsDOMNode(curNode))) {
NS_ENSURE_STATE(mHTMLEditor);
nsIAtom& marginProperty =
MarginPropertyAtomForIndent(*mHTMLEditor->mHTMLCSSUtils, curNode);
nsIAtom* marginProperty =
MarginPropertyAtomForIndent(mHTMLEditor->mHTMLCSSUtils,
GetAsDOMNode(curNode));
nsAutoString value;
NS_ENSURE_STATE(mHTMLEditor);
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(curNode,
marginProperty,
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(*curNode,
*marginProperty,
value);
float f;
nsCOMPtr<nsIAtom> unit;
@ -4106,11 +4109,12 @@ nsHTMLEditRules::WillOutdent(Selection* aSelection,
else if (useCSS)
{
NS_ENSURE_STATE(mHTMLEditor);
nsIAtom& marginProperty =
MarginPropertyAtomForIndent(*mHTMLEditor->mHTMLCSSUtils, curNode);
nsIAtom* marginProperty =
MarginPropertyAtomForIndent(mHTMLEditor->mHTMLCSSUtils,
GetAsDOMNode(curNode));
nsAutoString value;
NS_ENSURE_STATE(mHTMLEditor);
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(*n, marginProperty,
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(*n, *marginProperty,
value);
float f;
nsCOMPtr<nsIAtom> unit;
@ -8614,11 +8618,12 @@ nsHTMLEditRules::RelativeChangeIndentationOfElementNode(nsIDOMNode *aNode, int8_
}
NS_ENSURE_STATE(mHTMLEditor);
nsIAtom& marginProperty =
MarginPropertyAtomForIndent(*mHTMLEditor->mHTMLCSSUtils, *element);
nsIAtom* marginProperty =
MarginPropertyAtomForIndent(mHTMLEditor->mHTMLCSSUtils,
GetAsDOMNode(element));
nsAutoString value;
NS_ENSURE_STATE(mHTMLEditor);
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(*element, marginProperty,
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(*element, *marginProperty,
value);
float f;
nsCOMPtr<nsIAtom> unit;
@ -8655,13 +8660,13 @@ nsHTMLEditRules::RelativeChangeIndentationOfElementNode(nsIDOMNode *aNode, int8_
newValue.AppendFloat(f);
newValue.Append(nsDependentAtomString(unit));
NS_ENSURE_STATE(mHTMLEditor);
mHTMLEditor->mHTMLCSSUtils->SetCSSProperty(*element, marginProperty,
mHTMLEditor->mHTMLCSSUtils->SetCSSProperty(*element, *marginProperty,
newValue);
return NS_OK;
}
NS_ENSURE_STATE(mHTMLEditor);
mHTMLEditor->mHTMLCSSUtils->RemoveCSSProperty(*element, marginProperty,
mHTMLEditor->mHTMLCSSUtils->RemoveCSSProperty(*element, *marginProperty,
value);
// remove unnecessary DIV blocks: