Bug 805767 part.1 nsTextStateManager should use nsIWidget::GetIMEUpdatePreference() instead of the result of nsIWidget::OnIMEFocusChange() r=smaug

This commit is contained in:
Masayuki Nakano 2012-11-13 22:04:44 +09:00
parent 6d464c7d6e
commit e4a8770b29
5 changed files with 26 additions and 24 deletions

View File

@ -739,13 +739,11 @@ nsTextStateManager::nsTextStateManager(nsIWidget* aWidget,
false, false))->RunDOMEventWhenSafe();
}
nsresult rv = mWidget->OnIMEFocusChange(true);
if (rv == NS_ERROR_NOT_IMPLEMENTED) {
return;
}
NS_ENSURE_SUCCESS_VOID(rv);
mWidget->OnIMEFocusChange(true);
ObserveEditableNode();
if (mWidget->GetIMEUpdatePreference().mWantUpdates) {
ObserveEditableNode();
}
}
void

View File

@ -519,22 +519,20 @@ TabParent::RecvNotifyIMEFocus(const bool& aFocus,
uint32_t* aSeqno)
{
nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget)
if (!widget) {
aPreference->mWantUpdates = false;
aPreference->mWantHints = false;
return true;
}
*aSeqno = mIMESeqno;
mIMETabParent = aFocus ? this : nullptr;
mIMESelectionAnchor = 0;
mIMESelectionFocus = 0;
nsresult rv = widget->OnIMEFocusChange(aFocus);
widget->OnIMEFocusChange(aFocus);
if (aFocus) {
if (NS_SUCCEEDED(rv)) {
*aPreference = widget->GetIMEUpdatePreference();
} else {
aPreference->mWantUpdates = false;
aPreference->mWantHints = false;
}
*aPreference = widget->GetIMEUpdatePreference();
} else {
mIMECacheText.Truncate(0);
}

View File

@ -186,12 +186,12 @@ enum nsTopLevelWidgetZPlacement { // for PlaceBehind()
/**
* Preference for receiving IME updates
*
* If mWantUpdates is true, PuppetWidget will forward
* nsIWidget::OnIMETextChange and nsIWidget::OnIMESelectionChange to the chrome
* process. This incurs overhead from observers and IPDL. If the IME
* implementation on a particular platform doesn't care about OnIMETextChange
* and OnIMESelectionChange from content processes, they should set
* mWantUpdates to false to avoid these overheads.
* If mWantUpdates is true, nsTextStateManager will observe text change and
* selection change and call nsIWidget::OnIMETextChange() and
* nsIWidget::OnIMESelectionChange(). The observing cost is very expensive.
* If the IME implementation on a particular platform doesn't care about
* OnIMETextChange and OnIMESelectionChange, they should set mWantUpdates to
* false to avoid the cost.
*
* If mWantHints is true, PuppetWidget will forward the content of text fields
* to the chrome process to be cached. This way we return the cached content

View File

@ -429,16 +429,21 @@ PuppetWidget::OnIMEFocusChange(bool aFocus)
return NS_ERROR_FAILURE;
if (aFocus) {
if (!mIMEPreference.mWantUpdates && !mIMEPreference.mWantHints)
// call OnIMEFocusChange on blur but no other updates
return NS_ERROR_NOT_IMPLEMENTED;
OnIMESelectionChange(); // Update selection
if (mIMEPreference.mWantUpdates && mIMEPreference.mWantHints) {
OnIMESelectionChange(); // Update selection
}
} else {
mIMELastBlurSeqno = chromeSeqno;
}
return NS_OK;
}
nsIMEUpdatePreference
PuppetWidget::GetIMEUpdatePreference()
{
return mIMEPreference;
}
NS_IMETHODIMP
PuppetWidget::OnIMETextChange(uint32_t aStart, uint32_t aEnd, uint32_t aNewEnd)
{

View File

@ -158,6 +158,7 @@ public:
NS_IMETHOD OnIMETextChange(uint32_t aOffset, uint32_t aEnd,
uint32_t aNewEnd);
NS_IMETHOD OnIMESelectionChange(void);
virtual nsIMEUpdatePreference GetIMEUpdatePreference();
NS_IMETHOD SetCursor(nsCursor aCursor);
NS_IMETHOD SetCursor(imgIContainer* aCursor,