Bug 331846: Can't indent/outdent RTL blocks in Composer and Design Mode. r=timeless sr=bzbarsky a=dveditz

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_0_BRANCH@199414 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
uriber%gmail.com
2006-06-07 08:17:51 +00:00
parent b2be58ef55
commit cfc5894b03
2 changed files with 18 additions and 7 deletions

View File

@@ -145,6 +145,7 @@ EDITOR_ATOM(cssBorder, "border")
EDITOR_ATOM(cssBottom, "bottom")
EDITOR_ATOM(cssCaptionSide, "caption-side")
EDITOR_ATOM(cssColor, "color")
EDITOR_ATOM(cssDirection, "direction")
EDITOR_ATOM(cssFloat, "float")
EDITOR_ATOM(cssFontFamily, "font-family")
EDITOR_ATOM(cssFontSize, "font-size")

View File

@@ -930,11 +930,18 @@ nsHTMLEditRules::GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
return NS_OK;
}
nsIAtom* MarginPropertyAtomForIndent(nsHTMLCSSUtils* aHTMLCSSUtils, nsIDOMNode* aNode) {
nsAutoString direction;
aHTMLCSSUtils->GetComputedProperty(aNode, nsEditProperty::cssDirection, direction);
return direction.EqualsLiteral("rtl") ?
nsEditProperty::cssMarginRight : nsEditProperty::cssMarginLeft;
}
NS_IMETHODIMP
nsHTMLEditRules::GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)
{
if (!aCanIndent || !aCanOutdent)
return NS_ERROR_FAILURE;
return NS_ERROR_FAILURE;
*aCanIndent = PR_TRUE;
*aCanOutdent = PR_FALSE;
@@ -968,10 +975,11 @@ nsHTMLEditRules::GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)
break;
}
else if (useCSS) {
// we are in CSS mode, indentation is done using the margin-left property
// we are in CSS mode, indentation is done using the margin-left (or margin-right) property
nsIAtom* marginProperty = MarginPropertyAtomForIndent(mHTMLEditor->mHTMLCSSUtils, curNode);
nsAutoString value;
// retrieve its specified value
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(curNode, nsEditProperty::cssMarginLeft, value);
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(curNode, marginProperty, value);
float f;
nsCOMPtr<nsIAtom> unit;
// get its number part and its unit
@@ -3914,8 +3922,9 @@ nsHTMLEditRules::WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *
}
else if (useCSS)
{
nsIAtom* marginProperty = MarginPropertyAtomForIndent(mHTMLEditor->mHTMLCSSUtils, curNode);
nsAutoString value;
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(n, nsEditProperty::cssMarginLeft, value);
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(n, marginProperty, value);
float f;
nsIAtom * unit;
mHTMLEditor->mHTMLCSSUtils->ParseLength(value, &f, &unit);
@@ -8570,9 +8579,10 @@ nsHTMLEditRules::RelativeChangeIndentationOfElementNode(nsIDOMNode *aNode, PRInt
NS_ASSERTION(element, "not an element node");
if (element) {
nsIAtom* marginProperty = MarginPropertyAtomForIndent(mHTMLEditor->mHTMLCSSUtils, element);
nsAutoString value;
nsresult res;
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(aNode, nsEditProperty::cssMarginLeft, value);
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(aNode, marginProperty, value);
float f;
nsIAtom * unit;
mHTMLEditor->mHTMLCSSUtils->ParseLength(value, &f, &unit);
@@ -8609,10 +8619,10 @@ nsHTMLEditRules::RelativeChangeIndentationOfElementNode(nsIDOMNode *aNode, PRInt
nsAutoString newValue;
newValue.AppendFloat(f);
newValue.Append(unitString);
mHTMLEditor->mHTMLCSSUtils->SetCSSProperty(element, nsEditProperty::cssMarginLeft, newValue, PR_FALSE);
mHTMLEditor->mHTMLCSSUtils->SetCSSProperty(element, marginProperty, newValue, PR_FALSE);
}
else {
mHTMLEditor->mHTMLCSSUtils->RemoveCSSProperty(element, nsEditProperty::cssMarginLeft, value, PR_FALSE);
mHTMLEditor->mHTMLCSSUtils->RemoveCSSProperty(element, marginProperty, value, PR_FALSE);
if (nsHTMLEditUtils::IsDiv(aNode)) {
// we deal with a DIV ; let's see if it is useless and if we can remove it
nsCOMPtr<nsIDOMNamedNodeMap> attributeList;