Bug 748315 - Part 1. Consider text-align property even if HTMLEditor::IsCSSEnabled() is false. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Wed, 25 Oct 2017 16:13:02 +0900
changeset 688287 4aec57935ea4ab6e8c300a8a58b3e0d0ef89aadf
parent 688286 1e4f10cea5e70218143191e3d85a94f79d0e6305
child 688288 e84566247b9b6c5fe85ced2af03f32923deafb19
push id86710
push userbmo:m_kato@ga2.so-net.ne.jp
push dateSun, 29 Oct 2017 14:07:30 +0000
reviewersmasayuki
bugs748315
milestone58.0a1
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
editor/libeditor/HTMLEditRules.cpp
--- 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")) {