Bug 960871 part.8 Rename variable names of NS_COMPOSITION_CHANGE event r=smaug

This commit is contained in:
Masayuki Nakano 2014-10-07 19:01:49 +09:00
Родитель d08404080c
Коммит 6072e74d01
11 изменённых файлов: 94 добавлений и 91 удалений

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

@ -135,18 +135,18 @@ CompositionStringSynthesizer::DispatchEvent(bool* aDefaultPrevented)
mClauses->AppendElement(mCaret);
}
WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, widget);
textEvent.time = PR_IntervalNow();
textEvent.mData = mString;
WidgetCompositionEvent compChangeEvent(true, NS_COMPOSITION_CHANGE, widget);
compChangeEvent.time = PR_IntervalNow();
compChangeEvent.mData = mString;
if (!mClauses->IsEmpty()) {
textEvent.mRanges = mClauses;
compChangeEvent.mRanges = mClauses;
}
// XXX How should we set false for this on b2g?
textEvent.mFlags.mIsSynthesizedForTests = true;
compChangeEvent.mFlags.mIsSynthesizedForTests = true;
nsEventStatus status = nsEventStatus_eIgnore;
nsresult rv = widget->DispatchEvent(&textEvent, status);
nsresult rv = widget->DispatchEvent(&compChangeEvent, status);
*aDefaultPrevented = (status == nsEventStatus_eConsumeNoDefault);
ClearInternal();

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

@ -798,10 +798,10 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
break;
case NS_COMPOSITION_CHANGE:
{
WidgetCompositionEvent* textEvent = aEvent->AsCompositionEvent();
if (IsTargetCrossProcess(textEvent)) {
WidgetCompositionEvent* compositionEvent = aEvent->AsCompositionEvent();
if (IsTargetCrossProcess(compositionEvent)) {
// Will not be handled locally, remote the event
if (GetCrossProcessTarget()->SendTextEvent(*textEvent)) {
if (GetCrossProcessTarget()->SendTextEvent(*compositionEvent)) {
// Cancel local dispatching
aEvent->mFlags.mPropagationStopped = true;
}

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

@ -285,11 +285,11 @@ TextComposition::RequestToCommit(nsIWidget* aWidget, bool aDiscard)
nsAutoString commitData(aDiscard ? EmptyString() : lastData);
bool changingData = lastData != commitData;
WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, widget);
textEvent.mData = commitData;
textEvent.mFlags.mIsSynthesizedForTests = true;
WidgetCompositionEvent changeEvent(true, NS_COMPOSITION_CHANGE, widget);
changeEvent.mData = commitData;
changeEvent.mFlags.mIsSynthesizedForTests = true;
MaybeDispatchCompositionUpdate(&textEvent);
MaybeDispatchCompositionUpdate(&changeEvent);
// If changing the data or committing string isn't empty, we need to
// dispatch compositionchange event for setting the composition string
@ -297,7 +297,7 @@ TextComposition::RequestToCommit(nsIWidget* aWidget, bool aDiscard)
if (!Destroyed() && !widget->Destroyed() &&
(changingData || !commitData.IsEmpty())) {
nsEventStatus status = nsEventStatus_eIgnore;
widget->DispatchEvent(&textEvent, status);
widget->DispatchEvent(&changeEvent, status);
}
if (!Destroyed() && !widget->Destroyed()) {
@ -340,13 +340,13 @@ TextComposition::NotifyIME(IMEMessage aMessage)
void
TextComposition::EditorWillHandleTextEvent(
const WidgetCompositionEvent* aTextEvent)
const WidgetCompositionEvent* aCompositionChangeEvent)
{
mIsComposing = aTextEvent->IsComposing();
mRanges = aTextEvent->mRanges;
mIsComposing = aCompositionChangeEvent->IsComposing();
mRanges = aCompositionChangeEvent->mRanges;
mIsEditorHandlingEvent = true;
MOZ_ASSERT(mLastData == aTextEvent->mData,
MOZ_ASSERT(mLastData == aCompositionChangeEvent->mData,
"The text of a compositionchange event must be same as previous data "
"attribute value of the latest compositionupdate event");
}
@ -443,7 +443,8 @@ TextComposition::CompositionEventDispatcher::Run()
mIsSynthesizedEvent);
break;
}
case NS_COMPOSITION_END: {
case NS_COMPOSITION_END:
case NS_COMPOSITION_CHANGE: {
WidgetCompositionEvent compEvent(true, mEventMessage, widget);
compEvent.mData = mData;
compEvent.mFlags.mIsSynthesizedForTests =
@ -453,16 +454,6 @@ TextComposition::CompositionEventDispatcher::Run()
mIsSynthesizedEvent);
break;
}
case NS_COMPOSITION_CHANGE: {
WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, widget);
textEvent.mData = mData;
textEvent.mFlags.mIsSynthesizedForTests =
mTextComposition->IsSynthesizedForTests();
IMEStateManager::DispatchCompositionEvent(mEventTarget, presContext,
&textEvent, &status, nullptr,
mIsSynthesizedEvent);
break;
}
default:
MOZ_CRASH("Unsupported event");
}

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

@ -131,11 +131,12 @@ public:
class MOZ_STACK_CLASS TextEventHandlingMarker
{
public:
TextEventHandlingMarker(TextComposition* aComposition,
const WidgetCompositionEvent* aTextEvent)
TextEventHandlingMarker(
TextComposition* aComposition,
const WidgetCompositionEvent* aCompositionChangeEvent)
: mComposition(aComposition)
{
mComposition->EditorWillHandleTextEvent(aTextEvent);
mComposition->EditorWillHandleTextEvent(aCompositionChangeEvent);
}
~TextEventHandlingMarker()
@ -235,7 +236,8 @@ private:
* EditorWillHandleTextEvent() must be called before the focused editor
* handles the compositionchange event.
*/
void EditorWillHandleTextEvent(const WidgetCompositionEvent* aTextEvent);
void EditorWillHandleTextEvent(
const WidgetCompositionEvent* aCompositionChangeEvent);
/**
* EditorDidHandleTextEvent() must be called after the focused editor handles

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

@ -846,13 +846,13 @@ nsPlaintextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent)
{
NS_ABORT_IF_FALSE(aDOMTextEvent, "aDOMTextEvent must not be nullptr");
WidgetCompositionEvent* widgetTextEvent =
WidgetCompositionEvent* compositionChangeEvent =
aDOMTextEvent->GetInternalNSEvent()->AsCompositionEvent();
NS_ENSURE_TRUE(widgetTextEvent, NS_ERROR_INVALID_ARG);
MOZ_ASSERT(compChangeEvent->message == NS_COMPOSITION_CHANGE,
NS_ENSURE_TRUE(compositionChangeEvent, NS_ERROR_INVALID_ARG);
MOZ_ASSERT(compositionChangeEvent->message == NS_COMPOSITION_CHANGE,
"The internal event should be NS_COMPOSITION_CHANGE");
EnsureComposition(widgetTextEvent);
EnsureComposition(compositionChangeEvent);
nsCOMPtr<nsIPresShell> ps = GetPresShell();
NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED);
@ -872,7 +872,7 @@ nsPlaintextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent)
MOZ_ASSERT(!mPlaceHolderBatch,
"UpdateIMEComposition() must be called without place holder batch");
TextComposition::TextEventHandlingMarker
textEventHandlingMarker(mComposition, widgetTextEvent);
textEventHandlingMarker(mComposition, compositionChangeEvent);
NotifyEditorObservers(eNotifyEditorObserversOfBefore);
@ -881,7 +881,7 @@ nsPlaintextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent)
{
nsAutoPlaceHolderBatch batch(this, nsGkAtoms::IMETxnName);
rv = InsertText(widgetTextEvent->mData);
rv = InsertText(compositionChangeEvent->mData);
if (caretP) {
caretP->SetSelection(selection);

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

@ -1707,14 +1707,15 @@ nsWindow::RemoveIMEComposition()
AutoIMEMask selMask(mIMEMaskSelectionUpdate);
AutoIMEMask textMask(mIMEMaskTextUpdate);
WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, this);
InitEvent(textEvent, nullptr);
textEvent.mData = mIMEComposingText;
DispatchEvent(&textEvent);
WidgetCompositionEvent compositionChangeEvent(true, NS_COMPOSITION_CHANGE,
this);
InitEvent(compositionChangeEvent, nullptr);
compositionChangeEvent.mData = mIMEComposingText;
DispatchEvent(&compositionChangeEvent);
WidgetCompositionEvent event(true, NS_COMPOSITION_END, this);
InitEvent(event, nullptr);
DispatchEvent(&event);
WidgetCompositionEvent compEndEvent(true, NS_COMPOSITION_END, this);
InitEvent(compEndEvent, nullptr);
DispatchEvent(&compEndEvent);
}
void
@ -2086,14 +2087,15 @@ nsWindow::NotifyIME(const IMENotification& aIMENotification)
if (mIMEComposing) {
nsRefPtr<nsWindow> kungFuDeathGrip(this);
WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, this);
InitEvent(textEvent, nullptr);
DispatchEvent(&textEvent);
WidgetCompositionEvent compositionChangeEvent(
true, NS_COMPOSITION_CHANGE, this);
InitEvent(compositionChangeEvent, nullptr);
DispatchEvent(&compositionChangeEvent);
WidgetCompositionEvent compEvent(true, NS_COMPOSITION_END,
this);
InitEvent(compEvent, nullptr);
DispatchEvent(&compEvent);
WidgetCompositionEvent compositionEndEvent(
true, NS_COMPOSITION_END, this);
InitEvent(compositionEndEvent, nullptr);
DispatchEvent(&compositionEndEvent);
}
mozilla::widget::android::GeckoAppShell::NotifyIME(REQUEST_TO_CANCEL_COMPOSITION);

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

@ -2140,7 +2140,7 @@ TextInputHandler::InsertText(NSAttributedString* aAttrString,
NS_ENSURE_TRUE_VOID(SetSelection(*aReplacementRange));
}
// Dispatch keypress event with char instead of textEvent
// Dispatch keypress event with char instead of compositionchange event
WidgetKeyboardEvent keypressEvent(true, NS_KEY_PRESS, mWidget);
keypressEvent.isChar = IsPrintableChar(str.CharAt(0));
@ -2716,14 +2716,16 @@ IMEInputHandler::DispatchTextEvent(const nsString& aText,
nsRefPtr<IMEInputHandler> kungFuDeathGrip(this);
WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, mWidget);
textEvent.time = PR_IntervalNow();
textEvent.mData = aText;
WidgetCompositionEvent compositionChangeEvent(true, NS_COMPOSITION_CHANGE,
mWidget);
compositionChangeEvent.time = PR_IntervalNow();
compositionChangeEvent.mData = aText;
if (!aDoCommit) {
textEvent.mRanges = CreateTextRangeArray(aAttrString, aSelectedRange);
compositionChangeEvent.mRanges =
CreateTextRangeArray(aAttrString, aSelectedRange);
}
mLastDispatchedCompositionString = textEvent.mData;
return DispatchEvent(textEvent);
mLastDispatchedCompositionString = compositionChangeEvent.mData;
return DispatchEvent(compositionChangeEvent);
}
void

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

@ -1107,26 +1107,27 @@ nsGtkIMModule::DispatchTextEvent(const nsAString &aCompositionString,
}
}
WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE,
mLastFocusedWindow);
InitEvent(textEvent);
WidgetCompositionEvent compositionChangeEvent(true, NS_COMPOSITION_CHANGE,
mLastFocusedWindow);
InitEvent(compositionChangeEvent);
uint32_t targetOffset = mCompositionStart;
textEvent.mData = mDispatchedCompositionString = aCompositionString;
compositionChangeEvent.mData =
mDispatchedCompositionString = aCompositionString;
if (!aIsCommit) {
// NOTE: SetTextRangeList() assumes that mDispatchedCompositionString
// has been updated already.
textEvent.mRanges = CreateTextRangeArray();
targetOffset += textEvent.mRanges->TargetClauseOffset();
compositionChangeEvent.mRanges = CreateTextRangeArray();
targetOffset += compositionChangeEvent.mRanges->TargetClauseOffset();
}
mCompositionState = aIsCommit ?
eCompositionState_CommitTextEventDispatched :
eCompositionState_TextEventDispatched;
mLastFocusedWindow->DispatchEvent(&textEvent, status);
mLastFocusedWindow->DispatchEvent(&compositionChangeEvent, status);
if (lastFocusedWindow->IsDestroyed() ||
lastFocusedWindow != mLastFocusedWindow) {
PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,

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

@ -3046,14 +3046,15 @@ nsWindow::OnKeyPressEvent(GdkEventKey *aEvent)
DispatchEvent(&event, status);
}
else {
WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, this);
WidgetCompositionEvent compositionChangeEvent(
true, NS_COMPOSITION_CHANGE, this);
char16_t textString[3];
textString[0] = H_SURROGATE(event.charCode);
textString[1] = L_SURROGATE(event.charCode);
textString[2] = 0;
textEvent.mData = textString;
textEvent.time = event.time;
DispatchEvent(&textEvent, status);
compositionChangeEvent.mData = textString;
compositionChangeEvent.time = event.time;
DispatchEvent(&compositionChangeEvent, status);
}
}

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

@ -1650,18 +1650,19 @@ nsTextStore::FlushPendingActions()
PR_LOG(sTextStoreLog, PR_LOG_DEBUG,
("TSF: 0x%p nsTextStore::FlushPendingActions(), "
"dispatching compositionchange event...", this));
WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, mWidget);
mWidget->InitEvent(textEvent);
textEvent.mData = action.mData;
WidgetCompositionEvent compositionChange(true, NS_COMPOSITION_CHANGE,
mWidget);
mWidget->InitEvent(compositionChange);
compositionChange.mData = action.mData;
if (action.mRanges->IsEmpty()) {
TextRange wholeRange;
wholeRange.mStartOffset = 0;
wholeRange.mEndOffset = textEvent.mData.Length();
wholeRange.mEndOffset = compositionChange.mData.Length();
wholeRange.mRangeType = NS_TEXTRANGE_RAWINPUT;
action.mRanges->AppendElement(wholeRange);
}
textEvent.mRanges = action.mRanges;
mWidget->DispatchWindowEvent(&textEvent);
compositionChange.mRanges = action.mRanges;
mWidget->DispatchWindowEvent(&compositionChange);
// Be aware, the mWidget might already have been destroyed.
break;
}
@ -1677,10 +1678,11 @@ nsTextStore::FlushPendingActions()
PR_LOG(sTextStoreLog, PR_LOG_DEBUG,
("TSF: 0x%p nsTextStore::FlushPendingActions(), "
"dispatching compositionchange event...", this));
WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, mWidget);
mWidget->InitEvent(textEvent);
textEvent.mData = action.mData;
mWidget->DispatchWindowEvent(&textEvent);
WidgetCompositionEvent compositionChange(true, NS_COMPOSITION_CHANGE,
mWidget);
mWidget->InitEvent(compositionChange);
compositionChange.mData = action.mData;
mWidget->DispatchWindowEvent(&compositionChange);
if (!mWidget || mWidget->Destroyed()) {
break;
}
@ -1690,7 +1692,7 @@ nsTextStore::FlushPendingActions()
"dispatching compositionend event...", this));
WidgetCompositionEvent compositionEnd(true, NS_COMPOSITION_END,
mWidget);
compositionEnd.mData = textEvent.mData;
compositionEnd.mData = compositionChange.mData;
mWidget->InitEvent(compositionEnd);
mWidget->DispatchWindowEvent(&compositionEnd);
if (!mWidget || mWidget->Destroyed()) {

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

@ -379,25 +379,27 @@ PuppetWidget::IMEEndComposition(bool aCancel)
#endif
nsEventStatus status;
WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, this);
InitEvent(textEvent, nullptr);
textEvent.mSeqno = mIMELastReceivedSeqno;
WidgetCompositionEvent compositionChangeEvent(true, NS_COMPOSITION_CHANGE,
this);
InitEvent(compositionChangeEvent, nullptr);
compositionChangeEvent.mSeqno = mIMELastReceivedSeqno;
// SendEndIMEComposition is always called since ResetInputState
// should always be called even if we aren't composing something.
if (!mTabChild ||
!mTabChild->SendEndIMEComposition(aCancel, &textEvent.mData)) {
!mTabChild->SendEndIMEComposition(aCancel,
&compositionChangeEvent.mData)) {
return NS_ERROR_FAILURE;
}
if (!mIMEComposing)
return NS_OK;
DispatchEvent(&textEvent, status);
DispatchEvent(&compositionChangeEvent, status);
WidgetCompositionEvent compEvent(true, NS_COMPOSITION_END, this);
InitEvent(compEvent, nullptr);
compEvent.mSeqno = mIMELastReceivedSeqno;
DispatchEvent(&compEvent, status);
WidgetCompositionEvent compositionEndEvent(true, NS_COMPOSITION_END, this);
InitEvent(compositionEndEvent, nullptr);
compositionEndEvent.mSeqno = mIMELastReceivedSeqno;
DispatchEvent(&compositionEndEvent, status);
return NS_OK;
}