Bug 1304620 part.5 ContentCacheInParent should store the latest composition start offset with mCompositionStartInChild r=m_kato

When ContentCacheInParent receives eCompositionStart, it temporarily sets mCompositionStart to selection start offset.  However, if there is a composition in the remote process, the selection start is caret position in the composition string.  Therefore, it's not useful information.  Instead, the composition start offset should be used because around there are a lot of information.

For that, ContentCacheInParent should always store compostion start offset in the remote process with mCompositionStartInChild even if mWidgetHasComposition is false.  And when it receives eCompositionStart, mCompositionStart should be set to mCompositionStartInChild.

MozReview-Commit-ID: DksPNEsi6Ec

--HG--
extra : rebase_source : bcf2946273d24a4c37c33fa18a321660115e3fb6
This commit is contained in:
Masayuki Nakano 2016-10-12 21:52:01 +09:00
Родитель 610b4b4a2e
Коммит 141de4c2d1
2 изменённых файлов: 11 добавлений и 0 удалений

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

@ -510,6 +510,7 @@ ContentCacheInParent::ContentCacheInParent()
: ContentCache()
, mCommitStringByRequest(nullptr)
, mPendingEventsNeedingAck(0)
, mCompositionStartInChild(UINT32_MAX)
, mPendingCompositionCount(0)
, mWidgetHasComposition(false)
{
@ -539,6 +540,7 @@ ContentCacheInParent::AssignContent(const ContentCache& aOther,
// *current* composition start offset. Note that, in strictly speaking,
// widget should not use WidgetQueryContentEvent if there are some pending
// compositions (i.e., when mPendingCompositionCount is 2 or more).
mCompositionStartInChild = aOther.mCompositionStart;
if (mWidgetHasComposition) {
if (aOther.mCompositionStart != UINT32_MAX) {
mCompositionStart = aOther.mCompositionStart;
@ -1091,6 +1093,12 @@ ContentCacheInParent::OnCompositionEvent(const WidgetCompositionEvent& aEvent)
if (aEvent.mWidget && aEvent.mWidget->PluginHasFocus()) {
// If focus is on plugin, we cannot get selection range
mCompositionStart = 0;
} else if (mCompositionStartInChild != UINT32_MAX) {
// If there is pending composition in the remote process, let's use
// its start offset temporarily because this stores a lot of information
// around it and the user must look around there, so, showing some UI
// around it must make sense.
mCompositionStart = mCompositionStartInChild;
} else {
mCompositionStart = mSelection.StartOffset();
}

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

@ -414,6 +414,9 @@ private:
// a selection event and decreased after they are received in the child
// process.
uint32_t mPendingEventsNeedingAck;
// mCompositionStartInChild stores current composition start offset in the
// remote process.
uint32_t mCompositionStartInChild;
// mPendingCompositionCount is number of compositions which started in widget
// but not yet handled in the child process.
uint8_t mPendingCompositionCount;