Bug 705439 - Remove dead code: nsHTMLEditor::GetBlockSection / nsHTMLEditor::GetBlockSectionsForRange; r=ehsan
authorMs2ger <ms2ger@gmail.com>
Sat, 03 Dec 2011 22:50:17 +0100
changeset 81968 eb1b0c46ddd684dcbf16156ba05d68d444eb87ef
parent 81967 95d2ceb6b8ed51de1193f995010a077f75a845f7
child 81969 78de2c2bdad5d3c3d87da866f89733a944afd322
push idunknown
push userunknown
push dateunknown
reviewersehsan
bugs705439
milestone11.0a1
Bug 705439 - Remove dead code: nsHTMLEditor::GetBlockSection / nsHTMLEditor::GetBlockSectionsForRange; r=ehsan
editor/libeditor/html/nsHTMLEditor.cpp
editor/libeditor/html/nsHTMLEditor.h
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -965,165 +965,16 @@ nsHTMLEditor::GetBlockNodeParent(nsIDOMN
       break;
 
     p = tmp;
   }
   return p.forget();
 }
 
 ///////////////////////////////////////////////////////////////////////////
-// GetBlockSection: return leftmost/rightmost nodes in aChild's block
-//               
-nsresult
-nsHTMLEditor::GetBlockSection(nsIDOMNode *aChild,
-                              nsIDOMNode **aLeftNode, 
-                              nsIDOMNode **aRightNode) 
-{
-  nsresult result = NS_OK;
-  if (!aChild || !aLeftNode || !aRightNode) {return NS_ERROR_NULL_POINTER;}
-  *aLeftNode = aChild;
-  *aRightNode = aChild;
-
-  nsCOMPtr<nsIDOMNode>sibling;
-  result = aChild->GetPreviousSibling(getter_AddRefs(sibling));
-  while ((NS_SUCCEEDED(result)) && sibling)
-  {
-    bool isBlock;
-    NodeIsBlockStatic(sibling, &isBlock);
-    if (isBlock)
-    {
-      nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(sibling);
-      if (!nodeAsText) {
-        break;
-      }
-      // XXX: needs some logic to work for other leaf nodes besides text!
-    }
-    *aLeftNode = sibling;
-    result = (*aLeftNode)->GetPreviousSibling(getter_AddRefs(sibling)); 
-  }
-  NS_ADDREF((*aLeftNode));
-  // now do the right side
-  result = aChild->GetNextSibling(getter_AddRefs(sibling));
-  while ((NS_SUCCEEDED(result)) && sibling)
-  {
-    bool isBlock;
-    NodeIsBlockStatic(sibling, &isBlock);
-    if (isBlock) 
-    {
-      nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(sibling);
-      if (!nodeAsText) {
-        break;
-      }
-    }
-    *aRightNode = sibling;
-    result = (*aRightNode)->GetNextSibling(getter_AddRefs(sibling)); 
-  }
-  NS_ADDREF((*aRightNode));
-
-  return result;
-}
-
-
-///////////////////////////////////////////////////////////////////////////
-// GetBlockSectionsForRange: return list of block sections that intersect 
-//                           this range
-nsresult
-nsHTMLEditor::GetBlockSectionsForRange(nsIDOMRange *aRange,
-                                       nsCOMArray<nsIDOMRange>& aSections) 
-{
-  if (!aRange) {return NS_ERROR_NULL_POINTER;}
-
-  nsresult result;
-  nsCOMPtr<nsIContentIterator>iter =
-    do_CreateInstance("@mozilla.org/content/post-content-iterator;1", &result);
-  if (NS_FAILED(result) || !iter) {
-    return result;
-  }
-  nsCOMPtr<nsIDOMRange> lastRange;
-  iter->Init(aRange);
-  while (iter->IsDone())
-  {
-    nsCOMPtr<nsIContent> currentContent =
-      do_QueryInterface(iter->GetCurrentNode());
-
-    nsCOMPtr<nsIDOMNode> currentNode = do_QueryInterface(currentContent);
-    if (currentNode)
-    {
-      // <BR> divides block content ranges.  We can achieve this by nulling out lastRange
-      if (currentContent->Tag() == nsEditProperty::br)
-      {
-        lastRange = nsnull;
-      }
-      else
-      {
-        bool isNotInlineOrText;
-        result = NodeIsBlockStatic(currentNode, &isNotInlineOrText);
-        if (isNotInlineOrText)
-        {
-          PRUint16 nodeType;
-          currentNode->GetNodeType(&nodeType);
-          if (nsIDOMNode::TEXT_NODE == nodeType) {
-            isNotInlineOrText = true;
-          }
-        }
-        if (!isNotInlineOrText) {
-          nsCOMPtr<nsIDOMNode> leftNode;
-          nsCOMPtr<nsIDOMNode> rightNode;
-          result = GetBlockSection(currentNode,
-                                   getter_AddRefs(leftNode),
-                                   getter_AddRefs(rightNode));
-          if ((NS_SUCCEEDED(result)) && leftNode && rightNode) {
-            // Add range to the list if it doesn't overlap with the previous
-            // range.
-            bool addRange = true;
-            if (lastRange)
-            {
-              nsCOMPtr<nsIDOMNode> lastStartNode;
-              lastRange->GetStartContainer(getter_AddRefs(lastStartNode));
-              nsCOMPtr<nsIDOMNode> blockParentNodeOfLastStartNode =
-                GetBlockNodeParent(lastStartNode);
-              nsCOMPtr<nsIDOMElement> blockParentOfLastStartNode =
-                do_QueryInterface(blockParentNodeOfLastStartNode);
-              if (blockParentOfLastStartNode)
-              {
-                nsCOMPtr<nsIDOMNode> blockParentNodeOfLeftNode =
-                  GetBlockNodeParent(leftNode);
-                nsCOMPtr<nsIDOMElement> blockParentOfLeftNode =
-                  do_QueryInterface(blockParentNodeOfLeftNode);
-                if (blockParentOfLeftNode &&
-                    blockParentOfLastStartNode == blockParentOfLeftNode) {
-                  addRange = false;
-                }
-              }
-            }
-            if (addRange) {
-              nsCOMPtr<nsIDOMRange> range =
-                   do_CreateInstance("@mozilla.org/content/range;1", &result);
-              if ((NS_SUCCEEDED(result)) && range) {
-                // Initialize the range.
-                range->SetStart(leftNode, 0);
-                range->SetEnd(rightNode, 0);
-                aSections.AppendObject(range);
-                lastRange = do_QueryInterface(range);
-              }
-            }        
-          }
-        }
-      }
-    }
-    /* do not check result here, and especially do not return the result code.
-     * we rely on iter->IsDone to tell us when the iteration is complete
-     */
-    iter->Next();
-  }
-  return result;
-}
-
-
-///////////////////////////////////////////////////////////////////////////
 // NextNodeInBlock: gets the next/prev node in the block, if any.  Next node
 //                  must be an element or text node, others are ignored
 already_AddRefed<nsIDOMNode>
 nsHTMLEditor::NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir)
 {
   NS_ENSURE_TRUE(aNode, nsnull);
 
   nsresult rv;
--- a/editor/libeditor/html/nsHTMLEditor.h
+++ b/editor/libeditor/html/nsHTMLEditor.h
@@ -272,48 +272,16 @@ public:
   /* miscellaneous */
   // This sets background on the appropriate container element (table, cell,)
   //   or calls into nsTextEditor to set the page background
   NS_IMETHOD SetCSSBackgroundColor(const nsAString& aColor);
   NS_IMETHOD SetHTMLBackgroundColor(const nsAString& aColor);
 
   /* ------------ Block methods moved from nsEditor -------------- */
   static already_AddRefed<nsIDOMNode> GetBlockNodeParent(nsIDOMNode *aNode);
-  /** Determines the bounding nodes for the block section containing aNode.
-    * The calculation is based on some nodes intrinsically being block elements
-    * acording to HTML.  Style sheets are not considered in this calculation.
-    * <BR> tags separate block content sections.  So the HTML markup:
-    * <PRE>
-    *      <P>text1<BR>text2<B>text3</B></P>
-    * </PRE>
-    * contains two block content sections.  The first has the text node "text1"
-    * for both endpoints.  The second has "text2" as the left endpoint and
-    * "text3" as the right endpoint.
-    * Notice that offsets aren't required, only leaf nodes.  Offsets are implicit.
-    *
-    * @param aNode      the block content returned includes aNode
-    * @param aLeftNode  [OUT] the left endpoint of the block content containing aNode
-    * @param aRightNode [OUT] the right endpoint of the block content containing aNode
-    *
-    */
-  static nsresult GetBlockSection(nsIDOMNode  *aNode,
-                                  nsIDOMNode **aLeftNode, 
-                                  nsIDOMNode **aRightNode);
-
-  /** Compute the set of block sections in a given range.
-    * A block section is the set of (leftNode, rightNode) pairs given
-    * by GetBlockSection.  The set is computed by computing the 
-    * block section for every leaf node in the range and throwing 
-    * out duplicates.
-    *
-    * @param aRange     The range to compute block sections for.
-    * @param aSections  Allocated storage for the resulting set, stored as nsIDOMRanges.
-    */
-  static nsresult GetBlockSectionsForRange(nsIDOMRange      *aRange, 
-                                           nsCOMArray<nsIDOMRange>& aSections);
 
   static already_AddRefed<nsIDOMNode> NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir);
   nsresult IsNextCharWhitespace(nsIDOMNode *aParentNode, 
                                 PRInt32 aOffset, 
                                 bool *outIsSpace, 
                                 bool *outIsNBSP,
                                 nsCOMPtr<nsIDOMNode> *outNode = 0,
                                 PRInt32 *outOffset = 0);