mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
bug 841706 - remove nsSelectionIterator r=smaug
This commit is contained in:
parent
bd2576a706
commit
7722fdab93
@ -5,7 +5,6 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISelectionListener.idl"
|
||||
#include "nsIEnumerator.idl"
|
||||
#include "nsISelection.idl"
|
||||
|
||||
interface nsRange;
|
||||
@ -31,7 +30,7 @@ struct ScrollAxis;
|
||||
native nsDirection(nsDirection);
|
||||
native ScrollAxis(nsIPresShell::ScrollAxis);
|
||||
|
||||
[scriptable, builtinclass, uuid(2e44b10f-7d6d-4bf4-92e2-f9551d22f422)]
|
||||
[scriptable, builtinclass, uuid(a6d2cedd-afbc-4d25-bffb-e725b9881e30)]
|
||||
interface nsISelectionPrivate : nsISelection
|
||||
{
|
||||
const short ENDOFPRECEDINGLINE=0;
|
||||
@ -49,7 +48,6 @@ interface nsISelectionPrivate : nsISelection
|
||||
*/
|
||||
void endBatchChanges();
|
||||
|
||||
nsIEnumerator getEnumerator();
|
||||
DOMString toStringWithFormat(in string formatType, in unsigned long flags, in int32_t wrapColumn);
|
||||
void addSelectionListener(in nsISelectionListener newListener);
|
||||
void removeSelectionListener(in nsISelectionListener listenerToRemove);
|
||||
|
@ -4566,9 +4566,9 @@ nsEditor::CreateTxnForDeleteSelection(EDirection aAction,
|
||||
// allocate the out-param transaction
|
||||
nsRefPtr<EditAggregateTxn> aggTxn = new EditAggregateTxn();
|
||||
|
||||
nsSelectionIterator iter(selection);
|
||||
for (iter.First(); iter.IsDone() != NS_OK; iter.Next()) {
|
||||
nsRefPtr<nsRange> range = iter.CurrentItem();
|
||||
uint32_t rangeCount = selection->GetRangeCount();
|
||||
for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) {
|
||||
nsRefPtr<nsRange> range = selection->GetRangeAt(rangeIdx);
|
||||
NS_ENSURE_STATE(range);
|
||||
|
||||
// Same with range as with selection; if it is collapsed and action
|
||||
|
@ -19,7 +19,6 @@ class nsAutoScrollTimer;
|
||||
class nsIContentIterator;
|
||||
class nsIFrame;
|
||||
struct SelectionDetails;
|
||||
class nsSelectionIterator;
|
||||
|
||||
struct RangeData
|
||||
{
|
||||
@ -142,7 +141,6 @@ public:
|
||||
nsresult NotifySelectionListeners();
|
||||
|
||||
private:
|
||||
friend class ::nsSelectionIterator;
|
||||
|
||||
class ScrollSelectionIntoViewEvent;
|
||||
friend class ScrollSelectionIntoViewEvent;
|
||||
@ -222,30 +220,4 @@ private:
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
class nsSelectionIterator : public nsIBidirectionalEnumerator
|
||||
{
|
||||
public:
|
||||
/*BEGIN nsIEnumerator interfaces
|
||||
see the nsIEnumerator for more details*/
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIENUMERATOR
|
||||
|
||||
NS_DECL_NSIBIDIRECTIONALENUMERATOR
|
||||
|
||||
/*END nsIEnumerator interfaces*/
|
||||
/*BEGIN Helper Methods*/
|
||||
nsRange* CurrentItem();
|
||||
/*END Helper Methods*/
|
||||
|
||||
nsSelectionIterator(mozilla::Selection*);
|
||||
virtual ~nsSelectionIterator();
|
||||
|
||||
private:
|
||||
int32_t mIndex;
|
||||
mozilla::Selection* mDomSelection;
|
||||
};
|
||||
|
||||
|
||||
#endif // mozilla_Selection_h__
|
||||
|
@ -327,123 +327,6 @@ IsValidSelectionPoint(nsFrameSelection *aFrameSel, nsINode *aNode)
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsSelectionIterator)
|
||||
NS_IMPL_RELEASE(nsSelectionIterator)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSelectionIterator)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIEnumerator)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIBidirectionalEnumerator)
|
||||
NS_INTERFACE_MAP_END_AGGREGATED(mDomSelection)
|
||||
|
||||
|
||||
///////////BEGIN nsSelectionIterator methods
|
||||
|
||||
nsSelectionIterator::nsSelectionIterator(Selection* aList)
|
||||
:mIndex(0)
|
||||
{
|
||||
if (!aList)
|
||||
{
|
||||
NS_NOTREACHED("nsFrameSelection");
|
||||
return;
|
||||
}
|
||||
mDomSelection = aList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsSelectionIterator::~nsSelectionIterator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////END nsSelectionIterator methods
|
||||
|
||||
////////////BEGIN nsSelectionIterator methods
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSelectionIterator::Next()
|
||||
{
|
||||
mIndex++;
|
||||
int32_t cnt = mDomSelection->mRanges.Length();
|
||||
if (mIndex < cnt)
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSelectionIterator::Prev()
|
||||
{
|
||||
mIndex--;
|
||||
if (mIndex >= 0 )
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSelectionIterator::First()
|
||||
{
|
||||
if (!mDomSelection)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
mIndex = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSelectionIterator::Last()
|
||||
{
|
||||
if (!mDomSelection)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
mIndex = mDomSelection->mRanges.Length() - 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSelectionIterator::CurrentItem(nsISupports **aItem)
|
||||
{
|
||||
*aItem = static_cast<nsIDOMRange*>(CurrentItem());
|
||||
if (!*aItem) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_ADDREF(*aItem);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRange*
|
||||
nsSelectionIterator::CurrentItem()
|
||||
{
|
||||
return mDomSelection->mRanges.SafeElementAt(mIndex, sEmptyData).mRange;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSelectionIterator::IsDone()
|
||||
{
|
||||
int32_t cnt = mDomSelection->mRanges.Length();
|
||||
if (mIndex >= 0 && mIndex < cnt) {
|
||||
// XXX This is completely incompatible with the meaning of nsresult.
|
||||
// NS_ENUMERATOR_FALSE is defined to be 1. (bug 778111)
|
||||
return (nsresult)NS_ENUMERATOR_FALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////END nsSelectionIterator methods
|
||||
|
||||
|
||||
////////////BEGIN nsFrameSelection methods
|
||||
|
||||
nsFrameSelection::nsFrameSelection()
|
||||
@ -3047,18 +2930,12 @@ nsFrameSelection::DeleteFromDocument()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get an iterator
|
||||
nsSelectionIterator iter(mDomSelections[index]);
|
||||
res = iter.First();
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
|
||||
while (iter.IsDone() == static_cast<nsresult>(NS_ENUMERATOR_FALSE)) {
|
||||
nsRefPtr<nsRange> range = iter.CurrentItem();
|
||||
uint32_t rangeCount = mDomSelections[index]->GetRangeCount();
|
||||
for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) {
|
||||
nsRefPtr<nsRange> range = mDomSelections[index]->GetRangeAt(rangeIdx);
|
||||
res = range->DeleteContents();
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
iter.Next();
|
||||
}
|
||||
|
||||
// Collapse to the new location.
|
||||
@ -4354,14 +4231,6 @@ Selection::DoAutoScroll(nsIFrame* aFrame, nsPoint& aPoint)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Selection::GetEnumerator(nsIEnumerator** aIterator)
|
||||
{
|
||||
NS_ADDREF(*aIterator = new nsSelectionIterator(this));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** RemoveAllRanges zeroes the selection
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user