Bug 1275918 part.2 Update TextComposition::mCompositionStartOffset when it's modified in the remote process r=m_kato

MozReview-Commit-ID: H1SJTWWav6G

--HG--
extra : rebase_source : 6d7d79e7d4d719b720bed4f4c20196079fb8b5fb
This commit is contained in:
Masayuki Nakano 2016-06-14 21:06:34 +09:00
Родитель 50a7dd324b
Коммит f8210c2a4e
7 изменённых файлов: 79 добавлений и 9 удалений

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

@ -221,6 +221,39 @@ IMEStateManager::StopIMEStateManagement()
DestroyIMEContentObserver();
}
// static
void
IMEStateManager::MaybeStartOffsetUpdatedInChild(nsIWidget* aWidget,
uint32_t aStartOffset)
{
if (NS_WARN_IF(!sTextCompositions)) {
MOZ_LOG(sISMLog, LogLevel::Warning,
("ISM: IMEStateManager::MaybeStartOffsetUpdatedInChild("
"aWidget=0x%p, aStartOffset=%u), called when there is no "
"composition", aWidget, aStartOffset));
return;
}
RefPtr<TextComposition> composition = GetTextCompositionFor(aWidget);
if (NS_WARN_IF(!composition)) {
MOZ_LOG(sISMLog, LogLevel::Warning,
("ISM: IMEStateManager::MaybeStartOffsetUpdatedInChild("
"aWidget=0x%p, aStartOffset=%u), called when there is no "
"composition", aWidget, aStartOffset));
return;
}
if (composition->NativeOffsetOfStartComposition() == aStartOffset) {
return;
}
MOZ_LOG(sISMLog, LogLevel::Info,
("ISM: IMEStateManager::MaybeStartOffsetUpdatedInChild("
"aWidget=0x%p, aStartOffset=%u), old offset=%u",
aWidget, aStartOffset, composition->NativeOffsetOfStartComposition()));
composition->OnStartOffsetUpdatedInChild(aStartOffset);
}
// static
nsresult
IMEStateManager::OnDestroyPresContext(nsPresContext* aPresContext)

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

@ -97,6 +97,18 @@ public:
*/
static void StopIMEStateManagement();
/**
* MaybeStartOffsetUpdatedInChild() is called when composition start offset
* is maybe updated in the child process. I.e., even if it's not updated,
* this is called and never called if the composition is in this process.
* @param aWidget The widget whose native IME context has the
* composition.
* @param aStartOffset New composition start offset with native
* linebreaks.
*/
static void MaybeStartOffsetUpdatedInChild(nsIWidget* aWidget,
uint32_t aStartOffset);
static nsresult OnDestroyPresContext(nsPresContext* aPresContext);
static nsresult OnRemoveContent(nsPresContext* aPresContext,
nsIContent* aContent);

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

@ -509,6 +509,12 @@ TextComposition::OnCompositionEventDispatched(
}
}
void
TextComposition::OnStartOffsetUpdatedInChild(uint32_t aStartOffset)
{
mCompositionStartOffset = aStartOffset;
}
void
TextComposition::MaybeNotifyIMEOfCompositionEventHandled(
const WidgetCompositionEvent* aCompositionEvent)

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

@ -401,6 +401,15 @@ private:
*/
uint32_t GetSelectionStartOffset();
/**
* OnStartOffsetUpdatedInChild() is called when composition start offset
* is updated in the child process. I.e., this is called and never called
* if the composition is in this process.
* @param aStartOffset New composition start offset with native
* linebreaks.
*/
void OnStartOffsetUpdatedInChild(uint32_t aStartOffset);
/**
* CompositionEventDispatcher dispatches the specified composition (or text)
* event.

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

@ -1866,7 +1866,7 @@ TabParent::RecvNotifyIMEFocus(const ContentCache& aContentCache,
return true;
}
mContentCache.AssignContent(aContentCache, &aIMENotification);
mContentCache.AssignContent(aContentCache, widget, &aIMENotification);
IMEStateManager::NotifyIME(aIMENotification, widget, true);
if (aIMENotification.mMessage == NOTIFY_IME_OF_FOCUS) {
@ -1892,7 +1892,7 @@ TabParent::RecvNotifyIMETextChange(const ContentCache& aContentCache,
"The widget doesn't want text change notification caused by composition");
#endif
mContentCache.AssignContent(aContentCache, &aIMENotification);
mContentCache.AssignContent(aContentCache, widget, &aIMENotification);
mContentCache.MaybeNotifyIME(widget, aIMENotification);
return true;
}
@ -1907,7 +1907,7 @@ TabParent::RecvNotifyIMECompositionUpdate(
return true;
}
mContentCache.AssignContent(aContentCache, &aIMENotification);
mContentCache.AssignContent(aContentCache, widget, &aIMENotification);
mContentCache.MaybeNotifyIME(widget, aIMENotification);
return true;
}
@ -1920,7 +1920,7 @@ TabParent::RecvNotifyIMESelection(const ContentCache& aContentCache,
if (!widget)
return true;
mContentCache.AssignContent(aContentCache, &aIMENotification);
mContentCache.AssignContent(aContentCache, widget, &aIMENotification);
mContentCache.MaybeNotifyIME(widget, aIMENotification);
return true;
}
@ -1933,7 +1933,7 @@ TabParent::RecvUpdateContentCache(const ContentCache& aContentCache)
return true;
}
mContentCache.AssignContent(aContentCache);
mContentCache.AssignContent(aContentCache, widget);
return true;
}
@ -1962,7 +1962,7 @@ TabParent::RecvNotifyIMEPositionChange(const ContentCache& aContentCache,
return true;
}
mContentCache.AssignContent(aContentCache, &aIMENotification);
mContentCache.AssignContent(aContentCache, widget, &aIMENotification);
mContentCache.MaybeNotifyIME(widget, aIMENotification);
return true;
}

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

@ -438,6 +438,7 @@ ContentCacheInParent::ContentCacheInParent()
void
ContentCacheInParent::AssignContent(const ContentCache& aOther,
nsIWidget* aWidget,
const IMENotification* aNotification)
{
mCompositionStart = aOther.mCompositionStart;
@ -448,12 +449,20 @@ ContentCacheInParent::AssignContent(const ContentCache& aOther,
mTextRectArray = aOther.mTextRectArray;
mEditorRect = aOther.mEditorRect;
if (mIsComposing) {
NS_WARN_IF(mCompositionStart == UINT32_MAX);
IMEStateManager::MaybeStartOffsetUpdatedInChild(aWidget, mCompositionStart);
} else {
NS_WARN_IF(mCompositionStart != UINT32_MAX);
}
MOZ_LOG(sContentCacheLog, LogLevel::Info,
("ContentCacheInParent: 0x%p AssignContent(aNotification=%s), "
"Succeeded, mText.Length()=%u, mSelection={ mAnchor=%u, mFocus=%u, "
"mWritingMode=%s, mAnchorCharRect=%s, mFocusCharRect=%s, mRect=%s }, "
"mFirstCharRect=%s, mCaret={ mOffset=%u, mRect=%s }, mTextRectArray={ "
"mStart=%u, mRects.Length()=%u }, mCompositionStart=%u, mEditorRect=%s",
"mStart=%u, mRects.Length()=%u }, mIsComposing=%s, mCompositionStart=%u, "
"mEditorRect=%s",
this, GetNotificationName(aNotification),
mText.Length(), mSelection.mAnchor, mSelection.mFocus,
GetWritingModeName(mSelection.mWritingMode).get(),
@ -461,8 +470,8 @@ ContentCacheInParent::AssignContent(const ContentCache& aOther,
GetRectText(mSelection.mFocusCharRect).get(),
GetRectText(mSelection.mRect).get(), GetRectText(mFirstCharRect).get(),
mCaret.mOffset, GetRectText(mCaret.mRect).get(), mTextRectArray.mStart,
mTextRectArray.mRects.Length(), mCompositionStart,
GetRectText(mEditorRect).get()));
mTextRectArray.mRects.Length(), GetBoolName(mIsComposing),
mCompositionStart, GetRectText(mEditorRect).get()));
}
bool

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

@ -280,6 +280,7 @@ public:
* it's managed by TabParent itself.
*/
void AssignContent(const ContentCache& aOther,
nsIWidget* aWidget,
const IMENotification* aNotification = nullptr);
/**