Open Bug 33654 Opened 24 years ago Updated 17 days ago

TEXTAREA incorrectly applying ROWS= and COLS= (horizontal / vertical scrollbar extra space, with overlay scrollbars disabled)

Categories

(Core :: Layout: Form Controls, defect, P3)

x86
All
defect

Tracking

()

Future

People

(Reporter: andrew, Unassigned)

References

(Depends on 2 open bugs, Blocks 1 open bug, )

Details

(Keywords: testcase, Whiteboard: [html][behavior]relnote-devel)

Attachments

(17 files, 17 obsolete files)

468 bytes, text/html
Details
3.85 KB, patch
Details | Diff | Splinter Review
3.90 KB, patch
Details | Diff | Splinter Review
897 bytes, text/html
Details
704 bytes, text/html
Details
634 bytes, text/html
Details
1.93 KB, image/png
Details
9.76 KB, image/png
Details
10.17 KB, image/png
Details
61.24 KB, image/jpeg
Details
55.40 KB, image/jpeg
Details
2.14 KB, text/html
Details
52.34 KB, image/jpeg
Details
843 bytes, text/html
Details
941 bytes, text/html
Details
20.16 KB, patch
Details | Diff | Splinter Review
25.64 KB, patch
Details | Diff | Splinter Review
See the URL for an example of a TEXTAREA field specified as ROWS=5 COLS=30 which
is being displayed as (approximately!) ROWS=7 COLS=48
This looks like the input text or the textarea aren't getting the correct font.
Assignee: rods → beppe
Well, TEXTAREA isn't getting the correct font (see
http://bugzilla.mozilla.org/show_bug.cgi?id=28219) but that's a different
problem, although possibly related.

But when I look at the page (Linux 2000032711 build) the INPUT TYPE=TEXT field
is shown in the font specified in the style, but it is waay too wide.  Similarly
for TEXTAREA, except that the correct fotn is not used, and the area is also too
tall, even when scroll bars appear.
assigning to Kin
Assignee: beppe → kin
Target Milestone: --- → M16
Status: UNCONFIRMED → NEW
Ever confirmed: true
Accepting bug.
Status: NEW → ASSIGNED
moving to m17
Target Milestone: M16 → M17
we are still getting the wrong information for laying out the textarea. There is 
additional spaces in the column and an extra row, this probably has something to 
do with preserving space for the scrollbars
Keywords: correctness, nsbeta3
Target Milestone: M17 → M18
*** Bug 46106 has been marked as a duplicate of this bug. ***
setting to nsbeta3+
Whiteboard: nsbeta3+
Adding brackets around nsbeta3+. (Tell me if we've dropped that convention.)
Whiteboard: nsbeta3+ → [nsbeta3+]
setting priority in status whiteboard
Priority: P3 → P4
Whiteboard: [nsbeta3+] → [nsbeta3+][p:4]
i've read a post in an html authoring newsgroup about this problem. to
summarize, the (upset) poster tells that

if you have this in your stylesheet :
textarea { font-size: 8pt }

and this in your html form :
<textarea name="texte" cols="40" rows="12"></textarea>

then IE renders the correct textarea width, but Mozilla seems to compute the
width of the textarea based on a 12pt font (!)
if you type 40 characters, they do not add up to the full width of the area, as
you may have already noticed...
per beppe bouncing back to rods@netscape.com.

Rod, we are using the nsFormControlHelper methods to get our font and calculate
the control size ... is this a bug in the FormControlHelper methods? Or are we
using it incorrectly? Help?
Assignee: kin → rods
Status: ASSIGNED → NEW
Priority: P4 → P3
Whiteboard: [nsbeta3+][p:4]
Target Milestone: M18 → ---
The sizing is working fine. Basically, if it sizes correctly with the default 
font, which it is, then the problem lies elsewhere.

The problem is the textarea is not using the correct font. I have just attached 
an example of the textarea using "arial" and it isn't displaying that font.

In the url field the example is using "tahoma" which is very close to arial and 
again it isn't using tahoma.

reassigning back to you.
Assignee: rods → kin
Accepting bug.
Status: NEW → ASSIGNED
Target Milestone: --- → M18
Kin will debug this one to find out why we are not getting the appropriate data 
from the control. Rod, Kin may need your help to fix whatever is broken, it may 
require making changes in your area, it will just be easier to have Kin fix it 
instead of continuing to bounce it back and forth
Whiteboard: [nsbeta3+]
Okay, so I see that the editor is forcing the content area of the TextControl to 
use "font-family: monospace;" when the editor's PlainText flag is set.

If I remove this code, the correct font is used ... though the example attatched 
to this bug still creates a 30 column textarea where the string 
'123456789012345678901234567890' (30 chars) takes up about 2/3 of the width in 
NavQuirks mode. This happens because the nsFormControlHelper method is 
calculating the width of the textarea by taking the average width of the 'w' and 
'W' characters in the font and multiplying it by the number of columns and 
adding the scrollbar width. Rod, is that how NavQuirks mode is supposed to work?
confirming priority
Whiteboard: [nsbeta3+] → [nsbeta3+][p:3]
I just attatched a patch that makes the editor use the correct font.

Cc'ing akkana@netscape.com for help in testing this patch since it touches code 
used by PlaintText MsgCompose and PlainText editor.
Whiteboard: [nsbeta3+][p:3] → [nsbeta3+][p:3][Fix in hand]
I'm going on vacation so mjudge has graciously agreed to check this in for me. 
:-)
Assignee: kin → mjudge
Status: ASSIGNED → NEW
as soon as tree opens i will check this in
-mjudge
Status: NEW → ASSIGNED
fixed.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Updating QA contact.
QA Contact: ckritzer → bsharma
Although this is now using the COLS=... attribute according to
rods@netscape.com's definition of 'correctly'.  The ROWS=... attribute still
seems to be working wrong.  In my example page the TEXTAREA is set to 5 rows,
but the display contains space for 8 rows (plus scroll bar), at least it is with
the Linux build from 20000925.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
reassign to kin for evaluation
Assignee: mjudge → kin
Status: REOPENED → NEW
Not holding PR3 for this. Marking nsbeta3- and nominating for rtm so we don't
lose track of the patch.
Keywords: rtm
Whiteboard: [nsbeta3+][p:3][Fix in hand] → [nsbeta3-][p:3][Fix in hand]
Accepting bug.
Status: NEW → ASSIGNED
I will attach another testcase which doesn't specify font.

Height and Width of textarea are not changed correctly after switching
character coding. Too small or too large in such a case.
Clearing the "Fix in hand" status. Beppe, I'll need this rtm+'d to work on this.
Whiteboard: [nsbeta3-][p:3][Fix in hand] → [nsbeta3-][p:3]
textareas are a highly used form element, this does not have a workaround, this 
should be fixed for rtm

Kin, please follow guidelines for rtm bugs
Whiteboard: [nsbeta3-][p:3] → [nsbeta3-][p:3][rtm+ NEED INFO]
Target Milestone: M18 → M19
m19
removing the + per pdt sw rules
Whiteboard: [nsbeta3-][p:3][rtm+ NEED INFO] → [nsbeta3-][p:3][rtm NEED INFO]
I'm going to future this bug since the pdt committee probably won't let me check 
this in on the Netscape_20000922_BRANCH.

Andrew, I'm not seeing 8 rows when I display your page on my Linux box. I see it 
calculating 6 rows + scrollbar which rods@netscape.com's NavQuirks code says to 
calculate. If I switch viewer to use the Standard mode, I get 5 rows + a 
scrollbar.

As for the bug KOIKE Kazuhiko's sample points out, it's using the wrong font 
because in html.css, we tell all input elements and textareas to use the 'field' 
font:

    input { font: field; }

so that we get a monospace font by default in all input elements and textareas. 
To fix this bug, I'll have to add the following style to html.css:

    font input { font: inherit; }
    font textarea { font: inherit; }

But this may introduce some performance issues when rendering pages with input 
elements and textareas because of the search up the parent hierarchies that 
needs to be done when resloving the style.
Target Milestone: M19 → Future
removing need info and adding rtm-
Whiteboard: [nsbeta3-][p:3][rtm NEED INFO] → [nsbeta3-][p:3][rtm-]
Changing milestone from "Future" to "mozilla0.9".

Adding relnotesRTM keyword.
Keywords: relnoteRTM
Target Milestone: Future → mozilla0.9
What's the exact issue left here, then? (for the release note)

Gerv
Whiteboard: [nsbeta3-][p:3][rtm-] → [nsbeta3-][p:3][rtm-] relnote-devel
For the release notes:

Form input elements and textareas will not use the font face specified by <FONT>
tags that enclose them. To get around this, the author of the web page can use
style to explicitly set the font used by input elements or textareas, or they
can add the following style to the <HEAD> portion of their document so that
input elements and textares use the face specified by the <FONT> tag:

    font input    { font: inherit; }
    font textarea { font: inherit; }

Nom. nsbeta1. b.c. and correctness bug we'd like to fix for nsbeta1.
Keywords: nsbeta1
QA Contact Update
QA Contact: bsharma → vladimire
I'm going to close this bug as fixed, since the original reported bug was fixed. 

The fact that text widgets don't pick up the font specified in a <font> tag is 
something shared by all gfx form widgets, if a fix is made for quirk mode, as 
discussed in bug #53360, text widgets will get the fix for free.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago23 years ago
Resolution: --- → FIXED
I can't believe this was fixed.

http://wrms.catalyst.net.nz/mozilla-bug-demo.php

The textarea in this page is displayed as rows=6 and column=51 on 2001032708/Linux.

Status: RESOLVED → REOPENED
Resolution: FIXED → ---
mozilla.0.9.1
Target Milestone: mozilla0.9 → mozilla0.9.1
Target Milestone: mozilla0.9.1 → mozilla0.9.2
when I created a plain textarea:
<textarea name="textarea test" rows="6" cols="30"></textarea>

I was able to type in the following data, without getting vertical or horizontal 
scroll bars -- and I should have once I exceeded 30 characters in width and/or 6 
 lines. Note, there are 32 characters in width -- when I add the 33rd character 
I get the horizontal scrollbar. Now comes the funky part -- if I delete the 33rd 
character, I get the horizonatal and vertical scrollbars (what is that all 
about?). 

For the rows issue, I am able to type in 7 rows without getting the vertical 
scrollbar, the scrollbar does not display. If I go to the last line (the # 7) 
and hit enter, I get both the vertical and horizontal scrollbars -- why? 
SHouldn't I just get the vertical scrollbar?

Here is a copy of the text I typed in:

12345678901234567890123456789012
2
3
4
5
6
7

adding glazman, maybe there is some odd CSS thing happening.

Does the textarea frame include the area reserved for the scrollbars? So, if you 
see an empty textarea, and note the width and height (frame) is that the overall 
width and height, or does that change when the scrollbars get displayed? Could 
that be the problem? Could the text being inserted actually roll into the 
reserved space for the scrollbars?
Whiteboard: [nsbeta3-][p:3][rtm-] relnote-devel → [html][behavior]relnote-devel
kin, you should probably take a look at bug 82715 which seems related to the
current one...
Target Milestone: mozilla0.9.2 → mozilla0.9.3
this can and will affect how pages are rendered

reviewed and approved
Keywords: nsBranch
Status: REOPENED → ASSIGNED
putting out to 1.0
Keywords: nsBranch
Target Milestone: mozilla0.9.3 → mozilla1.0
Here is another example using rows=1 where it obviously is not 1 row.  This was
done on Windows 2000 and it doesn't work as of 0.9.3.
I mean here (http://www.baxleys.org/Mozilla/MozTextarea.htm) is another example.
is 98918 a dup of this bug?
*** Bug 98918 has been marked as a duplicate of this bug. ***
http://linux.apptechsys.com/textbox.html is another example of how rows are not
properly displayed.
Bulk move of mozilla1.0 bugs to mozilla.1.0.1. I will try to pull some of these
back in if I can.
Target Milestone: mozilla1.0 → mozilla1.0.1
Are any of these sufficiently simmilar to warrant
consolidation via duplication or dependancy change?

    bug 33654
    bug 52500
    bug 92980
    bug 103293
    bug 109392

-matt
why is this bug not in 1.0?

a textarea specified as having 1 row rendered as 3 rows is a serious issue,
IMHO. I thought those were exactly the bugs that have to be cleared pre-1.0.
Target Milestone: mozilla1.0.1 → mozilla1.0
Moving to Mozilla 1.1. Engineers are overloaded with higher priority bugs.
Target Milestone: mozilla1.0 → mozilla1.1
removing myself from the cc list
*** Bug 133342 has been marked as a duplicate of this bug. ***
While laying out a form with <textarea> and <input type="text"> fields, I found
that the textarea is correctly displayed in monospace font while the other
<input type="text"> fields are displayed in proportional font. This just kills
any type of layout control for forms on different browsers w/o resorting to
major hacking. OTOH, the design of forms is mainly determined by function.
Throwing layout control into your web application programs doesn't make sense
(as does not oversizing fields only to make them look right).
Form fields should _always_ be displayed in monospace font, IMO.

This is on Linux, using Mozilla 2002022613.
Mac people lobbied for variable-width fonts in single-line text fields, and got
their way, over the objection of unix people (who didn't really fight that hard
-- no one felt particularly strongly against it).  There's a bug (long since
marked fixed) that tracked the discussion, but you'd have to search for it -- I
was cc'ed, I'm pretty sure sfraser was as well (or perhaps filed it), but I
can't remember what the summary was so you'll have to do some searching.

You should be able to override that and force fixed-width with an entry in your
userContents.css -- see http://www.mozilla.org/unix/customizing.html
Attached file Interactive testcase
This bug does not depend on variable width fonts or the presence of font tags
(the testcase uses neither).
There is also no difference between quirks and standards mode (the testcase is
in standards mode)

The behaviour I get is this:
- there are always 3 more colums than specified
- there is always 1 more row than specified, except:
- when you ask for one row, you get 3

Some of the extra space migh be reserved for the scrollbars. Even if that is
the intended behaviour (is it?), it is reserving far too much space.
Also see this in windows 2000.
I'm using win 2k & mozilla 1.0 {Build2002023012}.
following textarea code not viewed properly.
<textarea name=memo  cols=42  rows=20 class=input></textarea>
It's in URL of
http://sgcc.net/bbs/write.php?id=malmo90&page=1&page_num=10&category=
&sn=off&ss=off&sc=off&keyword=&select_arrange=headnum&desc=asc&no=
&mode=write
so long.. :)
Document was written in EUC-KR character coding.

It seemed that COLS is working propely. But 'rows=20' isn't work.
The row size in the mozilla screen is exatly '1'.

I try to fix my html codes and I found that downloaded document work properly.
(Downloaded document han no additional images, objects.. etc.
It's just text document that includes html, css, javascript codes.)
Target Milestone: mozilla1.1alpha → Future
Blocks: 116779
*** Bug 169265 has been marked as a duplicate of this bug. ***
This is now happening with no fonts specified in the markup at all.
Just a simple <textarea cols=40 rows=2></textarea> will display with 3 rows.
In 2002-09-17 Linux & win2000 trunk builds I get exactly N+1 rows when rows=N.
OS: Linux → All
Blocks: 169265
Dead simple testcase. No frills, nothing fancy, just defaults.
Demonstrates 4 sizes of textareas, half of which are incorrect.
No longer blocks: 169265
*** Bug 174508 has been marked as a duplicate of this bug. ***
*** Bug 116779 has been marked as a duplicate of this bug. ***
Keywords: mozilla1.3
*** Bug 186271 has been marked as a duplicate of this bug. ***
See also the test
http://www.w3.org/MarkUp/Test/HTML401/20030123/tests/sec17_7-BF-01.html
related to ROWS, where the problem is clearly visible.
*** Bug 193296 has been marked as a duplicate of this bug. ***
Is there a particular or special reason why the keyword html4 should not be
added to this bugfile?
Need traction on this bug
QA Contact: vladimire → dsirnapalli
Keywords: nsbeta1
adt: nsbeta1-
Keywords: nsbeta1nsbeta1-
*** Bug 206946 has been marked as a duplicate of this bug. ***
Can't block a duplicate. That doesn't make any sense. Removing "blocks bug 116779."

Re: comment 75 -- TEXTAREA was in HTML 3.2, so html4 wouldn't be a valid keyword.

-M
No longer blocks: 116779
*** Bug 214744 has been marked as a duplicate of this bug. ***
Blocks: 107086
It looks as if this hasn't been looked at for a long time.
Reassigning to get it some attention.
Assignee: kinmoz → form
Status: ASSIGNED → NEW
*** Bug 215099 has been marked as a duplicate of this bug. ***
Keywords: testcase
*** Bug 234163 has been marked as a duplicate of this bug. ***
*** Bug 237523 has been marked as a duplicate of this bug. ***
Rendering of textarea rows=1 and text type=input in ie and mozilla.
Comment 46, way back when, is right on the money.  The textarea size is the
specified cols/rows plus space for scrollbars.  Since, unlike IE, we don't show
the scrollbars unless they are needed people feel that this is broken.

Possible options:

1)  Don't add in the scrollbar sizes when computing the size of the textarea.
    That will make things be "correct" as long as there is no overflow, and
   "incorrect" otherwise.
2)  Always show the scrollbars, like IE.
3)  Include the scrollbars only when we plan to show them (this is somewhat
    circular, since the size then depends on whether we show the scrollbars,
    which depends on the size).

Thoughts?  Any other options I'm missing?
Option 4) Let ROWS= and COLS= control the size of the textarea content only, so
when a scrollbar becomes visible, the textarea grows (assuming it's not
constrained by other layout constraints).

I don't particularly like any of these options but maybe option 4) isn't so bad...
That was basically my option #3.

The relevant code is in nsTextControlFrame::ReflowStandard, called from
nsTextControlFrame::GetPrefSize (mm.... box layout....)
Oh. My option 4 is not circular though.
Hmm... maybe with a lot of refactoring of nsTextControlFrame reflow... (would
need to reflow at the scrollbar-less width/height to decide whether we need the
scrollbars, and then if we do reflow again at the new width/height or something?)
I just said it would be well-defined, I didn't say it would be easy to implement
:-(.
(In reply to comment #86)
> Comment 46, way back when, is right on the money.  The textarea size is the
> specified cols/rows plus space for scrollbars.  Since, unlike IE, we don't
> show the scrollbars unless they are needed people feel that this is broken.

Are you sure that's the only thing going on? I see strange non-linear behaviour.
For example, look at attachment 13337 [details]. Notice that the textarea does not have
space for 30 characters (on my system, it's more like 26). That can't be due to
the scrollbars.

Now decrease the text size with CTRL-. On my system, the first time the text
gets a little smaller but the textarea's *gets wider* (and shows about 33
columns). If I decrease the font size again, it becomes narrower again (about 28
columns). That's weird. So I think something else is wrong too.

I think it's due to the textarea specifying a non-default font.
> Are you sure that's the only thing going on?

Yes.

> Notice that the textarea does not have space for 30 characters

Arial is a variable width font.  "30 characters" is meaningless in that case. 
We size for 30 "average characters" where the font itself reports the average
char width.  You may as well complain that you can't fit 30 'W' chars but can
fit far too many 'l' chars.

> but the textarea's *gets wider* (and shows about 33 columns)

This part I'm not seeing.  It may be due to the specifics of the font metrics of
the Arial fonts installed on your system  (or possibly even to us being unable
to find Arial at the new size and using a different font).

So the point is that the behavior for fixed-width fonts is due to the scrollbars
and probably needs fixing.  The behaviot for variable-width fonts is due to the
fact that there is no good solution there; we've gone with the solution that
most closely resembles IE's in the most cases as far as we can tell.
As to the intended behaviour, I design web forms and some of them need signed
approval. To achieve this I print the form after it's submitted, but I maintain
the form's shape/structure on the web page. This is done firstly with an
enclosing div that measures 8.5" x 11".

If I size a textarea that fits in an 8.5" space with 0.75" margins on IE I set
the width to be 80 cols. When the page loads it fits perfectly and I can enter
80 1s and the line goes right up to the (greyed out) scroll bar. But when I load
it in Fx the page is wider and the 80 1s don't go up to the edge of the text
area, infact there's space for 2 more 1s after those 80 and then the horizontal
scroll bar comes up, in IE the text wraps to the next line, even though there is
no space anywhere in the line yet. Note the width of the text area is set at 80
and the textarea is using a fixed-width font as far as I can tell.

Also note I cant get the wrapping behaviour of IE regardless of the wrap
attribute I set on the text area.

I will upload two attachments displaying the effect in both IE and Fx.

- rmjb
The wrapping stuff has nothing to do with this bug; it's covered by other bugs.
*** Bug 244687 has been marked as a duplicate of this bug. ***
*** Bug 258272 has been marked as a duplicate of this bug. ***
*** Bug 255651 has been marked as a duplicate of this bug. ***
*** Bug 261111 has been marked as a duplicate of this bug. ***
There is an improvement about the height of a textarea, because the patch of Bug
167001 increases the height of an input field and textarea field.
For example, the text of textarea does not overflow downward out of the textarea
by the TextZoom.
Rows not right....

<textarea name='resolution' style='width:100%' rows='3'><xsl:value-of
select="document/resolution"/></textarea>

Displays 4 rows... It should only display 3 rows.   
Attached patch patch (obsolete) — Splinter Review
I try to implement the option 3) or 4) that are mentioned on comment #86 and
comment #87, although about only ROWS.
Attached patch patch (obsolete) — Splinter Review
I modified for rows=1.
Attachment #175726 - Attachment is obsolete: true
Attached patch patch for rows and cols (obsolete) — Splinter Review
If the textarea has styled pixel or percent width or height, the scrollbars
appear inside the textarea, otherwise the scrollbars appear outside the
textarea.
Attachment #175730 - Attachment is obsolete: true
Attached file testcase for patch (obsolete) —
Attached file testcase for patch (obsolete) —
Attachment #176155 - Attachment is obsolete: true
Attached patch patch (obsolete) — Splinter Review
I modified for the reflow of LayoutBox, because max-element-width of contents
of the textarea is not updated by set mark-dirty, if the horizontal scrollbar
is removed by deleting a character.
Attachment #176151 - Attachment is obsolete: true
Attached image screen shot for patch
Is this behavior acceptable?
Attachment #176469 - Flags: review?(bzbarsky)
Comment on attachment 176469 [details] [diff] [review]
patch

I don't think I can review this patch any time in the near future -- I don't
really know the scroll frame code well.

The fact that this patch makes scrollframe do something special for text
control frames does make alarm bells go off in my head, though.
*** Bug 285228 has been marked as a duplicate of this bug. ***
Comment on attachment 176469 [details] [diff] [review]
patch

bzbarsky, thanks. I will ask to review to other reviewers.
Attachment #176469 - Flags: review?(bzbarsky)
Comment on attachment 176469 [details] [diff] [review]
patch

Pointing review request at roc; but note bz's comment 111.
Attachment #176469 - Flags: review?(roc)
I don't think major changes to nsGfxScrollFrame should be necessary.

Can't we do roughly what Boris suggested in
https://bugzilla.mozilla.org/show_bug.cgi?id=33654#c90
?
1) nsTextControlFrame::Reflow at intrinsic size excluding scrollbars
2) if there are no scrollbars, stop.
3) else reflow at intrinsic size plus sizes of scrollbars present.
3b) we can force the scrollframe to show the scrollbars that it was showing in
step 2, even if they're not actually needed, to ensure that the textframe
non-scrollbar area is exactly the specified ROWS and COLS. For this, we could
hack GetScrollbarStyles to ask the text control frame parent if it wants to
override the styles.
http://lxr.mozilla.org/mozilla/source/layout/generic/nsGfxScrollFrame.cpp#1119
> I don't think major changes to nsGfxScrollFrame should be necessary.

Does this indication refer about the following changes of the patche?
However, following changes correct appearance and disappearance of the
scrollbars, please refer to attachment 177495 [details].

+  nscoord scrollAreaHeight;
+  do {
+    scrollAreaHeight = scrollAreaRect.height;
+    PRBool updateMEW = PR_FALSE;
...
+  } while (scrollAreaHeight != scrollAreaRect.height);
I will add to the patch following changes.

for nsTextControlFrame::Reflow
< +  const nsStyleDisplay* disp = GetStyleDisplay();
< +  if (disp->mOverflowX == NS_STYLE_OVERFLOW_SCROLL ||
< +      aReflowState.mComputedHeight != NS_INTRINSICSIZE) {
---
> +  if (aReflowState.mComputedHeight != NS_INTRINSICSIZE) {

< +  if (disp->mOverflowY == NS_STYLE_OVERFLOW_SCROLL ||
< +      aReflowState.mComputedWidth != NS_INTRINSICSIZE) {
---
> +  if (aReflowState.mComputedWidth != NS_INTRINSICSIZE) {

and for nsGfxScrollFrameInner::Layout
< +              updateMEW = PR_TRUE;
---
> +              if (!aState.GetMaxElementWidth())
> +                updateMEW = PR_TRUE;
nsTextControlFrame could control the display of its scrollbars by modifying
GetScrollbarStyles here:
http://lxr.mozilla.org/mozilla/source/layout/generic/nsGfxScrollFrame.cpp#1119
That function can check the parent to see it it's an nsITextControlFrame and if
so, ask the text control frame whether the scrollbars should be 'auto' (for step
1 in comment #115) or 'hidden' or 'scroll' (for step 3 in comment #115). That
would be the only change required to nsGfxScrollFrame by the approach in comment
#115.
Attachment #176469 - Flags: review?(roc)
Attached patch patch (obsolete) — Splinter Review
Attachment #176469 - Attachment is obsolete: true
roc, please refer to the posted new patch of attachment 178042 [details] [diff] [review]. Is it wrong to
call |GetStyleDisplay()| at nsTextControlFrame::Reflow, although testcase of
attachment 178045 [details] is done successfully like as attachment 178047 [details]? 
I think that part of the patch is OK. The part I don't like is all the changes
to nsGfxScrollFrame. Can you reply to comment #119?
Comment on attachment 178042 [details] [diff] [review]
patch

I think that the changes was added according to the flow of comment 115.

There are two variables |mIncludingHbarSpace| and |needsHbarSpace| for
horizontal scrollbar. In the case of each value is true, they force to add
space of the horizontal scrollbar. There are copies of these variables in the
nsGfxScrollFrame. The value of |needsHbarSpace| is set by adding or removing
the space of the scrollbar at |nsGfxScrollFrameInner::Layout|. The change of
the size of the control frame causes to layout by parent marked dirty as
follows.

+  if (markHbarSpace || markVbarSpace)
+    parent->MarkDirty(aState);

There are not the changes that bzbarsky noticed on comment 111.
Attachment #178042 - Flags: review?(roc)
You don't need those variables. You can control scrollbar visibility by
modifying GetScrollbarStyles.
*** Bug 291356 has been marked as a duplicate of this bug. ***
*** Bug 291242 has been marked as a duplicate of this bug. ***
*** Bug 295352 has been marked as a duplicate of this bug. ***
*** Bug 304136 has been marked as a duplicate of this bug. ***
(In reply to comment #130)
> *** Bug 304136 has been marked as a duplicate of this bug. ***

I'd added a comment to 304136 explaining why having a 3-row high text area
appear when rows="2" is specified is unhelpful. Since that bug has been marked
as a duplicate, I'll include that comment here too, otherwise I suspect it won't
be noticed.

> I think that the last row is for the horizontal scroll bar.
> Try entering a long text with no spaces into the textarea.

The reason why this behaviour matters is that we have a web application that
requests some short summary text from the user. Our textarea is sized with
rows="2" so that the user is given a strong visual indication of how much text
is desired (more than a line, but preferably not an essay). The problem with the
behavioural inconsistency between Firefox and the other major browsers (as
exampled by IE6 and Opera 8) is that this visual indication of the amount of
required text is different on different user agents for a given rows attribute
value, and therefore the utility of that attribute is greatly diminished.

I shall now attempt to convince that following IE/Opera would be superior to the
current Firefox behaviour :-)

The HTML 4.01 spec says of the cols attribute:

"Users should be able to enter longer lines than this, so user agents should
provide some means to scroll through the contents of the control when the
contents extend beyond the visible area. User agents may wrap visible text lines
to keep long lines visible without the need for scrolling."

Thus, although providing a scrolling mechanism is allowed, it is not required,
as forcibly wrapping the visible text lines is also an option that a user agent
can take.

1. The desire for broad consistency with other browsers (where they are
conformant with the relevant recommendations) would suggest that behaving in the
same way as IE and Opera would be preferable. As already described, behaving
inconsistently lessens the usefulness of sizing textareas to give usability
hints to the user.

2. Since Firefox will already wrap the content text if it contains spaces, the
need for a horizontal scrollbar to appear is actually likely to be extremely
rare. This is because users will generally be entering words separated by spaces
(thus giving the user agent opportunities for wrapping lines at spaces) into the
textarea. The case where a long sequence of characters unbroken by a space is
entered must surely be far less common. Therefore, sizing the textarea correctly
for the least common case seems less than optimal. The alternative of sizing the
textarea to be the correct height for the specified number of rows and then
having the horizontal scrollbar eat into that space when/if it appears, would be
just as viable. Thus, there exists a better alternative to the current
behaviour, even if it is deemed that following the behaviour of IE and Opera is
not desirable.

3. (2) might be objected to on the grounds that a textarea with attribute
rows="1" would consist purely of a horizontal scrollbar, if an unbroken string
of non-space characters were entered. However, this is an extremely unlikely
scenario -- a text input field would almost certainly be used by a page designer
in preference to a textarea one row high. In any case, if thought to be a
serious objection, the rows="1" situation could be treated as a special case.

4. Intuition (i.e. the desireability of having the user agent do the least
surprising with a given chunk of HTML) would suggest that it is unhelpful to
have a textarea *three* rows high output when a textarea *two* rows high is
requested.
Attachment #143957 - Attachment description: Rendering of textarea rows=1 → Rendering of <textarea rows=1> vs <input type=text > (ie vs moz)
In addition to Comment #131, I'd just like to add that Firefox's behavior is also incorrect when the contents of a textarea don't scroll. It seems like Firefox was designed for a textarea that always gets overfilled, but what about instances where a textarea is for an address, where it is unlikely to ever have more than three rows in 99% of that form's uses? Firefox always displays an extra row, even if I have rows="3", unecessarily adding bulk to the page. It's also confusing to see a box taller than it should be, making the user think they haven't filled in enough information.

Plus it just doesn't make any sense from an HTML coding point of view to see four rows when I've specified three. If a web developer would find it undesirable to have a horizontal scrollbar decrease the viewable area of a text box, then they should add an extra row themselves, not have Firefox do it for them prematurely.
Attachment #178042 - Attachment is obsolete: true
Attachment #178042 - Flags: review?(roc)
Attached file testcase for patch
Attachment #176156 - Attachment is obsolete: true
Attached patch patch (obsolete) — Splinter Review
(In reply to comment #126)
> You don't need those variables. You can control scrollbar visibility by
> modifying GetScrollbarStyles.

roc, is this patch(attachment 206151 [details] [diff] [review]) wrong yet, because the changes does not modify GetScrollbarStyles?
Status: NEW → ASSIGNED
Comment on attachment 206151 [details] [diff] [review]
patch

Following boolean variables are used and conrtol scrollbar visibility. If these variables have default value as follows, the changes are of no effect. If the parent has interface to nsITextControlFrame, these variables are set according to comment 115.

mInsideVbarSpace = PR_TRUE; // for a style, space for scrollbar is inside of the frame
mInsideHbarSpace = PR_TRUE;
hasVbarSpace = PR_TRUE;  // the frame actually has a space for scrollbar
hasHbarSpace = PR_TRUE;
hasVScrollbar = PR_FALSE;  // if true, scrollbar is visible
hasHScrollbar = PR_FALSE;
Attachment #206151 - Flags: review?(roc)
(In reply to comment #86)
Option 5: Always show the vertical scroll bar. If wrapping is not enabled always show the horizontal scroll bar. If wrapping is enabled hide the horizontal scroll bar and do not add space for it. If wrapping is enabled make it impossible for text to extend beyond the width of the text area even if a line contains no spaces.

In this way, scroll bars are not dynamically added and removed at all (like in IE) so extra space never needs to be allocated for them. In most cases the horizontal scroll bar will never appear (wrapping is enabled). And in cases where a page author disabled wrapping he should probably expect a horizontal scroll bar to be visible anyway.

The presence of the vertical scroll bar will also have the affect of indicating to the end user that the box on thier screen is a container which expects text. As it is rendered now, an empty textarea on WinXP provides almost no cue to the user as to what the box is until the user moves the mouse over it and gets the I-beam cursor (WinXP renders the border as a 2D box).

Scroll bars should be disabled when no text extends beyond the bounds of the textarea as expected.
In reply to comment #131/132.......

I would like to see this feature work appropriately in FF.  We use 1 row text areas as inputs because they respond to width=[Percentage%].
*** Bug 332451 has been marked as a duplicate of this bug. ***
Attachment #206151 - Attachment is obsolete: true
Attachment #206151 - Flags: review?(roc)
*** Bug 343576 has been marked as a duplicate of this bug. ***
This one continues to be an issue for me as well when trying to create accurate cross browser layouts.
Attached patch patch (obsolete) — Splinter Review
I tried to modify previous patch using |GetScrollbarStyles| and |SetScrollbarStyles| in order to control styles of the scrollbars. New variables are used as follows,

    mInside[VH]barSpace -- if true, the space is inside a textarea
    mNeeds[VH]barSpace -- if true, the space will be appended by |SetScrollbarStyles|
    mHas[VH]barSpace -- if true, the space was appended

The changes to |nsHTMLScrollFrame::TryLayout| are from the reason that the appended spaces are not used to place the text. When the scrollbars appear or disappear, I use |FrameNeedsReflow| to start the reflow at changes of |nsHTMLScrollFrame::Reflow|. However, in the midst of a reflowing, it seems that |FrameNeedsReflow| does not work, so that I check the condition and start it after in |ProcessReflowCommands|.
Attached patch patch (obsolete) — Splinter Review
I added a new interface |NeedsReflow| to |nsITextControlFrame|, it is called when scrollbars are appearing or disappearing and it clears |mPrefSize| just now.
Attachment #334890 - Attachment is obsolete: true
Saito-san, please request review and sr if the patch is completed.
Comment on attachment 335214 [details] [diff] [review]
patch

roc, could you review this patch?

I intend to influence behavior only when there is a scrollbar outside the textarea. The decision as to whether to include the space of the scrollbar is in |SetScrollbarStyles| and |GetScrollbarStylesFromFrame|.
Attachment #335214 - Flags: review?(roc)
You shouldn't need the SizeNeedsRecalc call, since FrameNeedsReflow handles that, no?
(In reply to comment #148)
> You shouldn't need the SizeNeedsRecalc call, since FrameNeedsReflow handles
> that, no?
> 

Yes, I think so. However, FrameNeedsReflow is called after at PresShell::ProcessReflowCommands. As the result, the following message is displayed from nsTextControlFrame::ComputeAutoSize. I think that mPrefSize should be cleared immediately. If it is not necessary, new interface NeedsReflow is also not needed.

    NS_ASSERTION(ancestorAutoSize.width == autoSize.width,
                 "Incorrect size computed by ComputeAutoSize?");
> However, FrameNeedsReflow is called after at PresShell::ProcessReflowCommands

Er... no.  It's not.  The relevant part of your code is:

+  presShell->FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_IS_DIRTY, PR_TRUE);
+  SizeNeedsRecalc(mPrefSize);

That first call does a SizeNeedsRecalc, right?  Why is the second call needed?
Assignee: layout.form-controls → nobody
Status: ASSIGNED → NEW
QA Contact: dsirnapalli → layout.form-controls
Assignee: nobody → hsaito54
> That first call does a SizeNeedsRecalc, right?  Why is the second call needed?

The first call does not do the SizeNeedsRecalc, because I changed the code of FrameNeedsReflow as follows.

+  if (aForce && mIsReflowing) {
+    struct NeedsReflowParam* param = new (struct NeedsReflowParam);
+    if (param) {
...
+      return NS_OK;
+    }
+  }

If there is not the second call, many warning "Incorrect size computed by ComputeAutoSize?" is asserted.
Ah.  I think that change to FrameNeedsReflow is probably wrong, offhand.  Shouldn't you just add a post-reflow callback to trigger the reflow instead of doing that?
(In reply to comment #152)
> Ah.  I think that change to FrameNeedsReflow is probably wrong, offhand. 
> Shouldn't you just add a post-reflow callback to trigger the reflow instead of
> doing that?
> 

If there is not the change to FrameNeedsReflow, the warning "can't mark frame dirty during reflow" is asserted, certainly, the reflow does not work. Should I search other approach without that change?
I guess my question is why you're hacking "do stuff after the reflow finishes" functionality into FrameNeedsReflow and calling that during reflow, when we already have a similar setup with nsIReflowCallback.  Is nsIReflowCallback not sufficient for what you need out of it?  (Note: I haven't read most of the patch, just the textcontrol frame part.)
Boris, thanks for your advice, my approach was quiet insufficient. I think that I can suppress the extra changes to nsTextControlFrame and nsPresShell.
Attached patch patch (obsolete) — Splinter Review
I use MarkIntrinsicWidthsDirty instead of SizeNeedsRecalc(mPrefSize) and move the FrameNeedsReflow to ReflowFinished.
Attachment #335214 - Attachment is obsolete: true
Attachment #335521 - Flags: review?(roc)
Attachment #335214 - Flags: review?(roc)
Textarea tag displays one more row than specified in "rows" attribute.

I specify rows="4", Firefox shows 5 rows. Other browsers show 4 rows (Safari 4, Chrome, IE8, Opera 9).
Flags: wanted1.9.2?
Flags: wanted1.9.2?
Flags: wanted1.9.2-
Flags: blocking1.9.2-
Comment on attachment 335521 [details] [diff] [review]
patch

Needs to be updated to trunk. Sorry that I forgot about this review.
Attachment #335521 - Flags: review?(roc) → review-
Attached patch patch (obsolete) — Splinter Review
I updated the patch on the trunk.

roc, could you review this patch?
Attachment #335521 - Attachment is obsolete: true
Attachment #437216 - Flags: review?(roc)
+  PRPackedBool mInsideVbarSpace:1;
+  PRPackedBool mInsideHbarSpace:1;
+  PRPackedBool mNeedsVbarSpace:1;
+  PRPackedBool mNeedsHbarSpace:1;
+  PRPackedBool mHasVbarSpace:1;
+  PRPackedBool mHasHbarSpace:1;

I'd like to avoid the need for these variables. I'd also like to avoid the need for SetScrollbarStyles().

Maybe we can do all of this from nsTextControlFrame? Call GetActualScrollbarSizes before and after we reflow the scrollframe child. If a scrollbar appeared or disappeared and we're using ROWS/COLS, issue a post-reflow callback to reflow ourselves. Keep the current change to nsTextControlFrame::CalcIntrinsicSize but don't call SetScrollbarStyles.
Attachment #437216 - Attachment is obsolete: true
Attachment #437216 - Flags: review?(roc)
Attached patch patch (obsolete) — Splinter Review
> I'd like to avoid the need for these variables. I'd also like to avoid the need
> for SetScrollbarStyles().

I try to do so on your advice, but following variables still remained.

+  PRPackedBool mInsideHbarSpace:1;
+  PRPackedBool mInsideVbarSpace:1;
+  PRPackedBool mHasHbarSpace:1;
+  PRPackedBool mHasVbarSpace:1;

These variables needs to control the appearance of the scrollbars outward or the disappearance. I think that this change doesn't influence in case of the space in the inside of the textarea.

I saw another bug during a test, but I want to fix here because it is related to this change closely.

In case of the space in the inside of the textarea and the attribute for the wrap text isn't off, the vertical scrollbar that appeared once doesn't disappear even if the several typed letters are deleted. Following change is related to this bug. The function |Contains| isn't true because it is assumed that there is vertical scrollbar in measuring width of scrolledRect.

-    nsSize insideBorderSize =
-      ComputeInsideBorderSize(aState,
-                              nsSize(kidDesiredSize.width, kidDesiredSize.height));
-    nsRect scrolledRect =
-      mInner.GetScrolledRectInternal(kidDesiredSize.mOverflowArea, insideBorderSize);
-    if (nsRect(nsPoint(0, 0), insideBorderSize).Contains(scrolledRect)) {
+    PRBool force = mInner.mInsideVbarSpace && aState->mReflowedContentsWithVScrollbar;
+    if (!force) {
+      nsSize insideBorderSize =
+        ComputeInsideBorderSize(aState,
+                                nsSize(kidDesiredSize.width, kidDesiredSize.height));
+      nsRect scrolledRect =
+        mInner.GetScrolledRectInternal(kidDesiredSize.mOverflowArea, insideBorderSize);
+      force = nsRect(nsPoint(0, 0), insideBorderSize).Contains(scrolledRect);
+    }
+    if (force) {
Attachment #439499 - Flags: review?(roc)
(In reply to comment #163)
> I try to do so on your advice, but following variables still remained.
> 
> +  PRPackedBool mInsideHbarSpace:1;
> +  PRPackedBool mInsideVbarSpace:1;
> +  PRPackedBool mHasHbarSpace:1;
> +  PRPackedBool mHasVbarSpace:1;

Can you explain in a comment exactly what these variables mean?

> I saw another bug during a test, but I want to fix here because it is related
> to this change closely.

Can you put it in a separate patch? That will make this easier to review.
Attachment #439499 - Attachment is obsolete: true
Attachment #439499 - Flags: review?(roc)
Attached patch base patch (obsolete) — Splinter Review
I separated the patch and modified the comment.
Attachment #439698 - Flags: review?(roc)
Attached patch additional patch for another bug (obsolete) — Splinter Review
Could you also review this additional patch?
Attachment #439699 - Flags: review?(roc)
I still don't really understand what you mean by "inside" and "outside" here. Can you explain it, perhaps with a screenshot?
Attachment #439698 - Attachment is obsolete: true
Attachment #439698 - Flags: review?(roc)
Attached patch base patch (obsolete) — Splinter Review
I want to modify nsTextControlFrame.cpp and nsTextControlFrame.h to remove following variables.

+  // controls space of the scrollbars
+  PRPackedBool mtcshHasHbarSpace;
+  PRPackedBool mHasVbarSpace;

> I still don't really understand what you mean by "inside" and "outside" here.
> Can you explain it, perhaps with a screenshot?

The "inside" is meaning that the scrollbar appear inward as follows.
The scrollable frame's size does not change.

    +-----------+
    + 1         +
    + 2         +
    +_3_________+

    +--------+--+
    + 2      |^ +
    + 3      |  +
    +_4______|__+

The "outside" is meaning that the scrollbar appear outward as follows.
The scrollable frame's size does change.

    +---------+
    + 1       +
    + 2       +
    +_3_______+

    +---------+--+
    + 2       +^ |
    + 3       +  |
    +_4_______+_ |
Attachment #439825 - Flags: review?(roc)
OK.

I really don't think we need to add new nsGfxScrollFrameInner state here. We should be able to do everything from nsTextControlFrame.

You can add an API to nsIScrollableFrame to disable scrollbars directly. It would modify mNeverHasVerticalScrollbar/mNeverHasHorizontalScrollbar.

Then when 'rows' is specified, nsTextControlFrame will directly enable/disable the horizontal scrollbar and when 'cols' is specified, it will enable/disable the vertical scrollbar. Make nsTextControlFrame::ComputeIntrinsicSize not include space for scrollbars you have explicitly disabled.

In nsTextControlFrame::Reflow, after reflowing the scrollframe check if you need to try to enable or disable each scrollbar that you are directly controlling. If content is overflowing in a direction where the scrollbar is disabled, you should enable it. If a scrollbar is not being shown in a given direction, you should disable it.

Whenever you enable/disable a scrollbar in this way, you'll need to mark yourself as needing reflow in a post-reflow callback.

Can you try that?
Attachment #439699 - Attachment is obsolete: true
Attachment #439699 - Flags: review?(roc)
Attachment #439825 - Attachment is obsolete: true
Attachment #439825 - Flags: review?(roc)
Attached patch patchSplinter Review
How about this patch, although I have to do enough test?

I use mNeverHasVerticalScrollbar/mNeverHasHorizontalScrollbar to disable the scrollbars via a new API |SetScrollbarSpace|.

New boolean mForceHasHorizontalScrollbar and mForceHasVerticalScrollbar are used to enable the scrollbars via the |SetScrollbarSpace|.

New boolean mCannotHasHorizontalScrollbar and mCannotHasVerticalScrollbar are used to ask to disable the scrollbars by reason that it does not have enough space. In this case, the appended space for scrollbars is removed, and these boolean keep the state not to repeat enable and disable.

I get the overflow state via a new API |GetScrollbarOverflowState| instead of |GetActualScrollbarSizes|.

In |TryLayout|, if the scrollbars can not be enabled, I stop the reflow and set boolean mCannotHasHorizontalScrollbar/mCannotHasVerticalScrollbar and mNeedsReflowParentFrame to restart the reflow.
> You can add an API to nsIScrollableFrame to disable scrollbars directly. It
> would modify mNeverHasVerticalScrollbar/mNeverHasHorizontalScrollbar.

I used mNeverHasVerticalScrollbar/mNeverHasHorizontalScrollbar to disable scrollbars. However, these boolean can't be used to enable scrollbars because the appended space is used to put content. I add new boolean mForceHasHorizontalScrollbar/mForceHasVerticalScrollbar so that these boolean force to display the scrollbars on the space.
This does not use mCannotHasHorizontalScrollbar/mCannotHasVerticalScrollbar because the scrollbar is displayed even if the space is too narrow.
I added a change likewise to behave as to appearance/disappearance of the scrollbars even if the frame is resized on the corner.
Attachment #444005 - Attachment is obsolete: true
Depends on: 292284
Comment on attachment 442925 [details] [diff] [review]
patch

Asking review to Roc to have feedback on these patches.
Attachment #442925 - Flags: review?(roc)
Attachment #445636 - Flags: review?(roc)
Looks like we have a patch.  Can this patch be reviewed?
It would be nice to see movement on this...
Hi Guys, 
No need o change any browser based code, since just by adding following style in css resolve this issue

textarea{
   overflow-x: hidden
}

Note: it is only applicable when there is no horizontal scroll bar required
Hi Guys, 
No need o change any browser based code, since just by adding following style in css resolve this issue

textarea{
   overflow-x: hidden
}

Note: it is only applicable when there is no horizontal scroll bar required
@santosh: This bug cannot be fixed with css owerflow.

Firefox still the only browser in the earth which renders a tetxarea adding one extra row.
Now we got a nobody asked for chrome ui redesing in ver 29, instead of fixing a 14 years old primitive bug...
Keywords: relnote
16 years since this bug was reported and hasn't been fixed?
wow... soon 2017 and still not fixed... css isn't the solution

oh boy ,,,..it exists in 2019 as well

This bug is affecting Discord, an extremely popular chat application:
https://trello.com/c/lV4rOHLj/880-chat-bar-is-a-line-taller-than-usual-on-firefox

Hmm, so this seems to be due to the scrollbar size? So scrollbar-width: none, on the <textarea> seems to fix this, fwiw.

This should still be fixed of course.

Yes, and overflow-x: hidden also removes the "phantom scrollbar". It's just a case of the 2-year-old P3 bug vs the 20-year-old P3 bug.

This bug reminds me of 1999. Good times

See Also: → 1600170
Assignee: hsaito54 → nobody
Severity: normal → S3

The severity field for this bug is relatively low, S3. However, the bug has 27 duplicates, 103 votes and 91 CCs.
:emilio, could you consider increasing the bug severity?

For more information, please visit auto_nag documentation.

Flags: needinfo?(emilio)
Flags: needinfo?(emilio)
Summary: TEXTAREA incorrectly applying ROWS= and COLS= → TEXTAREA incorrectly applying ROWS= and COLS= (horizontal / vertical scrollbar extra space, with overlay scrollbars disabled)
Depends on: 1830576
You need to log in before you can comment on or make changes to this bug.