Bug 17152

Summary: Paragraphs indented with :first-letter and text-align CSS render incorrectly
Product: WebKit Reporter: Daniel G. Taylor <dan>
Component: Layout and RenderingAssignee: mitz
Status: RESOLVED FIXED    
Severity: Normal CC: mitz, webkit
Priority: P2 Keywords: HasReduction
Version: 523.x (Safari 3)   
Hardware: All   
OS: All   
URL: http://programmer-art.org
Attachments:
Description Flags
test case
none
Reduction showing the root cause
none
Reduction showing the root cause
none
Improve the logic for when to apply padding, border and margin before a text node sam: review+

Description Daniel G. Taylor 2008-02-02 11:12:08 PST
When using the :first-letter CSS to indent paragraphs and then text-align: justify WebKit will sometimes render parts of the text on top of each other.

How to reproduce the problem
-----------------------
Go to http://programmer-art.org
Resize the window horizontally and watch as text shifts around.
Comment 1 Daniel G. Taylor 2008-02-03 06:37:55 PST
I have uploaded a simpler example with the two CSS rules and a few paragraphs here:

http://programmer-art.org/dropbox/bug.html
Comment 2 Robert Blaut 2008-02-03 13:18:45 PST
Created attachment 18888 [details]
test case

uploaded test case
Comment 3 mitz 2008-02-25 17:34:33 PST
I have just made things worse by changing numSpaces from int to unsigned. The real problem though is that line breaking results in totWidth > availableWidth in computeHorizontalPositionsForLine().
Comment 4 mitz 2008-02-25 17:40:14 PST
Created attachment 19365 [details]
Reduction showing the root cause

This shows that the problem is line breaking.
Comment 5 mitz 2008-02-25 17:57:21 PST
Created attachment 19368 [details]
Reduction showing the root cause

This is not even about first-letter. It is just the assumption expressed in findNextLineBreak():

            bool appliedStartWidth = pos > 0; // If the span originated on a previous line,
                                              // then assume the start width has been applied.
Comment 6 mitz 2008-02-25 21:53:18 PST
Created attachment 19370 [details]
Improve the logic for when to apply padding, border and margin before a text node
Comment 7 mitz 2008-02-25 21:56:53 PST
(In reply to comment #0)
> When using the :first-letter CSS to indent paragraphs

Out of curiosity, why would you do that instead of using the text-indent property?
Comment 8 mitz 2008-02-25 22:53:47 PST
Fixed in <http://trac.webkit.org/projects/webkit/changeset/30590>.
Comment 9 Daniel G. Taylor 2008-02-26 07:03:26 PST
(In reply to comment #7)
> (In reply to comment #0)
> > When using the :first-letter CSS to indent paragraphs
> 
> Out of curiosity, why would you do that instead of using the text-indent
> property?
> 

Good question. In all the years I've used CSS I never knew about that property! Using it on my site now as it seems to be the proper way to do things.

Thanks for fixing the bug!