Bug 688438 - Fix the IME code to handle text controls correctly when checking for IME status; r=bzbarsky

This commit is contained in:
Ehsan Akhgari 2012-05-24 17:49:44 -04:00
parent 4276f83863
commit 23ed568f53
2 changed files with 18 additions and 2 deletions

View File

@ -1478,7 +1478,12 @@ nsIContent::IMEState
nsIContent::GetDesiredIMEState()
{
if (!IsEditableInternal()) {
return IMEState(IMEState::DISABLED);
// Check for the special case where we're dealing with elements which don't
// have the editable flag set, but are readwrite (such as text controls).
if (!IsElement() ||
!AsElement()->State().HasState(NS_EVENT_STATE_MOZ_READWRITE)) {
return IMEState(IMEState::DISABLED);
}
}
// NOTE: The content for independent editors (e.g., input[type=text],
// textarea) must override this method, so, we don't need to worry about

View File

@ -660,13 +660,24 @@ nsTextStateManager::ContentRemoved(nsIDocument* aDocument,
new TextChangeEvent(mWidget, offset, offset + childOffset, offset));
}
static bool IsEditable(nsINode* node) {
if (node->IsEditable()) {
return true;
}
// |node| might be readwrite (for example, a text control)
if (node->IsElement() && node->AsElement()->State().HasState(NS_EVENT_STATE_MOZ_READWRITE)) {
return true;
}
return false;
}
static nsINode* GetRootEditableNode(nsPresContext* aPresContext,
nsIContent* aContent)
{
if (aContent) {
nsINode* root = nsnull;
nsINode* node = aContent;
while (node && node->IsEditable()) {
while (node && IsEditable(node)) {
root = node;
node = node->GetNodeParent();
}