Closed Bug 476324 Opened 17 years ago Closed 16 years ago

Missing first newline when rendering the html command <pre style='display:inline'>

Categories

(Core :: DOM: HTML Parser, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: bradbell, Unassigned)

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 (.NET CLR 3.5.30729) Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 (.NET CLR 3.5.30729) The first newline is sometimes missing when viewing preformatted text in Firefox version 3 (when the newline is missing is described below). Reproducible: Always Steps to Reproduce: 1. Copy and paste the text below, between and including <html> and </html>, into an editor window: <html> <head></head> <body> Before <pre style='display:inline'> x = 5 </pre> After. </body> </html> 2. Save the text as an html file (for example, as temp.html). 3. View the file (temp.html) in Firefox version 3. Note that the newline before "x = 5" is missing. 4. In the editor, add one space directly after the text "<pre style='display:inline'>" so that it becomes "<pre style='display:inline'> " and theb save the file. 5. Reload the file in Firefox and notice that the newline before "x = 5" is now displayed in the browser. Actual Results: At the end of Step 3, the result displayed by Firefox 3 is: "Before x = 5 After." At the end of Step 5, the result displayed by Firefox is: "Before x = 5 After." Expected Results: The result after Step 5 is expected after Step 3. I get the "Actual Results" above with both 1. Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 (.NET CLR 3.5.30729). 2. Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/2008111318 Ubuntu/8.10 (intrepid) Firefox/3.0.4
Same thing happens in Chrome, and afaict this is correct as the space allows for a line-break, otherwise it is inline text (specified with display:inline).
Please keep the discussion in the bug itself. From email: Thanks for your prompt reply. It seemed to me that if you wanted the "x = 5" on the same line you would use <html> <head></head> <body> Before <pre style='display:inline'> x = 5 </pre> After. </body> </html> Is ignoring the first newline part of the specifications on the http://www.w3.org/ site?
Component: General → Layout: Block and Inline
Product: Firefox → Core
QA Contact: general → layout.block-and-inline
Version: unspecified → Trunk
This part of the spec also seems relevant: http://www.w3.org/TR/CSS21/visuren.html#propdef-display . Does the newline get trashed or is it ignored because of the inline directive? Seems like the latter, as the former would be incorrect (at least according to that spec, which seems under-specified).
I would have thought that the relevant spec was http://www.w3.org/TR/html401/appendix/notes.html#notes-line-breaks - since ye olde bug 823, parser's been producing the same thing for <pre>\nx and <pre>x, so layout isn't actually making any decision there. (Though I've always been a little puzzled by the way that \n</pre> and </pre> don't produce the same thing.)
Yeah, this isn't a CSS issue at all; this is purely a parser-level thing. Over to parser, but I believe this is invalid; Henri, can you confirm?
Component: Layout: Block and Inline → HTML: Parser
QA Contact: layout.block-and-inline → parser
(In reply to comment #6) > I would have thought that the relevant spec was > http://www.w3.org/TR/html401/appendix/notes.html#notes-line-breaks We are now tracking HTML5--not HTML4. (In reply to comment #7) > Over to parser, but I believe this is invalid; Henri, can you confirm? Yes, this is invalid. From the spec: > A start tag whose tag name is one of: "pre", "listing" > > If the stack of open elements has a p element in scope, > then act as if an end tag with the tag name "p" had been seen. > > Insert an HTML element for the token. > > If the next token is a U+000A LINE FEED (LF) character token, > then ignore that token and move on to the next one. (Newlines > at the start of pre blocks are ignored as an authoring > convenience.) http://www.whatwg.org/specs/web-apps/current-work/
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: