mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 21:00:50 +00:00
Bug 1176954 part.4 Define IMENotification::TextChangeDataBase and whose member names should be same as IMEContentObserver::TextChangeData's r=smaug
This commit is contained in:
parent
69720d0ea0
commit
c1fdc81cac
@ -1727,8 +1727,8 @@ IMEContentObserver::TextChangeEvent::Run()
|
||||
|
||||
IMENotification notification(NOTIFY_IME_OF_TEXT_CHANGE);
|
||||
notification.mTextChangeData.mStartOffset = mData.mStartOffset;
|
||||
notification.mTextChangeData.mOldEndOffset = mData.mRemovedEndOffset;
|
||||
notification.mTextChangeData.mNewEndOffset = mData.mAddedEndOffset;
|
||||
notification.mTextChangeData.mRemovedEndOffset = mData.mRemovedEndOffset;
|
||||
notification.mTextChangeData.mAddedEndOffset = mData.mAddedEndOffset;
|
||||
notification.mTextChangeData.mCausedByComposition =
|
||||
mData.mCausedOnlyByComposition;
|
||||
IMEStateManager::NotifyIME(notification, mIMEContentObserver->mWidget);
|
||||
|
@ -197,16 +197,16 @@ parent:
|
||||
*
|
||||
* contentCache Cache of content
|
||||
* offset Starting offset of the change
|
||||
* end Ending offset of the range deleted
|
||||
* newEnd New ending offset after insertion
|
||||
* removedEnd Ending offset of the range deleted
|
||||
* addedEnd New ending offset after insertion
|
||||
* causedByComposition true if the change is caused by composition
|
||||
*
|
||||
* for insertion, offset == end
|
||||
* for deletion, offset == newEnd
|
||||
*/
|
||||
prio(urgent) async NotifyIMETextChange(ContentCache contentCache,
|
||||
uint32_t offset, uint32_t end,
|
||||
uint32_t newEnd,
|
||||
uint32_t offset, uint32_t removedEnd,
|
||||
uint32_t addedEnd,
|
||||
bool causedByComposition);
|
||||
|
||||
/**
|
||||
|
@ -1972,8 +1972,8 @@ TabParent::RecvNotifyIMEFocus(const bool& aFocus,
|
||||
bool
|
||||
TabParent::RecvNotifyIMETextChange(const ContentCache& aContentCache,
|
||||
const uint32_t& aStart,
|
||||
const uint32_t& aEnd,
|
||||
const uint32_t& aNewEnd,
|
||||
const uint32_t& aRemovedEnd,
|
||||
const uint32_t& aAddedEnd,
|
||||
const bool& aCausedByComposition)
|
||||
{
|
||||
nsCOMPtr<nsIWidget> widget = GetWidget();
|
||||
@ -1991,8 +1991,8 @@ TabParent::RecvNotifyIMETextChange(const ContentCache& aContentCache,
|
||||
|
||||
IMENotification notification(NOTIFY_IME_OF_TEXT_CHANGE);
|
||||
notification.mTextChangeData.mStartOffset = aStart;
|
||||
notification.mTextChangeData.mOldEndOffset = aEnd;
|
||||
notification.mTextChangeData.mNewEndOffset = aNewEnd;
|
||||
notification.mTextChangeData.mRemovedEndOffset = aRemovedEnd;
|
||||
notification.mTextChangeData.mAddedEndOffset = aAddedEnd;
|
||||
notification.mTextChangeData.mCausedByComposition = aCausedByComposition;
|
||||
|
||||
mContentCache.AssignContent(aContentCache, ¬ification);
|
||||
|
@ -167,8 +167,8 @@ public:
|
||||
override;
|
||||
virtual bool RecvNotifyIMETextChange(const ContentCache& aContentCache,
|
||||
const uint32_t& aStart,
|
||||
const uint32_t& aEnd,
|
||||
const uint32_t& aNewEnd,
|
||||
const uint32_t& aRemovedEnd,
|
||||
const uint32_t& aAddedEnd,
|
||||
const bool& aCausedByComposition) override;
|
||||
virtual bool RecvNotifyIMESelectedCompositionRect(const ContentCache& aContentCache) override;
|
||||
virtual bool RecvNotifyIMESelection(const ContentCache& aContentCache,
|
||||
|
@ -762,8 +762,8 @@ PuppetWidget::NotifyIMEOfTextChange(const IMENotification& aIMENotification)
|
||||
mTabChild->SendNotifyIMETextChange(
|
||||
mContentCache,
|
||||
aIMENotification.mTextChangeData.mStartOffset,
|
||||
aIMENotification.mTextChangeData.mOldEndOffset,
|
||||
aIMENotification.mTextChangeData.mNewEndOffset,
|
||||
aIMENotification.mTextChangeData.mRemovedEndOffset,
|
||||
aIMENotification.mTextChangeData.mAddedEndOffset,
|
||||
aIMENotification.mTextChangeData.mCausedByComposition);
|
||||
} else {
|
||||
mTabChild->SendUpdateContentCache(mContentCache);
|
||||
|
@ -1737,8 +1737,8 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
||||
// combine with this text change, and overflow might occur if
|
||||
// we just use INT32_MAX
|
||||
IMENotification notification(NOTIFY_IME_OF_TEXT_CHANGE);
|
||||
notification.mTextChangeData.mOldEndOffset =
|
||||
notification.mTextChangeData.mNewEndOffset = INT32_MAX / 2;
|
||||
notification.mTextChangeData.mRemovedEndOffset =
|
||||
notification.mTextChangeData.mAddedEndOffset = INT32_MAX / 2;
|
||||
NotifyIMEOfTextChange(notification);
|
||||
FlushIMEChanges();
|
||||
}
|
||||
@ -2246,8 +2246,8 @@ nsWindow::NotifyIMEOfTextChange(const IMENotification& aIMENotification)
|
||||
|
||||
ALOGIME("IME: NotifyIMEOfTextChange: s=%d, oe=%d, ne=%d",
|
||||
aIMENotification.mTextChangeData.mStartOffset,
|
||||
aIMENotification.mTextChangeData.mOldEndOffset,
|
||||
aIMENotification.mTextChangeData.mNewEndOffset);
|
||||
aIMENotification.mTextChangeData.mRemovedEndOffset,
|
||||
aIMENotification.mTextChangeData.mAddedEndOffset);
|
||||
|
||||
/* Make sure Java's selection is up-to-date */
|
||||
mIMESelectionChanged = false;
|
||||
|
@ -183,8 +183,8 @@ protected:
|
||||
}
|
||||
IMEChange(const IMENotification& aIMENotification)
|
||||
: mStart(aIMENotification.mTextChangeData.mStartOffset)
|
||||
, mOldEnd(aIMENotification.mTextChangeData.mOldEndOffset)
|
||||
, mNewEnd(aIMENotification.mTextChangeData.mNewEndOffset)
|
||||
, mOldEnd(aIMENotification.mTextChangeData.mRemovedEndOffset)
|
||||
, mNewEnd(aIMENotification.mTextChangeData.mAddedEndOffset)
|
||||
{
|
||||
MOZ_ASSERT(aIMENotification.mMessage ==
|
||||
mozilla::widget::NOTIFY_IME_OF_TEXT_CHANGE,
|
||||
|
@ -679,8 +679,8 @@ struct ParamTraits<mozilla::widget::IMENotification>
|
||||
return;
|
||||
case mozilla::widget::NOTIFY_IME_OF_TEXT_CHANGE:
|
||||
WriteParam(aMsg, aParam.mTextChangeData.mStartOffset);
|
||||
WriteParam(aMsg, aParam.mTextChangeData.mOldEndOffset);
|
||||
WriteParam(aMsg, aParam.mTextChangeData.mNewEndOffset);
|
||||
WriteParam(aMsg, aParam.mTextChangeData.mRemovedEndOffset);
|
||||
WriteParam(aMsg, aParam.mTextChangeData.mAddedEndOffset);
|
||||
WriteParam(aMsg, aParam.mTextChangeData.mCausedByComposition);
|
||||
return;
|
||||
case mozilla::widget::NOTIFY_IME_OF_MOUSE_BUTTON_EVENT:
|
||||
@ -724,9 +724,9 @@ struct ParamTraits<mozilla::widget::IMENotification>
|
||||
return ReadParam(aMsg, aIter,
|
||||
&aResult->mTextChangeData.mStartOffset) &&
|
||||
ReadParam(aMsg, aIter,
|
||||
&aResult->mTextChangeData.mOldEndOffset) &&
|
||||
&aResult->mTextChangeData.mRemovedEndOffset) &&
|
||||
ReadParam(aMsg, aIter,
|
||||
&aResult->mTextChangeData.mNewEndOffset) &&
|
||||
&aResult->mTextChangeData.mAddedEndOffset) &&
|
||||
ReadParam(aMsg, aIter,
|
||||
&aResult->mTextChangeData.mCausedByComposition);
|
||||
case mozilla::widget::NOTIFY_IME_OF_MOUSE_BUTTON_EVENT:
|
||||
|
@ -617,8 +617,8 @@ struct IMENotification
|
||||
break;
|
||||
case NOTIFY_IME_OF_TEXT_CHANGE:
|
||||
mTextChangeData.mStartOffset = 0;
|
||||
mTextChangeData.mOldEndOffset = 0;
|
||||
mTextChangeData.mNewEndOffset = 0;
|
||||
mTextChangeData.mRemovedEndOffset = 0;
|
||||
mTextChangeData.mAddedEndOffset = 0;
|
||||
mTextChangeData.mCausedByComposition = false;
|
||||
break;
|
||||
case NOTIFY_IME_OF_MOUSE_BUTTON_EVENT:
|
||||
@ -670,10 +670,10 @@ struct IMENotification
|
||||
// TODO: Needs to merge the ranges rather than overwriting.
|
||||
mTextChangeData.mStartOffset =
|
||||
aNotification.mTextChangeData.mStartOffset;
|
||||
mTextChangeData.mOldEndOffset =
|
||||
aNotification.mTextChangeData.mOldEndOffset;
|
||||
mTextChangeData.mNewEndOffset =
|
||||
aNotification.mTextChangeData.mNewEndOffset;
|
||||
mTextChangeData.mRemovedEndOffset =
|
||||
aNotification.mTextChangeData.mRemovedEndOffset;
|
||||
mTextChangeData.mAddedEndOffset =
|
||||
aNotification.mTextChangeData.mAddedEndOffset;
|
||||
mTextChangeData.mCausedByComposition =
|
||||
mTextChangeData.mCausedByComposition &&
|
||||
aNotification.mTextChangeData.mCausedByComposition;
|
||||
@ -719,33 +719,39 @@ struct IMENotification
|
||||
}
|
||||
};
|
||||
|
||||
struct TextChangeDataBase
|
||||
{
|
||||
// mStartOffset is the start offset of modified or removed text in
|
||||
// original content and inserted text in new content.
|
||||
uint32_t mStartOffset;
|
||||
// mRemovalEndOffset is the end offset of modified or removed text in
|
||||
// original content. If the value is same as mStartOffset, no text hasn't
|
||||
// been removed yet.
|
||||
uint32_t mRemovedEndOffset;
|
||||
// mAddedEndOffset is the end offset of inserted text or same as
|
||||
// mStartOffset if just removed. The vlaue is offset in the new content.
|
||||
uint32_t mAddedEndOffset;
|
||||
|
||||
bool mCausedByComposition;
|
||||
|
||||
uint32_t OldLength() const { return mRemovedEndOffset - mStartOffset; }
|
||||
uint32_t NewLength() const { return mAddedEndOffset - mStartOffset; }
|
||||
|
||||
bool IsInInt32Range() const
|
||||
{
|
||||
return mStartOffset <= INT32_MAX &&
|
||||
mRemovedEndOffset <= INT32_MAX &&
|
||||
mAddedEndOffset <= INT32_MAX;
|
||||
}
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
// NOTIFY_IME_OF_SELECTION_CHANGE specific data
|
||||
SelectionChangeData mSelectionChangeData;
|
||||
|
||||
// NOTIFY_IME_OF_TEXT_CHANGE specific data
|
||||
struct
|
||||
{
|
||||
uint32_t mStartOffset;
|
||||
uint32_t mOldEndOffset;
|
||||
uint32_t mNewEndOffset;
|
||||
|
||||
bool mCausedByComposition;
|
||||
|
||||
uint32_t OldLength() const { return mOldEndOffset - mStartOffset; }
|
||||
uint32_t NewLength() const { return mNewEndOffset - mStartOffset; }
|
||||
int32_t AdditionalLength() const
|
||||
{
|
||||
return static_cast<int32_t>(mNewEndOffset - mOldEndOffset);
|
||||
}
|
||||
bool IsInInt32Range() const
|
||||
{
|
||||
return mStartOffset <= INT32_MAX &&
|
||||
mOldEndOffset <= INT32_MAX &&
|
||||
mNewEndOffset <= INT32_MAX;
|
||||
}
|
||||
} mTextChangeData;
|
||||
TextChangeDataBase mTextChangeData;
|
||||
|
||||
// NOTIFY_IME_OF_MOUSE_BUTTON_EVENT specific data
|
||||
struct
|
||||
|
@ -4315,12 +4315,12 @@ nsTextStore::OnTextChangeInternal(const IMENotification& aIMENotification)
|
||||
MOZ_LOG(sTextStoreLog, LogLevel::Debug,
|
||||
("TSF: 0x%p nsTextStore::OnTextChangeInternal(aIMENotification={ "
|
||||
"mMessage=0x%08X, mTextChangeData={ mStartOffset=%lu, "
|
||||
"mOldEndOffset=%lu, mNewEndOffset=%lu}), mSink=0x%p, mSinkMask=%s, "
|
||||
"mComposition.IsComposing()=%s",
|
||||
"mRemovedEndOffset=%lu, mAddedEndOffset=%lu}), mSink=0x%p, "
|
||||
"mSinkMask=%s, mComposition.IsComposing()=%s",
|
||||
this, aIMENotification.mMessage,
|
||||
aIMENotification.mTextChangeData.mStartOffset,
|
||||
aIMENotification.mTextChangeData.mOldEndOffset,
|
||||
aIMENotification.mTextChangeData.mNewEndOffset, mSink.get(),
|
||||
aIMENotification.mTextChangeData.mRemovedEndOffset,
|
||||
aIMENotification.mTextChangeData.mAddedEndOffset, mSink.get(),
|
||||
GetSinkMaskNameStr(mSinkMask).get(),
|
||||
GetBoolName(mComposition.IsComposing())));
|
||||
|
||||
@ -4344,9 +4344,9 @@ nsTextStore::OnTextChangeInternal(const IMENotification& aIMENotification)
|
||||
textChange.acpStart =
|
||||
static_cast<LONG>(aIMENotification.mTextChangeData.mStartOffset);
|
||||
textChange.acpOldEnd =
|
||||
static_cast<LONG>(aIMENotification.mTextChangeData.mOldEndOffset);
|
||||
static_cast<LONG>(aIMENotification.mTextChangeData.mRemovedEndOffset);
|
||||
textChange.acpNewEnd =
|
||||
static_cast<LONG>(aIMENotification.mTextChangeData.mNewEndOffset);
|
||||
static_cast<LONG>(aIMENotification.mTextChangeData.mAddedEndOffset);
|
||||
NotifyTSFOfTextChange(textChange);
|
||||
} else {
|
||||
MOZ_LOG(sTextStoreLog, LogLevel::Error,
|
||||
|
Loading…
x
Reference in New Issue
Block a user