зеркало из https://github.com/mozilla/pjs.git
changes to remove selection
This commit is contained in:
Родитель
e56553b995
Коммит
8242e39f7f
|
@ -50,16 +50,13 @@
|
|||
#include "nsITextContent.h"
|
||||
#include "nsXIFConverter.h"
|
||||
|
||||
#include "nsSelection.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsDocumentFragment.h"
|
||||
|
||||
#if XP_NEW_SELECTION
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsICollection.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#endif //XP_NEW_SELECTION
|
||||
|
||||
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
|
@ -77,14 +74,11 @@ static NS_DEFINE_IID(kIDOMStyleSheetCollectionIID, NS_IDOMSTYLESHEETCOLLECTION_I
|
|||
static NS_DEFINE_IID(kIDOMStyleSheetIID, NS_IDOMSTYLESHEET_IID);
|
||||
static NS_DEFINE_IID(kIDocumentObserverIID, NS_IDOCUMENT_OBSERVER_IID);
|
||||
static NS_DEFINE_IID(kICSSStyleSheetIID, NS_ICSS_STYLE_SHEET_IID);
|
||||
|
||||
#if XP_NEW_SELECTION
|
||||
static NS_DEFINE_IID(kCRangeCID, NS_RANGE_CID);
|
||||
static NS_DEFINE_IID(kIDOMRange, NS_IDOMRANGE_IID);
|
||||
static NS_DEFINE_IID(kCRangeListCID, NS_RANGELIST_CID);
|
||||
static NS_DEFINE_IID(kICollectionIID, NS_ICOLLECTION_IID);
|
||||
static NS_DEFINE_IID(kIEnumeratorIID, NS_IENUMERATOR_IID);
|
||||
#endif //XP_NEW_SELECION
|
||||
|
||||
class nsDOMStyleSheetCollection : public nsIDOMStyleSheetCollection,
|
||||
public nsIScriptObjectOwner,
|
||||
|
@ -415,11 +409,7 @@ nsDocument::nsDocument()
|
|||
mListenerManager = nsnull;
|
||||
mDisplaySelection = PR_FALSE;
|
||||
mInDestructor = PR_FALSE;
|
||||
#if XP_NEW_SELECTION
|
||||
if (!NS_SUCCEEDED(nsRepository::CreateInstance(kCRangeListCID, nsnull, kICollectionIID, (void **)&mSelection))){
|
||||
#else
|
||||
if (NS_OK != NS_NewSelection(&mSelection)) {
|
||||
#endif
|
||||
printf("*************** Error: nsDocument::nsDocument - Creation of Selection failed!\n");
|
||||
}
|
||||
mDOMStyleSheets = nsnull;
|
||||
|
@ -1532,7 +1522,6 @@ void nsDocument::Finalize(JSContext *aContext)
|
|||
/**
|
||||
* Returns the Selection Object
|
||||
*/
|
||||
#if XP_NEW_SELECTION
|
||||
NS_IMETHODIMP nsDocument::GetSelection(nsICollection ** aSelection) {
|
||||
if (!aSelection)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
@ -1545,18 +1534,6 @@ NS_IMETHODIMP nsDocument::GetSelection(nsICollection ** aSelection) {
|
|||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#else
|
||||
NS_IMETHODIMP nsDocument::GetSelection(nsISelection *& aSelection) {
|
||||
if (mSelection != nsnull) {
|
||||
NS_ADDREF(mSelection);
|
||||
aSelection = mSelection;
|
||||
return NS_OK;
|
||||
} else {
|
||||
aSelection = nsnull;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#endif //XP_NEW_SELECTION
|
||||
|
||||
/**
|
||||
* Selects all the Content
|
||||
|
@ -1617,7 +1594,6 @@ NS_IMETHODIMP nsDocument::SelectAll() {
|
|||
|
||||
//NS_RELEASE(start);
|
||||
//NS_RELEASE(end);
|
||||
#if XP_NEW_SELECTION
|
||||
mSelection->Clear();//clear all old selection
|
||||
nsIDOMRange *range = nsnull;
|
||||
if (NS_SUCCEEDED(nsRepository::CreateInstance(kCRangeCID, nsnull, kIDOMRange, (void **)&range))){ //create an irange
|
||||
|
@ -1642,13 +1618,6 @@ NS_IMETHODIMP nsDocument::SelectAll() {
|
|||
}
|
||||
NS_IF_RELEASE(range);//allready referenced in the selection now.
|
||||
}
|
||||
#else
|
||||
nsSelectionRange * range = mSelection->GetRange();
|
||||
nsSelectionPoint * startPnt = range->GetStartPoint();
|
||||
nsSelectionPoint * endPnt = range->GetEndPoint();
|
||||
startPnt->SetPoint(start, -1, PR_TRUE);
|
||||
endPnt->SetPoint(end, -1, PR_FALSE);
|
||||
#endif
|
||||
SetDisplaySelection(PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1832,7 +1801,6 @@ PRBool nsDocument::IsInSelection(const nsIContent* aContent) const
|
|||
{
|
||||
PRBool result = PR_FALSE;
|
||||
|
||||
#if XP_NEW_SELECTION
|
||||
//travers through an iterator to see if the acontent is in the ranges
|
||||
if (mSelection != nsnull)
|
||||
{
|
||||
|
@ -1845,23 +1813,6 @@ PRBool nsDocument::IsInSelection(const nsIContent* aContent) const
|
|||
NS_IF_RELEASE(enumerator);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (mSelection != nsnull)
|
||||
{
|
||||
nsSelectionRange* range = mSelection->GetRange();
|
||||
if (range != nsnull)
|
||||
{
|
||||
nsSelectionPoint* startPoint = range->GetStartPoint();
|
||||
nsSelectionPoint* endPoint = range->GetEndPoint();
|
||||
|
||||
nsIContent* startContent = startPoint->GetContent();
|
||||
nsIContent* endContent = endPoint->GetContent();
|
||||
result = IsInRange(startContent, endContent, aContent);
|
||||
NS_IF_RELEASE(startContent);
|
||||
NS_IF_RELEASE(endContent);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
|
||||
}
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
#if XP_NEW_SELECTION
|
||||
class nsICollection;
|
||||
#else
|
||||
class nsISelection;
|
||||
#endif
|
||||
class nsIEventListenerManager;
|
||||
class nsDOMStyleSheetCollection;
|
||||
|
||||
|
@ -190,11 +186,7 @@ public:
|
|||
/**
|
||||
* Returns the Selection Object
|
||||
*/
|
||||
#if XP_NEW_SELECTION
|
||||
NS_IMETHOD GetSelection(nsICollection ** aSelection);
|
||||
#else
|
||||
NS_IMETHOD GetSelection(nsISelection *& aSelection);
|
||||
#endif
|
||||
/**
|
||||
* Selects all the Content
|
||||
*/
|
||||
|
@ -305,11 +297,7 @@ protected:
|
|||
virtual ~nsDocument();
|
||||
nsresult Init();
|
||||
|
||||
#if XP_NEW_SELECTION
|
||||
nsICollection * mSelection;
|
||||
#else
|
||||
nsISelection * mSelection;
|
||||
#endif
|
||||
nsIArena* mArena;
|
||||
nsString* mDocumentTitle;
|
||||
nsIURL* mDocumentURL;
|
||||
|
|
|
@ -33,9 +33,6 @@ CPPSRCS = \
|
|||
nsPresContext.cpp \
|
||||
nsPrintContext.cpp \
|
||||
nsPrintPreviewContext.cpp \
|
||||
nsSelection.cpp \
|
||||
nsSelectionPoint.cpp \
|
||||
nsSelectionRange.cpp \
|
||||
nsSpaceManager.cpp \
|
||||
nsStyleContext.cpp \
|
||||
nsStyleCoord.cpp \
|
||||
|
@ -61,9 +58,6 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\nsPresContext.obj \
|
||||
.\$(OBJDIR)\nsPrintContext.obj \
|
||||
.\$(OBJDIR)\nsPrintPreviewContext.obj \
|
||||
.\$(OBJDIR)\nsSelection.obj \
|
||||
.\$(OBJDIR)\nsSelectionPoint.obj \
|
||||
.\$(OBJDIR)\nsSelectionRange.obj \
|
||||
.\$(OBJDIR)\nsSpaceManager.obj \
|
||||
.\$(OBJDIR)\nsStyleContext.obj \
|
||||
.\$(OBJDIR)\nsStyleCoord.obj \
|
||||
|
|
|
@ -50,16 +50,13 @@
|
|||
#include "nsITextContent.h"
|
||||
#include "nsXIFConverter.h"
|
||||
|
||||
#include "nsSelection.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsDocumentFragment.h"
|
||||
|
||||
#if XP_NEW_SELECTION
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsICollection.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#endif //XP_NEW_SELECTION
|
||||
|
||||
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
|
@ -77,14 +74,11 @@ static NS_DEFINE_IID(kIDOMStyleSheetCollectionIID, NS_IDOMSTYLESHEETCOLLECTION_I
|
|||
static NS_DEFINE_IID(kIDOMStyleSheetIID, NS_IDOMSTYLESHEET_IID);
|
||||
static NS_DEFINE_IID(kIDocumentObserverIID, NS_IDOCUMENT_OBSERVER_IID);
|
||||
static NS_DEFINE_IID(kICSSStyleSheetIID, NS_ICSS_STYLE_SHEET_IID);
|
||||
|
||||
#if XP_NEW_SELECTION
|
||||
static NS_DEFINE_IID(kCRangeCID, NS_RANGE_CID);
|
||||
static NS_DEFINE_IID(kIDOMRange, NS_IDOMRANGE_IID);
|
||||
static NS_DEFINE_IID(kCRangeListCID, NS_RANGELIST_CID);
|
||||
static NS_DEFINE_IID(kICollectionIID, NS_ICOLLECTION_IID);
|
||||
static NS_DEFINE_IID(kIEnumeratorIID, NS_IENUMERATOR_IID);
|
||||
#endif //XP_NEW_SELECION
|
||||
|
||||
class nsDOMStyleSheetCollection : public nsIDOMStyleSheetCollection,
|
||||
public nsIScriptObjectOwner,
|
||||
|
@ -415,11 +409,7 @@ nsDocument::nsDocument()
|
|||
mListenerManager = nsnull;
|
||||
mDisplaySelection = PR_FALSE;
|
||||
mInDestructor = PR_FALSE;
|
||||
#if XP_NEW_SELECTION
|
||||
if (!NS_SUCCEEDED(nsRepository::CreateInstance(kCRangeListCID, nsnull, kICollectionIID, (void **)&mSelection))){
|
||||
#else
|
||||
if (NS_OK != NS_NewSelection(&mSelection)) {
|
||||
#endif
|
||||
printf("*************** Error: nsDocument::nsDocument - Creation of Selection failed!\n");
|
||||
}
|
||||
mDOMStyleSheets = nsnull;
|
||||
|
@ -1532,7 +1522,6 @@ void nsDocument::Finalize(JSContext *aContext)
|
|||
/**
|
||||
* Returns the Selection Object
|
||||
*/
|
||||
#if XP_NEW_SELECTION
|
||||
NS_IMETHODIMP nsDocument::GetSelection(nsICollection ** aSelection) {
|
||||
if (!aSelection)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
@ -1545,18 +1534,6 @@ NS_IMETHODIMP nsDocument::GetSelection(nsICollection ** aSelection) {
|
|||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#else
|
||||
NS_IMETHODIMP nsDocument::GetSelection(nsISelection *& aSelection) {
|
||||
if (mSelection != nsnull) {
|
||||
NS_ADDREF(mSelection);
|
||||
aSelection = mSelection;
|
||||
return NS_OK;
|
||||
} else {
|
||||
aSelection = nsnull;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#endif //XP_NEW_SELECTION
|
||||
|
||||
/**
|
||||
* Selects all the Content
|
||||
|
@ -1617,7 +1594,6 @@ NS_IMETHODIMP nsDocument::SelectAll() {
|
|||
|
||||
//NS_RELEASE(start);
|
||||
//NS_RELEASE(end);
|
||||
#if XP_NEW_SELECTION
|
||||
mSelection->Clear();//clear all old selection
|
||||
nsIDOMRange *range = nsnull;
|
||||
if (NS_SUCCEEDED(nsRepository::CreateInstance(kCRangeCID, nsnull, kIDOMRange, (void **)&range))){ //create an irange
|
||||
|
@ -1642,13 +1618,6 @@ NS_IMETHODIMP nsDocument::SelectAll() {
|
|||
}
|
||||
NS_IF_RELEASE(range);//allready referenced in the selection now.
|
||||
}
|
||||
#else
|
||||
nsSelectionRange * range = mSelection->GetRange();
|
||||
nsSelectionPoint * startPnt = range->GetStartPoint();
|
||||
nsSelectionPoint * endPnt = range->GetEndPoint();
|
||||
startPnt->SetPoint(start, -1, PR_TRUE);
|
||||
endPnt->SetPoint(end, -1, PR_FALSE);
|
||||
#endif
|
||||
SetDisplaySelection(PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1832,7 +1801,6 @@ PRBool nsDocument::IsInSelection(const nsIContent* aContent) const
|
|||
{
|
||||
PRBool result = PR_FALSE;
|
||||
|
||||
#if XP_NEW_SELECTION
|
||||
//travers through an iterator to see if the acontent is in the ranges
|
||||
if (mSelection != nsnull)
|
||||
{
|
||||
|
@ -1845,23 +1813,6 @@ PRBool nsDocument::IsInSelection(const nsIContent* aContent) const
|
|||
NS_IF_RELEASE(enumerator);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (mSelection != nsnull)
|
||||
{
|
||||
nsSelectionRange* range = mSelection->GetRange();
|
||||
if (range != nsnull)
|
||||
{
|
||||
nsSelectionPoint* startPoint = range->GetStartPoint();
|
||||
nsSelectionPoint* endPoint = range->GetEndPoint();
|
||||
|
||||
nsIContent* startContent = startPoint->GetContent();
|
||||
nsIContent* endContent = endPoint->GetContent();
|
||||
result = IsInRange(startContent, endContent, aContent);
|
||||
NS_IF_RELEASE(startContent);
|
||||
NS_IF_RELEASE(endContent);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
|
||||
}
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
#if XP_NEW_SELECTION
|
||||
class nsICollection;
|
||||
#else
|
||||
class nsISelection;
|
||||
#endif
|
||||
class nsIEventListenerManager;
|
||||
class nsDOMStyleSheetCollection;
|
||||
|
||||
|
@ -190,11 +186,7 @@ public:
|
|||
/**
|
||||
* Returns the Selection Object
|
||||
*/
|
||||
#if XP_NEW_SELECTION
|
||||
NS_IMETHOD GetSelection(nsICollection ** aSelection);
|
||||
#else
|
||||
NS_IMETHOD GetSelection(nsISelection *& aSelection);
|
||||
#endif
|
||||
/**
|
||||
* Selects all the Content
|
||||
*/
|
||||
|
@ -305,11 +297,7 @@ protected:
|
|||
virtual ~nsDocument();
|
||||
nsresult Init();
|
||||
|
||||
#if XP_NEW_SELECTION
|
||||
nsICollection * mSelection;
|
||||
#else
|
||||
nsISelection * mSelection;
|
||||
#endif
|
||||
nsIArena* mArena;
|
||||
nsString* mDocumentTitle;
|
||||
nsIURL* mDocumentURL;
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
#include "nsIFactory.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsISelection.h"
|
||||
|
||||
static NS_DEFINE_IID(kIRangeListIterator, NS_IENUMERATOR_IID);
|
||||
static NS_DEFINE_IID(kIRangeList, NS_ICOLLECTION_IID);
|
||||
static NS_DEFINE_IID(kICollectionIID, NS_ICOLLECTION_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kISelectionIID, NS_ISELECTION_IID);
|
||||
|
||||
|
||||
class nsRangeListIterator;
|
||||
|
@ -25,7 +27,9 @@ see the nsICollection for more details*/
|
|||
|
||||
virtual nsresult Clear();
|
||||
/*END nsICollection interfaces*/
|
||||
|
||||
/*BEGIN nsISelection interfaces*/
|
||||
virtual nsresult HandleKeyEvent(nsGUIEvent *aGuiEvent, nsIFrame *aFrame);
|
||||
/*END nsISelection interfacse*/
|
||||
nsRangeList();
|
||||
virtual ~nsRangeList();
|
||||
|
||||
|
@ -77,7 +81,7 @@ nsresult NS_NewRangeList(nsICollection **aRangeList)
|
|||
nsRangeList *rlist = new nsRangeList;
|
||||
if (!rlist)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsresult result = rlist->QueryInterface(kIRangeList , (void **)aRangeList);
|
||||
nsresult result = rlist->QueryInterface(kICollectionIID , (void **)aRangeList);
|
||||
if (!NS_SUCCEEDED(result))
|
||||
{
|
||||
delete rlist;
|
||||
|
@ -210,7 +214,7 @@ nsRangeListIterator::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIRangeList)) {
|
||||
if (aIID.Equals(kICollectionIID)) {
|
||||
*aInstancePtr = (void *)mRangeList;
|
||||
NS_ADDREF(mRangeList);
|
||||
return NS_OK;
|
||||
|
@ -275,7 +279,7 @@ nsRangeList::ResizeBuffer(PRUint32 aNewBufSize)
|
|||
|
||||
//END nsRangeList methods
|
||||
|
||||
//BEGIN nsIRangeList interface implementations
|
||||
//BEGIN nsICollection interface implementations
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsRangeList)
|
||||
|
@ -294,8 +298,13 @@ nsRangeList::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIRangeList)) {
|
||||
*aInstancePtr = (void*)(nsIEnumerator*)this;
|
||||
if (aIID.Equals(kICollectionIID)) {
|
||||
*aInstancePtr = (void*)(nsICollection *)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals( kISelectionIID)) {
|
||||
*aInstancePtr = (void*)(nsISelection *)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -356,5 +365,17 @@ nsRangeList::Clear()
|
|||
|
||||
|
||||
|
||||
//END nsIDOMRangeInterface methods
|
||||
//END nsICollection methods
|
||||
|
||||
//BEGIN nsISelection methods
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsRangeList::HandleKeyEvent(nsGUIEvent *aGuiEvent, nsIFrame *aFrame)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
//END nsISelection methods
|
||||
|
|
Загрузка…
Ссылка в новой задаче