Bug 591047 - (4/7) Adding no updates option to IME notifications; r=masayuki sr=roc a=blocking-fennec

This commit is contained in:
Brad Lassey 2010-09-23 23:28:15 -04:00
parent 0fbcc1134a
commit 3db964bd25
2 changed files with 23 additions and 3 deletions

View File

@ -286,7 +286,8 @@ public:
nsresult Init(nsIWidget* aWidget,
nsPresContext* aPresContext,
nsINode* aNode);
nsINode* aNode,
PRBool aWantUpdates);
void Destroy(void);
nsCOMPtr<nsIWidget> mWidget;
@ -307,10 +308,16 @@ nsTextStateManager::nsTextStateManager()
nsresult
nsTextStateManager::Init(nsIWidget* aWidget,
nsPresContext* aPresContext,
nsINode* aNode)
nsINode* aNode,
PRBool aWantUpdates)
{
mWidget = aWidget;
if (!aWantUpdates) {
mEditableNode = aNode;
return NS_OK;
}
nsIPresShell* presShell = aPresContext->PresShell();
// get selection and root content
@ -590,6 +597,8 @@ nsIMEStateManager::OnTextStateFocus(nsPresContext* aPresContext,
return NS_OK;
NS_ENSURE_SUCCESS(rv, rv);
PRBool wantUpdates = rv != NS_SUCCESS_IME_NO_UPDATES;
// OnIMEFocusChange may cause focus and sTextStateObserver to change
// In that case return and keep the current sTextStateObserver
NS_ENSURE_TRUE(!sTextStateObserver, NS_OK);
@ -597,7 +606,8 @@ nsIMEStateManager::OnTextStateFocus(nsPresContext* aPresContext,
sTextStateObserver = new nsTextStateManager();
NS_ENSURE_TRUE(sTextStateObserver, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(sTextStateObserver);
rv = sTextStateObserver->Init(widget, aPresContext, editableNode);
rv = sTextStateObserver->Init(widget, aPresContext,
editableNode, wantUpdates);
if (NS_FAILED(rv)) {
sTextStateObserver->mDestroying = PR_TRUE;
sTextStateObserver->Destroy();

View File

@ -133,6 +133,13 @@ typedef nsEventStatus (* EVENT_CALLBACK)(nsGUIEvent *event);
#define NS_STYLE_WINDOW_SHADOW_TOOLTIP 3
#define NS_STYLE_WINDOW_SHADOW_SHEET 4
/**
* nsIWidget::OnIMEFocusChange should be called during blur,
* but other OnIME*Change methods should not be called
*/
#define NS_SUCCESS_IME_NO_UPDATES \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_WIDGET, 1)
/**
* Cursor types.
*/
@ -1234,6 +1241,9 @@ class nsIWidget : public nsISupports {
*
* If this returns NS_ERROR_*, OnIMETextChange and OnIMESelectionChange
* and OnIMEFocusChange(PR_FALSE) will be never called.
*
* If this returns NS_SUCCESS_IME_NO_UPDATES, OnIMEFocusChange(PR_FALSE)
* will be called but OnIMETextChange and OnIMESelectionChange will NOT.
*/
NS_IMETHOD OnIMEFocusChange(PRBool aFocus) = 0;