diff --git a/mozilla/content/events/public/MANIFEST b/mozilla/content/events/public/MANIFEST index 4a0bd33a190..df7b989f7f9 100644 --- a/mozilla/content/events/public/MANIFEST +++ b/mozilla/content/events/public/MANIFEST @@ -3,4 +3,6 @@ # nsIEventListenerManager.h nsIEventStateManager.h -nsIPrivateDOMEvent.h \ No newline at end of file +nsIPrivateDOMEvent.h +nsIPrivateTextEvent.h +nsIPrivateTextRange.h diff --git a/mozilla/content/events/public/Makefile.in b/mozilla/content/events/public/Makefile.in index a1bebfe1205..6df90bf3fca 100644 --- a/mozilla/content/events/public/Makefile.in +++ b/mozilla/content/events/public/Makefile.in @@ -28,6 +28,8 @@ EXPORTS = \ nsIEventListenerManager.h \ nsIEventStateManager.h \ nsIPrivateDOMEvent.h \ + nsIPrivateTextEvent.h \ + nsIPrivateTextRange.h \ $(NULL) EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) diff --git a/mozilla/content/events/public/makefile.win b/mozilla/content/events/public/makefile.win index 51c3e4d81d9..7087cf535f1 100644 --- a/mozilla/content/events/public/makefile.win +++ b/mozilla/content/events/public/makefile.win @@ -22,6 +22,8 @@ EXPORTS = \ nsIEventListenerManager.h \ nsIEventStateManager.h \ nsIPrivateDOMEvent.h \ + nsIPrivateTextEvent.h \ + nsIPrivateTextRange.h \ $(NULL) MODULE=raptor diff --git a/mozilla/content/events/public/nsIPrivateTextEvent.h b/mozilla/content/events/public/nsIPrivateTextEvent.h new file mode 100644 index 00000000000..baf75fcd85f --- /dev/null +++ b/mozilla/content/events/public/nsIPrivateTextEvent.h @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIPrivateTextEvent_h__ +#define nsIPrivateTextEvent_h__ + +#include "nsGUIEvent.h" +#include "nsISupports.h" +#include "nsIPrivateTextRange.h" + +#define NS_IPRIVATETEXTEVENT_IID \ +{ /* 37B69251-4ACE-11d3-9EA6-0060089FE59B */ \ +0x37b69251, 0x4ace, 0x11d3, \ +{0x9e, 0xa6, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b} } + +class nsIPrivateTextEvent : public nsISupports { + +public: + static const nsIID& GetIID() { static nsIID iid = NS_IPRIVATETEXTEVENT_IID; return iid; } + + NS_IMETHOD GetText(nsString& aText) = 0; + NS_IMETHOD GetInputRange(nsIPrivateTextRangeList** aInputRange) = 0; + NS_IMETHOD GetEventReply(nsTextEventReply** aReply) = 0; +}; + +#endif // nsIPrivateTextEvent_h__ + diff --git a/mozilla/content/events/public/nsIPrivateTextRange.h b/mozilla/content/events/public/nsIPrivateTextRange.h new file mode 100644 index 00000000000..02486b8c4b0 --- /dev/null +++ b/mozilla/content/events/public/nsIPrivateTextRange.h @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIPrivateTextRange_h__ +#define nsIPrivateTextRange_h__ + +#include "nsISupports.h" +#include "nsString.h" + +#define NS_IPRIVATETEXTRANGE_IID \ +{0xb471ab41, 0x2a79, 0x11d3, \ +{ 0x9e, 0xa4, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b } } + +class nsIPrivateTextRange : public nsISupports { +public: + static const nsIID& GetIID() { static nsIID iid = NS_IPRIVATETEXTRANGE_IID; return iid; } + enum { + TEXTRANGE_CARETPOSITION = 1, + TEXTRANGE_RAWINPUT = 2, + TEXTRANGE_SELECTEDRAWTEXT = 3, + TEXTRANGE_CONVERTEDTEXT = 4, + TEXTRANGE_SELECTEDCONVERTEDTEXT = 5 + }; + + NS_IMETHOD GetRangeStart(PRUint16* aRangeStart)=0; + NS_IMETHOD SetRangeStart(PRUint16 aRangeStart)=0; + + NS_IMETHOD GetRangeEnd(PRUint16* aRangeEnd)=0; + NS_IMETHOD SetRangeEnd(PRUint16 aRangeEnd)=0; + + NS_IMETHOD GetRangeType(PRUint16* aRangeType)=0; + NS_IMETHOD SetRangeType(PRUint16 aRangeType)=0; +}; + +#define NS_IPRIVATETEXTRANGELIST_IID \ +{ 0x1ee9d531, 0x2a79, 0x11d3, \ +{ 0x9e, 0xa4, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b} } + +class nsIPrivateTextRangeList : public nsISupports { +public: + static const nsIID& GetIID() { static nsIID iid = NS_IPRIVATETEXTRANGELIST_IID; return iid; } + + NS_IMETHOD GetLength(PRUint16* aLength)=0; + NS_IMETHOD Item(PRUint16 aIndex, nsIPrivateTextRange** aReturn)=0; +}; + +#endif // nsIPrivateTextRange_h__ diff --git a/mozilla/content/events/src/Makefile.in b/mozilla/content/events/src/Makefile.in index b23c83d1028..ee1dfafa3b7 100644 --- a/mozilla/content/events/src/Makefile.in +++ b/mozilla/content/events/src/Makefile.in @@ -31,7 +31,7 @@ CPPSRCS = \ nsEventStateManager.cpp \ nsDOMEvent.cpp \ nsDOMEventsIIDs.cpp \ - nsDOMTextRange.cpp \ + nsPrivateTextRange.cpp \ $(NULL) MODULE=layout @@ -41,7 +41,7 @@ EXPORTS = \ nsEventStateManager.h \ nsDOMEvent.h \ nsDOMEventsIIDs.h \ - nsDOMTextRange.h \ + nsPrivateTextRange.h \ $(NULL) EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) diff --git a/mozilla/content/events/src/makefile.win b/mozilla/content/events/src/makefile.win index 7785b222c46..626c0a7bded 100644 --- a/mozilla/content/events/src/makefile.win +++ b/mozilla/content/events/src/makefile.win @@ -30,18 +30,18 @@ CPPSRCS= nsEventListenerManager.cpp \ nsEventStateManager.cpp \ nsDOMEvent.cpp \ nsDOMEventsIIDs.cpp \ - nsDOMTextRange.cpp \ + nsPrivateTextRange.cpp \ $(NULL) CPP_OBJS= .\$(OBJDIR)\nsEventListenerManager.obj \ .\$(OBJDIR)\nsEventStateManager.obj \ .\$(OBJDIR)\nsDOMEvent.obj \ .\$(OBJDIR)\nsDOMEventsIIDs.obj \ - .\$(OBJDIR)\nsDOMTextRange.obj \ + .\$(OBJDIR)\nsPrivateTextRange.obj \ $(NULL) -EXPORTS= nsEventListenerManager.h nsEventStateManager.h nsDOMEvent.h nsDOMEventsIIDs.h nsDOMTextRange.h +EXPORTS= nsEventListenerManager.h nsEventStateManager.h nsDOMEvent.h nsDOMEventsIIDs.h nsPrivateTextRange.h LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \ -I$(PUBLIC)\dom -I$(PUBLIC)\js -I..\..\html\base\src -I$(PUBLIC)\netlib diff --git a/mozilla/content/events/src/nsDOMEvent.cpp b/mozilla/content/events/src/nsDOMEvent.cpp index d0f8bd2b0f8..cf5c2fdf179 100644 --- a/mozilla/content/events/src/nsDOMEvent.cpp +++ b/mozilla/content/events/src/nsDOMEvent.cpp @@ -26,7 +26,7 @@ #include "nsIWidget.h" #include "nsIWebShell.h" #include "nsIPresShell.h" -#include "nsDOMTextRange.h" +#include "nsPrivateTextRange.h" #include "nsIDocument.h" static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID); @@ -36,6 +36,7 @@ static NS_DEFINE_IID(kIDOMEventIID, NS_IDOMEVENT_IID); static NS_DEFINE_IID(kIDOMUIEventIID, NS_IDOMUIEVENT_IID); static NS_DEFINE_IID(kIDOMNSUIEventIID, NS_IDOMNSUIEVENT_IID); static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID); +static NS_DEFINE_IID(kIPrivateTextEventIID, NS_IPRIVATETEXTEVENT_IID); static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); static char* mEventNames[] = { @@ -63,19 +64,19 @@ nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent) { // build the range list -- ranges need to be DOM-ified since the IME transaction // will hold a ref, the widget representation isn't persistent // - nsIDOMTextRange** tempTextRangeList = new nsIDOMTextRange*[((nsTextEvent*)aEvent)->rangeCount]; + nsIPrivateTextRange** tempTextRangeList = new nsIPrivateTextRange*[((nsTextEvent*)aEvent)->rangeCount]; if (tempTextRangeList!=nsnull) { for(PRUint16 i=0;i<((nsTextEvent*)aEvent)->rangeCount;i++) { - nsDOMTextRange* tempDOMTextRange = new nsDOMTextRange((((nsTextEvent*)aEvent)->rangeArray[i]).mStartOffset, + nsPrivateTextRange* tempPrivateTextRange = new nsPrivateTextRange((((nsTextEvent*)aEvent)->rangeArray[i]).mStartOffset, (((nsTextEvent*)aEvent)->rangeArray[i]).mEndOffset, (((nsTextEvent*)aEvent)->rangeArray[i]).mRangeType); - if (tempDOMTextRange!=nsnull) { - tempDOMTextRange->AddRef(); - tempTextRangeList[i] = (nsIDOMTextRange*)tempDOMTextRange; + if (tempPrivateTextRange!=nsnull) { + tempPrivateTextRange->AddRef(); + tempTextRangeList[i] = (nsIPrivateTextRange*)tempPrivateTextRange; } } - mTextRange = (nsIDOMTextRangeList*) new nsDOMTextRangeList(((nsTextEvent*)aEvent)->rangeCount,tempTextRangeList); + mTextRange = (nsIPrivateTextRangeList*) new nsPrivateTextRangeList(((nsTextEvent*)aEvent)->rangeCount,tempTextRangeList); if (mTextRange!=nsnull) mTextRange->AddRef(); } } @@ -122,6 +123,11 @@ nsresult nsDOMEvent::QueryInterface(const nsIID& aIID, AddRef(); return NS_OK; } + if (aIID.Equals(kIPrivateTextEventIID)) { + *aInstancePtrResult=(void*)((nsIPrivateTextEvent*)this); + AddRef(); + return NS_OK; + } return NS_NOINTERFACE; } @@ -243,7 +249,7 @@ NS_METHOD nsDOMEvent::GetText(nsString& aText) return NS_ERROR_FAILURE; } -NS_METHOD nsDOMEvent::GetInputRange(nsIDOMTextRangeList** aInputRange) +NS_METHOD nsDOMEvent::GetInputRange(nsIPrivateTextRangeList** aInputRange) { if (mEvent->message == NS_TEXT_EVENT) { *aInputRange = mTextRange; @@ -253,8 +259,13 @@ NS_METHOD nsDOMEvent::GetInputRange(nsIDOMTextRangeList** aInputRange) return NS_ERROR_FAILURE; } -NS_METHOD nsDOMEvent::SetInputRange(nsIDOMTextRangeList* aInputRange) +NS_METHOD nsDOMEvent::GetEventReply(nsTextEventReply** aReply) { + if (mEvent->message==NS_TEXT_EVENT) { + *aReply = &(((nsTextEvent*)mEvent)->theReply); + return NS_OK; + } + return NS_ERROR_FAILURE; } diff --git a/mozilla/content/events/src/nsDOMEvent.h b/mozilla/content/events/src/nsDOMEvent.h index 2bbce70517c..90fc2994ff2 100644 --- a/mozilla/content/events/src/nsDOMEvent.h +++ b/mozilla/content/events/src/nsDOMEvent.h @@ -23,6 +23,8 @@ #include "nsIDOMNSUIEvent.h" #include "nsISupports.h" #include "nsIPrivateDOMEvent.h" +#include "nsIPrivateTextEvent.h" +#include "nsIPrivateTextRange.h" #include "nsIPresContext.h" #include "nsPoint.h" @@ -31,7 +33,7 @@ class nsIContent; class nsIDOMRenderingContext; -class nsDOMEvent : public nsIDOMUIEvent, public nsIDOMNSUIEvent, public nsIPrivateDOMEvent { +class nsDOMEvent : public nsIDOMUIEvent, public nsIDOMNSUIEvent, public nsIPrivateDOMEvent, public nsIPrivateTextEvent { public: // Note: this enum must be kept in sync with mEventNames in nsDOMEvent.cpp @@ -82,12 +84,6 @@ public: NS_IMETHOD PreventDefault(); - NS_IMETHOD GetText(nsString& aText); - - NS_IMETHOD GetInputRange(nsIDOMTextRangeList** aInputRange); - - NS_IMETHOD SetInputRange(nsIDOMTextRangeList* aInputRange); - NS_IMETHOD GetScreenX(PRInt32* aScreenX); NS_IMETHOD GetScreenY(PRInt32* aScreenY); @@ -133,15 +129,20 @@ public: NS_IMETHOD DuplicatePrivateData(); NS_IMETHOD SetTarget(nsIDOMNode* aNode); + // nsIPrivateTextEvent interface + NS_IMETHOD GetText(nsString& aText); + NS_IMETHOD GetInputRange(nsIPrivateTextRangeList** aInputRange); + NS_IMETHOD GetEventReply(nsTextEventReply** aReply); + + protected: nsEvent* mEvent; nsIPresContext* mPresContext; nsIDOMNode* mTarget; nsString* mText; - nsIDOMTextRangeList* mTextRange; + nsIPrivateTextRangeList* mTextRange; const char* GetEventName(PRUint32 aEventType); - }; #endif // nsDOMEvent_h__ diff --git a/mozilla/layout/events/src/nsDOMTextRange.cpp b/mozilla/content/events/src/nsPrivateTextRange.cpp similarity index 57% rename from mozilla/layout/events/src/nsDOMTextRange.cpp rename to mozilla/content/events/src/nsPrivateTextRange.cpp index 6461ed63dbb..6820b20eace 100644 --- a/mozilla/layout/events/src/nsDOMTextRange.cpp +++ b/mozilla/content/events/src/nsPrivateTextRange.cpp @@ -16,12 +16,12 @@ * Reserved. */ -#include "nsDOMTextRange.h" +#include "nsPrivateTextRange.h" -static NS_DEFINE_IID(kIDOMTextRange, NS_IDOMTEXTRANGE_IID); -static NS_DEFINE_IID(kIDOMTextRangeList,NS_IDOMTEXTRANGELIST_IID); +static NS_DEFINE_IID(kIPrivateTextRange, NS_IPRIVATETEXTRANGE_IID); +static NS_DEFINE_IID(kIPrivateTextRangeList,NS_IPRIVATETEXTRANGELIST_IID); -nsDOMTextRange::nsDOMTextRange(PRUint16 aRangeStart, PRUint16 aRangeEnd, PRUint16 aRangeType) +nsPrivateTextRange::nsPrivateTextRange(PRUint16 aRangeStart, PRUint16 aRangeEnd, PRUint16 aRangeType) : mRangeStart(aRangeStart), mRangeEnd(aRangeEnd), mRangeType(aRangeType) @@ -29,23 +29,23 @@ nsDOMTextRange::nsDOMTextRange(PRUint16 aRangeStart, PRUint16 aRangeEnd, PRUint1 NS_INIT_REFCNT(); } -nsDOMTextRange::~nsDOMTextRange(void) +nsPrivateTextRange::~nsPrivateTextRange(void) { } -NS_IMPL_ADDREF(nsDOMTextRange) -NS_IMPL_RELEASE(nsDOMTextRange) +NS_IMPL_ADDREF(nsPrivateTextRange) +NS_IMPL_RELEASE(nsPrivateTextRange) -nsresult nsDOMTextRange::QueryInterface(const nsIID& aIID, +nsresult nsPrivateTextRange::QueryInterface(const nsIID& aIID, void** aInstancePtrResult) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - if (aIID.Equals(kIDOMTextRange)) { - *aInstancePtrResult = (void*) ((nsIDOMTextRange*)this); + if (aIID.Equals(kIPrivateTextRange)) { + *aInstancePtrResult = (void*) ((nsIPrivateTextRange*)this); AddRef(); return NS_OK; } @@ -53,44 +53,44 @@ nsresult nsDOMTextRange::QueryInterface(const nsIID& aIID, return NS_NOINTERFACE; } -NS_METHOD nsDOMTextRange::GetRangeStart(PRUint16* aRangeStart) +NS_METHOD nsPrivateTextRange::GetRangeStart(PRUint16* aRangeStart) { *aRangeStart = mRangeStart; return NS_OK; } -NS_METHOD nsDOMTextRange::SetRangeStart(PRUint16 aRangeStart) +NS_METHOD nsPrivateTextRange::SetRangeStart(PRUint16 aRangeStart) { mRangeStart = aRangeStart; return NS_OK; } -NS_METHOD nsDOMTextRange::GetRangeEnd(PRUint16* aRangeEnd) +NS_METHOD nsPrivateTextRange::GetRangeEnd(PRUint16* aRangeEnd) { *aRangeEnd = mRangeEnd; return NS_OK; } -NS_METHOD nsDOMTextRange::SetRangeEnd(PRUint16 aRangeEnd) +NS_METHOD nsPrivateTextRange::SetRangeEnd(PRUint16 aRangeEnd) { mRangeEnd = aRangeEnd; return NS_OK; } -NS_METHOD nsDOMTextRange::GetRangeType(PRUint16* aRangeType) +NS_METHOD nsPrivateTextRange::GetRangeType(PRUint16* aRangeType) { *aRangeType = mRangeType; return NS_OK; } -NS_METHOD nsDOMTextRange::SetRangeType(PRUint16 aRangeType) +NS_METHOD nsPrivateTextRange::SetRangeType(PRUint16 aRangeType) { mRangeType = aRangeType; return NS_OK; } -nsDOMTextRangeList::nsDOMTextRangeList(PRUint16 aLength,nsIDOMTextRange** aList) +nsPrivateTextRangeList::nsPrivateTextRangeList(PRUint16 aLength,nsIPrivateTextRange** aList) : mLength(aLength), mList(aList) { @@ -100,25 +100,25 @@ nsDOMTextRangeList::nsDOMTextRangeList(PRUint16 aLength,nsIDOMTextRange** aList) NS_INIT_REFCNT(); } -nsDOMTextRangeList::~nsDOMTextRangeList(void) +nsPrivateTextRangeList::~nsPrivateTextRangeList(void) { int i; for(i=0;iRelease(); } -NS_IMPL_ADDREF(nsDOMTextRangeList) -NS_IMPL_RELEASE(nsDOMTextRangeList) +NS_IMPL_ADDREF(nsPrivateTextRangeList) +NS_IMPL_RELEASE(nsPrivateTextRangeList) -nsresult nsDOMTextRangeList::QueryInterface(const nsIID& aIID, +nsresult nsPrivateTextRangeList::QueryInterface(const nsIID& aIID, void** aInstancePtrResult) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - if (aIID.Equals(kIDOMTextRangeList)) { - *aInstancePtrResult = (void*) ((nsIDOMTextRangeList*)this); + if (aIID.Equals(kIPrivateTextRangeList)) { + *aInstancePtrResult = (void*) ((nsIPrivateTextRangeList*)this); AddRef(); return NS_OK; } @@ -126,13 +126,13 @@ nsresult nsDOMTextRangeList::QueryInterface(const nsIID& aIID, return NS_NOINTERFACE; } -NS_METHOD nsDOMTextRangeList::GetLength(PRUint16* aLength) +NS_METHOD nsPrivateTextRangeList::GetLength(PRUint16* aLength) { *aLength = mLength; return NS_OK; } -NS_METHOD nsDOMTextRangeList::Item(PRUint16 aIndex, nsIDOMTextRange** aReturn) +NS_METHOD nsPrivateTextRangeList::Item(PRUint16 aIndex, nsIPrivateTextRange** aReturn) { if (aIndex>mLength) { *aReturn = nsnull; diff --git a/mozilla/layout/events/src/nsDOMTextRange.h b/mozilla/content/events/src/nsPrivateTextRange.h similarity index 69% rename from mozilla/layout/events/src/nsDOMTextRange.h rename to mozilla/content/events/src/nsPrivateTextRange.h index 7ef62c0830e..6dae836b92a 100644 --- a/mozilla/layout/events/src/nsDOMTextRange.h +++ b/mozilla/content/events/src/nsPrivateTextRange.h @@ -16,19 +16,18 @@ * Reserved. */ -#ifndef nsDOMTextRange_h__ -#define nsDOMTextRange_h__ +#ifndef nsPrivateTextRange_h__ +#define nsPrivateTextRange_h__ -#include "nsIDOMTextRange.h" -#include "nsIDOMTextRangeList.h" +#include "nsIPrivateTextRange.h" -class nsDOMTextRange : public nsIDOMTextRange +class nsPrivateTextRange : public nsIPrivateTextRange { NS_DECL_ISUPPORTS public: - nsDOMTextRange(PRUint16 aRangeStart, PRUint16 aRangeEnd, PRUint16 aRangeType); - virtual ~nsDOMTextRange(void); + nsPrivateTextRange(PRUint16 aRangeStart, PRUint16 aRangeEnd, PRUint16 aRangeType); + virtual ~nsPrivateTextRange(void); NS_IMETHOD GetRangeStart(PRUint16* aRangeStart); NS_IMETHOD SetRangeStart(PRUint16 aRangeStart); @@ -46,22 +45,22 @@ protected: PRUint16 mRangeType; }; -class nsDOMTextRangeList: public nsIDOMTextRangeList +class nsPrivateTextRangeList: public nsIPrivateTextRangeList { NS_DECL_ISUPPORTS public: - nsDOMTextRangeList(PRUint16 aLength,nsIDOMTextRange** aList); - virtual ~nsDOMTextRangeList(void); + nsPrivateTextRangeList(PRUint16 aLength,nsIPrivateTextRange** aList); + virtual ~nsPrivateTextRangeList(void); NS_IMETHOD GetLength(PRUint16* aLength); - NS_IMETHOD Item(PRUint16 aIndex, nsIDOMTextRange** aReturn); + NS_IMETHOD Item(PRUint16 aIndex, nsIPrivateTextRange** aReturn); protected: - PRUint16 mLength; - nsIDOMTextRange** mList; + PRUint16 mLength; + nsIPrivateTextRange** mList; }; diff --git a/mozilla/editor/base/IMETextTxn.cpp b/mozilla/editor/base/IMETextTxn.cpp index 081de15ccd8..61d60160d96 100644 --- a/mozilla/editor/base/IMETextTxn.cpp +++ b/mozilla/editor/base/IMETextTxn.cpp @@ -20,8 +20,7 @@ #include "IMECommitTxn.h" #include "nsEditor.h" #include "nsIDOMCharacterData.h" -#include "nsIDOMTextRange.h" -#include "nsIDOMTextRangeList.h" +#include "nsIPrivateTextRange.h" #include "nsIDOMSelection.h" #include "nsIPresShell.h" #include "EditAggregateTxn.h" @@ -50,7 +49,7 @@ IMETextTxn::~IMETextTxn() NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement, PRUint32 aOffset, PRUint32 aReplaceLength, - nsIDOMTextRangeList* aTextRangeList, + nsIPrivateTextRangeList* aTextRangeList, const nsString &aStringToInsert, nsIPresShell *aPresShell) { @@ -143,7 +142,7 @@ NS_IMETHODIMP IMETextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) // // we absorbe the next IME transaction by adopting it's insert string as our own // - nsIDOMTextRangeList* newTextRangeList; + nsIPrivateTextRangeList* newTextRangeList; otherTxn->GetData(mStringToInsert,&newTextRangeList); mRangeList = do_QueryInterface(newTextRangeList); *aDidMerge = PR_TRUE; @@ -218,7 +217,7 @@ IMETextTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr) /* ============ protected methods ================== */ -NS_IMETHODIMP IMETextTxn::GetData(nsString& aResult,nsIDOMTextRangeList** aTextRangeList) +NS_IMETHODIMP IMETextTxn::GetData(nsString& aResult,nsIPrivateTextRangeList** aTextRangeList) { aResult = mStringToInsert; *aTextRangeList = mRangeList; @@ -231,7 +230,7 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void) PRBool haveSelectedRange, haveCaretPosition; PRUint16 textRangeListLength,selectionStart,selectionEnd, textRangeType, caretPosition, i; - nsIDOMTextRange* textRange; + nsIPrivateTextRange* textRange; haveSelectedRange = PR_FALSE; haveCaretPosition = PR_FALSE; @@ -239,19 +238,19 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void) #ifdef DEBUG_tague PRUint16 listlen,start,stop,type; - nsIDOMTextRange* rangePtr; + nsIPrivateTextRange* rangePtr; result = mRangeList->GetLength(&listlen); - printf("nsIDOMTextRangeList[%p]\n",mRangeList); + printf("nsIPrivateTextRangeList[%p]\n",mRangeList); for (i=0;iItem(i,&rangePtr); rangePtr->GetRangeStart(&start); rangePtr->GetRangeEnd(&stop); rangePtr->GetRangeType(&type); printf("range[%d] start=%d end=%d type=",i,start,stop,type); - if (type==nsIDOMTextRange::TEXTRANGE_RAWINPUT) printf("TEXTRANGE_RAWINPUT\n"); - if (type==nsIDOMTextRange::TEXTRANGE_SELECTEDRAWTEXT) printf("TEXTRANGE_SELECTEDRAWTEXT\n"); - if (type==nsIDOMTextRange::TEXTRANGE_CONVERTEDTEXT) printf("TEXTRANGE_CONVERTEDTEXT\n"); - if (type==nsIDOMTextRange::TEXTRANGE_SELECTEDCONVERTEDTEXT) printf("TEXTRANGE_SELECTEDCONVERTEDTEXT\n"); + if (type==nsIPrivateTextRange::TEXTRANGE_RAWINPUT) printf("TEXTRANGE_RAWINPUT\n"); + if (type==nsIPrivateTextRange::TEXTRANGE_SELECTEDRAWTEXT) printf("TEXTRANGE_SELECTEDRAWTEXT\n"); + if (type==nsIPrivateTextRange::TEXTRANGE_CONVERTEDTEXT) printf("TEXTRANGE_CONVERTEDTEXT\n"); + if (type==nsIPrivateTextRange::TEXTRANGE_SELECTEDCONVERTEDTEXT) printf("TEXTRANGE_SELECTEDCONVERTEDTEXT\n"); } #endif @@ -266,13 +265,13 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void) if (NS_SUCCEEDED(result)) { result = textRange->GetRangeType(&textRangeType); - if (textRangeType==nsIDOMTextRange::TEXTRANGE_SELECTEDCONVERTEDTEXT) + if (textRangeType==nsIPrivateTextRange::TEXTRANGE_SELECTEDCONVERTEDTEXT) { haveSelectedRange = PR_TRUE; textRange->GetRangeStart(&selectionStart); textRange->GetRangeEnd(&selectionEnd); } - if (textRangeType==nsIDOMTextRange::TEXTRANGE_CARETPOSITION) + if (textRangeType==nsIPrivateTextRange::TEXTRANGE_CARETPOSITION) { haveCaretPosition = PR_TRUE; textRange->GetRangeStart(&caretPosition); diff --git a/mozilla/editor/base/IMETextTxn.h b/mozilla/editor/base/IMETextTxn.h index fea487a3318..6882505237b 100644 --- a/mozilla/editor/base/IMETextTxn.h +++ b/mozilla/editor/base/IMETextTxn.h @@ -21,7 +21,7 @@ #include "EditTxn.h" #include "nsIDOMCharacterData.h" -#include "nsIDOMTextRangeList.h" +#include "nsIPrivateTextRange.h" #include "nsCOMPtr.h" // {D4D25721-2813-11d3-9EA3-0060089FE59B} @@ -59,7 +59,7 @@ public: NS_IMETHOD Init(nsIDOMCharacterData *aElement, PRUint32 aOffset, PRUint32 aReplaceLength, - nsIDOMTextRangeList* aTextRangeList, + nsIPrivateTextRangeList* aTextRangeList, const nsString& aString, nsIPresShell* aPresShell); @@ -87,7 +87,7 @@ public: NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); /** return the string data associated with this transaction */ - NS_IMETHOD GetData(nsString& aResult, nsIDOMTextRangeList** aTextRangeList); + NS_IMETHOD GetData(nsString& aResult, nsIPrivateTextRangeList** aTextRangeList); /** must be called before any IMETextTxn is instantiated */ static nsresult ClassInit(); @@ -109,7 +109,7 @@ protected: nsString mStringToInsert; /** the range list **/ - nsCOMPtr mRangeList; + nsCOMPtr mRangeList; /** the presentation shell, which we'll need to get the selection */ nsIPresShell* mPresShell; diff --git a/mozilla/editor/base/nsEditor.cpp b/mozilla/editor/base/nsEditor.cpp index ca573c5f251..6497e9026f9 100644 --- a/mozilla/editor/base/nsEditor.cpp +++ b/mozilla/editor/base/nsEditor.cpp @@ -3728,11 +3728,15 @@ nsEditor::EndComposition(void) } NS_IMETHODIMP -nsEditor::SetCompositionString(const nsString& aCompositionString, nsIDOMTextRangeList* aTextRangeList) +nsEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply) { + nsCOMPtr caretP; nsresult result = SetInputMethodText(aCompositionString,aTextRangeList); mIMEBufferLength = aCompositionString.Length(); + mPresShell->GetCaret(getter_AddRefs(caretP)); + caretP->GetWindowRelativeCoordinates(aReply->mCursorPosition,aReply->mCursorIsCollapsed); + return result; } @@ -3910,7 +3914,7 @@ nsEditor::GetFirstTextNode(nsIDOMNode *aNode, nsIDOMNode **aRetNode) //END nsEditor Private methods NS_IMETHODIMP -nsEditor::SetInputMethodText(const nsString& aStringToInsert,nsIDOMTextRangeList *aTextRangeList) +nsEditor::SetInputMethodText(const nsString& aStringToInsert,nsIPrivateTextRangeList *aTextRangeList) { IMETextTxn *txn; nsresult result; @@ -3962,7 +3966,7 @@ nsEditor::SetInputMethodText(const nsString& aStringToInsert,nsIDOMTextRangeList NS_IMETHODIMP nsEditor::CreateTxnForIMEText(const nsString & aStringToInsert, - nsIDOMTextRangeList* aTextRangeList, + nsIPrivateTextRangeList* aTextRangeList, IMETextTxn ** aTxn) { nsresult result; @@ -4011,7 +4015,7 @@ nsEditor::CreateTxnForRemoveStyleSheet(nsICSSStyleSheet* aSheet, RemoveStyleShee -NS_IMETHODIMP nsEditor::DoInitialInputMethodInsert(const nsString & aStringToInsert,nsIDOMTextRangeList* aTextRangeList) +NS_IMETHODIMP nsEditor::DoInitialInputMethodInsert(const nsString & aStringToInsert,nsIPrivateTextRangeList* aTextRangeList) { if (!mDoc) { return NS_ERROR_NOT_INITIALIZED; diff --git a/mozilla/editor/base/nsEditor.h b/mozilla/editor/base/nsEditor.h index 25511d47329..5cfb343a4b5 100644 --- a/mozilla/editor/base/nsEditor.h +++ b/mozilla/editor/base/nsEditor.h @@ -26,7 +26,7 @@ #include "nsIDOMCharacterData.h" #include "nsIDOMEventListener.h" #include "nsIDOMRange.h" -#include "nsIDOMTextRangeList.h" +#include "nsIPrivateTextRange.h" #include "nsCOMPtr.h" #include "nsIStringBundle.h" #include "nsITransactionManager.h" @@ -185,7 +185,7 @@ public: NS_IMETHOD BeginComposition(void); - NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIDOMTextRangeList* aTextRangeList); + NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList, nsTextEventReply *aReply); NS_IMETHOD EndComposition(void); @@ -316,7 +316,7 @@ protected: InsertTextTxn ** aTxn); NS_IMETHOD CreateTxnForIMEText(const nsString & aStringToInsert, - nsIDOMTextRangeList* aTextRangeList, + nsIPrivateTextRangeList* aTextRangeList, IMETextTxn ** aTxn); /** create a transaction for adding a style sheet @@ -334,7 +334,7 @@ protected: */ NS_IMETHOD DoInitialInsert(const nsString & aStringToInsert); - NS_IMETHOD DoInitialInputMethodInsert(const nsString& aStringToInsert,nsIDOMTextRangeList* aTextRangeList); + NS_IMETHOD DoInitialInputMethodInsert(const nsString& aStringToInsert,nsIPrivateTextRangeList* aTextRangeList); NS_IMETHOD DeleteText(nsIDOMCharacterData *aElement, @@ -373,7 +373,7 @@ protected: NS_IMETHOD DebugDumpContent() const; - NS_IMETHOD SetInputMethodText(const nsString& aStringToInsert, nsIDOMTextRangeList* aTextRangeList); + NS_IMETHOD SetInputMethodText(const nsString& aStringToInsert, nsIPrivateTextRangeList* aTextRangeList); // called each time we modify the document. Increments the mod // count of the doc. diff --git a/mozilla/editor/base/nsEditorEventListeners.cpp b/mozilla/editor/base/nsEditorEventListeners.cpp index 6cbe2f036a6..a280e5a66fe 100644 --- a/mozilla/editor/base/nsEditorEventListeners.cpp +++ b/mozilla/editor/base/nsEditorEventListeners.cpp @@ -30,6 +30,7 @@ #include "nsIStringStream.h" #include "nsIDOMUIEvent.h" #include "nsIDOMNSUIEvent.h" +#include "nsIPrivateTextEvent.h" // for testing only #include "nsIHTMLEditor.h" @@ -1035,19 +1036,21 @@ nsTextEditorTextListener::HandleText(nsIDOMEvent* aTextEvent) { nsString composedText; nsresult result; - nsCOMPtruiEvent; - nsIDOMTextRangeList *textRangeList; + nsCOMPtr textEvent; + nsIPrivateTextRangeList *textRangeList; + nsTextEventReply *textEventReply; - uiEvent = do_QueryInterface(aTextEvent); - if (!uiEvent) { + textEvent = do_QueryInterface(aTextEvent); + if (!textEvent) { //non-ui event passed in. bad things. return NS_OK; } - uiEvent->GetText(composedText); - uiEvent->GetInputRange(&textRangeList); + textEvent->GetText(composedText); + textEvent->GetInputRange(&textRangeList); + textEvent->GetEventReply(&textEventReply); textRangeList->AddRef(); - result = mEditor->SetCompositionString(composedText,textRangeList); + result = mEditor->SetCompositionString(composedText,textRangeList,textEventReply); return result; } diff --git a/mozilla/editor/base/nsHTMLEditor.cpp b/mozilla/editor/base/nsHTMLEditor.cpp index 8a256ad9481..872746ba674 100644 --- a/mozilla/editor/base/nsHTMLEditor.cpp +++ b/mozilla/editor/base/nsHTMLEditor.cpp @@ -2768,9 +2768,9 @@ NS_IMETHODIMP nsHTMLEditor::EndComposition(void) return nsTextEditor::EndComposition(); } -NS_IMETHODIMP nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIDOMTextRangeList* aTextRangeList) +NS_IMETHODIMP nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList, nsTextEventReply* aReply) { - return nsTextEditor::SetCompositionString(aCompositionString,aTextRangeList); + return nsTextEditor::SetCompositionString(aCompositionString,aTextRangeList,aReply); } NS_IMETHODIMP diff --git a/mozilla/editor/base/nsHTMLEditor.h b/mozilla/editor/base/nsHTMLEditor.h index b065b50ef4f..38807d25970 100644 --- a/mozilla/editor/base/nsHTMLEditor.h +++ b/mozilla/editor/base/nsHTMLEditor.h @@ -106,7 +106,7 @@ public: NS_IMETHOD InsertHTML(const nsString& aInputString); NS_IMETHOD BeginComposition(void); - NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIDOMTextRangeList* aTextRange); + NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRange, nsTextEventReply* aReply); NS_IMETHOD EndComposition(void); NS_IMETHOD OutputToString(nsString& aOutputString, diff --git a/mozilla/editor/base/nsJSEditorLog.cpp b/mozilla/editor/base/nsJSEditorLog.cpp index c2f83376068..84441a5f4a7 100644 --- a/mozilla/editor/base/nsJSEditorLog.cpp +++ b/mozilla/editor/base/nsJSEditorLog.cpp @@ -810,7 +810,7 @@ nsJSEditorLog::BeginComposition(void) } NS_IMETHODIMP -nsJSEditorLog::SetCompositionString(const nsString& aCompositionString,nsIDOMTextRangeList* aTextRangeList) +nsJSEditorLog::SetCompositionString(const nsString& aCompositionString,nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply) { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/mozilla/editor/base/nsJSEditorLog.h b/mozilla/editor/base/nsJSEditorLog.h index 939a986322a..85200d4cf88 100644 --- a/mozilla/editor/base/nsJSEditorLog.h +++ b/mozilla/editor/base/nsJSEditorLog.h @@ -143,7 +143,7 @@ public: NS_IMETHOD JoinTableCells(); NS_IMETHOD NormalizeTable(nsIDOMElement *aTable); NS_IMETHOD BeginComposition(void); - NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIDOMTextRangeList* aTextRangeList); + NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply); NS_IMETHOD EndComposition(void); NS_IMETHOD StartLogging(nsIFileSpec *aLogFile); NS_IMETHOD StopLogging(); diff --git a/mozilla/editor/base/nsTextEditor.cpp b/mozilla/editor/base/nsTextEditor.cpp index dd753cc39eb..6b1f11bed1d 100644 --- a/mozilla/editor/base/nsTextEditor.cpp +++ b/mozilla/editor/base/nsTextEditor.cpp @@ -2934,9 +2934,9 @@ nsTextEditor::BeginComposition(void) } NS_IMETHODIMP -nsTextEditor::SetCompositionString(const nsString& aCompositionString,nsIDOMTextRangeList* aTextRangeList) +nsTextEditor::SetCompositionString(const nsString& aCompositionString,nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply) { - return nsEditor::SetCompositionString(aCompositionString,aTextRangeList); + return nsEditor::SetCompositionString(aCompositionString,aTextRangeList,aReply); } NS_IMETHODIMP diff --git a/mozilla/editor/base/nsTextEditor.h b/mozilla/editor/base/nsTextEditor.h index f31512e457d..b1db7393bf3 100644 --- a/mozilla/editor/base/nsTextEditor.h +++ b/mozilla/editor/base/nsTextEditor.h @@ -114,7 +114,7 @@ public: // Input/Output NS_IMETHOD BeginComposition(void); - NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIDOMTextRangeList* aRangeList); + NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aRangeList, nsTextEventReply* aReply); NS_IMETHOD EndComposition(void); NS_IMETHOD OutputToString(nsString& aOutputString, diff --git a/mozilla/editor/libeditor/base/IMETextTxn.cpp b/mozilla/editor/libeditor/base/IMETextTxn.cpp index 081de15ccd8..61d60160d96 100644 --- a/mozilla/editor/libeditor/base/IMETextTxn.cpp +++ b/mozilla/editor/libeditor/base/IMETextTxn.cpp @@ -20,8 +20,7 @@ #include "IMECommitTxn.h" #include "nsEditor.h" #include "nsIDOMCharacterData.h" -#include "nsIDOMTextRange.h" -#include "nsIDOMTextRangeList.h" +#include "nsIPrivateTextRange.h" #include "nsIDOMSelection.h" #include "nsIPresShell.h" #include "EditAggregateTxn.h" @@ -50,7 +49,7 @@ IMETextTxn::~IMETextTxn() NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement, PRUint32 aOffset, PRUint32 aReplaceLength, - nsIDOMTextRangeList* aTextRangeList, + nsIPrivateTextRangeList* aTextRangeList, const nsString &aStringToInsert, nsIPresShell *aPresShell) { @@ -143,7 +142,7 @@ NS_IMETHODIMP IMETextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) // // we absorbe the next IME transaction by adopting it's insert string as our own // - nsIDOMTextRangeList* newTextRangeList; + nsIPrivateTextRangeList* newTextRangeList; otherTxn->GetData(mStringToInsert,&newTextRangeList); mRangeList = do_QueryInterface(newTextRangeList); *aDidMerge = PR_TRUE; @@ -218,7 +217,7 @@ IMETextTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr) /* ============ protected methods ================== */ -NS_IMETHODIMP IMETextTxn::GetData(nsString& aResult,nsIDOMTextRangeList** aTextRangeList) +NS_IMETHODIMP IMETextTxn::GetData(nsString& aResult,nsIPrivateTextRangeList** aTextRangeList) { aResult = mStringToInsert; *aTextRangeList = mRangeList; @@ -231,7 +230,7 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void) PRBool haveSelectedRange, haveCaretPosition; PRUint16 textRangeListLength,selectionStart,selectionEnd, textRangeType, caretPosition, i; - nsIDOMTextRange* textRange; + nsIPrivateTextRange* textRange; haveSelectedRange = PR_FALSE; haveCaretPosition = PR_FALSE; @@ -239,19 +238,19 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void) #ifdef DEBUG_tague PRUint16 listlen,start,stop,type; - nsIDOMTextRange* rangePtr; + nsIPrivateTextRange* rangePtr; result = mRangeList->GetLength(&listlen); - printf("nsIDOMTextRangeList[%p]\n",mRangeList); + printf("nsIPrivateTextRangeList[%p]\n",mRangeList); for (i=0;iItem(i,&rangePtr); rangePtr->GetRangeStart(&start); rangePtr->GetRangeEnd(&stop); rangePtr->GetRangeType(&type); printf("range[%d] start=%d end=%d type=",i,start,stop,type); - if (type==nsIDOMTextRange::TEXTRANGE_RAWINPUT) printf("TEXTRANGE_RAWINPUT\n"); - if (type==nsIDOMTextRange::TEXTRANGE_SELECTEDRAWTEXT) printf("TEXTRANGE_SELECTEDRAWTEXT\n"); - if (type==nsIDOMTextRange::TEXTRANGE_CONVERTEDTEXT) printf("TEXTRANGE_CONVERTEDTEXT\n"); - if (type==nsIDOMTextRange::TEXTRANGE_SELECTEDCONVERTEDTEXT) printf("TEXTRANGE_SELECTEDCONVERTEDTEXT\n"); + if (type==nsIPrivateTextRange::TEXTRANGE_RAWINPUT) printf("TEXTRANGE_RAWINPUT\n"); + if (type==nsIPrivateTextRange::TEXTRANGE_SELECTEDRAWTEXT) printf("TEXTRANGE_SELECTEDRAWTEXT\n"); + if (type==nsIPrivateTextRange::TEXTRANGE_CONVERTEDTEXT) printf("TEXTRANGE_CONVERTEDTEXT\n"); + if (type==nsIPrivateTextRange::TEXTRANGE_SELECTEDCONVERTEDTEXT) printf("TEXTRANGE_SELECTEDCONVERTEDTEXT\n"); } #endif @@ -266,13 +265,13 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void) if (NS_SUCCEEDED(result)) { result = textRange->GetRangeType(&textRangeType); - if (textRangeType==nsIDOMTextRange::TEXTRANGE_SELECTEDCONVERTEDTEXT) + if (textRangeType==nsIPrivateTextRange::TEXTRANGE_SELECTEDCONVERTEDTEXT) { haveSelectedRange = PR_TRUE; textRange->GetRangeStart(&selectionStart); textRange->GetRangeEnd(&selectionEnd); } - if (textRangeType==nsIDOMTextRange::TEXTRANGE_CARETPOSITION) + if (textRangeType==nsIPrivateTextRange::TEXTRANGE_CARETPOSITION) { haveCaretPosition = PR_TRUE; textRange->GetRangeStart(&caretPosition); diff --git a/mozilla/editor/libeditor/base/IMETextTxn.h b/mozilla/editor/libeditor/base/IMETextTxn.h index fea487a3318..6882505237b 100644 --- a/mozilla/editor/libeditor/base/IMETextTxn.h +++ b/mozilla/editor/libeditor/base/IMETextTxn.h @@ -21,7 +21,7 @@ #include "EditTxn.h" #include "nsIDOMCharacterData.h" -#include "nsIDOMTextRangeList.h" +#include "nsIPrivateTextRange.h" #include "nsCOMPtr.h" // {D4D25721-2813-11d3-9EA3-0060089FE59B} @@ -59,7 +59,7 @@ public: NS_IMETHOD Init(nsIDOMCharacterData *aElement, PRUint32 aOffset, PRUint32 aReplaceLength, - nsIDOMTextRangeList* aTextRangeList, + nsIPrivateTextRangeList* aTextRangeList, const nsString& aString, nsIPresShell* aPresShell); @@ -87,7 +87,7 @@ public: NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); /** return the string data associated with this transaction */ - NS_IMETHOD GetData(nsString& aResult, nsIDOMTextRangeList** aTextRangeList); + NS_IMETHOD GetData(nsString& aResult, nsIPrivateTextRangeList** aTextRangeList); /** must be called before any IMETextTxn is instantiated */ static nsresult ClassInit(); @@ -109,7 +109,7 @@ protected: nsString mStringToInsert; /** the range list **/ - nsCOMPtr mRangeList; + nsCOMPtr mRangeList; /** the presentation shell, which we'll need to get the selection */ nsIPresShell* mPresShell; diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index ca573c5f251..6497e9026f9 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -3728,11 +3728,15 @@ nsEditor::EndComposition(void) } NS_IMETHODIMP -nsEditor::SetCompositionString(const nsString& aCompositionString, nsIDOMTextRangeList* aTextRangeList) +nsEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply) { + nsCOMPtr caretP; nsresult result = SetInputMethodText(aCompositionString,aTextRangeList); mIMEBufferLength = aCompositionString.Length(); + mPresShell->GetCaret(getter_AddRefs(caretP)); + caretP->GetWindowRelativeCoordinates(aReply->mCursorPosition,aReply->mCursorIsCollapsed); + return result; } @@ -3910,7 +3914,7 @@ nsEditor::GetFirstTextNode(nsIDOMNode *aNode, nsIDOMNode **aRetNode) //END nsEditor Private methods NS_IMETHODIMP -nsEditor::SetInputMethodText(const nsString& aStringToInsert,nsIDOMTextRangeList *aTextRangeList) +nsEditor::SetInputMethodText(const nsString& aStringToInsert,nsIPrivateTextRangeList *aTextRangeList) { IMETextTxn *txn; nsresult result; @@ -3962,7 +3966,7 @@ nsEditor::SetInputMethodText(const nsString& aStringToInsert,nsIDOMTextRangeList NS_IMETHODIMP nsEditor::CreateTxnForIMEText(const nsString & aStringToInsert, - nsIDOMTextRangeList* aTextRangeList, + nsIPrivateTextRangeList* aTextRangeList, IMETextTxn ** aTxn) { nsresult result; @@ -4011,7 +4015,7 @@ nsEditor::CreateTxnForRemoveStyleSheet(nsICSSStyleSheet* aSheet, RemoveStyleShee -NS_IMETHODIMP nsEditor::DoInitialInputMethodInsert(const nsString & aStringToInsert,nsIDOMTextRangeList* aTextRangeList) +NS_IMETHODIMP nsEditor::DoInitialInputMethodInsert(const nsString & aStringToInsert,nsIPrivateTextRangeList* aTextRangeList) { if (!mDoc) { return NS_ERROR_NOT_INITIALIZED; diff --git a/mozilla/editor/libeditor/base/nsEditor.h b/mozilla/editor/libeditor/base/nsEditor.h index 25511d47329..5cfb343a4b5 100644 --- a/mozilla/editor/libeditor/base/nsEditor.h +++ b/mozilla/editor/libeditor/base/nsEditor.h @@ -26,7 +26,7 @@ #include "nsIDOMCharacterData.h" #include "nsIDOMEventListener.h" #include "nsIDOMRange.h" -#include "nsIDOMTextRangeList.h" +#include "nsIPrivateTextRange.h" #include "nsCOMPtr.h" #include "nsIStringBundle.h" #include "nsITransactionManager.h" @@ -185,7 +185,7 @@ public: NS_IMETHOD BeginComposition(void); - NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIDOMTextRangeList* aTextRangeList); + NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList, nsTextEventReply *aReply); NS_IMETHOD EndComposition(void); @@ -316,7 +316,7 @@ protected: InsertTextTxn ** aTxn); NS_IMETHOD CreateTxnForIMEText(const nsString & aStringToInsert, - nsIDOMTextRangeList* aTextRangeList, + nsIPrivateTextRangeList* aTextRangeList, IMETextTxn ** aTxn); /** create a transaction for adding a style sheet @@ -334,7 +334,7 @@ protected: */ NS_IMETHOD DoInitialInsert(const nsString & aStringToInsert); - NS_IMETHOD DoInitialInputMethodInsert(const nsString& aStringToInsert,nsIDOMTextRangeList* aTextRangeList); + NS_IMETHOD DoInitialInputMethodInsert(const nsString& aStringToInsert,nsIPrivateTextRangeList* aTextRangeList); NS_IMETHOD DeleteText(nsIDOMCharacterData *aElement, @@ -373,7 +373,7 @@ protected: NS_IMETHOD DebugDumpContent() const; - NS_IMETHOD SetInputMethodText(const nsString& aStringToInsert, nsIDOMTextRangeList* aTextRangeList); + NS_IMETHOD SetInputMethodText(const nsString& aStringToInsert, nsIPrivateTextRangeList* aTextRangeList); // called each time we modify the document. Increments the mod // count of the doc. diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index 8a256ad9481..872746ba674 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -2768,9 +2768,9 @@ NS_IMETHODIMP nsHTMLEditor::EndComposition(void) return nsTextEditor::EndComposition(); } -NS_IMETHODIMP nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIDOMTextRangeList* aTextRangeList) +NS_IMETHODIMP nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList, nsTextEventReply* aReply) { - return nsTextEditor::SetCompositionString(aCompositionString,aTextRangeList); + return nsTextEditor::SetCompositionString(aCompositionString,aTextRangeList,aReply); } NS_IMETHODIMP diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.h b/mozilla/editor/libeditor/html/nsHTMLEditor.h index b065b50ef4f..38807d25970 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.h +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.h @@ -106,7 +106,7 @@ public: NS_IMETHOD InsertHTML(const nsString& aInputString); NS_IMETHOD BeginComposition(void); - NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIDOMTextRangeList* aTextRange); + NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRange, nsTextEventReply* aReply); NS_IMETHOD EndComposition(void); NS_IMETHOD OutputToString(nsString& aOutputString, diff --git a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp index 6cbe2f036a6..a280e5a66fe 100644 --- a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp +++ b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp @@ -30,6 +30,7 @@ #include "nsIStringStream.h" #include "nsIDOMUIEvent.h" #include "nsIDOMNSUIEvent.h" +#include "nsIPrivateTextEvent.h" // for testing only #include "nsIHTMLEditor.h" @@ -1035,19 +1036,21 @@ nsTextEditorTextListener::HandleText(nsIDOMEvent* aTextEvent) { nsString composedText; nsresult result; - nsCOMPtruiEvent; - nsIDOMTextRangeList *textRangeList; + nsCOMPtr textEvent; + nsIPrivateTextRangeList *textRangeList; + nsTextEventReply *textEventReply; - uiEvent = do_QueryInterface(aTextEvent); - if (!uiEvent) { + textEvent = do_QueryInterface(aTextEvent); + if (!textEvent) { //non-ui event passed in. bad things. return NS_OK; } - uiEvent->GetText(composedText); - uiEvent->GetInputRange(&textRangeList); + textEvent->GetText(composedText); + textEvent->GetInputRange(&textRangeList); + textEvent->GetEventReply(&textEventReply); textRangeList->AddRef(); - result = mEditor->SetCompositionString(composedText,textRangeList); + result = mEditor->SetCompositionString(composedText,textRangeList,textEventReply); return result; } diff --git a/mozilla/editor/public/nsIEditor.h b/mozilla/editor/public/nsIEditor.h index 8cca073f003..dd4404dc45f 100644 --- a/mozilla/editor/public/nsIEditor.h +++ b/mozilla/editor/public/nsIEditor.h @@ -27,7 +27,7 @@ class nsIDOMNode; class nsITransaction; class nsIEditActionListener; class nsIFileSpec; -class nsIDOMTextRangeList; +class nsIPrivateTextRangeList; class nsICSSStyleSheet; class nsIOutputStream; class nsIDocumentStateListener; @@ -35,7 +35,7 @@ class nsIDOMDocument; class nsIDOMSelection; class nsIPresShell; class nsString; - +struct nsTextEventReply; /* Editor interface to outside world */ @@ -203,7 +203,7 @@ public: * BeginComposition must be called prior to this. */ - NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIDOMTextRangeList* aTextRangeList) = 0; + NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList, nsTextEventReply* aReply) = 0; /** * BeginComposition() Handles the end of inline input composition. diff --git a/mozilla/editor/public/nsIHTMLEditor.h b/mozilla/editor/public/nsIHTMLEditor.h index 9ee08180e54..faf10054cad 100644 --- a/mozilla/editor/public/nsIHTMLEditor.h +++ b/mozilla/editor/public/nsIHTMLEditor.h @@ -36,6 +36,7 @@ class nsIAtom; class nsIOutputStream; class nsIDOMWindow; class nsIFileSpec; +struct nsTextEventReply; /** * The HTML editor interface. @@ -362,7 +363,7 @@ public: // IME editing Methods NS_IMETHOD BeginComposition(void)=0; - NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIDOMTextRangeList* aTextRangeList)=0; + NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply *aReply)=0; NS_IMETHOD EndComposition(void)=0; diff --git a/mozilla/editor/public/nsITextEditor.h b/mozilla/editor/public/nsITextEditor.h index c865601b447..a2a77193fe3 100644 --- a/mozilla/editor/public/nsITextEditor.h +++ b/mozilla/editor/public/nsITextEditor.h @@ -377,7 +377,7 @@ public: // IME Editing Methods NS_IMETHOD BeginComposition(void)=0; - NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIDOMTextRangeList* aTextRangeList)=0; + NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList, nsTextEventReply* aReply)=0; NS_IMETHOD EndComposition(void)=0; diff --git a/mozilla/layout/events/public/MANIFEST b/mozilla/layout/events/public/MANIFEST index 4a0bd33a190..df7b989f7f9 100644 --- a/mozilla/layout/events/public/MANIFEST +++ b/mozilla/layout/events/public/MANIFEST @@ -3,4 +3,6 @@ # nsIEventListenerManager.h nsIEventStateManager.h -nsIPrivateDOMEvent.h \ No newline at end of file +nsIPrivateDOMEvent.h +nsIPrivateTextEvent.h +nsIPrivateTextRange.h diff --git a/mozilla/layout/events/public/Makefile.in b/mozilla/layout/events/public/Makefile.in index a1bebfe1205..6df90bf3fca 100644 --- a/mozilla/layout/events/public/Makefile.in +++ b/mozilla/layout/events/public/Makefile.in @@ -28,6 +28,8 @@ EXPORTS = \ nsIEventListenerManager.h \ nsIEventStateManager.h \ nsIPrivateDOMEvent.h \ + nsIPrivateTextEvent.h \ + nsIPrivateTextRange.h \ $(NULL) EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) diff --git a/mozilla/layout/events/public/makefile.win b/mozilla/layout/events/public/makefile.win index 51c3e4d81d9..7087cf535f1 100644 --- a/mozilla/layout/events/public/makefile.win +++ b/mozilla/layout/events/public/makefile.win @@ -22,6 +22,8 @@ EXPORTS = \ nsIEventListenerManager.h \ nsIEventStateManager.h \ nsIPrivateDOMEvent.h \ + nsIPrivateTextEvent.h \ + nsIPrivateTextRange.h \ $(NULL) MODULE=raptor diff --git a/mozilla/layout/events/public/nsIPrivateTextEvent.h b/mozilla/layout/events/public/nsIPrivateTextEvent.h new file mode 100644 index 00000000000..baf75fcd85f --- /dev/null +++ b/mozilla/layout/events/public/nsIPrivateTextEvent.h @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIPrivateTextEvent_h__ +#define nsIPrivateTextEvent_h__ + +#include "nsGUIEvent.h" +#include "nsISupports.h" +#include "nsIPrivateTextRange.h" + +#define NS_IPRIVATETEXTEVENT_IID \ +{ /* 37B69251-4ACE-11d3-9EA6-0060089FE59B */ \ +0x37b69251, 0x4ace, 0x11d3, \ +{0x9e, 0xa6, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b} } + +class nsIPrivateTextEvent : public nsISupports { + +public: + static const nsIID& GetIID() { static nsIID iid = NS_IPRIVATETEXTEVENT_IID; return iid; } + + NS_IMETHOD GetText(nsString& aText) = 0; + NS_IMETHOD GetInputRange(nsIPrivateTextRangeList** aInputRange) = 0; + NS_IMETHOD GetEventReply(nsTextEventReply** aReply) = 0; +}; + +#endif // nsIPrivateTextEvent_h__ + diff --git a/mozilla/layout/events/public/nsIPrivateTextRange.h b/mozilla/layout/events/public/nsIPrivateTextRange.h new file mode 100644 index 00000000000..02486b8c4b0 --- /dev/null +++ b/mozilla/layout/events/public/nsIPrivateTextRange.h @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIPrivateTextRange_h__ +#define nsIPrivateTextRange_h__ + +#include "nsISupports.h" +#include "nsString.h" + +#define NS_IPRIVATETEXTRANGE_IID \ +{0xb471ab41, 0x2a79, 0x11d3, \ +{ 0x9e, 0xa4, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b } } + +class nsIPrivateTextRange : public nsISupports { +public: + static const nsIID& GetIID() { static nsIID iid = NS_IPRIVATETEXTRANGE_IID; return iid; } + enum { + TEXTRANGE_CARETPOSITION = 1, + TEXTRANGE_RAWINPUT = 2, + TEXTRANGE_SELECTEDRAWTEXT = 3, + TEXTRANGE_CONVERTEDTEXT = 4, + TEXTRANGE_SELECTEDCONVERTEDTEXT = 5 + }; + + NS_IMETHOD GetRangeStart(PRUint16* aRangeStart)=0; + NS_IMETHOD SetRangeStart(PRUint16 aRangeStart)=0; + + NS_IMETHOD GetRangeEnd(PRUint16* aRangeEnd)=0; + NS_IMETHOD SetRangeEnd(PRUint16 aRangeEnd)=0; + + NS_IMETHOD GetRangeType(PRUint16* aRangeType)=0; + NS_IMETHOD SetRangeType(PRUint16 aRangeType)=0; +}; + +#define NS_IPRIVATETEXTRANGELIST_IID \ +{ 0x1ee9d531, 0x2a79, 0x11d3, \ +{ 0x9e, 0xa4, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b} } + +class nsIPrivateTextRangeList : public nsISupports { +public: + static const nsIID& GetIID() { static nsIID iid = NS_IPRIVATETEXTRANGELIST_IID; return iid; } + + NS_IMETHOD GetLength(PRUint16* aLength)=0; + NS_IMETHOD Item(PRUint16 aIndex, nsIPrivateTextRange** aReturn)=0; +}; + +#endif // nsIPrivateTextRange_h__ diff --git a/mozilla/layout/events/src/Makefile.in b/mozilla/layout/events/src/Makefile.in index b23c83d1028..ee1dfafa3b7 100644 --- a/mozilla/layout/events/src/Makefile.in +++ b/mozilla/layout/events/src/Makefile.in @@ -31,7 +31,7 @@ CPPSRCS = \ nsEventStateManager.cpp \ nsDOMEvent.cpp \ nsDOMEventsIIDs.cpp \ - nsDOMTextRange.cpp \ + nsPrivateTextRange.cpp \ $(NULL) MODULE=layout @@ -41,7 +41,7 @@ EXPORTS = \ nsEventStateManager.h \ nsDOMEvent.h \ nsDOMEventsIIDs.h \ - nsDOMTextRange.h \ + nsPrivateTextRange.h \ $(NULL) EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) diff --git a/mozilla/layout/events/src/makefile.win b/mozilla/layout/events/src/makefile.win index 7785b222c46..626c0a7bded 100644 --- a/mozilla/layout/events/src/makefile.win +++ b/mozilla/layout/events/src/makefile.win @@ -30,18 +30,18 @@ CPPSRCS= nsEventListenerManager.cpp \ nsEventStateManager.cpp \ nsDOMEvent.cpp \ nsDOMEventsIIDs.cpp \ - nsDOMTextRange.cpp \ + nsPrivateTextRange.cpp \ $(NULL) CPP_OBJS= .\$(OBJDIR)\nsEventListenerManager.obj \ .\$(OBJDIR)\nsEventStateManager.obj \ .\$(OBJDIR)\nsDOMEvent.obj \ .\$(OBJDIR)\nsDOMEventsIIDs.obj \ - .\$(OBJDIR)\nsDOMTextRange.obj \ + .\$(OBJDIR)\nsPrivateTextRange.obj \ $(NULL) -EXPORTS= nsEventListenerManager.h nsEventStateManager.h nsDOMEvent.h nsDOMEventsIIDs.h nsDOMTextRange.h +EXPORTS= nsEventListenerManager.h nsEventStateManager.h nsDOMEvent.h nsDOMEventsIIDs.h nsPrivateTextRange.h LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \ -I$(PUBLIC)\dom -I$(PUBLIC)\js -I..\..\html\base\src -I$(PUBLIC)\netlib diff --git a/mozilla/layout/events/src/nsDOMEvent.cpp b/mozilla/layout/events/src/nsDOMEvent.cpp index d0f8bd2b0f8..cf5c2fdf179 100644 --- a/mozilla/layout/events/src/nsDOMEvent.cpp +++ b/mozilla/layout/events/src/nsDOMEvent.cpp @@ -26,7 +26,7 @@ #include "nsIWidget.h" #include "nsIWebShell.h" #include "nsIPresShell.h" -#include "nsDOMTextRange.h" +#include "nsPrivateTextRange.h" #include "nsIDocument.h" static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID); @@ -36,6 +36,7 @@ static NS_DEFINE_IID(kIDOMEventIID, NS_IDOMEVENT_IID); static NS_DEFINE_IID(kIDOMUIEventIID, NS_IDOMUIEVENT_IID); static NS_DEFINE_IID(kIDOMNSUIEventIID, NS_IDOMNSUIEVENT_IID); static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID); +static NS_DEFINE_IID(kIPrivateTextEventIID, NS_IPRIVATETEXTEVENT_IID); static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); static char* mEventNames[] = { @@ -63,19 +64,19 @@ nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent) { // build the range list -- ranges need to be DOM-ified since the IME transaction // will hold a ref, the widget representation isn't persistent // - nsIDOMTextRange** tempTextRangeList = new nsIDOMTextRange*[((nsTextEvent*)aEvent)->rangeCount]; + nsIPrivateTextRange** tempTextRangeList = new nsIPrivateTextRange*[((nsTextEvent*)aEvent)->rangeCount]; if (tempTextRangeList!=nsnull) { for(PRUint16 i=0;i<((nsTextEvent*)aEvent)->rangeCount;i++) { - nsDOMTextRange* tempDOMTextRange = new nsDOMTextRange((((nsTextEvent*)aEvent)->rangeArray[i]).mStartOffset, + nsPrivateTextRange* tempPrivateTextRange = new nsPrivateTextRange((((nsTextEvent*)aEvent)->rangeArray[i]).mStartOffset, (((nsTextEvent*)aEvent)->rangeArray[i]).mEndOffset, (((nsTextEvent*)aEvent)->rangeArray[i]).mRangeType); - if (tempDOMTextRange!=nsnull) { - tempDOMTextRange->AddRef(); - tempTextRangeList[i] = (nsIDOMTextRange*)tempDOMTextRange; + if (tempPrivateTextRange!=nsnull) { + tempPrivateTextRange->AddRef(); + tempTextRangeList[i] = (nsIPrivateTextRange*)tempPrivateTextRange; } } - mTextRange = (nsIDOMTextRangeList*) new nsDOMTextRangeList(((nsTextEvent*)aEvent)->rangeCount,tempTextRangeList); + mTextRange = (nsIPrivateTextRangeList*) new nsPrivateTextRangeList(((nsTextEvent*)aEvent)->rangeCount,tempTextRangeList); if (mTextRange!=nsnull) mTextRange->AddRef(); } } @@ -122,6 +123,11 @@ nsresult nsDOMEvent::QueryInterface(const nsIID& aIID, AddRef(); return NS_OK; } + if (aIID.Equals(kIPrivateTextEventIID)) { + *aInstancePtrResult=(void*)((nsIPrivateTextEvent*)this); + AddRef(); + return NS_OK; + } return NS_NOINTERFACE; } @@ -243,7 +249,7 @@ NS_METHOD nsDOMEvent::GetText(nsString& aText) return NS_ERROR_FAILURE; } -NS_METHOD nsDOMEvent::GetInputRange(nsIDOMTextRangeList** aInputRange) +NS_METHOD nsDOMEvent::GetInputRange(nsIPrivateTextRangeList** aInputRange) { if (mEvent->message == NS_TEXT_EVENT) { *aInputRange = mTextRange; @@ -253,8 +259,13 @@ NS_METHOD nsDOMEvent::GetInputRange(nsIDOMTextRangeList** aInputRange) return NS_ERROR_FAILURE; } -NS_METHOD nsDOMEvent::SetInputRange(nsIDOMTextRangeList* aInputRange) +NS_METHOD nsDOMEvent::GetEventReply(nsTextEventReply** aReply) { + if (mEvent->message==NS_TEXT_EVENT) { + *aReply = &(((nsTextEvent*)mEvent)->theReply); + return NS_OK; + } + return NS_ERROR_FAILURE; } diff --git a/mozilla/layout/events/src/nsDOMEvent.h b/mozilla/layout/events/src/nsDOMEvent.h index 2bbce70517c..90fc2994ff2 100644 --- a/mozilla/layout/events/src/nsDOMEvent.h +++ b/mozilla/layout/events/src/nsDOMEvent.h @@ -23,6 +23,8 @@ #include "nsIDOMNSUIEvent.h" #include "nsISupports.h" #include "nsIPrivateDOMEvent.h" +#include "nsIPrivateTextEvent.h" +#include "nsIPrivateTextRange.h" #include "nsIPresContext.h" #include "nsPoint.h" @@ -31,7 +33,7 @@ class nsIContent; class nsIDOMRenderingContext; -class nsDOMEvent : public nsIDOMUIEvent, public nsIDOMNSUIEvent, public nsIPrivateDOMEvent { +class nsDOMEvent : public nsIDOMUIEvent, public nsIDOMNSUIEvent, public nsIPrivateDOMEvent, public nsIPrivateTextEvent { public: // Note: this enum must be kept in sync with mEventNames in nsDOMEvent.cpp @@ -82,12 +84,6 @@ public: NS_IMETHOD PreventDefault(); - NS_IMETHOD GetText(nsString& aText); - - NS_IMETHOD GetInputRange(nsIDOMTextRangeList** aInputRange); - - NS_IMETHOD SetInputRange(nsIDOMTextRangeList* aInputRange); - NS_IMETHOD GetScreenX(PRInt32* aScreenX); NS_IMETHOD GetScreenY(PRInt32* aScreenY); @@ -133,15 +129,20 @@ public: NS_IMETHOD DuplicatePrivateData(); NS_IMETHOD SetTarget(nsIDOMNode* aNode); + // nsIPrivateTextEvent interface + NS_IMETHOD GetText(nsString& aText); + NS_IMETHOD GetInputRange(nsIPrivateTextRangeList** aInputRange); + NS_IMETHOD GetEventReply(nsTextEventReply** aReply); + + protected: nsEvent* mEvent; nsIPresContext* mPresContext; nsIDOMNode* mTarget; nsString* mText; - nsIDOMTextRangeList* mTextRange; + nsIPrivateTextRangeList* mTextRange; const char* GetEventName(PRUint32 aEventType); - }; #endif // nsDOMEvent_h__ diff --git a/mozilla/layout/events/src/nsPrivateTextRange.cpp b/mozilla/layout/events/src/nsPrivateTextRange.cpp new file mode 100644 index 00000000000..6820b20eace --- /dev/null +++ b/mozilla/layout/events/src/nsPrivateTextRange.cpp @@ -0,0 +1,150 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsPrivateTextRange.h" + +static NS_DEFINE_IID(kIPrivateTextRange, NS_IPRIVATETEXTRANGE_IID); +static NS_DEFINE_IID(kIPrivateTextRangeList,NS_IPRIVATETEXTRANGELIST_IID); + +nsPrivateTextRange::nsPrivateTextRange(PRUint16 aRangeStart, PRUint16 aRangeEnd, PRUint16 aRangeType) +: mRangeStart(aRangeStart), + mRangeEnd(aRangeEnd), + mRangeType(aRangeType) +{ + NS_INIT_REFCNT(); +} + +nsPrivateTextRange::~nsPrivateTextRange(void) +{ + +} + +NS_IMPL_ADDREF(nsPrivateTextRange) +NS_IMPL_RELEASE(nsPrivateTextRange) + +nsresult nsPrivateTextRange::QueryInterface(const nsIID& aIID, + void** aInstancePtrResult) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + if (aIID.Equals(kIPrivateTextRange)) { + *aInstancePtrResult = (void*) ((nsIPrivateTextRange*)this); + AddRef(); + return NS_OK; + } + + return NS_NOINTERFACE; +} + +NS_METHOD nsPrivateTextRange::GetRangeStart(PRUint16* aRangeStart) +{ + *aRangeStart = mRangeStart; + return NS_OK; +} + +NS_METHOD nsPrivateTextRange::SetRangeStart(PRUint16 aRangeStart) +{ + mRangeStart = aRangeStart; + return NS_OK; +} + +NS_METHOD nsPrivateTextRange::GetRangeEnd(PRUint16* aRangeEnd) +{ + *aRangeEnd = mRangeEnd; + return NS_OK; +} + +NS_METHOD nsPrivateTextRange::SetRangeEnd(PRUint16 aRangeEnd) +{ + mRangeEnd = aRangeEnd; + return NS_OK; +} + +NS_METHOD nsPrivateTextRange::GetRangeType(PRUint16* aRangeType) +{ + *aRangeType = mRangeType; + return NS_OK; +} + +NS_METHOD nsPrivateTextRange::SetRangeType(PRUint16 aRangeType) +{ + mRangeType = aRangeType; + return NS_OK; +} + + +nsPrivateTextRangeList::nsPrivateTextRangeList(PRUint16 aLength,nsIPrivateTextRange** aList) +: mLength(aLength), + mList(aList) +{ + if (aList==nsnull) + aLength = 0; + + NS_INIT_REFCNT(); +} + +nsPrivateTextRangeList::~nsPrivateTextRangeList(void) +{ + int i; + for(i=0;iRelease(); +} + +NS_IMPL_ADDREF(nsPrivateTextRangeList) +NS_IMPL_RELEASE(nsPrivateTextRangeList) + +nsresult nsPrivateTextRangeList::QueryInterface(const nsIID& aIID, + void** aInstancePtrResult) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + if (aIID.Equals(kIPrivateTextRangeList)) { + *aInstancePtrResult = (void*) ((nsIPrivateTextRangeList*)this); + AddRef(); + return NS_OK; + } + + return NS_NOINTERFACE; +} + +NS_METHOD nsPrivateTextRangeList::GetLength(PRUint16* aLength) +{ + *aLength = mLength; + return NS_OK; +} + +NS_METHOD nsPrivateTextRangeList::Item(PRUint16 aIndex, nsIPrivateTextRange** aReturn) +{ + if (aIndex>mLength) { + *aReturn = nsnull; + return NS_ERROR_FAILURE; + } + + mList[aIndex]->AddRef(); + *aReturn = mList[aIndex]; + + return NS_OK; +} + + + + diff --git a/mozilla/layout/events/src/nsPrivateTextRange.h b/mozilla/layout/events/src/nsPrivateTextRange.h new file mode 100644 index 00000000000..6dae836b92a --- /dev/null +++ b/mozilla/layout/events/src/nsPrivateTextRange.h @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsPrivateTextRange_h__ +#define nsPrivateTextRange_h__ + +#include "nsIPrivateTextRange.h" + +class nsPrivateTextRange : public nsIPrivateTextRange +{ + NS_DECL_ISUPPORTS +public: + + nsPrivateTextRange(PRUint16 aRangeStart, PRUint16 aRangeEnd, PRUint16 aRangeType); + virtual ~nsPrivateTextRange(void); + + NS_IMETHOD GetRangeStart(PRUint16* aRangeStart); + NS_IMETHOD SetRangeStart(PRUint16 aRangeStart); + + NS_IMETHOD GetRangeEnd(PRUint16* aRangeEnd); + NS_IMETHOD SetRangeEnd(PRUint16 aRangeEnd); + + NS_IMETHOD GetRangeType(PRUint16* aRangeType); + NS_IMETHOD SetRangeType(PRUint16 aRangeType); + +protected: + + PRUint16 mRangeStart; + PRUint16 mRangeEnd; + PRUint16 mRangeType; +}; + +class nsPrivateTextRangeList: public nsIPrivateTextRangeList +{ + NS_DECL_ISUPPORTS +public: + + nsPrivateTextRangeList(PRUint16 aLength,nsIPrivateTextRange** aList); + virtual ~nsPrivateTextRangeList(void); + + NS_IMETHOD GetLength(PRUint16* aLength); + + NS_IMETHOD Item(PRUint16 aIndex, nsIPrivateTextRange** aReturn); + +protected: + + PRUint16 mLength; + nsIPrivateTextRange** mList; +}; + + +#endif