From a6ebc050dee764d09bc20af291400122e4e5f1cc Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Sat, 10 Oct 2015 10:21:02 +0900 Subject: [PATCH] Bug 1211352 part.5 PuppetWidget should cache only the focused editor rect information while a plugin has focus r=m_kato --- widget/PuppetWidget.cpp | 43 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 2bd483241c7b..7c0c9dbb7c2f 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -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; }