Bug 144990

Summary: Unnecessary line-wrapping for no apparent reason
Product: WebKit Reporter: Chris Rebert <webkit>
Component: CSSAssignee: Myles C. Maxfield <mmaxfield>
Status: RESOLVED FIXED    
Severity: Normal CC: mmaxfield, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Mac (Intel)   
OS: OS X 10.10   
URL: http://jsfiddle.net/3mzzwbw7/
Bug Depends on:    
Bug Blocks: 159753    
Attachments:
Description Flags
Screenshot showing incorrect rendering of example on Safari
none
Copy of JS Fiddle example
none
Reduction none

Description Chris Rebert 2015-05-13 23:24:19 PDT
Created attachment 253100 [details]
Screenshot showing incorrect rendering of example on Safari

Original Bootstrap bug: https://github.com/twbs/bootstrap/issues/15998
Safari Version: 8.0.6 (10600.6.3)

To reproduce:
1. Open http://jsfiddle.net/3mzzwbw7/ in Safari
2. Look at the "Chelesa EBALE" text

Expected result:
There is ample horizontal room for the text, so it should fit on a single line.

Actual result:
The text is line-wrapped across 2 lines ("Chelesa" on line 1 and "EBALE" on line 2).

Other browsers:
Both Chrome and Firefox render the text on a single line, as expected.
Comment 1 Chris Rebert 2015-05-13 23:26:23 PDT
Created attachment 253101 [details]
Copy of JS Fiddle example
Comment 2 Myles C. Maxfield 2015-05-19 17:49:06 PDT
<rdar://problem/20950962>
Comment 3 Myles C. Maxfield 2015-05-19 17:53:27 PDT
Likely due to a disagreement with the fast and complex text codepaths
Comment 4 Myles C. Maxfield 2015-05-19 18:06:34 PDT
Created attachment 253414 [details]
Reduction
Comment 5 Myles C. Maxfield 2015-05-19 18:10:50 PDT
Reduction attached. The element is a float. My intuition says that RenderText::computePreferredLogicalWidths()'s measurement of the width of the text is somehow ending up smaller than BreakingContext::handleText()'s measurement.
Comment 6 Myles C. Maxfield 2015-05-19 18:28:07 PDT
Simple line layout means that TextFragmentIterator is used instead of BreakingContext
Comment 7 Myles C. Maxfield 2015-05-19 18:56:13 PDT
This is due to float precision. :(

The disagreement is between RenderText::computePreferredLogicalWidths() and BreakingContext::handleText(). The initial layout uses simple line layout, but when you interact with the page, RenderText::positionForPoint() uses the regular line layout (this subsequent layout is the problematic one).

The width of the float is calculated as the sum of the following items:

"Chelsea" => 64.998001
" " => 5.00400019
"EBALE" => 55.9980011
Total: 126.000000

Simple line layout agrees with this calculation.

However, when we get around to using regular line layout, the width of the text inside the float is calculated as the sum of the following items:

"Chelsea" => 64.998001
" EBALE" => 61.0020065
Total: 126.000008

Note that 126.0f + 1 ULP = 126.000008
Comment 8 Simon Fraser (smfr) 2015-07-17 21:31:40 PDT
No longer occurs
Comment 9 Chris Rebert 2015-07-17 23:19:16 PDT
Confirmed that this no longer repros as of r186963.
I've removed this from Bootstrap's Wall of Browser bugs:
https://github.com/twbs/bootstrap/pull/16842