From ddcdc2b80d77c9bf8c16a954acd9b0ab5f0793f0 Mon Sep 17 00:00:00 2001 From: "bzbarsky@mit.edu" Date: Tue, 21 Aug 2007 20:22:21 -0700 Subject: [PATCH] Make maxlength not affect initial values or scripted sets. Bug 345267, r+sr=mats, a=dbaron --- layout/forms/Makefile.in | 6 ++ layout/forms/nsTextControlFrame.cpp | 11 ++- layout/forms/test/Makefile.in | 51 ++++++++++++++ layout/forms/test/test_bug345267.html | 93 ++++++++++++++++++++++++++ layout/reftests/bugs/345267-1-ref.html | 6 ++ layout/reftests/bugs/345267-1a.html | 6 ++ layout/reftests/bugs/345267-1b.html | 10 +++ layout/reftests/bugs/345267-1c.html | 10 +++ layout/reftests/bugs/345267-1d.html | 10 +++ layout/reftests/bugs/reftest.list | 4 ++ 10 files changed, 204 insertions(+), 3 deletions(-) create mode 100644 layout/forms/test/Makefile.in create mode 100644 layout/forms/test/test_bug345267.html create mode 100644 layout/reftests/bugs/345267-1-ref.html create mode 100644 layout/reftests/bugs/345267-1a.html create mode 100644 layout/reftests/bugs/345267-1b.html create mode 100644 layout/reftests/bugs/345267-1c.html create mode 100644 layout/reftests/bugs/345267-1d.html diff --git a/layout/forms/Makefile.in b/layout/forms/Makefile.in index 38ae2f595520..09a601c2c929 100644 --- a/layout/forms/Makefile.in +++ b/layout/forms/Makefile.in @@ -42,6 +42,12 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk +DIRS = $(NULL) + +ifdef MOZ_MOCHITEST +DIRS += test +endif + MODULE = layout LIBRARY_NAME = gkforms_s LIBXUL_LIBRARY = 1 diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 1b3b62a888c3..1cb7c883a848 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -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 textEditor = do_QueryInterface(editor); - if (textEditor) - textEditor->InsertText(currentValue); + if (plaintextEditor) + plaintextEditor->InsertText(currentValue); } + plaintextEditor->SetMaxTextLength(savedMaxLength); editor->SetFlags(savedFlags); if (selPriv) selPriv->EndBatchChanges(); diff --git a/layout/forms/test/Makefile.in b/layout/forms/test/Makefile.in new file mode 100644 index 000000000000..5fef22cd46dc --- /dev/null +++ b/layout/forms/test/Makefile.in @@ -0,0 +1,51 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Mozilla Foundation. +# Portions created by the Initial Developer are Copyright (C) 2007 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ +relativesrcdir = layout/forms/test + +include $(DEPTH)/config/autoconf.mk +include $(topsrcdir)/config/rules.mk + +_TEST_FILES = test_bug345267.html \ + $(NULL) + +libs:: $(_TEST_FILES) + $(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir) diff --git a/layout/forms/test/test_bug345267.html b/layout/forms/test/test_bug345267.html new file mode 100644 index 000000000000..0e97d93cbca4 --- /dev/null +++ b/layout/forms/test/test_bug345267.html @@ -0,0 +1,93 @@ + + + + + Test for Bug 345267 + + + + + + +Mozilla Bug 345267 +

+ + + + + +

+ +
+
+
+ + + diff --git a/layout/reftests/bugs/345267-1-ref.html b/layout/reftests/bugs/345267-1-ref.html new file mode 100644 index 000000000000..9bb47653ab66 --- /dev/null +++ b/layout/reftests/bugs/345267-1-ref.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/layout/reftests/bugs/345267-1a.html b/layout/reftests/bugs/345267-1a.html new file mode 100644 index 000000000000..feace49e6ba5 --- /dev/null +++ b/layout/reftests/bugs/345267-1a.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/layout/reftests/bugs/345267-1b.html b/layout/reftests/bugs/345267-1b.html new file mode 100644 index 000000000000..60726b6d8e9e --- /dev/null +++ b/layout/reftests/bugs/345267-1b.html @@ -0,0 +1,10 @@ + + + + + + + diff --git a/layout/reftests/bugs/345267-1c.html b/layout/reftests/bugs/345267-1c.html new file mode 100644 index 000000000000..1e78bec0dc3b --- /dev/null +++ b/layout/reftests/bugs/345267-1c.html @@ -0,0 +1,10 @@ + + + + + + + diff --git a/layout/reftests/bugs/345267-1d.html b/layout/reftests/bugs/345267-1d.html new file mode 100644 index 000000000000..d912035a530d --- /dev/null +++ b/layout/reftests/bugs/345267-1d.html @@ -0,0 +1,10 @@ + + + + + + + diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index ecc6bfafc8f3..d674c20833ac 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -146,6 +146,10 @@ fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == 336736-1.html 336736-1-ref.html # somet == 339289-1.html 339289-1-ref.html == 341043-1a.html 341043-1-ref.html != 341043-1b.html 341043-1-ref.html +== 345267-1a.html 345267-1-ref.html +== 345267-1b.html 345267-1-ref.html +== 345267-1c.html 345267-1-ref.html +== 345267-1d.html 345267-1-ref.html == 346774-1a.html 346774-1-ref.html == 346774-1b.html 346774-1-ref.html == 346774-1c.html 346774-1-ref.html