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

--HG--
extra : rebase_source : 4c532f5ece3e88e907aabfef2197bced1223d9f2
This commit is contained in:
Ehsan Akhgari 2011-10-16 16:15:40 -04:00
parent 8cfbed187e
commit 92c83507d3
2 changed files with 18 additions and 2 deletions

View File

@ -1348,7 +1348,12 @@ PRUint32
nsIContent::GetDesiredIMEState()
{
if (!IsEditableInternal()) {
return IME_STATUS_DISABLE;
// 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 IME_STATUS_DISABLE;
}
}
// 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

@ -646,13 +646,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();
}