Bug 488420 IME enabled state is not modified when a focused editor's readonly attribute is changed r=smaug

This commit is contained in:
Masayuki Nakano
2010-05-05 02:40:39 +09:00
parent 512a425f0c
commit 18b4a77d23
13 changed files with 787 additions and 77 deletions

View File

@@ -125,6 +125,7 @@
#include "nsIDOMUserDataHandler.h"
#include "nsGenericHTMLElement.h"
#include "nsIEditor.h"
#include "nsIEditorIMESupport.h"
#include "nsIEditorDocShell.h"
#include "nsEventDispatcher.h"
#include "nsContentCreatorFunctions.h"
@@ -636,6 +637,47 @@ nsIContent::GetFlattenedTreeParent() const
return parent;
}
PRUint32
nsIContent::GetDesiredIMEState()
{
if (!IsEditableInternal()) {
return IME_STATUS_DISABLE;
}
nsIContent *editableAncestor = nsnull;
for (nsIContent* parent = GetParent();
parent && parent->HasFlag(NODE_IS_EDITABLE);
parent = parent->GetParent()) {
editableAncestor = parent;
}
// This is in another editable content, use the result of it.
if (editableAncestor) {
return editableAncestor->GetDesiredIMEState();
}
nsIDocument* doc = GetCurrentDoc();
if (!doc) {
return IME_STATUS_DISABLE;
}
nsIPresShell* ps = doc->GetPrimaryShell();
if (!ps) {
return IME_STATUS_DISABLE;
}
nsPresContext* pc = ps->GetPresContext();
if (!pc) {
return IME_STATUS_DISABLE;
}
nsIEditor* editor = GetHTMLEditor(pc);
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(editor);
if (!imeEditor) {
return IME_STATUS_DISABLE;
}
// Use "enable" for the default value because IME is disabled unexpectedly,
// it makes serious a11y problem.
PRUint32 state = IME_STATUS_ENABLE;
nsresult rv = imeEditor->GetPreferredIMEState(&state);
NS_ENSURE_SUCCESS(rv, IME_STATUS_ENABLE);
return state;
}
//----------------------------------------------------------------------
NS_IMPL_ADDREF(nsChildContentList)