Bug 705439 - Remove dead code: nsHTMLEditor::GetBlockSection / nsHTMLEditor::GetBlockSectionsForRange; r=ehsan

This commit is contained in:
Ms2ger 2011-12-03 22:50:17 +01:00
Родитель b7e3766328
Коммит 60226fe6de
2 изменённых файлов: 0 добавлений и 181 удалений

Просмотреть файл

@ -969,155 +969,6 @@ nsHTMLEditor::GetBlockNodeParent(nsIDOMNode *aNode)
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

Просмотреть файл

@ -277,38 +277,6 @@ public:
/* ------------ 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,