Backout changeset aabe14890eb2 (bug 1190172 part 5)
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 23 Apr 2016 20:00:35 +0900
changeset 318444 03fb870d6b0bf38e0243a2e3687ea6cccc949f63
parent 318443 c02a5a394dba5d35110002e6206726e746a7a3ff
child 318445 df7fa82b5fc98269e7f0ce3a798f8caf3c2bd08c
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1190172
milestone48.0a1
backs outaabe14890eb2074a2db9a95f4f1f1168d0efb3a4
Backout changeset aabe14890eb2 (bug 1190172 part 5)
editor/libeditor/nsHTMLEditor.h
editor/libeditor/nsHTMLEditorStyle.cpp
--- a/editor/libeditor/nsHTMLEditor.h
+++ b/editor/libeditor/nsHTMLEditor.h
@@ -672,17 +672,17 @@ protected:
   nsresult ApplyDefaultProperties();
   nsresult RemoveStyleInside(nsIContent& aNode,
                              nsIAtom* aProperty,
                              const nsAString* aAttribute,
                              const bool aChildrenOnly = false);
   nsresult RemoveInlinePropertyImpl(nsIAtom* aProperty,
                                     const nsAString* aAttribute);
 
-  bool NodeIsProperty(nsINode& aNode);
+  bool NodeIsProperty(nsIDOMNode *aNode);
   bool IsAtFrontOfNode(nsIDOMNode *aNode, int32_t aOffset);
   bool IsAtEndOfNode(nsIDOMNode *aNode, int32_t aOffset);
   bool IsOnlyAttribute(const nsIContent* aElement, const nsAString& aAttribute);
 
   nsresult RemoveBlockContainer(nsIDOMNode *inNode);
 
   nsIContent* GetPriorHTMLSibling(nsINode* aNode);
   nsresult GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
--- a/editor/libeditor/nsHTMLEditorStyle.cpp
+++ b/editor/libeditor/nsHTMLEditorStyle.cpp
@@ -581,17 +581,17 @@ nsHTMLEditor::SplitStyleAbovePoint(nsCOM
       mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(GetAsDOMNode(node),
         aProperty, aAttribute, isSet, firstValue, nsHTMLCSSUtils::eSpecified);
     }
     if (// node is the correct inline prop
         (aProperty && node->IsHTMLElement(aProperty)) ||
         // node is href - test if really <a href=...
         (aProperty == nsGkAtoms::href && nsHTMLEditUtils::IsLink(node)) ||
         // or node is any prop, and we asked to split them all
-        (!aProperty && NodeIsProperty(node)) ||
+        (!aProperty && NodeIsProperty(GetAsDOMNode(node))) ||
         // or the style is specified in the style attribute
         isSet) {
       // Found a style node we need to split
       int32_t offset = SplitNodeDeep(*node, *(*aNode)->AsContent(), *aOffset,
                                      EmptyContainers::yes, aOutLeftNode,
                                      aOutRightNode);
       NS_ENSURE_TRUE(offset != -1, NS_ERROR_FAILURE);
       // reset startNode/startOffset
@@ -679,21 +679,26 @@ nsHTMLEditor::ClearStyle(nsCOMPtr<nsINod
     // reset our node offset values to the resulting new sel point
     *aNode = newSelParent;
     *aOffset = newSelOffset;
   }
 
   return NS_OK;
 }
 
-bool
-nsHTMLEditor::NodeIsProperty(nsINode& aNode)
+bool nsHTMLEditor::NodeIsProperty(nsIDOMNode *aNode)
 {
-  return IsContainer(&aNode) && IsEditable(&aNode) && !IsBlockNode(&aNode) &&
-         !aNode.IsHTMLElement(nsGkAtoms::a);
+  NS_ENSURE_TRUE(aNode, false);
+  if (!IsContainer(aNode))  return false;
+  if (!IsEditable(aNode))   return false;
+  if (IsBlockNode(aNode))   return false;
+  if (NodeIsType(aNode, nsGkAtoms::a)) {
+    return false;
+  }
+  return true;
 }
 
 nsresult nsHTMLEditor::ApplyDefaultProperties()
 {
   nsresult res = NS_OK;
   uint32_t j, defcon = mDefaultStyles.Length();
   for (j=0; j<defcon; j++)
   {
@@ -730,17 +735,17 @@ nsHTMLEditor::RemoveStyleInside(nsIConte
     (
       // node is prop we asked for
       (aProperty && aNode.NodeInfo()->NameAtom() == aProperty) ||
       // but check for link (<a href=...)
       (aProperty == nsGkAtoms::href && nsHTMLEditUtils::IsLink(&aNode)) ||
       // and for named anchors
       (aProperty == nsGkAtoms::name && nsHTMLEditUtils::IsNamedAnchor(&aNode)) ||
       // or node is any prop and we asked for that
-      (!aProperty && NodeIsProperty(aNode))
+      (!aProperty && NodeIsProperty(aNode.AsDOMNode()))
     )
   ) {
     nsresult res;
     // if we weren't passed an attribute, then we want to
     // remove any matching inlinestyles entirely
     if (!aAttribute || aAttribute->IsEmpty()) {
       NS_NAMED_LITERAL_STRING(styleAttr, "style");
       NS_NAMED_LITERAL_STRING(classAttr, "class");