Added support for replies from private DOM text events. See bug #4826

This commit is contained in:
tague%netscape.com 1999-08-06 02:32:13 +00:00
Родитель 6518c2f859
Коммит 1e3c4f5ac5
45 изменённых файлов: 822 добавлений и 521 удалений

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

@ -3,4 +3,6 @@
#
nsIEventListenerManager.h
nsIEventStateManager.h
nsIPrivateDOMEvent.h
nsIPrivateDOMEvent.h
nsIPrivateTextEvent.h
nsIPrivateTextRange.h

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

@ -28,6 +28,8 @@ EXPORTS = \
nsIEventListenerManager.h \
nsIEventStateManager.h \
nsIPrivateDOMEvent.h \
nsIPrivateTextEvent.h \
nsIPrivateTextRange.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

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

@ -22,6 +22,8 @@ EXPORTS = \
nsIEventListenerManager.h \
nsIEventStateManager.h \
nsIPrivateDOMEvent.h \
nsIPrivateTextEvent.h \
nsIPrivateTextRange.h \
$(NULL)
MODULE=raptor

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

@ -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__

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

@ -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__

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

@ -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))

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

@ -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

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

@ -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;
}

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

@ -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__

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

@ -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;i<mLength;i++)
mList[i]->Release();
}
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;
}

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

@ -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

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

@ -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;i<listlen;i++) {
(void)mRangeList->Item(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);

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

@ -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<nsIDOMTextRangeList> mRangeList;
nsCOMPtr<nsIPrivateTextRangeList> mRangeList;
/** the presentation shell, which we'll need to get the selection */
nsIPresShell* mPresShell;

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

@ -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<nsICaret> 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;

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

@ -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.

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

@ -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;
nsCOMPtr<nsIDOMUIEvent>uiEvent;
nsIDOMTextRangeList *textRangeList;
nsCOMPtr<nsIPrivateTextEvent> 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;
}

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

@ -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

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

@ -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,

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

@ -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;
}

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

@ -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();

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

@ -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

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

@ -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,

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

@ -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;i<listlen;i++) {
(void)mRangeList->Item(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);

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

@ -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<nsIDOMTextRangeList> mRangeList;
nsCOMPtr<nsIPrivateTextRangeList> mRangeList;
/** the presentation shell, which we'll need to get the selection */
nsIPresShell* mPresShell;

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

@ -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<nsICaret> 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;

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

@ -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.

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

@ -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

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

@ -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,

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

@ -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;
nsCOMPtr<nsIDOMUIEvent>uiEvent;
nsIDOMTextRangeList *textRangeList;
nsCOMPtr<nsIPrivateTextEvent> 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;
}

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

@ -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.

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

@ -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;

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

@ -1,390 +0,0 @@
/* -*- 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")=0; 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 nsITextEditor_h__
#define nsITextEditor_h__
#define NS_ITEXTEDITOR_IID \
{/* afe65c90-bb82-11d2-86d8-000064657374*/ \
0xafe65c90, 0xbb82, 0x11d2, \
{0x8f, 0xd8, 0x0, 0x00, 0x64, 0x65, 0x73, 0x74} }
#include "nsIEditor.h"
#include "nscore.h"
class nsISupportsArray;
class nsIAtom;
class nsIOutputStream;
class nsString;
class nsIFileSpec;
#define TEXT_EDITOR_FLAG_PLAINTEXT 0x01 // only plain text entry is allowed via events
#define TEXT_EDITOR_FLAG_SINGLELINE 0x02 // enter key and CR-LF handled specially
#define TEXT_EDITOR_FLAG_PASSWORD 0x04 // text is not entered into content, only a representative character
#define TEXT_EDITOR_FLAG_READONLY 0x08 // editing events are disabled. Editor may still accept focus.
#define TEXT_EDITOR_FLAG_DISABLED 0x10 // all events are disabled (like scrolling). Editor will not accept focus.
#define TEXT_EDITOR_FLAG_FILTER 0x20 // text input is limited to certain character types, use mFilter
/**
* The general text editor interface.
* <P>
* Use to edit text represented as a DOM tree.
* This interface is used for both plain text and rich text (attributed text).
* Different types of text fields are instantiated as a result of installing the
* proper GUI Manager and Edit Rules. For example,
* a single line plain text editor is instantiated by using the SingleLinePlainTextGUIManager
* to limit UI and the SingleLinePlainTextEditRules to filter input and output.
*/
class nsITextEditor : public nsISupports
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_ITEXTEDITOR_IID; return iid; }
/** Initialize the text editor
* @param aDoc the document being edited. Cannot be changed after Init
* @param aPresShell the presentation shell displaying aDoc. Cannot be changed after Init
*/
NS_IMETHOD Init(nsIDOMDocument *aDoc,
nsIPresShell *aPresShell)=0;
/** return the edit flags for this editor */
NS_IMETHOD GetFlags(PRUint32 *aFlags)=0;
/** set the edit flags for this editor. May be called at any time. */
NS_IMETHOD SetFlags(PRUint32 aFlags)=0;
/** get the length of the document in characters */
NS_IMETHOD GetDocumentLength(PRInt32 *aCount)=0;
/**
* SetTextProperties() sets the aggregate properties on the current selection
*
* @param aProperty the property to set on the selection
* @param aAttribute the attribute of the property, if applicable. May be null.
* Example: aProperty="font", aAttribute="color"
* @param aValue if aAttribute is not null, the value of the attribute. May be null.
* Example: aProperty="font", aAttribute="color", aValue="0x00FFFF"
*/
NS_IMETHOD SetTextProperty(nsIAtom *aProperty,
const nsString *aAttribute,
const nsString *aValue)=0;
/**
* GetTextProperties() gets the aggregate properties of the current selection.
* All object in the current selection are scanned and their attributes are
* represented in a list of Property object.
*
* @param aProperty the property to get on the selection
* @param aAttribute the attribute of the property, if applicable. May be null.
* Example: aProperty="font", aAttribute="color"
* @param aValue if aAttribute is not null, the value of the attribute. May be null.
* Example: aProperty="font", aAttribute="color", aValue="0x00FFFF"
* @param aFirst [OUT] PR_TRUE if the first text node in the selection has the property
* @param aAny [OUT] PR_TRUE if any of the text nodes in the selection have the property
* @param aAll [OUT] PR_TRUE if all of the text nodes in the selection have the property
*/
NS_IMETHOD GetTextProperty(nsIAtom *aProperty,
const nsString *aAttribute,
const nsString *aValue,
PRBool &aFirst, PRBool &aAny, PRBool &aAll)=0;
/**
* RemoveTextProperties() deletes the properties from all text in the current selection.
* If aProperty is not set on the selection, nothing is done.
*
* @param aProperty the property to reomve from the selection
* @param aAttribute the attribute of the property, if applicable. May be null.
* Example: aProperty="font", aAttribute="color"
* nsIEditProperty::allAttributes is special. It indicates that
* all content-based text properties are to be removed from the selection.
*/
NS_IMETHOD RemoveTextProperty(nsIAtom *aProperty, const nsString *aAttribute)=0;
/**
* Set the background color of the the document background
*/
NS_IMETHOD SetBackgroundColor(const nsString& aColor)=0;
/**
* DeleteSelection removes all nodes in the current selection.
* @param aDir if eLTR, delete to the right (for example, the DEL key)
* if eRTL, delete to the left (for example, the BACKSPACE key)
*/
NS_IMETHOD DeleteSelection(nsIEditor::ECollapsedSelectionAction aAction)=0;
/**
* InsertText() Inserts a string at the current location, given by the selection.
* If the selection is not collapsed, the selection is deleted and the insertion
* takes place at the resulting collapsed selection.
* It is expected that this would be used for Paste.
*
* NOTE: what happens if the string contains a CR?
*
* @param aString the string to be inserted
*/
NS_IMETHOD InsertText(const nsString& aStringToInsert)=0;
/**
* SetMaxTextLength sets a limit on the number of characters the document is allowed to contain.
* Any text insertion will truncate the inserted string to respect this number
* It is somewhat expensive to set this property, so do so only when necessary.
* A value of -1 means there is no limit.
*/
NS_IMETHOD SetMaxTextLength(PRInt32 aMaxLength)=0;
/**
* The handler for the ENTER key.
* @see nsIEditor::InsertBreak
*/
NS_IMETHOD InsertBreak()=0;
/** turn the undo system on or off
* @param aEnable if PR_TRUE, the undo system is turned on if it is available
* if PR_FALSE the undo system is turned off if it was previously on
* @return if aEnable is PR_TRUE, returns NS_OK if the undo system could be initialized properly
* if aEnable is PR_FALSE, returns NS_OK.
*/
NS_IMETHOD EnableUndo(PRBool aEnable)=0;
/** Undo reverses the effects of the last Do operation, if Undo is enabled in the editor.
* It is provided here so clients need no knowledge of whether the editor has a transaction manager or not.
* If a transaction manager is present, it is told to undo and the result of
* that undo is returned.
* Otherwise, the Undo request is ignored and an error NS_ERROR_NOT_AVAILABLE is returned.
*
*/
NS_IMETHOD Undo(PRUint32 aCount)=0;
/** returns state information about the undo system.
* @param aIsEnabled [OUT] PR_TRUE if undo is enabled
* @param aCanUndo [OUT] PR_TRUE if at least one transaction is currently ready to be undone.
*/
NS_IMETHOD CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo)=0;
/** Redo reverses the effects of the last Undo operation
* It is provided here so clients need no knowledge of whether the editor has a transaction manager or not.
* If a transaction manager is present, it is told to redo and the result of the previously undone
* transaction is reapplied to the document.
* If no transaction is available for Redo, or if the document has no transaction manager,
* the Redo request is ignored and an error NS_ERROR_NOT_AVAILABLE is returned.
*
*/
NS_IMETHOD Redo(PRUint32 aCount)=0;
/** returns state information about the redo system.
* @param aIsEnabled [OUT] PR_TRUE if redo is enabled
* @param aCanRedo [OUT] PR_TRUE if at least one transaction is currently ready to be redone.
*/
NS_IMETHOD CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo)=0;
/** BeginTransaction is a signal to the editor that the caller will execute multiple updates
* to the content tree that should be treated as a single operation,
* in the most efficient way possible.<br>
* All transactions executed between a call to BeginTransaction and EndTransaction
* will be undoable as an atomic action.<br>
* EndTransaction must be called after BeginTransaction.<br>
* Calls to BeginTransaction can be nested, as long as EndTransaction is called once per BeginTransaction.
*/
NS_IMETHOD BeginTransaction()=0;
/** EndTransaction is a signal to the editor that the caller is finished updating the content model.
* BeginTransaction must be called before EndTransaction is called.
* Calls to BeginTransaction can be nested, as long as EndTransaction is called once per BeginTransaction.
*/
NS_IMETHOD EndTransaction()=0;
/* the following methods are the convenience methods to make text editing easy for the embedding App
* all simple getter and setter methods use Get/Set/RemoveProperties
* we're looking for a balance between convenience and API bloat, since many of these actions can be
* achieved in other ways.
*/
// Selection and navigation -- exposed here for convenience
/** move the selection up (towards the beginning of the document.)
* @param aIncrement the amount to move the Selection
* legal values are nsIEditor::Line, nsIEditor::Page
*/
NS_IMETHOD MoveSelectionUp(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
/** move the selection down (towards the end of the document.)
* @param aIncrement the amount to move the Selection
* legal values are nsIEditor::Line, nsIEditor::Page
*/
NS_IMETHOD MoveSelectionDown(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
/** move the selection by some increment.
* The dir attribute for the document is used to decide if "next" is LTR or RTL
* @param aIncrement the amount to move the Selection
* legal values are nsIEditor::Word, nsIEditor::Sentence, nsIEditor::Paragraph
* @param aExtendSelection
*/
NS_IMETHOD MoveSelectionNext(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
NS_IMETHOD MoveSelectionPrevious(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
/** select the next portion of the document
* The dir attribute for the document is used to decide if "next" is LTR or RTL
* @param aType the kind of selection to create.
* legal values are nsIEditor::Word, nsIEditor::Sentence, nsIEditor::Paragraph
* nsIEditor::Document
* @param aExtendSelection
*/
NS_IMETHOD SelectNext(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
/** select the previous portion of the document
* The dir attribute for the document is used to decide if "next" is LTR or RTL
* @param aType the kind of selection to create.
* legal values are nsIEditor::Word, nsIEditor::Sentence, nsIEditor::Paragraph
* nsIEditor::Document
* @param aExtendSelection
*/
NS_IMETHOD SelectPrevious(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
/** select the entire contents of the document */
NS_IMETHOD SelectAll()=0;
/** sets the document selection to the beginning of the document */
NS_IMETHOD BeginningOfDocument()=0;
/** sets the document selection to the end of the document */
NS_IMETHOD EndOfDocument()=0;
/** Respond to the menu 'Save' command; this may put up save UI if the document
* hasn't been saved yet.
*/
NS_IMETHOD Save()=0;
/** Respond to the menu 'Save As' command; this will put up save UI
* @param aSavingCopy true if we are saving off a copy of the document
* without changing the disk file associated with the doc.
* This would correspond to a 'Save Copy As' menu command.
*/
NS_IMETHOD SaveAs(PRBool aSavingCopy)=0;
/** cut the currently selected text, putting it into the OS clipboard
* What if no text is selected?
* What about mixed selections?
* What are the clipboard formats?
*/
NS_IMETHOD Cut()=0;
/** copy the currently selected text, putting it into the OS clipboard
* What if no text is selected?
* What about mixed selections?
* What are the clipboard formats?
*/
NS_IMETHOD Copy()=0;
/** paste the text in the OS clipboard at the cursor position, replacing
* the selected text (if any)
*/
NS_IMETHOD Paste()=0;
/** paste the text in the OS clipboard at the cursor position
* as a quotation (whose representation is dependant on the editor type),
* replacing the selected text (if any)
* @param aCitation The "mid" URL of the source message
*/
NS_IMETHOD PasteAsQuotation()=0;
/** insert a string as quoted text,
* as a quotation (whose representation is dependant on the editor type),
* replacing the selected text (if any)
* @param aQuotedText The actual text to be quoted
* @param aCitation The "mid" URL of the source message
*/
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText)=0;
/** scroll the viewport up (towards the beginning of the document.)
* @param aIncrement the amount to scroll
* legal values are nsIEditor::Line, nsIEditor::Page
*/
NS_IMETHOD ScrollUp(nsIAtom *aIncrement)=0;
/** scroll the viewport down (towards the end of the document.)
* @param aIncrement the amount to scroll
* legal values are nsIEditor::Line, nsIEditor::Page
*/
NS_IMETHOD ScrollDown(nsIAtom *aIncrement)=0;
/** scroll the viewport so the selection is in view.
* @param aScrollToBegin PR_TRUE if the beginning of the selection is to be scrolled into view.
* PR_FALSE if the end of the selection is to be scrolled into view
*/
NS_IMETHOD ScrollIntoView(PRBool aScrollToBegin)=0;
// Input/Output
/**
* Output methods:
* aFormatType is a mime type, like text/plain.
*/
NS_IMETHOD OutputToString(nsString& aOutputString,
const nsString& aFormatType,
PRUint32 aFlags) = 0;
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
const nsString& aFormatType,
const nsString* aCharsetOverride,
PRUint32 aFlags) = 0;
/** Get and set the body wrap width
* @param aWrapColumn - the column to wrap at. This is set as a COLS attribute
* on a PRE block.
*
* Special values:
* 0 = wrap to window width
* -1 = no wrap at all
*
*/
NS_IMETHOD GetBodyWrapWidth(PRInt32 *aWrapColumn)=0;
NS_IMETHOD SetBodyWrapWidth(PRInt32 aWrapColumn)=0;
// Miscellaneous Methods
/** Apply the style sheet, specified by aURL, to the
* text editor's document.
*/
NS_IMETHOD ApplyStyleSheet(const nsString& aURL)=0;
/*
NS_IMETHOD CheckSpelling()=0;
NS_IMETHOD SpellingLanguage(nsIAtom *aLanguage)=0;
*/
/* The editor doesn't know anything about specific services like SpellChecking.
* Services can be invoked on the content, and these services can use the editor if they choose
* to get transactioning/undo/redo.
* For things like auto-spellcheck, the App should implement nsIDocumentObserver and
* trigger off of ContentChanged notifications.
*/
// IME Editing Methods
NS_IMETHOD BeginComposition(void)=0;
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIDOMTextRangeList* aTextRangeList)=0;
NS_IMETHOD EndComposition(void)=0;
// Logging Methods
NS_IMETHOD StartLogging(nsIFileSpec *aLogFile)=0;
NS_IMETHOD StopLogging()=0;
};
#endif //nsIEditor_h__

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

@ -3,4 +3,6 @@
#
nsIEventListenerManager.h
nsIEventStateManager.h
nsIPrivateDOMEvent.h
nsIPrivateDOMEvent.h
nsIPrivateTextEvent.h
nsIPrivateTextRange.h

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

@ -28,6 +28,8 @@ EXPORTS = \
nsIEventListenerManager.h \
nsIEventStateManager.h \
nsIPrivateDOMEvent.h \
nsIPrivateTextEvent.h \
nsIPrivateTextRange.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

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

@ -22,6 +22,8 @@ EXPORTS = \
nsIEventListenerManager.h \
nsIEventStateManager.h \
nsIPrivateDOMEvent.h \
nsIPrivateTextEvent.h \
nsIPrivateTextRange.h \
$(NULL)
MODULE=raptor

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

@ -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__

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

@ -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__

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

@ -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))

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

@ -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

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

@ -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;
}

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

@ -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__

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

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

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

@ -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;i<mLength;i++)
mList[i]->Release();
}
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;
}

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

@ -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