Bug 1211352 part.5 PuppetWidget should cache only the focused editor rect information while a plugin has focus r=m_kato

This commit is contained in:
Masayuki Nakano 2015-10-10 10:21:02 +09:00
parent 795194af70
commit 7aedbbd965

View File

@ -697,9 +697,18 @@ PuppetWidget::NotifyIMEOfFocusChange(const IMENotification& aIMENotification)
bool gotFocus = aIMENotification.mMessage == NOTIFY_IME_OF_FOCUS;
if (gotFocus) {
// When IME gets focus, we should initalize all information of the content.
if (NS_WARN_IF(!mContentCache.CacheAll(this, &aIMENotification))) {
return NS_ERROR_FAILURE;
if (mInputContext.mIMEState.mEnabled != IMEState::PLUGIN) {
// When IME gets focus, we should initalize all information of the
// content.
if (NS_WARN_IF(!mContentCache.CacheAll(this, &aIMENotification))) {
return NS_ERROR_FAILURE;
}
} else {
// However, if a plugin has focus, only the editor rect information is
// available.
if (NS_WARN_IF(!mContentCache.CacheEditorRect(this, &aIMENotification))) {
return NS_ERROR_FAILURE;
}
}
} else {
// When IME loses focus, we don't need to store anything.
@ -724,7 +733,8 @@ PuppetWidget::NotifyIMEOfCompositionUpdate(
NS_ENSURE_TRUE(mTabChild, NS_ERROR_FAILURE);
if (NS_WARN_IF(!mContentCache.CacheSelection(this, &aIMENotification))) {
if (mInputContext.mIMEState.mEnabled != IMEState::PLUGIN &&
NS_WARN_IF(!mContentCache.CacheSelection(this, &aIMENotification))) {
return NS_ERROR_FAILURE;
}
mTabChild->SendNotifyIMECompositionUpdate(mContentCache, aIMENotification);
@ -769,6 +779,11 @@ PuppetWidget::NotifyIMEOfTextChange(const IMENotification& aIMENotification)
if (!mTabChild)
return NS_ERROR_FAILURE;
// While a plugin has focus, text change notification shouldn't be available.
if (NS_WARN_IF(mInputContext.mIMEState.mEnabled == IMEState::PLUGIN)) {
return NS_ERROR_FAILURE;
}
// FYI: text change notification is the first notification after
// a user operation changes the content. So, we need to modify
// the cache as far as possible here.
@ -803,6 +818,12 @@ PuppetWidget::NotifyIMEOfSelectionChange(
if (!mTabChild)
return NS_ERROR_FAILURE;
// While a plugin has focus, selection change notification shouldn't be
// available.
if (NS_WARN_IF(mInputContext.mIMEState.mEnabled == IMEState::PLUGIN)) {
return NS_ERROR_FAILURE;
}
// Note that selection change must be notified after text change if it occurs.
// Therefore, we don't need to query text content again here.
mContentCache.SetSelection(
@ -830,6 +851,13 @@ PuppetWidget::NotifyIMEOfMouseButtonEvent(
return NS_ERROR_FAILURE;
}
// While a plugin has focus, mouse button event notification shouldn't be
// available.
if (NS_WARN_IF(mInputContext.mIMEState.mEnabled == IMEState::PLUGIN)) {
return NS_ERROR_FAILURE;
}
bool consumedByIME = false;
if (!mTabChild->SendNotifyIMEMouseButtonEvent(aIMENotification,
&consumedByIME)) {
@ -849,7 +877,12 @@ PuppetWidget::NotifyIMEOfPositionChange(const IMENotification& aIMENotification)
return NS_ERROR_FAILURE;
}
if (NS_WARN_IF(!mContentCache.CacheEditorRect(this, &aIMENotification)) ||
if (NS_WARN_IF(!mContentCache.CacheEditorRect(this, &aIMENotification))) {
return NS_ERROR_FAILURE;
}
// While a plugin has focus, selection range isn't available. So, we don't
// need to cache it at that time.
if (mInputContext.mIMEState.mEnabled != IMEState::PLUGIN &&
NS_WARN_IF(!mContentCache.CacheSelection(this, &aIMENotification))) {
return NS_ERROR_FAILURE;
}