Closed
Bug 27951
Opened 25 years ago
Closed 25 years ago
<INPUT TYPE="RESET"> doesn't clear text field
Categories
(Core :: Layout: Form Controls, defect, P3)
Core
Layout: Form Controls
Tracking
()
VERIFIED
FIXED
M15
People
(Reporter: djoham, Assigned: pollmann)
References
Details
(Whiteboard: fix in hand)
Attachments
(3 files)
From Bug Helper:
User-Agent: Mozilla/4.61 [en] (X11; I; Linux 2.2.12-20 i686)
BuildID: 2000021510
Sometime between the release of M13 and this build, the intput type of RESET
doesn't seems to have been broken.
The test case I'm submitting works as expected on Linux Netscape 4.x as well as
in Linux Mozilla M13. Something must have regressed....
Reproducible: Always
Steps to Reproduce:
1.fill in some text on a form with a reset button
2.click on the reset button
3.
Actual Results: nothing happens
Expected Results: the text box should be cleared.
Comment 2•25 years ago
|
||
Component: Browser-General → Form Submission
Comment 3•25 years ago
|
||
Confirmed on Linux build 2000.02.21.08. Reassign to component owner.
Summary: <INPUT TYPE="RESET"> Doesn't work → <INPUT TYPE="RESET"> doesn't clear text field
Comment 4•25 years ago
|
||
Oops. Forgot to check the right box. Reassigning for real now.
Assignee: leger → karnaze
QA Contact: cbegle → ckritzer
Comment 6•25 years ago
|
||
narrowing down the time when this regression was introduced:
this bug does not occur with 2000020509 linux rh6.1
this bug occurs with 2000020708 linux rh6.1
Comment 7•25 years ago
|
||
This bug only occurs if the text input has value="" or value attr not given:
<input type=text value=""> or <input type=text>
This bug does not occur if the text input has non-empty value attr, for example:
<input type=text value="1234">
Comment 8•25 years ago
|
||
Comment 9•25 years ago
|
||
Here is what gdb is showing me:
It looks this bug 27951 was introduced when
editor/base/nsTextEditRules.cpp rev 1.97 landed.
nsTextEditRules needs to be modified to correct this.
in layout/html/forms/src/nsGfxTextControlFrame.cpp:
The nsGfxTextControlFrame calls this function:
htmlEditor->InsertText(aValue);
when aValue == "" nothing happens, and when aValue != "" it works fine.
in editor/base/nsHTMLEditor.cpp:
inside nsHTMLEditor::InsertText(), this function is called:
result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
nsTextEditRules::WillDoAction
then calls:
nsTextEditRules::WillInsertText
Take a look at this code, it shows why this problem is happening:
http://lxr.mozilla.org/seamonkey/source/editor/base/nsTextEditRules.cpp#505
Comment 10•25 years ago
|
||
Adding jfrancis to cc-list,
he committed editor/base/nsTextEditRules.cpp rev 1.97
Assignee | ||
Comment 11•25 years ago
|
||
Thanks Matt for excellent work debugging this one!
I'm going to hand it off to jfrancis@netscape.com to find an alternate hack for
IME or setting a text field to "". Also CC'ing buster, the GfxTextControlFrame
guru.
Assignee: pollmann → jfrancis
Component: Form Submission → HTML Form Controls
OS: Linux → All
Hardware: PC → All
Comment 12•25 years ago
|
||
You should not need to ever call InsertText() with an empty string. What are you
trying to do? If you are trying to clear the string this is not the way to do
it.
Comment 13•25 years ago
|
||
handing back to pollmann to make sure i find out what's up...
Assignee: jfrancis → pollmann
Assignee | ||
Comment 14•25 years ago
|
||
Yes, it appears that the code in nsGfxTextControlFrame is trying to set the text
of the input using the InsertText call. What is the correct call to make here?
Buster might have more information on this. The code in question is
nsGfxTextControlFrame::SetTextControlFrameState() around line 1372. It appears
to be trying to set the complete contents of the editor.
Handing it back to jfrancis for an answer. (Feel free to bounce it back to me)
This bug is a hot potato! :)
Assignee: pollmann → jfrancis
Comment 15•25 years ago
|
||
ok - i'm looking into this...
Comment 16•25 years ago
|
||
In nsGfxTextControlFrame::SetTextControlFrameState(), try making these changes:
// get the flags, remove readonly and disabled, set the value, restore
flags
PRUint32 flags, savedFlags;
mEditor->GetFlags(&savedFlags);
flags = savedFlags;
flags &= ~(nsIHTMLEditor::eEditorDisabledMask);
flags &= ~(nsIHTMLEditor::eEditorReadonlyMask);
mEditor->SetFlags(flags);
+ mEditor->SelectAll();
+ mEditor->DeleteSelection(nsIEditor::eNone);
htmlEditor->InsertText(aValue);
mEditor->SetFlags(savedFlags);
Note that the lines with the "+" are new (and don't include the +, obviously).
SelectAll(), then DeleteSelection() is the right way to clear out the string.
back to pollmann....
Assignee: jfrancis → pollmann
Assignee | ||
Comment 17•25 years ago
|
||
*** Bug 30458 has been marked as a duplicate of this bug. ***
Comment 18•25 years ago
|
||
I think they may also happen if the input type is file... Enclosing attachment.
Comment 19•25 years ago
|
||
I think they may also happen if the input type is file... Enclosing attachment.
Comment 20•25 years ago
|
||
Assignee | ||
Comment 21•25 years ago
|
||
Yes, this is happening with text inputs, text areas, and password, and file
inputs. The fix that jfrancis proposed takes care of this bug. I'll check it
in when the tree opens for general checkins. Thanks!
Status: NEW → ASSIGNED
Whiteboard: fix in hand
Target Milestone: M15
Assignee | ||
Comment 22•25 years ago
|
||
*** Bug 31329 has been marked as a duplicate of this bug. ***
Assignee | ||
Updated•25 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 23•25 years ago
|
||
I just checked in jfracis's fix.
To verify this fix, go to the above testcases. Clicking on Reset should clear
the inputs for all of them. Thanks!
Assignee | ||
Comment 24•25 years ago
|
||
*** Bug 27835 has been marked as a duplicate of this bug. ***
You need to log in
before you can comment on or make changes to this bug.
Description
•