Bug 748315 - Part 1. Consider text-align property even if HTMLEditor::IsCSSEnabled() is false. r?masayuki
Actually, we don't consider CSS property to get alignment when IsCSSEnabled()
is false. For WebKit and Blink compatibility, we should consider this situation.
MozReview-Commit-ID: 9ORntUmbIbf
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -918,16 +918,45 @@ HTMLEditRules::GetAlignment(bool* aMixed
for (; nodeToExamine; nodeToExamine = nodeToExamine->GetParentNode()) {
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)) {
+ nsAutoString value;
+ htmlEditor->mCSSEditUtils->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;
+ }
+ if (value.EqualsLiteral("justify")) {
+ *aAlign = nsIHTMLEditor::eJustify;
+ return NS_OK;
+ }
+ if (value.EqualsLiteral("left")) {
+ *aAlign = nsIHTMLEditor::eLeft;
+ return NS_OK;
+ }
+ // XXX
+ // text-align: start and end aren't supported yet
+ }
+ }
+
if (HTMLEditUtils::SupportsAlignAttr(*nodeToExamine)) {
// Check for alignment
nsAutoString typeAttrVal;
nodeToExamine->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::align,
typeAttrVal);
ToLowerCase(typeAttrVal);
if (!typeAttrVal.IsEmpty()) {
if (typeAttrVal.EqualsLiteral("center")) {