bug 839051 - remove usage of nsISelectionPrivate::GetEnumerator() r=smaug

This commit is contained in:
Trevor Saunders 2013-02-07 09:17:47 -05:00
parent 2917a9b84a
commit 2b39e8cb3c
5 changed files with 98 additions and 249 deletions

View File

@ -34,12 +34,11 @@
#include "nsICharsetConverterManager.h"
#include "nsGkAtoms.h"
#include "nsIContent.h"
#include "nsIEnumerator.h"
#include "nsIParserService.h"
#include "nsIScriptContext.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptSecurityManager.h"
#include "nsISelection.h"
#include "mozilla/Selection.h"
#include "nsISelectionPrivate.h"
#include "nsITransferable.h" // for kUnicodeMime
#include "nsContentUtils.h"
@ -1348,19 +1347,17 @@ nsHTMLCopyEncoder::SetSelection(nsISelection* aSelection)
nsCOMPtr<nsIDOMRange> range;
nsCOMPtr<nsIDOMNode> commonParent;
int32_t count = 0;
nsresult rv = aSelection->GetRangeCount(&count);
NS_ENSURE_SUCCESS(rv, rv);
Selection* selection = static_cast<Selection*>(aSelection);
uint32_t rangeCount = selection->GetRangeCount();
// if selection is uninitialized return
if (!count)
if (!rangeCount)
return NS_ERROR_FAILURE;
// we'll just use the common parent of the first range. Implicit assumption
// here that multi-range selections are table cell selections, in which case
// the common parent is somewhere in the table and we don't really care where.
rv = aSelection->GetRangeAt(0, getter_AddRefs(range));
nsresult rv = aSelection->GetRangeAt(0, getter_AddRefs(range));
NS_ENSURE_SUCCESS(rv, rv);
if (!range)
return NS_ERROR_NULL_POINTER;
@ -1412,25 +1409,10 @@ nsHTMLCopyEncoder::SetSelection(nsISelection* aSelection)
//NS_ENSURE_SUCCESS(rv, rv);
NS_NewDomSelection(getter_AddRefs(mSelection));
NS_ENSURE_TRUE(mSelection, NS_ERROR_FAILURE);
nsCOMPtr<nsISelectionPrivate> privSelection( do_QueryInterface(aSelection) );
NS_ENSURE_TRUE(privSelection, NS_ERROR_FAILURE);
// get selection range enumerator
nsCOMPtr<nsIEnumerator> enumerator;
rv = privSelection->GetEnumerator(getter_AddRefs(enumerator));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(enumerator, NS_ERROR_FAILURE);
// loop thru the ranges in the selection
enumerator->First();
nsCOMPtr<nsISupports> currentItem;
while (static_cast<nsresult>(NS_ENUMERATOR_FALSE) == enumerator->IsDone())
{
rv = enumerator->CurrentItem(getter_AddRefs(currentItem));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(currentItem, NS_ERROR_FAILURE);
range = do_QueryInterface(currentItem);
for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) {
range = selection->GetRangeAt(rangeIdx);
NS_ENSURE_TRUE(range, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMRange> myRange;
range->CloneRange(getter_AddRefs(myRange));
@ -1442,8 +1424,6 @@ nsHTMLCopyEncoder::SetSelection(nsISelection* aSelection)
rv = mSelection->AddRange(myRange);
NS_ENSURE_SUCCESS(rv, rv);
enumerator->Next();
}
return NS_OK;

View File

@ -72,7 +72,6 @@
#include "nsIEditActionListener.h" // for nsIEditActionListener
#include "nsIEditorObserver.h" // for nsIEditorObserver
#include "nsIEditorSpellCheck.h" // for nsIEditorSpellCheck
#include "nsIEnumerator.h" // for nsIEnumerator, etc
#include "nsIFrame.h" // for nsIFrame
#include "nsIInlineSpellChecker.h" // for nsIInlineSpellChecker, etc
#include "nsIMEStateManager.h" // for nsIMEStateManager
@ -3892,21 +3891,13 @@ nsEditor::GetStartNodeAndOffset(nsISelection *aSelection,
*outStartNode = nullptr;
*outStartOffset = 0;
nsCOMPtr<nsISelectionPrivate>selPrivate(do_QueryInterface(aSelection));
nsCOMPtr<nsIEnumerator> enumerator;
nsresult result = selPrivate->GetEnumerator(getter_AddRefs(enumerator));
NS_ENSURE_SUCCESS(result, result);
NS_ENSURE_TRUE(enumerator, NS_ERROR_FAILURE);
Selection* selection = static_cast<Selection*>(aSelection);
NS_ENSURE_TRUE(selection->GetRangeCount(), NS_ERROR_FAILURE);
enumerator->First();
nsCOMPtr<nsISupports> currentItem;
result = enumerator->CurrentItem(getter_AddRefs(currentItem));
NS_ENSURE_SUCCESS(result, result);
nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
nsRange* range = selection->GetRangeAt(0);
NS_ENSURE_TRUE(range, NS_ERROR_FAILURE);
result = range->GetStartContainer(outStartNode);
nsresult result = range->GetStartContainer(outStartNode);
NS_ENSURE_SUCCESS(result, result);
result = range->GetStartOffset(outStartOffset);
@ -3928,18 +3919,11 @@ nsEditor::GetEndNodeAndOffset(nsISelection *aSelection,
*outEndNode = nullptr;
nsCOMPtr<nsISelectionPrivate>selPrivate(do_QueryInterface(aSelection));
nsCOMPtr<nsIEnumerator> enumerator;
nsresult result = selPrivate->GetEnumerator(getter_AddRefs(enumerator));
if (NS_FAILED(result) || !enumerator)
return NS_ERROR_FAILURE;
enumerator->First();
nsCOMPtr<nsISupports> currentItem;
if (NS_FAILED(enumerator->CurrentItem(getter_AddRefs(currentItem))))
return NS_ERROR_FAILURE;
Selection* selection = static_cast<Selection*>(aSelection);
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(selection->GetRangeCount(), NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
nsRange* range = selection->GetRangeAt(0);
NS_ENSURE_TRUE(range, NS_ERROR_FAILURE);
if (NS_FAILED(range->GetEndContainer(outEndNode)))

View File

@ -38,7 +38,6 @@
#include "nsIDOMNode.h"
#include "nsIDOMRange.h"
#include "nsIDOMText.h"
#include "nsIEnumerator.h"
#include "nsIHTMLAbsPosEditor.h"
#include "nsIHTMLDocument.h"
#include "nsINode.h"
@ -2306,22 +2305,13 @@ nsHTMLEditRules::WillDeleteSelection(Selection* aSelection,
// else blocks not same type, or not siblings. Delete everything except
// table elements.
nsCOMPtr<nsIEnumerator> enumerator;
res = aSelection->GetEnumerator(getter_AddRefs(enumerator));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(enumerator, NS_ERROR_UNEXPECTED);
join = true;
for (enumerator->First(); NS_OK!=enumerator->IsDone(); enumerator->Next())
{
nsCOMPtr<nsISupports> currentItem;
res = enumerator->CurrentItem(getter_AddRefs(currentItem));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(currentItem, NS_ERROR_UNEXPECTED);
uint32_t rangeCount = aSelection->GetRangeCount();
for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) {
nsRefPtr<nsRange> range = aSelection->GetRangeAt(rangeIdx);
// build a list of nodes in the range
nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
nsCOMArray<nsIDOMNode> arrayOfNodes;
nsTrivialFunctor functor;
nsDOMSubtreeIterator iter;
@ -5776,25 +5766,15 @@ nsHTMLEditRules::GetListActionNodes(nsCOMArray<nsIDOMNode> &outArrayOfNodes,
nsCOMPtr<nsISelection>selection;
res = mHTMLEditor->GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(res, res);
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
NS_ENSURE_TRUE(selPriv, NS_ERROR_FAILURE);
Selection* sel = static_cast<Selection*>(selection.get());
NS_ENSURE_TRUE(sel, NS_ERROR_FAILURE);
// added this in so that ui code can ask to change an entire list, even if selection
// is only in part of it. used by list item dialog.
if (aEntireList)
{
nsCOMPtr<nsIEnumerator> enumerator;
res = selPriv->GetEnumerator(getter_AddRefs(enumerator));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(enumerator, NS_ERROR_UNEXPECTED);
for (enumerator->First(); NS_OK!=enumerator->IsDone(); enumerator->Next())
{
nsCOMPtr<nsISupports> currentItem;
res = enumerator->CurrentItem(getter_AddRefs(currentItem));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(currentItem, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
uint32_t rangeCount = sel->GetRangeCount();
for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) {
nsRefPtr<nsRange> range = sel->GetRangeAt(rangeIdx);
nsCOMPtr<nsIDOMNode> commonParent, parent, tmp;
range->GetCommonAncestorContainer(getter_AddRefs(commonParent));
if (commonParent)
@ -7797,21 +7777,11 @@ nsHTMLEditRules::SelectionEndpointInNode(nsINode* aNode, bool* aResult)
nsCOMPtr<nsISelection>selection;
nsresult res = mHTMLEditor->GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(res, res);
nsCOMPtr<nsISelectionPrivate>selPriv(do_QueryInterface(selection));
nsCOMPtr<nsIEnumerator> enumerator;
res = selPriv->GetEnumerator(getter_AddRefs(enumerator));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(enumerator, NS_ERROR_UNEXPECTED);
for (enumerator->First(); NS_OK!=enumerator->IsDone(); enumerator->Next())
{
nsCOMPtr<nsISupports> currentItem;
res = enumerator->CurrentItem(getter_AddRefs(currentItem));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(currentItem, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
Selection* sel = static_cast<Selection*>(selection.get());
uint32_t rangeCount = sel->GetRangeCount();
for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) {
nsRefPtr<nsRange> range = sel->GetRangeAt(rangeIdx);
nsCOMPtr<nsIDOMNode> startParent, endParent;
range->GetStartContainer(getter_AddRefs(startParent));
if (startParent)

View File

@ -37,7 +37,6 @@
#include "nsCSSStyleSheet.h"
#include "nsIDOMStyleSheet.h"
#include "nsIEnumerator.h"
#include "nsIContent.h"
#include "nsIContentIterator.h"
#include "nsIDOMRange.h"
@ -2388,7 +2387,7 @@ nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aRet
nsresult res = GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
Selection* sel = static_cast<Selection*>(selection.get());
bool bNodeFound = false;
bool isCollapsed = selection->Collapsed();
@ -2453,7 +2452,7 @@ nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aRet
int32_t anchorOffset = -1;
if (anchorNode)
selection->GetAnchorOffset(&anchorOffset);
nsCOMPtr<nsIDOMNode> focusNode;
res = selection->GetFocusNode(getter_AddRefs(focusNode));
NS_ENSURE_SUCCESS(res, res);
@ -2464,19 +2463,6 @@ nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aRet
// Link node must be the same for both ends of selection
if (NS_SUCCEEDED(res) && anchorNode)
{
#ifdef DEBUG_cmanske
{
nsAutoString name;
anchorNode->GetNodeName(name);
printf("GetSelectedElement: Anchor node of selection: ");
wprintf(name.get());
printf(" Offset: %d\n", anchorOffset);
focusNode->GetNodeName(name);
printf("Focus node of selection: ");
wprintf(name.get());
printf(" Offset: %d\n", focusOffset);
}
#endif
nsCOMPtr<nsIDOMElement> parentLinkOfAnchor;
res = GetElementOrParentByTagName(NS_LITERAL_STRING("href"), anchorNode, getter_AddRefs(parentLinkOfAnchor));
// XXX: ERROR_HANDLING can parentLinkOfAnchor be null?
@ -2493,7 +2479,7 @@ nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aRet
if (NS_SUCCEEDED(res) && parentLinkOfFocus == parentLinkOfAnchor)
bNodeFound = true;
}
// We found a link node parent
if (bNodeFound) {
// GetElementOrParentByTagName addref'd this, so we don't need to do it here
@ -2518,77 +2504,63 @@ nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aRet
if (!isCollapsed) // Don't bother to examine selection if it is collapsed
{
nsCOMPtr<nsIEnumerator> enumerator;
res = selPriv->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(res))
{
if(!enumerator)
return NS_ERROR_NULL_POINTER;
nsRefPtr<nsRange> currange = sel->GetRangeAt(0);
if (currange) {
nsCOMPtr<nsIContentIterator> iter =
do_CreateInstance("@mozilla.org/content/post-content-iterator;1", &res);
NS_ENSURE_SUCCESS(res, res);
enumerator->First();
nsCOMPtr<nsISupports> currentItem;
res = enumerator->CurrentItem(getter_AddRefs(currentItem));
if ((NS_SUCCEEDED(res)) && currentItem)
iter->Init(currange);
// loop through the content iterator for each content node
while (!iter->IsDone())
{
nsCOMPtr<nsIDOMRange> currange( do_QueryInterface(currentItem) );
nsCOMPtr<nsIContentIterator> iter =
do_CreateInstance("@mozilla.org/content/post-content-iterator;1", &res);
NS_ENSURE_SUCCESS(res, res);
iter->Init(currange);
// loop through the content iterator for each content node
while (!iter->IsDone())
// Query interface to cast nsIContent to nsIDOMNode
// then get tagType to compare to aTagName
// Clone node of each desired type and append it to the aDomFrag
selectedElement = do_QueryInterface(iter->GetCurrentNode());
if (selectedElement)
{
// Query interface to cast nsIContent to nsIDOMNode
// then get tagType to compare to aTagName
// Clone node of each desired type and append it to the aDomFrag
selectedElement = do_QueryInterface(iter->GetCurrentNode());
if (selectedElement)
// If we already found a node, then we have another element,
// thus there's not just one element selected
if (bNodeFound)
{
// If we already found a node, then we have another element,
// thus there's not just one element selected
if (bNodeFound)
{
bNodeFound = false;
break;
}
selectedElement->GetNodeName(domTagName);
ToLowerCase(domTagName);
if (anyTag)
{
// Get name of first selected element
selectedElement->GetTagName(TagName);
ToLowerCase(TagName);
anyTag = false;
}
// The "A" tag is a pain,
// used for both link(href is set) and "Named Anchor"
nsCOMPtr<nsIDOMNode> selectedNode = do_QueryInterface(selectedElement);
if ( (isLinkTag && nsHTMLEditUtils::IsLink(selectedNode)) ||
(isNamedAnchorTag && nsHTMLEditUtils::IsNamedAnchor(selectedNode)) )
{
bNodeFound = true;
} else if (TagName == domTagName) { // All other tag names are handled here
bNodeFound = true;
}
if (!bNodeFound)
{
// Check if node we have is really part of the selection???
break;
}
bNodeFound = false;
break;
}
selectedElement->GetNodeName(domTagName);
ToLowerCase(domTagName);
if (anyTag)
{
// Get name of first selected element
selectedElement->GetTagName(TagName);
ToLowerCase(TagName);
anyTag = false;
}
// The "A" tag is a pain,
// used for both link(href is set) and "Named Anchor"
nsCOMPtr<nsIDOMNode> selectedNode = do_QueryInterface(selectedElement);
if ( (isLinkTag && nsHTMLEditUtils::IsLink(selectedNode)) ||
(isNamedAnchorTag && nsHTMLEditUtils::IsNamedAnchor(selectedNode)) )
{
bNodeFound = true;
} else if (TagName == domTagName) { // All other tag names are handled here
bNodeFound = true;
}
if (!bNodeFound)
{
// Check if node we have is really part of the selection???
break;
}
iter->Next();
}
} else {
// Should never get here?
isCollapsed = true;
printf("isCollapsed was FALSE, but no elements found in selection\n");
iter->Next();
}
} else {
printf("Could not create enumerator for GetSelectionProperties\n");
// Should never get here?
isCollapsed = true;
NS_WARNING("isCollapsed was FALSE, but no elements found in selection\n");
}
}
}
@ -4678,23 +4650,13 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
NS_ENSURE_SUCCESS(res, res);
if (!cancel && !handled)
{
// get selection range enumerator
nsCOMPtr<nsIEnumerator> enumerator;
res = selection->GetEnumerator(getter_AddRefs(enumerator));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(enumerator, NS_ERROR_FAILURE);
// loop thru the ranges in the selection
enumerator->First();
nsCOMPtr<nsISupports> currentItem;
nsAutoString bgcolor; bgcolor.AssignLiteral("bgcolor");
nsCOMPtr<nsIDOMNode> cachedBlockParent = nullptr;
while (static_cast<nsresult>(NS_ENUMERATOR_FALSE) == enumerator->IsDone()) {
res = enumerator->CurrentItem(getter_AddRefs(currentItem));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(currentItem, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
uint32_t rangeCount = selection->GetRangeCount();
for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) {
nsCOMPtr<nsIDOMNode> cachedBlockParent = nullptr;
nsRefPtr<nsRange> range = selection->GetRangeAt(rangeIdx);
NS_ENSURE_TRUE(range, NS_ERROR_FAILURE);
// check for easy case: both range endpoints in same text node
nsCOMPtr<nsIDOMNode> startNode, endNode;
@ -4854,7 +4816,6 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
}
}
}
enumerator->Next();
}
}
if (!cancel)

View File

@ -33,7 +33,6 @@
#include "nsIDOMRange.h"
#include "nsIEditor.h"
#include "nsIEditorIMESupport.h"
#include "nsIEnumerator.h"
#include "nsINameSpaceManager.h"
#include "nsINode.h"
#include "nsISelection.h"
@ -144,22 +143,10 @@ nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
NS_ENSURE_SUCCESS(res, res);
if (!cancel && !handled) {
// get selection range enumerator
nsCOMPtr<nsIEnumerator> enumerator;
res = selection->GetEnumerator(getter_AddRefs(enumerator));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(enumerator, NS_ERROR_FAILURE);
// loop thru the ranges in the selection
nsCOMPtr<nsISupports> currentItem;
for (enumerator->First();
static_cast<nsresult>(NS_ENUMERATOR_FALSE) == enumerator->IsDone();
enumerator->Next()) {
res = enumerator->CurrentItem(getter_AddRefs(currentItem));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(currentItem, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMRange> range(do_QueryInterface(currentItem));
uint32_t rangeCount = selection->GetRangeCount();
for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) {
nsRefPtr<nsRange> range = selection->GetRangeAt(rangeIdx);
// adjust range to include any ancestors whose children are entirely
// selected
@ -1115,23 +1102,15 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty,
result = GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(result, result);
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
Selection* sel = static_cast<Selection*>(selection.get());
bool isCollapsed = selection->Collapsed();
nsCOMPtr<nsIDOMNode> collapsedNode;
nsCOMPtr<nsIEnumerator> enumerator;
result = selPriv->GetEnumerator(getter_AddRefs(enumerator));
NS_ENSURE_SUCCESS(result, result);
NS_ENSURE_TRUE(enumerator, NS_ERROR_NULL_POINTER);
enumerator->First();
nsCOMPtr<nsISupports> currentItem;
result = enumerator->CurrentItem(getter_AddRefs(currentItem));
nsRefPtr<nsRange> range = sel->GetRangeAt(0);
// XXX: should be a while loop, to get each separate range
// XXX: ERROR_HANDLING can currentItem be null?
if (NS_SUCCEEDED(result) && currentItem) {
if (range) {
bool firstNodeInRange = true; // for each range, set a flag
nsCOMPtr<nsIDOMRange> range(do_QueryInterface(currentItem));
if (isCollapsed) {
range->GetStartContainer(getter_AddRefs(collapsedNode));
@ -1379,22 +1358,10 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAStr
NS_ENSURE_SUCCESS(res, res);
if (!cancel && !handled)
{
// get selection range enumerator
nsCOMPtr<nsIEnumerator> enumerator;
res = selection->GetEnumerator(getter_AddRefs(enumerator));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(enumerator, NS_ERROR_FAILURE);
// loop thru the ranges in the selection
enumerator->First();
nsCOMPtr<nsISupports> currentItem;
while (static_cast<nsresult>(NS_ENUMERATOR_FALSE) == enumerator->IsDone()) {
res = enumerator->CurrentItem(getter_AddRefs(currentItem));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(currentItem, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
uint32_t rangeCount = selection->GetRangeCount();
for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) {
nsRefPtr<nsRange> range = selection->GetRangeAt(rangeIdx);
if (aProperty == nsEditProperty::name)
{
// promote range if it starts or end in a named anchor and we
@ -1500,7 +1467,6 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAStr
}
arrayOfNodes.Clear();
}
enumerator->Next();
}
}
if (!cancel)
@ -1566,24 +1532,13 @@ nsHTMLEditor::RelativeFontChange( int32_t aSizeChange)
nsAutoSelectionReset selectionResetter(selection, this);
nsAutoTxnsConserveSelection dontSpazMySelection(this);
// get selection range enumerator
nsCOMPtr<nsIEnumerator> enumerator;
nsresult res = selection->GetEnumerator(getter_AddRefs(enumerator));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(enumerator, NS_ERROR_FAILURE);
// loop thru the ranges in the selection
enumerator->First();
nsCOMPtr<nsISupports> currentItem;
while (static_cast<nsresult>(NS_ENUMERATOR_FALSE) == enumerator->IsDone()) {
res = enumerator->CurrentItem(getter_AddRefs(currentItem));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(currentItem, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
uint32_t rangeCount = selection->GetRangeCount();
for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) {
nsRefPtr<nsRange> range = selection->GetRangeAt(rangeIdx);
// adjust range to include any ancestors who's children are entirely selected
res = PromoteInlineRange(range);
nsresult res = PromoteInlineRange(range);
NS_ENSURE_SUCCESS(res, res);
// check for easy case: both range endpoints in same text node
@ -1665,10 +1620,9 @@ nsHTMLEditor::RelativeFontChange( int32_t aSizeChange)
NS_ENSURE_SUCCESS(res, res);
}
}
enumerator->Next();
}
return res;
return NS_OK;
}
nsresult