@ -48,29 +48,31 @@ ToChar(bool aBool)
}
static const char *
ToChar ( Event Message aEvent Message )
ToChar ( IM EMessage aIM EMessage )
{
switch ( aEventMessage ) {
case eQuerySelectedText :
return " eQuerySelectedText " ;
case eQueryTextContent :
return " eQueryTextContent " ;
case eQueryCaretRect :
return " eQueryCaretRect " ;
case eQueryTextRect :
return " eQueryTextRect " ;
case eQueryEditorRect :
return " eQueryEditorRect " ;
case eQueryContentState :
return " eQueryContentState " ;
case eQuerySelectionAsTransferable :
return " eQuerySelectionAsTransferable " ;
case eQueryCharacterAtPoint :
return " eQueryCharacterAtPoint " ;
case eQueryDOMWidgetHittest :
return " eQueryDOMWidgetHittest " ;
switch ( aIMEMessage ) {
case NOTIFY_IME_OF_NOTHING :
return " NOTIFY_IME_OF_NOTHING " ;
case NOTIFY_IME_OF_FOCUS :
return " NOTIFY_IME_OF_FOCUS " ;
case NOTIFY_IME_OF_BLUR :
return " NOTIFY_IME_OF_BLUR " ;
case NOTIFY_IME_OF_SELECTION_CHANGE :
return " NOTIFY_IME_OF_SELECTION_CHANGE " ;
case NOTIFY_IME_OF_TEXT_CHANGE :
return " NOTIFY_IME_OF_TEXT_CHANGE " ;
case NOTIFY_IME_OF_COMPOSITION_UPDATE :
return " NOTIFY_IME_OF_COMPOSITION_UPDATE " ;
case NOTIFY_IME_OF_POSITION_CHANGE :
return " NOTIFY_IME_OF_POSITION_CHANGE " ;
case NOTIFY_IME_OF_MOUSE_BUTTON_EVENT :
return " NOTIFY_IME_OF_MOUSE_BUTTON_EVENT " ;
case REQUEST_TO_COMMIT_COMPOSITION :
return " REQUEST_TO_COMMIT_COMPOSITION " ;
case REQUEST_TO_CANCEL_COMPOSITION :
return " REQUEST_TO_CANCEL_COMPOSITION " ;
default :
return " Unsupported message " ;
return " Unexpected valu e " ;
}
}
@ -192,14 +194,15 @@ IMEContentObserver::IMEContentObserver()
: mESM ( nullptr )
, mSuppressNotifications ( 0 )
, mPreCharacterDataChangeLength ( - 1 )
, mSendingNotification ( NOTIFY_IME_OF_NOTHING )
, mIsObserving ( false )
, mIMEHasFocus ( false )
, mIsFocusEventPending ( false )
, mIsSelectionChangeEventPending ( false )
, mSelectionChangeCausedOnlyByComposition ( false )
, mSelectionChangeCausedOnlyBySelectionEvent ( false )
, mIsPositionChangeEventPending ( false )
, mNeedsToNotifyIMEOfFocusSet ( false )
, mNeedsToNotifyIMEOfTextChange ( false )
, mNeedsToNotifyIMEOfSelectionChange ( false )
, mNeedsToNotifyIMEOfPositionChange ( false )
, mIsFlushingPendingNotifications ( false )
, mIsHandlingQueryContentEvent ( false )
{
# ifdef DEBUG
mTextChangeData . Test ( ) ;
@ -563,10 +566,6 @@ IMEContentObserver::ReflowInterruptible(DOMHighResTimeStamp aStart,
nsresult
IMEContentObserver : : HandleQueryContentEvent ( WidgetQueryContentEvent * aEvent )
{
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::HandleQueryContentEvent(aEvent={ "
" mMessage=%s }) " , this , ToChar ( aEvent - > mMessage ) ) ) ;
// If the instance has cache, it should use the cached selection which was
// sent to the widget.
if ( aEvent - > mMessage = = eQuerySelectedText & & aEvent - > mUseNativeLineBreak & &
@ -584,6 +583,12 @@ IMEContentObserver::HandleQueryContentEvent(WidgetQueryContentEvent* aEvent)
return NS_OK ;
}
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::HandleQueryContentEvent(aEvent={ "
" mMessage=%s }) " , this , ToChar ( aEvent - > mMessage ) ) ) ;
AutoRestore < bool > handling ( mIsHandlingQueryContentEvent ) ;
mIsHandlingQueryContentEvent = true ;
ContentEventHandler handler ( GetPresContext ( ) ) ;
nsresult rv = handler . HandleQueryContentEvent ( aEvent ) ;
if ( aEvent - > mSucceeded ) {
@ -1001,51 +1006,32 @@ IMEContentObserver::PostFocusSetNotification()
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::PostFocusSetNotification() " , this ) ) ;
mIsFocusEventPending = true ;
mNeedsToNotifyIMEOfFocusSet = true ;
}
void
IMEContentObserver : : PostTextChangeNotification (
const TextChangeDataBase & aTextChangeData )
IMEContentObserver : : PostTextChangeNotification ( )
{
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::PostTextChangeNotification( "
" a TextChangeData=%s)" ,
this , TextChangeDataToString ( a TextChangeData) . get ( ) ) ) ;
" m TextChangeData=%s)" ,
this , TextChangeDataToString ( m TextChangeData) . get ( ) ) ) ;
mTextChangeData + = aTextChangeData ;
MOZ_ASSERT ( mTextChangeData . IsValid ( ) ,
" mTextChangeData must have text change data " ) ;
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::PostTextChangeNotification(), "
" mTextChangeData=%s) " ,
this , TextChangeDataToString ( mTextChangeData ) . get ( ) ) ) ;
mNeedsToNotifyIMEOfTextChange = true ;
}
void
IMEContentObserver : : PostSelectionChangeNotification (
bool aCausedByComposition ,
bool aCausedBySelectionEvent )
IMEContentObserver : : PostSelectionChangeNotification ( )
{
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::PostSelectionChangeNotification( "
" aCausedByComposition=%s, aCausedBySelectionEvent=%s) " ,
this , ToChar ( aCausedByComposition ) , ToChar ( aCausedBySelectionEvent ) ) ) ;
( " IMECO: 0x%p IMEContentObserver::PostSelectionChangeNotification(), "
" mSelectionData={ mCausedByComposition=%s, mCausedBySelectionEvent=%s } " ,
this , ToChar ( mSelectionData . mCausedByComposition ) ,
ToChar ( mSelectionData . mCausedBySelectionEvent ) ) ) ;
if ( ! mIsSelectionChangeEventPending ) {
mSelectionChangeCausedOnlyByComposition = aCausedByComposition ;
} else {
mSelectionChangeCausedOnlyByComposition =
mSelectionChangeCausedOnlyByComposition & & aCausedByComposition ;
}
if ( ! mSelectionChangeCausedOnlyBySelectionEvent ) {
mSelectionChangeCausedOnlyBySelectionEvent = aCausedBySelectionEvent ;
} else {
mSelectionChangeCausedOnlyBySelectionEvent =
mSelectionChangeCausedOnlyBySelectionEvent & & aCausedBySelectionEvent ;
}
mIsSelectionChangeEventPending = true ;
mNeedsToNotifyIMEOfSelectionChange = true ;
}
void
@ -1067,7 +1053,8 @@ IMEContentObserver::MaybeNotifyIMEOfTextChange(
" aTextChangeData=%s) " ,
this , TextChangeDataToString ( aTextChangeData ) . get ( ) ) ) ;
PostTextChangeNotification ( aTextChangeData ) ;
mTextChangeData + = aTextChangeData ;
PostTextChangeNotification ( ) ;
FlushMergeableNotifications ( ) ;
}
@ -1081,8 +1068,9 @@ IMEContentObserver::MaybeNotifyIMEOfSelectionChange(
" aCausedByComposition=%s, aCausedBySelectionEvent=%s) " ,
this , ToChar ( aCausedByComposition ) , ToChar ( aCausedBySelectionEvent ) ) ) ;
PostSelectionChangeNotification ( aCausedByComposition ,
aCausedBySelectionEvent ) ;
mSelectionData . AssignReason ( aCausedByComposition ,
aCausedBySelectionEvent ) ;
PostSelectionChangeNotification ( ) ;
FlushMergeableNotifications ( ) ;
}
@ -1091,6 +1079,18 @@ IMEContentObserver::MaybeNotifyIMEOfPositionChange()
{
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::MaybeNotifyIMEOfPositionChange() " , this ) ) ;
// If reflow is caused by ContentEventHandler during PositionChangeEvent
// sending NOTIFY_IME_OF_POSITION_CHANGE, we don't need to notify IME of it
// again since ContentEventHandler returns the result including this reflow's
// result.
if ( mIsHandlingQueryContentEvent & &
mSendingNotification = = NOTIFY_IME_OF_POSITION_CHANGE ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::MaybeNotifyIMEOfPositionChange(), "
" ignored since caused by ContentEventHandler during sending "
" NOTIY_IME_OF_POSITION_CHANGE " , this ) ) ;
return ;
}
PostPositionChangeNotification ( ) ;
FlushMergeableNotifications ( ) ;
}
@ -1104,7 +1104,7 @@ IMEContentObserver::UpdateSelectionCache()
return false ;
}
mSelectionData . Clear ( ) ;
mSelectionData . ClearSelectionData ( ) ;
// XXX Cannot we cache some information for reducing the cost to compute
// selection offset and writing mode?
@ -1120,8 +1120,8 @@ IMEContentObserver::UpdateSelectionCache()
* mSelectionData . mString = selection . mReply . mString ;
mSelectionData . SetWritingMode ( selection . GetWritingMode ( ) ) ;
mSelectionData . mReversed = selection . mReply . mReversed ;
mSelectionData . mCausedByComposition = false ;
mSelectionData . mCausedBySelectionEvent = false ;
// WARNING: Don't modify the reason of selection change here.
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::UpdateSelectionCache(), "
@ -1137,7 +1137,7 @@ IMEContentObserver::PostPositionChangeNotification()
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::PostPositionChangeNotification() " , this ) ) ;
mIsPositionChangeEventPending = true ;
mNeedsToNotifyIMEOfPositionChange = true ;
}
bool
@ -1215,63 +1215,22 @@ IMEContentObserver::FlushMergeableNotifications()
return ;
}
AutoRestore < bool > flusing ( mIsFlushingPendingNotifications ) ;
mIsFlushingPendingNotifications = true ;
// NOTE: Reset each pending flag because sending notification may cause
// another change.
if ( mIsFocusEventPending ) {
if ( ! NeedsToNotifyIMEOfSomething ( ) ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::FlushMergeableNotifications(), "
" creating FocusSetEvent... " , this ) ) ;
mIsFocusEventPending = false ;
nsContentUtils : : AddScriptRunner ( new FocusSetEvent ( this ) ) ;
// This is the first notification to IME. So, we don't need to notify any
// more since IME starts to query content after it gets focus.
ClearPendingNotifications ( ) ;
( " IMECO: 0x%p IMEContentObserver::FlushMergeableNotifications(), "
" FAILED, due to no pending notifications " , this ) ) ;
return ;
}
if ( mTextChangeData . IsValid ( ) ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::FlushMergeableNotifications(), "
" creating TextChangeEvent... " , this ) ) ;
nsContentUtils : : AddScriptRunner ( new TextChangeEvent ( this , mTextChangeData ) ) ;
}
// Be aware, PuppetWidget depends on the order of this. A selection change
// notification should not be sent before a text change notification because
// PuppetWidget shouldn't query new text content every selection change.
if ( mIsSelectionChangeEventPending ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::FlushMergeableNotifications(), "
" creating SelectionChangeEvent... " , this ) ) ;
mIsSelectionChangeEventPending = false ;
nsContentUtils : : AddScriptRunner (
new SelectionChangeEvent ( this , mSelectionChangeCausedOnlyByComposition ,
mSelectionChangeCausedOnlyBySelectionEvent ) ) ;
}
// NOTE: Reset each pending flag because sending notification may cause
// another change.
if ( mIsPositionChangeEventPending ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::FlushMergeableNotifications(), "
" creating PositionChangeEvent... " , this ) ) ;
mIsPositionChangeEventPending = false ;
nsContentUtils : : AddScriptRunner ( new PositionChangeEvent ( this ) ) ;
}
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::FlushMergeableNotifications(), "
" creating IMENotificationSender... " , this ) ) ;
// If notifications may cause new change, we should notify them now.
if ( mTextChangeData . IsValid ( ) | |
mIsSelectionChangeEventPending | |
mIsPositionChangeEventPending ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::FlushMergeableNotifications(), "
" posting AsyncMergeableNotificationsFlusher to current thread " , this ) ) ;
nsRefPtr < AsyncMergeableNotificationsFlusher > asyncFlusher =
new AsyncMergeableNotificationsFlusher ( this ) ;
NS_DispatchToCurrentThread ( asyncFlusher ) ;
}
mIsFlushingPendingNotifications = true ;
nsContentUtils : : AddScriptRunner ( new IMENotificationSender ( this ) ) ;
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::FlushMergeableNotifications(), "
@ -1283,7 +1242,8 @@ IMEContentObserver::FlushMergeableNotifications()
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
bool
IMEContentObserver : : AChangeEvent : : CanNotifyIME ( ) const
IMEContentObserver : : AChangeEvent : : CanNotifyIME (
ChangeEventType aChangeEventType ) const
{
if ( NS_WARN_IF ( ! mIMEContentObserver ) ) {
return false ;
@ -1294,7 +1254,7 @@ IMEContentObserver::AChangeEvent::CanNotifyIME() const
return false ;
}
// If setting focus, just check the state.
if ( m ChangeEventType = = eChangeEventType_Focus ) {
if ( a ChangeEventType = = eChangeEventType_Focus ) {
return ! NS_WARN_IF ( mIMEContentObserver - > mIMEHasFocus ) ;
}
// If we've not notified IME of focus yet, we shouldn't notify anything.
@ -1309,13 +1269,24 @@ IMEContentObserver::AChangeEvent::CanNotifyIME() const
}
bool
IMEContentObserver : : AChangeEvent : : IsSafeToNotifyIME ( ) const
IMEContentObserver : : AChangeEvent : : IsSafeToNotifyIME (
ChangeEventType aChangeEventType ) const
{
if ( NS_WARN_IF ( ! nsContentUtils : : IsSafeToRunScript ( ) ) ) {
return false ;
}
// While we're sending a notification, we shouldn't send another notification
// recursively.
if ( mIMEContentObserver - > mSendingNotification ! = NOTIFY_IME_OF_NOTHING ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::AChangeEvent::IsSafeToNotifyIME(), "
" putting off sending notification due to detecting recursive call, "
" mIMEContentObserver={ mSendingNotification=%s } " ,
this , ToChar ( mIMEContentObserver - > mSendingNotification ) ) ) ;
return false ;
}
State state = mIMEContentObserver - > GetState ( ) ;
if ( mChangeEventType = = eChangeEventType_Focus ) {
if ( a ChangeEventType = = eChangeEventType_Focus ) {
if ( NS_WARN_IF ( state ! = eState_Initializing & & state ! = eState_Observing ) ) {
return false ;
}
@ -1326,28 +1297,90 @@ IMEContentObserver::AChangeEvent::IsSafeToNotifyIME() const
}
/******************************************************************************
* mozilla : : IMEContentObserver : : FocusSetEvent
* mozilla : : IMEContentObserver : : IMENotificationSender
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
NS_IMETHODIMP
IMEContentObserver : : FocusSetEvent : : Run ( )
IMEContentObserver : : IMENotificationSender : : Run ( )
{
if ( ! CanNotifyIME ( ) ) {
MOZ_ASSERT ( mIMEContentObserver - > mIsFlushingPendingNotifications ) ;
// NOTE: Reset each pending flag because sending notification may cause
// another change.
if ( mIMEContentObserver - > mNeedsToNotifyIMEOfFocusSet ) {
mIMEContentObserver - > mNeedsToNotifyIMEOfFocusSet = false ;
SendFocusSet ( ) ;
// This is the first notification to IME. So, we don't need to notify
// anymore since IME starts to query content after it gets focus.
mIMEContentObserver - > ClearPendingNotifications ( ) ;
mIMEContentObserver - > mIsFlushingPendingNotifications = false ;
return NS_OK ;
}
if ( mIMEContentObserver - > mNeedsToNotifyIMEOfTextChange ) {
mIMEContentObserver - > mNeedsToNotifyIMEOfTextChange = false ;
SendTextChange ( ) ;
}
// If a text change notification causes another text change again, we should
// notify IME of that before sending a selection change notification.
if ( ! mIMEContentObserver - > mNeedsToNotifyIMEOfTextChange ) {
// Be aware, PuppetWidget depends on the order of this. A selection change
// notification should not be sent before a text change notification because
// PuppetWidget shouldn't query new text content every selection change.
if ( mIMEContentObserver - > mNeedsToNotifyIMEOfSelectionChange ) {
mIMEContentObserver - > mNeedsToNotifyIMEOfSelectionChange = false ;
SendSelectionChange ( ) ;
}
}
// If a text change notification causes another text change again or a
// selection change notification causes either a text change or another
// selection change, we should notify IME of those before sending a position
// change notification.
if ( ! mIMEContentObserver - > mNeedsToNotifyIMEOfTextChange & &
! mIMEContentObserver - > mNeedsToNotifyIMEOfSelectionChange ) {
if ( mIMEContentObserver - > mNeedsToNotifyIMEOfPositionChange ) {
mIMEContentObserver - > mNeedsToNotifyIMEOfPositionChange = false ;
SendPositionChange ( ) ;
}
}
// If notifications caused some new change, we should notify them now.
mIMEContentObserver - > mIsFlushingPendingNotifications =
mIMEContentObserver - > NeedsToNotifyIMEOfSomething ( ) ;
if ( mIMEContentObserver - > mIsFlushingPendingNotifications ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender::Run(), "
" posting AsyncMergeableNotificationsFlusher to current thread " , this ) ) ;
nsRefPtr < AsyncMergeableNotificationsFlusher > asyncFlusher =
new AsyncMergeableNotificationsFlusher ( mIMEContentObserver ) ;
NS_DispatchToCurrentThread ( asyncFlusher ) ;
}
return NS_OK ;
}
void
IMEContentObserver : : IMENotificationSender : : SendFocusSet ( )
{
if ( ! CanNotifyIME ( eChangeEventType_Focus ) ) {
// If IMEContentObserver has already gone, we don't need to notify IME of
// focus.
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::FocusSetEvent::Run(), FAILED, due to "
" impossible to notify IME of focus " , this ) ) ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendFocusSet(), FAILED, due to impossible to notify IME of focus " ,
this ) ) ;
mIMEContentObserver - > ClearPendingNotifications ( ) ;
return NS_OK ;
return ;
}
if ( ! IsSafeToNotifyIME ( ) ) {
if ( ! IsSafeToNotifyIME ( eChangeEventType_Focus ) ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::FocusSetEvent::Run(), retrying to "
" send NOTIFY_IME_OF_FOCUS... " , this ) ) ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendFocusSet(), retrying to send NOTIFY_IME_OF_FOCUS..." , this ) ) ;
mIMEContentObserver - > PostFocusSetNotification ( ) ;
return NS_OK ;
return ;
}
mIMEContentObserver - > mIMEHasFocus = true ;
@ -1355,166 +1388,177 @@ IMEContentObserver::FocusSetEvent::Run()
mIMEContentObserver - > UpdateSelectionCache ( ) ;
MOZ_LOG ( sIMECOLog , LogLevel : : Info ,
( " IMECO: 0x%p IMEContentObserver::FocusSetEvent::Run(), "
" sending NOTIFY_IME_OF_FOCUS... " , this ) ) ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendFocusSet(), sending NOTIFY_IME_OF_FOCUS..." , this ) ) ;
MOZ_RELEASE_ASSERT ( mIMEContentObserver - > mSendingNotification = =
NOTIFY_IME_OF_NOTHING ) ;
mIMEContentObserver - > mSendingNotification = NOTIFY_IME_OF_FOCUS ;
IMEStateManager : : NotifyIME ( IMENotification ( NOTIFY_IME_OF_FOCUS ) ,
mIMEContentObserver - > mWidget ) ;
mIMEContentObserver - > mSendingNotification = NOTIFY_IME_OF_NOTHING ;
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::FocusSetEvent::Run(), "
" sent NOTIFY_IME_OF_FOCUS " , this ) ) ;
return NS_OK ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendFocusSet(), sent NOTIFY_IME_OF_FOCUS " , this ) ) ;
}
/******************************************************************************
* mozilla : : IMEContentObserver : : SelectionChangeEvent
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
NS_IMETHODIMP
IMEContentObserver : : SelectionChangeEvent : : Run ( )
void
IMEContentObserver : : IMENotificationSender : : SendSelectionChange ( )
{
if ( ! CanNotifyIME ( ) ) {
if ( ! CanNotifyIME ( eChangeEventType_Selection ) ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::SelectionChangeEvent::Run(), FAILED, "
" due to impossible to notify IME of selection change " , this ) ) ;
return NS_OK ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendSelectionChange(), FAILED, due to impossible to notify IME of "
" selection change " , this ) ) ;
return ;
}
if ( ! IsSafeToNotifyIME ( ) ) {
if ( ! IsSafeToNotifyIME ( eChangeEventType_Selection ) ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::SelectionChangeEvent::Run(), "
" retrying to send NOTIFY_IME_OF_SELECTION_CHANGE... " , this ) ) ;
mIMEContentObserver - > PostSelectionChangeNotification (
mCausedByComposition , mCausedBySelectionEvent ) ;
return NS_OK ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendSelectionChange(), retrying to send "
" NOTIFY_IME_OF_SELECTION_CHANGE... " , this ) ) ;
mIMEContentObserver - > PostSelectionChangeNotification ( ) ;
return ;
}
SelectionChangeData lastSelChangeData = mIMEContentObserver - > mSelectionData ;
if ( NS_WARN_IF ( ! mIMEContentObserver - > UpdateSelectionCache ( ) ) ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Error ,
( " IMECO: 0x%p IMEContentObserver::SelectionChangeEvent::Run(), FAILED, "
" due to UpdateSelectionCache() failure " , this ) ) ;
return NS_OK ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendSelectionChange(), FAILED, due to UpdateSelectionCache() failure " ,
this ) ) ;
return ;
}
// If the IME doesn't want selection change notifications caused by
// composition, we should do nothing anymore.
if ( mCausedByComposition & &
SelectionChangeData & newSelChangeData = mIMEContentObserver - > mSelectionData ;
if ( newSelChangeData . mCausedByComposition & &
! mIMEContentObserver - >
mUpdatePreference . WantChangesCausedByComposition ( ) ) {
return NS_OK ;
return ;
}
// The state may be changed since querying content causes flushing layout.
if ( ! CanNotifyIME ( ) ) {
if ( ! CanNotifyIME ( eChangeEventType_Selection ) ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::SelectionChangeEvent::Run(), FAILED, "
" due to flushing layout having changed something " , this ) ) ;
return NS_OK ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendSelectionChange(), FAILED, due to flushing layout having changed "
" something " , this ) ) ;
return ;
}
// If the selection isn't changed actually, we shouldn't notify IME of
// selection change.
SelectionChangeData & newSelChangeData = mIMEContentObserver - > mSelectionData ;
if ( lastSelChangeData . IsValid ( ) & &
lastSelChangeData . mOffset = = newSelChangeData . mOffset & &
lastSelChangeData . String ( ) = = newSelChangeData . String ( ) & &
lastSelChangeData . GetWritingMode ( ) = = newSelChangeData . GetWritingMode ( ) & &
lastSelChangeData . mReversed = = newSelChangeData . mReversed ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::SelectionChangeEvent::Run(), not "
" notifying IME of NOTIFY_IME_OF_SELECTION_CHANGE due to not changed "
" actually " , this ) ) ;
return NS_OK ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendSelectionChange(), not notifying IME of "
" NOTIFY_IME_OF_SELECTION_CHANGE due to not changed actually" , this ) ) ;
return ;
}
MOZ_LOG ( sIMECOLog , LogLevel : : Info ,
( " IMECO: 0x%p IMEContentObserver::SelectionChangeEvent::Run(), "
" sending NOTIFY_IME_OF_SELECTION_CHANGE... newSelChangeData=%s " ,
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendSelectionChange(), sending NOTIFY_IME_OF_SELECTION_CHANGE... "
" newSelChangeData=%s " ,
this , SelectionChangeDataToString ( newSelChangeData ) . get ( ) ) ) ;
IMENotification notification ( NOTIFY_IME_OF_SELECTION_CHANGE ) ;
notification . SetData ( mIMEContentObserver - > mSelectionData ,
mCausedByComposition , mCausedBySelectionEvent ) ;
notification . SetData ( mIMEContentObserver - > mSelectionData ) ;
MOZ_RELEASE_ASSERT ( mIMEContentObserver - > mSendingNotification = =
NOTIFY_IME_OF_NOTHING ) ;
mIMEContentObserver - > mSendingNotification = NOTIFY_IME_OF_SELECTION_CHANGE ;
IMEStateManager : : NotifyIME ( notification , mIMEContentObserver - > mWidget ) ;
mIMEContentObserver - > mSendingNotification = NOTIFY_IME_OF_NOTHING ;
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::SelectionChangeEvent::Run(), "
" sent NOTIFY_IME_OF_SELECTION_CHANGE " , this ) ) ;
return NS_OK ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendSelectionChange(), sent NOTIFY_IME_OF_SELECTION_CHANGE " , this ) ) ;
}
/******************************************************************************
* mozilla : : IMEContentObserver : : TextChangeEvent
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
NS_IMETHODIMP
IMEContentObserver : : TextChangeEvent : : Run ( )
void
IMEContentObserver : : IMENotificationSender : : SendTextChange ( )
{
if ( ! CanNotifyIME ( ) ) {
if ( ! CanNotifyIME ( eChangeEventType_Text ) ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::TextChangeEvent::Run(), FAILED, "
" due to impossible to notify IME of text change " , this ) ) ;
return NS_OK ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendTextChange(), FAILED, due to impossible to notify IME of text "
" change " , this ) ) ;
return ;
}
if ( ! IsSafeToNotifyIME ( ) ) {
if ( ! IsSafeToNotifyIME ( eChangeEventType_Text ) ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::TextChangeEvent::Run(), retrying to "
" send NOTIFY_IME_OF_TEXT_CHANGE... " , this ) ) ;
mIMEContentObserver - > PostTextChangeNotification ( mTextChangeData ) ;
return NS_OK ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendTextChange(), retrying to send NOTIFY_IME_OF_TEXT_CHANGE... " ,
this ) ) ;
mIMEContentObserver - > PostTextChangeNotification ( ) ;
return ;
}
MOZ_LOG ( sIMECOLog , LogLevel : : Info ,
( " IMECO: 0x%p IMEContentObserver::TextChangeEvent::Run(), "
" sending NOTIFY_IME_OF_TEXT_CHANGE... mTextChangeData=%s " ,
this , TextChangeDataToString ( mTextChangeData ) . get ( ) ) ) ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendTextChange(), sending NOTIFY_IME_OF_TEXT_CHANGE... "
" mIMEContentObserver={ mTextChangeData=%s } " ,
this , TextChangeDataToString ( mIMEContentObserver - > mTextChangeData ) . get ( ) ) ) ;
IMENotification notification ( NOTIFY_IME_OF_TEXT_CHANGE ) ;
notification . SetData ( mTextChangeData ) ;
notification . SetData ( mIMEContentObserver - > mTextChangeData ) ;
mIMEContentObserver - > mTextChangeData . Clear ( ) ;
MOZ_RELEASE_ASSERT ( mIMEContentObserver - > mSendingNotification = =
NOTIFY_IME_OF_NOTHING ) ;
mIMEContentObserver - > mSendingNotification = NOTIFY_IME_OF_TEXT_CHANGE ;
IMEStateManager : : NotifyIME ( notification , mIMEContentObserver - > mWidget ) ;
mIMEContentObserver - > mSendingNotification = NOTIFY_IME_OF_NOTHING ;
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::TextChangeEvent::Run(), "
" sent NOTIFY_IME_OF_TEXT_CHANGE " , this ) ) ;
return NS_OK ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendTextChange(), sent NOTIFY_IME_OF_TEXT_CHANGE " , this ) ) ;
}
/******************************************************************************
* mozilla : : IMEContentObserver : : PositionChangeEvent
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
NS_IMETHODIMP
IMEContentObserver : : PositionChangeEvent : : Run ( )
void
IMEContentObserver : : IMENotificationSender : : SendPositionChange ( )
{
if ( ! CanNotifyIME ( ) ) {
if ( ! CanNotifyIME ( eChangeEventType_Position ) ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::PositionChangeEvent::Run(), FAILED, "
" due to impossible to notify IME of position change " , this ) ) ;
return NS_OK ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendPositionChange(), FAILED, due to impossible to notify IME of "
" position change " , this ) ) ;
return ;
}
if ( ! IsSafeToNotifyIME ( ) ) {
if ( ! IsSafeToNotifyIME ( eChangeEventType_Position ) ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::PositionChangeEvent::Run(), "
" retrying to send NOTIFY_IME_OF_POSITION_CHANGE... " , this ) ) ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendPositionChange(), retrying to send "
" NOTIFY_IME_OF_POSITION_CHANGE... " , this ) ) ;
mIMEContentObserver - > PostPositionChangeNotification ( ) ;
return NS_OK ;
return ;
}
MOZ_LOG ( sIMECOLog , LogLevel : : Info ,
( " IMECO: 0x%p IMEContentObserver::PositionChangeEvent::Run(), "
" sending NOTIFY_IME_OF_POSITION_CHANGE... " , this ) ) ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendPositionChange(), sending NOTIFY_IME_OF_POSITION_CHANGE..." , this ) ) ;
MOZ_RELEASE_ASSERT ( mIMEContentObserver - > mSendingNotification = =
NOTIFY_IME_OF_NOTHING ) ;
mIMEContentObserver - > mSendingNotification = NOTIFY_IME_OF_POSITION_CHANGE ;
IMEStateManager : : NotifyIME ( IMENotification ( NOTIFY_IME_OF_POSITION_CHANGE ) ,
mIMEContentObserver - > mWidget ) ;
mIMEContentObserver - > mSendingNotification = NOTIFY_IME_OF_NOTHING ;
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::PositionChangeEvent::Run(), "
" sent NOTIFY_IME_OF_POSITION_CHANGE " , this ) ) ;
return NS_OK ;
( " IMECO: 0x%p IMEContentObserver::IMENotificationSender:: "
" SendPositionChange(), sent NOTIFY_IME_OF_POSITION_CHANGE " , this ) ) ;
}
/******************************************************************************
@ -1524,7 +1568,7 @@ IMEContentObserver::PositionChangeEvent::Run()
NS_IMETHODIMP
IMEContentObserver : : AsyncMergeableNotificationsFlusher : : Run ( )
{
if ( ! CanNotifyIME ( ) ) {
if ( ! CanNotifyIME ( eChangeEventType_FlushPendingEvents ) ) {
MOZ_LOG ( sIMECOLog , LogLevel : : Debug ,
( " IMECO: 0x%p IMEContentObserver::AsyncMergeableNotificationsFlusher:: "
" Run(), FAILED, due to impossible to flush pending notifications " ,