Avoid doing some work when initializing textfields.
Bug 221150, patch by
peterv and a little bit me, r=me, sr=roc
--- a/editor/idl/nsIPlaintextEditor.idl
+++ b/editor/idl/nsIPlaintextEditor.idl
@@ -34,17 +34,17 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIDOMKeyEvent;
-[scriptable, uuid(35d74f2b-3d03-43c5-8ace-9d90c3e31244)]
+[scriptable, uuid(1480e196-0d5c-40cf-8563-ed8a33eabcf2)]
interface nsIPlaintextEditor : nsISupports
{
// XXX Why aren't these in nsIEditor?
const long eEditorPlaintextMask = 0x0001; /* only plain text entry is allowed via events */
const long eEditorSingleLineMask = 0x0002; /* enter key and CR-LF handled specially */
const long eEditorPasswordMask = 0x0004; /* text is not entered into content, only a representative character */
const long eEditorReadonlyMask = 0x0008; /* editing events are disabled. Editor may still accept focus. */
@@ -84,16 +84,24 @@ interface nsIPlaintextEditor : nsISuppor
/** Get and set the body wrap width.
*
* Special values:
* 0 = wrap to window width
* -1 = no wrap at all
*/
attribute long wrapWidth;
+ /**
+ * Similar to the setter for wrapWidth, but just sets the editor
+ * internal state without actually changing the content being edited
+ * to wrap at that column. This should only be used by callers who
+ * are sure that their content is already set up correctly.
+ */
+ void setWrapColumn(in long aWrapColumn);
+
/** Get and set newline handling.
*
* Values are the constants defined above.
*/
attribute long newlineHandling;
/**
* EditorKeyPress consumes a keyevent.
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -975,17 +975,17 @@ static void CutStyle(const char* stylena
}
//
// Change the wrap width on the root of this document.
//
NS_IMETHODIMP
nsPlaintextEditor::SetWrapWidth(PRInt32 aWrapColumn)
{
- mWrapColumn = aWrapColumn;
+ SetWrapColumn(aWrapColumn);
// Make sure we're a plaintext editor, otherwise we shouldn't
// do the rest of this.
PRUint32 flags = 0;
GetFlags(&flags);
if (!(flags & eEditorPlaintextMask))
return NS_OK;
@@ -1044,16 +1044,23 @@ nsPlaintextEditor::SetWrapWidth(PRInt32
else if (mWrapToWindow || aWrapColumn == 0)
styleValue.AppendLiteral("white-space: -moz-pre-wrap;");
else
styleValue.AppendLiteral("white-space: pre;");
return rootElement->SetAttribute(styleName, styleValue);
}
+NS_IMETHODIMP
+nsPlaintextEditor::SetWrapColumn(PRInt32 aWrapColumn)
+{
+ mWrapColumn = aWrapColumn;
+ return NS_OK;
+}
+
//
// Get the newline handling for this editor
//
NS_IMETHODIMP
nsPlaintextEditor::GetNewlineHandling(PRInt32 *aNewlineHandling)
{
NS_ENSURE_ARG_POINTER(aNewlineHandling);
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -1484,17 +1484,17 @@ nsTextControlFrame::CreateFrameFor(nsICo
// do not wrap when wrap=off
textEditor->SetWrapWidth(-1);
} else {
// Set wrapping normally otherwise
textEditor->SetWrapWidth(GetCols());
}
} else {
// Never wrap non-textareas
- textEditor->SetWrapWidth(-1);
+ textEditor->SetWrapColumn(-1);
}
// Set max text field length
PRInt32 maxLength;
if (GetMaxLength(&maxLength)) {
textEditor->SetMaxTextLength(maxLength);
}
--- a/layout/style/forms.css
+++ b/layout/style/forms.css
@@ -91,17 +91,17 @@ input {
letter-spacing: normal;
cursor: text;
-moz-binding: url("chrome://global/content/platformHTMLBindings.xml#inputFields");
text-indent: 0;
-moz-user-select: text;
}
input > .anonymous-div {
- white-space : nowrap;
+ white-space: pre;
}
textarea {
margin: 1px 0 1px 0;
border: 2px inset ThreeDFace;
background-color: -moz-Field;
color: -moz-FieldText;
font: medium -moz-fixed;