Bug 1190172 part 3 - Remove old method variants; r=ehsan
authorAryeh Gregor <ayg@aryeh.name>
Sun, 01 May 2016 16:11:52 +0300
changeset 295629 204cbd92cc3751f247f4075971c9a840e0f1bac2
parent 295628 09235b9b9c4cabf6d00add930dcf54acd4b485b5
child 295630 1ccf786fd04fb560f71aacaf8fa5182837630148
push id19015
push usercbook@mozilla.com
push dateMon, 02 May 2016 09:39:23 +0000
treeherderfx-team@2080375bc69d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1190172
milestone49.0a1
Bug 1190172 part 3 - Remove old method variants; r=ehsan
editor/libeditor/nsHTMLEditor.h
editor/libeditor/nsHTMLEditorStyle.cpp
--- a/editor/libeditor/nsHTMLEditor.h
+++ b/editor/libeditor/nsHTMLEditor.h
@@ -665,32 +665,27 @@ protected:
                                 nsIAtom *aProperty,
                                 const nsAString *aAttribute);
   nsresult SplitStyleAbovePoint(nsCOMPtr<nsINode>* aNode, int32_t* aOffset,
                                 nsIAtom* aProperty,
                                 const nsAString* aAttribute,
                                 nsIContent** aOutLeftNode = nullptr,
                                 nsIContent** aOutRightNode = nullptr);
   nsresult ApplyDefaultProperties();
-  nsresult RemoveStyleInside(nsIDOMNode *aNode,
-                             nsIAtom *aProperty,
-                             const nsAString *aAttribute,
-                             const bool aChildrenOnly = false);
   nsresult RemoveStyleInside(nsIContent& aNode,
                              nsIAtom* aProperty,
                              const nsAString* aAttribute,
                              const bool aChildrenOnly = false);
   nsresult RemoveInlinePropertyImpl(nsIAtom* aProperty,
                                     const nsAString* aAttribute);
 
   bool NodeIsProperty(nsIDOMNode *aNode);
   bool HasAttr(nsIDOMNode *aNode, const nsAString *aAttribute);
   bool IsAtFrontOfNode(nsIDOMNode *aNode, int32_t aOffset);
   bool IsAtEndOfNode(nsIDOMNode *aNode, int32_t aOffset);
-  bool IsOnlyAttribute(nsIDOMNode *aElement, const nsAString *aAttribute);
   bool IsOnlyAttribute(const nsIContent* aElement, const nsAString& aAttribute);
 
   nsresult RemoveBlockContainer(nsIDOMNode *inNode);
 
   nsIContent* GetPriorHTMLSibling(nsINode* aNode);
   nsresult GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
   nsIContent* GetPriorHTMLSibling(nsINode* aParent, int32_t aOffset);
   nsresult GetPriorHTMLSibling(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr<nsIDOMNode> *outNode);
--- a/editor/libeditor/nsHTMLEditorStyle.cpp
+++ b/editor/libeditor/nsHTMLEditorStyle.cpp
@@ -668,17 +668,17 @@ nsHTMLEditor::ClearStyle(nsCOMPtr<nsINod
     {
       // Track the point at the new hierarchy.  This is so we can know where
       // to put the selection after we call RemoveStyleInside().
       // RemoveStyleInside() could remove any and all of those nodes, so I
       // have to use the range tracking system to find the right spot to put
       // selection.
       nsAutoTrackDOMPoint tracker(mRangeUpdater,
                                   address_of(newSelParent), &newSelOffset);
-      res = RemoveStyleInside(GetAsDOMNode(leftNode), aProperty, aAttribute);
+      res = RemoveStyleInside(*leftNode, aProperty, aAttribute);
       NS_ENSURE_SUCCESS(res, res);
     }
     // reset our node offset values to the resulting new sel point
     *aNode = newSelParent;
     *aOffset = newSelOffset;
   }
 
   return NS_OK;
@@ -705,29 +705,16 @@ nsresult nsHTMLEditor::ApplyDefaultPrope
     PropItem *propItem = mDefaultStyles[j];
     NS_ENSURE_TRUE(propItem, NS_ERROR_NULL_POINTER);
     res = SetInlineProperty(propItem->tag, propItem->attr, propItem->value);
     NS_ENSURE_SUCCESS(res, res);
   }
   return res;
 }
 
-nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
-                                         // null here means remove all properties
-                                         nsIAtom *aProperty,
-                                         const nsAString *aAttribute,
-                                         const bool aChildrenOnly)
-{
-  NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
-  nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
-  NS_ENSURE_STATE(content);
-
-  return RemoveStyleInside(*content, aProperty, aAttribute, aChildrenOnly);
-}
-
 nsresult
 nsHTMLEditor::RemoveStyleInside(nsIContent& aNode,
                                 nsIAtom* aProperty,
                                 const nsAString* aAttribute,
                                 const bool aChildrenOnly /* = false */)
 {
   if (aNode.NodeType() == nsIDOMNode::TEXT_NODE) {
     return NS_OK;
@@ -829,27 +816,16 @@ nsHTMLEditor::RemoveStyleInside(nsIConte
     )
   ) {
     // if we are setting font size, remove any nested bigs and smalls
     return RemoveContainer(&aNode);
   }
   return NS_OK;
 }
 
-bool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
-                                     const nsAString *aAttribute)
-{
-  NS_ENSURE_TRUE(aNode && aAttribute, false);  // ooops
-
-  nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
-  NS_ENSURE_TRUE(content, false);  // ooops
-
-  return IsOnlyAttribute(content, *aAttribute);
-}
-
 bool
 nsHTMLEditor::IsOnlyAttribute(const nsIContent* aContent,
                               const nsAString& aAttribute)
 {
   MOZ_ASSERT(aContent);
 
   uint32_t attrCount = aContent->GetAttrCount();
   for (uint32_t i = 0; i < attrCount; ++i) {
@@ -1348,47 +1324,46 @@ nsHTMLEditor::RemoveInlinePropertyImpl(n
                                           aAttribute, value);
             }
           }
         }
       } else {
         // Not the easy case.  Range not contained in single text node.
         nsCOMPtr<nsIContentIterator> iter = NS_NewContentSubtreeIterator();
 
-        nsTArray<nsCOMPtr<nsINode>> arrayOfNodes;
+        nsTArray<OwningNonNull<nsIContent>> arrayOfNodes;
 
         // Iterate range and build up array
         for (iter->Init(range); !iter->IsDone(); iter->Next()) {
           nsCOMPtr<nsINode> node = iter->GetCurrentNode();
           NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
 
-          if (IsEditable(node)) {
-            arrayOfNodes.AppendElement(node);
+          if (IsEditable(node) && node->IsContent()) {
+            arrayOfNodes.AppendElement(*node->AsContent());
           }
         }
 
         // Loop through the list, remove the property on each node
         for (auto& node : arrayOfNodes) {
-          res = RemoveStyleInside(GetAsDOMNode(node), aProperty, aAttribute);
+          res = RemoveStyleInside(node, aProperty, aAttribute);
           NS_ENSURE_SUCCESS(res, res);
           if (IsCSSEnabled() &&
               mHTMLCSSUtils->IsCSSEditableProperty(node, aProperty,
                                                    aAttribute) &&
               mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(node,
                   aProperty, aAttribute, EmptyString(),
                   nsHTMLCSSUtils::eComputed) &&
               // startNode's computed style indicates the CSS equivalence to
               // the HTML style to remove is applied; but we found no element
               // in the ancestors of startNode carrying specified styles;
               // assume it comes from a rule and let's try to insert a span
               // "inverting" the style
               mHTMLCSSUtils->IsCSSInvertible(*aProperty, aAttribute)) {
             NS_NAMED_LITERAL_STRING(value, "-moz-editor-invert-value");
-            SetInlinePropertyOnNode(*node->AsContent(), *aProperty,
-                                    aAttribute, value);
+            SetInlinePropertyOnNode(node, *aProperty, aAttribute, value);
           }
         }
       }
     }
   }
   if (!cancel) {
     // Post-process
     res = mRules->DidDoAction(selection, &ruleInfo, res);