Bug 124146 - dir=auto causes spaces to not get collapsed
Summary: dir=auto causes spaces to not get collapsed
Status: RESOLVED DUPLICATE of bug 109624
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.9
: P2 Normal
Assignee: Myles C. Maxfield
URL: https://en.wikipedia.org/w/index.php?...
Keywords: InRadar
Depends on:
Reported: 2013-11-11 06:46 PST by Derk-Jan Hartman
Modified: 2016-02-22 14:56 PST (History)
5 users (show)

See Also:

small test case (163 bytes, text/html)
2013-11-11 06:46 PST, Derk-Jan Hartman
no flags Details
Screenshot (50.56 KB, image/png)
2013-11-11 06:48 PST, Derk-Jan Hartman
no flags Details
Reduction (98 bytes, text/html)
2015-07-01 15:35 PDT, Myles C. Maxfield
no flags Details
Reduction (78 bytes, text/html)
2015-07-01 15:37 PDT, Myles C. Maxfield
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Derk-Jan Hartman 2013-11-11 06:46:25 PST
See the screenshot, a fragment of the page at https://en.wikipedia.org/w/index.php?title=Wikipedia_talk%3ARequests_for_adminship&action=history&offset=20131111000000 

The part of the line after the arrow, but before the ) parentheses is a span with dir=auto set. As is clearly visible, the text in this inline-block is incorrectly measured causing it to overlap the parentheses. Resetting the implied unicode-bidi: -webkit-isolate; to normal, fixes the problem.

A reduced testcase is included
Comment 1 Derk-Jan Hartman 2013-11-11 06:46:58 PST
Created attachment 216565 [details]
small test case
Comment 2 Derk-Jan Hartman 2013-11-11 06:47:32 PST
Oh and using: Version 7.0 (9537.71)
Comment 3 Derk-Jan Hartman 2013-11-11 06:48:25 PST
Created attachment 216566 [details]
Comment 4 Aharon (Vladimir) Lanin 2013-12-09 00:13:41 PST
This appears to be the same as https://code.google.com/p/chromium/issues/detail?id=323270, which has been fixed there.
Comment 5 Derk-Jan Hartman 2013-12-23 03:59:47 PST
Can someone import the fix if this really is already fixed in chromium ?
Comment 6 Aharon (Vladimir) Lanin 2014-01-08 02:08:59 PST
Please also see https://code.google.com/p/chromium/issues/detail?id=330974 (now fixed there).
Comment 7 Aharon (Vladimir) Lanin 2014-03-03 06:26:21 PST
Still not fixed in Safari 7.0.2 Mac:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.74.9 (KHTML, like Gecko) Version/7.0.2 Safari/537.74.9

Is this a duplicate of bug 109624?

Can someone please import the fix?
Comment 8 Derk-Jan Hartman 2015-06-30 13:49:31 PDT
Still a problem in Safari 9 Seed 1..
So sad....
Comment 9 Radar WebKit Bug Importer 2015-06-30 21:58:41 PDT
Comment 10 Myles C. Maxfield 2015-07-01 15:35:15 PDT
Created attachment 255958 [details]
Comment 11 Myles C. Maxfield 2015-07-01 15:37:41 PDT
Created attachment 255959 [details]
Comment 12 Myles C. Maxfield 2015-07-01 15:43:31 PDT
Not related to simple line layout
Comment 13 Myles C. Maxfield 2015-07-01 15:53:37 PDT
The layout box for the "a   b" is getting the correct width, but the bidi run still includes the entire "a   b" string, causing our paint code to naively draw in the collapsed spaces
Comment 14 Myles C. Maxfield 2015-07-01 15:57:32 PDT
We mark <span dir="auto"> as an isolate
Comment 15 Myles C. Maxfield 2015-07-01 16:02:17 PDT
Looks like our midpoint logic in RenderBlockFlow::appendRunsForObject() is failing, possibly due to the isolate. (Midpoints are how we perform space collapsing)
Comment 16 Myles C. Maxfield 2015-07-01 16:18:41 PDT
Wow, yeah, our midpoint handling is completely busted with regard to isolate.

In particular, RenderBlockFlow::appendRunsForObject() assumes that we are iterating in the order of midpoints (aka in logical order, because the midpoints are inserted by our line breaking logic, which is (correctly) insensitive to bidi).

However, constructBidiRunsForSegment() in RenderBlockLineLayout.cpp doesn't iterate in logical order, which is acceptable because of the definition of "isolate" (namely, that isolated elements can be processed out-of-band because they don't require any context)

Overall: our line breaking logic builds up a data structure of midpoints in logical order, and when we process a run of text inside constructBidiRunsForSegment(), we keep a cursor into that data structure and expect it to progress at the same rate that our bidi text processing progresses. However, our bidi text processing doesn't operate in logical order, so when the processing consults the data structure, it's looking in the wrong place inside it.

Fixing this is no simple matter.
Comment 17 Myles C. Maxfield 2015-07-02 08:53:09 PDT
After talking with Zalan, we came up with a pretty simple solution for this. The bidi processing is organized into passes; we can just reset the midpoint cursor for each pass.
Comment 18 Myles C. Maxfield 2015-07-09 13:33:30 PDT

*** This bug has been marked as a duplicate of bug 109624 ***
Comment 19 Derk-Jan Hartman 2016-02-22 14:51:11 PST
This was marked as a duplicate, but this problem as presented in the reducde testcase still exists in both Version 9.0.3 (11601.4.4) and in nightly builds.
Comment 20 Derk-Jan Hartman 2016-02-22 14:56:20 PST
My apologies, Spotlight failed me in opening WebKit (picked the website, instead of the app) and I hadn't notice therefore I was not testing with the nightly.

Retested, and it is fixed in the nightlies afterall (but not in 9.0.x).

*** This bug has been marked as a duplicate of bug 109624 ***