Summary: directional overrides, both in the form of unicode-bidi:bidi-override and in the form of Unicode directional overrides (LRO and RLO) are not handled properly, resulting in incorrect layout order. To reproduce: open the testcase in Safari Expected: all lines to be the same as the reference line. Firefox renders as expected. Actual: in the CSS lines, "fed" and "ihg" appear instead of "def" and "ghi", and in the Unicode line, "fed" appears instead of "def". Similar problems on the Hebrew side.
Created attachment 3778 [details] testcase
Created attachment 3784 [details] testcase Extended tescase
Created attachment 3785 [details] patch for CG-rendered runs only This patches the run-levels side of things, which resolves the issue for all text that subsequently gets rendered by the CG codepath. (This makes the testcase render as expected only if you apply the patch for bug 4844 along with this patch). The problem with ATSUI is that it applies its own bidi algorithm and there is no API to disable it, so I think the best option is to do something similar to what is already done with visually-ordered text, which is to embed the run in a LRO/RLO - PDF pair. I think this will also require adding to RenderText objects knowledge of their override state.
Created attachment 3792 [details] suggested patch Went ahead and added bidi override state to BidiRun and InlineTextBox for the sole purpose of letting WebTextRenderer know that it has to force ATSUI to render in visual or reverse-visual order.
Comment on attachment 3792 [details] suggested patch Looks good. r=me.