Make maxlength not affect initial values or scripted sets. Bug 345267,

r+sr=mats, a=dbaron


git-svn-id: svn://10.0.0.236/trunk@232492 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2007-08-22 03:22:22 +00:00
parent 5204b6c384
commit 6e2b534f5e
10 changed files with 204 additions and 3 deletions

View File

@@ -2696,14 +2696,19 @@ nsTextControlFrame::SetValue(const nsAString& aValue)
flags &= ~(nsIPlaintextEditor::eEditorReadonlyMask);
editor->SetFlags(flags);
// Also don't enforce max-length here
PRInt32 savedMaxLength;
plaintextEditor->GetMaxTextLength(&savedMaxLength);
plaintextEditor->SetMaxTextLength(-1);
if (currentValue.Length() < 1)
editor->DeleteSelection(nsIEditor::eNone);
else {
nsCOMPtr<nsIPlaintextEditor> textEditor = do_QueryInterface(editor);
if (textEditor)
textEditor->InsertText(currentValue);
if (plaintextEditor)
plaintextEditor->InsertText(currentValue);
}
plaintextEditor->SetMaxTextLength(savedMaxLength);
editor->SetFlags(savedFlags);
if (selPriv)
selPriv->EndBatchChanges();