Bug 543398 Drop nsTextEventReply and nsIPrivateCompositionEvent r=smaug, sr=roc

This commit is contained in:
Masayuki Nakano 2010-04-10 18:24:35 +09:00
Родитель 71424d5bdf
Коммит e38734397e
17 изменённых файлов: 32 добавлений и 279 удалений

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

@ -52,7 +52,6 @@ EXPORTS = \
nsIPrivateDOMEvent.h \
nsIPrivateTextEvent.h \
nsIPrivateTextRange.h \
nsIPrivateCompositionEvent.h \
nsPLDOMEvent.h \
nsEventDispatcher.h \
nsPIDOMEventTarget.h \

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

@ -1,61 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIPrivateCompositionEvent_h__
#define nsIPrivateCompositionEvent_h__
#include "nsEvent.h"
#include "nsISupports.h"
// {901B82D5-67C0-45ad-86AE-AB9A6BD74111}
#define NS_IPRIVATECOMPOSITIONEVENT_IID \
{ 0x901b82d5, 0x67c0, 0x45ad, \
{ 0x86, 0xae, 0xab, 0x9a, 0x6b, 0xd7, 0x41, 0x11 } }
class nsIPrivateCompositionEvent : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRIVATECOMPOSITIONEVENT_IID)
NS_IMETHOD GetCompositionReply(struct nsTextEventReply** aReply) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIPrivateCompositionEvent,
NS_IPRIVATECOMPOSITIONEVENT_IID)
#endif // nsIPrivateCompositionEvent_h__

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

@ -43,8 +43,8 @@
#include "nsIPrivateTextRange.h"
#define NS_IPRIVATETEXTEVENT_IID \
{0xeee4a0f0, 0x7fb0, 0x494c, \
{0x80, 0xe3, 0x30, 0xd3, 0x08, 0x95, 0x15, 0x2c}}
{ 0xb6840e02, 0x9e56, 0x49d8, \
{ 0x84, 0xd, 0x5f, 0xc1, 0xcb, 0x6c, 0xff, 0xb3 } }
class nsIPrivateTextEvent : public nsISupports {
@ -53,7 +53,6 @@ public:
NS_IMETHOD GetText(nsString& aText) = 0;
NS_IMETHOD_(already_AddRefed<nsIPrivateTextRangeList>) GetInputRange() = 0;
NS_IMETHOD_(nsTextEventReply*) GetEventReply() = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIPrivateTextEvent, NS_IPRIVATETEXTEVENT_IID)

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

@ -44,7 +44,6 @@
#include "nsIContent.h"
#include "nsIPresShell.h"
#include "nsIDocument.h"
#include "nsIPrivateCompositionEvent.h"
#include "nsIDOMEventTarget.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"

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

@ -106,14 +106,6 @@ NS_METHOD_(already_AddRefed<nsIPrivateTextRangeList>) nsDOMTextEvent::GetInputRa
return nsnull;
}
NS_METHOD_(nsTextEventReply*) nsDOMTextEvent::GetEventReply()
{
if (mEvent->message == NS_TEXT_TEXT) {
return &(static_cast<nsTextEvent*>(mEvent)->theReply);
}
return nsnull;
}
nsresult NS_NewDOMTextEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsTextEvent *aEvent)

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

@ -57,7 +57,6 @@ public:
// nsIPrivateTextEvent interface
NS_IMETHOD GetText(nsString& aText);
NS_IMETHOD_(already_AddRefed<nsIPrivateTextRangeList>) GetInputRange();
NS_IMETHOD_(nsTextEventReply*) GetEventReply();
protected:
nsString mText;

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

@ -119,7 +119,6 @@ DOMCI_DATA(UIEvent, nsDOMUIEvent)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMUIEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMUIEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSUIEvent)
NS_INTERFACE_MAP_ENTRY(nsIPrivateCompositionEvent)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(UIEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
@ -370,17 +369,6 @@ nsDOMUIEvent::GetIsChar(PRBool* aIsChar)
}
}
NS_METHOD nsDOMUIEvent::GetCompositionReply(nsTextEventReply** aReply)
{
if((mEvent->message == NS_COMPOSITION_START))
{
*aReply = &(static_cast<nsCompositionEvent*>(mEvent)->theReply);
return NS_OK;
}
*aReply = nsnull;
return NS_ERROR_FAILURE;
}
NS_METHOD
nsDOMUIEvent::DuplicatePrivateData()
{

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

@ -42,13 +42,11 @@
#include "nsIDOMUIEvent.h"
#include "nsIDOMNSUIEvent.h"
#include "nsIDOMAbstractView.h"
#include "nsIPrivateCompositionEvent.h"
#include "nsDOMEvent.h"
class nsDOMUIEvent : public nsDOMEvent,
public nsIDOMUIEvent,
public nsIDOMNSUIEvent,
public nsIPrivateCompositionEvent
public nsIDOMNSUIEvent
{
public:
nsDOMUIEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent);
@ -65,9 +63,6 @@ public:
// nsIPrivateDOMEvent interface
NS_IMETHOD DuplicatePrivateData();
// nsIPrivateCompositionEvent interface
NS_IMETHOD GetCompositionReply(nsTextEventReply** aReply);
// Forward to nsDOMEvent
NS_FORWARD_TO_NSDOMEVENT

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

@ -41,31 +41,30 @@
%{C++
class nsIPrivateTextRangeList;
struct nsTextEventReply;
%}
[ptr] native nsIPrivateTextRangeListPtr(nsIPrivateTextRangeList);
[ptr] native nsTextEventReplyPtr(nsTextEventReply);
[scriptable, uuid(8093f91d-fe39-4a17-b9db-73468c3a536b)]
[scriptable, uuid(5cb3f9c9-5ab9-40fd-8ee2-0d1c7abd20dd)]
interface nsIEditorIMESupport : nsISupports
{
/**
* beginComposition(nsTextEventReply* aReply) Handles the start of inline input composition.
* beginComposition() Handles the start of inline input composition.
*/
[noscript] void beginComposition(in nsTextEventReplyPtr aReply);
[noscript] void beginComposition();
/**
* setCompositionString() Sets the inline input composition string.
* beginComposition must be called prior to this.
*/
[noscript] void setCompositionString(in DOMString aCompositionString, in nsIPrivateTextRangeListPtr aTextRange, in nsTextEventReplyPtr aReply);
[noscript] void setCompositionString(in DOMString aCompositionString,
in nsIPrivateTextRangeListPtr aTextRange);
/**
* endComposition() Handles the end of inline input composition.

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

@ -1969,85 +1969,17 @@ nsEditor::StopPreservingSelection()
//
// The BeingComposition method is called from the Editor Composition event listeners.
//
nsresult
nsEditor::QueryComposition(nsTextEventReply* aReply)
{
nsCOMPtr<nsISelection> selection;
nsCOMPtr<nsISelectionController> selcon = do_QueryReferent(mSelConWeak);
if (selcon)
selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
if (!ps) return NS_ERROR_NOT_INITIALIZED;
nsRefPtr<nsCaret> caretP = ps->GetCaret();
if (caretP) {
if (aReply) {
caretP->SetCaretDOMSelection(selection);
// XXX_kin: BEGIN HACK! HACK! HACK!
// XXX_kin:
// XXX_kin: This is lame! The IME stuff needs caret coordinates
// XXX_kin: synchronously, but the editor could be using async
// XXX_kin: updates (reflows and paints) for performance reasons.
// XXX_kin: In order to give IME what it needs, we have to temporarily
// XXX_kin: switch to sync updating during this call so that the
// XXX_kin: nsAutoUpdateViewBatch can force sync reflows and paints
// XXX_kin: so that we get back accurate caret coordinates.
PRUint32 flags = 0;
if (NS_SUCCEEDED(GetFlags(&flags)) &&
(flags & nsIPlaintextEditor::eEditorUseAsyncUpdatesMask))
{
PRBool restoreFlags = PR_FALSE;
if (NS_SUCCEEDED(SetFlags(flags & (~nsIPlaintextEditor::eEditorUseAsyncUpdatesMask))))
{
// Scope the viewBatch within this |if| block so that we
// force synchronous reflows and paints before restoring
// our editor flags below.
nsAutoUpdateViewBatch viewBatch(this);
restoreFlags = PR_TRUE;
}
// Restore the previous set of flags!
if (restoreFlags)
SetFlags(flags);
}
// XXX_kin: END HACK! HACK! HACK!
nsRect rect;
nsIFrame* frame = caretP->GetGeometry(selection, &rect);
if (!frame)
return NS_ERROR_FAILURE;
nsPoint nearestWidgetOffset;
aReply->mReferenceWidget = frame->GetWindowOffset(nearestWidgetOffset);
rect.MoveBy(nearestWidgetOffset);
aReply->mCursorPosition =
rect.ToOutsidePixels(frame->PresContext()->AppUnitsPerDevPixel());
}
}
return NS_OK;
}
NS_IMETHODIMP
nsEditor::BeginComposition(nsTextEventReply* aReply)
nsEditor::BeginComposition()
{
#ifdef DEBUG_tague
printf("nsEditor::StartComposition\n");
#endif
nsresult ret = QueryComposition(aReply);
mInIMEMode = PR_TRUE;
if (mPhonetic)
mPhonetic->Truncate(0);
return ret;
return NS_OK;
}
NS_IMETHODIMP
@ -2084,7 +2016,8 @@ nsEditor::EndComposition(void)
}
NS_IMETHODIMP
nsEditor::SetCompositionString(const nsAString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
nsEditor::SetCompositionString(const nsAString& aCompositionString,
nsIPrivateTextRangeList* aTextRangeList)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -355,8 +355,6 @@ protected:
*/
PRBool GetDesiredSpellCheckState();
nsresult QueryComposition(nsTextEventReply* aReply);
public:
/** All editor operations which alter the doc should be prefaced

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

@ -52,7 +52,6 @@
#include "nsIDOMMouseEvent.h"
#include "nsIDOMNSUIEvent.h"
#include "nsIPrivateTextEvent.h"
#include "nsIPrivateCompositionEvent.h"
#include "nsIEditorMailSupport.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
@ -444,11 +443,9 @@ nsEditorEventListener::HandleText(nsIDOMEvent* aTextEvent)
nsAutoString composedText;
nsresult result;
nsCOMPtr<nsIPrivateTextRangeList> textRangeList;
nsTextEventReply* textEventReply;
textEvent->GetText(composedText);
textRangeList = textEvent->GetInputRange();
textEventReply = textEvent->GetEventReply();
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor, &result);
if (imeEditor) {
PRUint32 flags;
@ -459,7 +456,7 @@ nsEditorEventListener::HandleText(nsIDOMEvent* aTextEvent)
return NS_OK;
}
}
result = imeEditor->SetCompositionString(composedText,textRangeList,textEventReply);
result = imeEditor->SetCompositionString(composedText, textRangeList);
}
return result;
}
@ -750,24 +747,13 @@ nsEditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
NS_IMETHODIMP
nsEditorEventListener::HandleStartComposition(nsIDOMEvent* aCompositionEvent)
{
nsCOMPtr<nsIPrivateCompositionEvent> pCompositionEvent = do_QueryInterface(aCompositionEvent);
if (!pCompositionEvent) return NS_ERROR_FAILURE;
nsTextEventReply* eventReply;
nsresult rv = pCompositionEvent->GetCompositionReply(&eventReply);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor);
NS_ASSERTION(imeEditor, "The editor doesn't support IME?");
return imeEditor->BeginComposition(eventReply);
return static_cast<nsEditor*>(mEditor)->BeginComposition();
}
NS_IMETHODIMP
nsEditorEventListener::HandleEndComposition(nsIDOMEvent* aCompositionEvent)
{
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor);
NS_ASSERTION(imeEditor, "The editor doesn't support IME?");
return imeEditor->EndComposition();
return static_cast<nsEditor*>(mEditor)->EndComposition();
}
/**

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

@ -867,7 +867,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertLineBreak()
}
NS_IMETHODIMP
nsPlaintextEditor::BeginComposition(nsTextEventReply* aReply)
nsPlaintextEditor::BeginComposition()
{
NS_ENSURE_TRUE(!mInIMEMode, NS_OK);
@ -882,7 +882,7 @@ nsPlaintextEditor::BeginComposition(nsTextEventReply* aReply)
}
}
return nsEditor::BeginComposition(aReply);
return nsEditor::BeginComposition();
}
NS_IMETHODIMP
@ -1560,7 +1560,8 @@ nsPlaintextEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
#endif
NS_IMETHODIMP
nsPlaintextEditor::SetCompositionString(const nsAString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
nsPlaintextEditor::SetCompositionString(const nsAString& aCompositionString,
nsIPrivateTextRangeList* aTextRangeList)
{
if (!aTextRangeList && !aCompositionString.IsEmpty())
{
@ -1597,72 +1598,20 @@ nsPlaintextEditor::SetCompositionString(const nsAString& aCompositionString, nsI
{
mIMETextRangeList = aTextRangeList;
// XXX_kin: BEGIN HACK! HACK! HACK!
// XXX_kin:
// XXX_kin: This is lame! The IME stuff needs caret coordinates
// XXX_kin: synchronously, but the editor could be using async
// XXX_kin: updates (reflows and paints) for performance reasons.
// XXX_kin: In order to give IME what it needs, we have to temporarily
// XXX_kin: switch to sync updating during this call so that the
// XXX_kin: nsAutoPlaceHolderBatch can force sync reflows, paints,
// XXX_kin: and selection scrolling, so that we get back accurate
// XXX_kin: caret coordinates.
SetIsIMEComposing(); // We set mIsIMEComposing properly.
PRUint32 flags = 0;
PRBool restoreFlags = PR_FALSE;
result = InsertText(aCompositionString);
if (NS_SUCCEEDED(GetFlags(&flags)) &&
(flags & nsIPlaintextEditor::eEditorUseAsyncUpdatesMask))
{
if (NS_SUCCEEDED(SetFlags(
flags & (~nsIPlaintextEditor::eEditorUseAsyncUpdatesMask))))
restoreFlags = PR_TRUE;
}
mIMEBufferLength = aCompositionString.Length();
// XXX_kin: END HACK! HACK! HACK!
if (caretP)
caretP->SetCaretDOMSelection(selection);
// we need the nsAutoPlaceHolderBatch destructor called before hitting
// GetCaretCoordinates so the states in Frame system sync with content
// therefore, we put the nsAutoPlaceHolderBatch into a inner block
{
nsAutoPlaceHolderBatch batch(this, nsGkAtoms::IMETxnName);
SetIsIMEComposing(); // We set mIsIMEComposing properly.
result = InsertText(aCompositionString);
mIMEBufferLength = aCompositionString.Length();
if (caretP)
caretP->SetCaretDOMSelection(selection);
// second part of 23558 fix:
if (aCompositionString.IsEmpty())
mIMETextNode = nsnull;
}
// XXX_kin: BEGIN HACK! HACK! HACK!
// XXX_kin:
// XXX_kin: Restore the previous set of flags!
if (restoreFlags)
SetFlags(flags);
// XXX_kin: END HACK! HACK! HACK!
// second part of 23558 fix:
if (aCompositionString.IsEmpty())
mIMETextNode = nsnull;
}
if (caretP)
{
nsRect rect;
nsIFrame* frame = caretP->GetGeometry(selection, &rect);
if (!frame)
return NS_ERROR_FAILURE;
nsPoint nearestWidgetOffset;
aReply->mReferenceWidget = frame->GetWindowOffset(nearestWidgetOffset);
rect.MoveBy(nearestWidgetOffset);
aReply->mCursorPosition =
rect.ToOutsidePixels(frame->PresContext()->AppUnitsPerDevPixel());
}
return result;
}

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

@ -89,11 +89,10 @@ public:
/* ------------ nsIEditorIMESupport overrides -------------- */
NS_IMETHOD SetCompositionString(const nsAString &aCompositionString,
nsIPrivateTextRangeList *aTextRange,
nsTextEventReply *aReply);
nsIPrivateTextRangeList *aTextRange);
/* ------------ Overrides of nsEditor interface methods -------------- */
NS_IMETHOD BeginComposition(nsTextEventReply* aReply);
NS_IMETHOD BeginComposition();
NS_IMETHOD SetAttributeOrEquivalent(nsIDOMElement * aElement,
const nsAString & aAttribute,
const nsAString & aValue,

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

@ -90,6 +90,4 @@ class nsMenuEvent;
class nsSimpleGestureEvent;
class nsContentCommandEvent;
struct nsTextEventReply;
#endif // nsEvent_h__

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

@ -998,21 +998,6 @@ struct nsTextRange
typedef nsTextRange* nsTextRangeArray;
// XXX We should drop this struct because the results are provided by query
// content events now, so, this struct finished the role.
struct nsTextEventReply
{
nsTextEventReply()
: mReferenceWidget(nsnull)
{
}
nsIntRect mCursorPosition;
nsIWidget* mReferenceWidget;
};
typedef struct nsTextEventReply nsTextEventReply;
class nsTextEvent : public nsInputEvent
{
public:
@ -1023,7 +1008,6 @@ public:
}
nsString theText;
nsTextEventReply theReply; // OBSOLETE
PRUint32 rangeCount;
// Note that the range array may not specify a caret position; in that
// case there will be no range of type NS_TEXTRANGE_CARETPOSITION in the
@ -1039,8 +1023,6 @@ public:
: nsInputEvent(isTrusted, msg, w, NS_COMPOSITION_EVENT)
{
}
nsTextEventReply theReply; // OBSOLETE
};
/* Mouse Scroll Events: Line Scrolling, Pixel Scrolling and Common Event Flows

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

@ -144,7 +144,7 @@ PRUint32 nsChildView::sLastInputEventCount = 0;
- (id)initWithFrame:(NSRect)inFrame geckoChild:(nsChildView*)inChild;
// sends gecko an ime composition event
- (nsIntRect) sendCompositionEvent:(PRInt32)aEventType;
- (void) sendCompositionEvent:(PRInt32)aEventType;
// sends gecko an ime text event
- (void) sendTextEvent:(PRUnichar*) aBuffer
@ -4416,20 +4416,19 @@ GetUSLayoutCharFromKeyTranslate(UInt32 aKeyCode, UInt32 aModifiers)
}
#endif // NP_NO_CARBON
- (nsIntRect)sendCompositionEvent:(PRInt32) aEventType
- (void)sendCompositionEvent:(PRInt32) aEventType
{
#ifdef DEBUG_IME
NSLog(@"****in sendCompositionEvent; type = %d", aEventType);
#endif
if (!mGeckoChild)
return nsIntRect(0, 0, 0, 0);
return;
// static void init_composition_event( *aEvent, int aType)
nsCompositionEvent event(PR_TRUE, aEventType, mGeckoChild);
event.time = PR_IntervalNow();
mGeckoChild->DispatchWindowEvent(event);
return event.theReply.mCursorPosition;
}
- (void)sendTextEvent:(PRUnichar*) aBuffer