-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge spans, simplify applyLinePadding and fix fillLineGap behaviour #216
Conversation
Just noticed that linePadding005 is in fact showing the wrong behaviour, and I need to fix by putting back the negative margin that somehow got pulled out before. [Update: absence of negative margin was fixed, this comment no longer applies.] |
…ing) that originate from the same ISD element. Move span background color down to the leaf-most span, and use padding for linePadding and fillLineGap. Round the frontier between lines for fillLineGap to avoid user agent rounding errors that lead to unwanted gaps or overlaps.
5550b69
to
766e8a9
Compare
@nigelmegitt Thanks for the all the effort. This looks super promising. What about |
Thanks for the pointer @palemieux ; weirdly that quite big visual difference gave a tiny numerical value from the image comparison tool so I didn't look at it in detail. I can reproduce the difference, and will investigate. |
Having looked at this, I think there's a discussion to be had about which is the correct render of linePadding3. The line above "Two lines" is generated by the preserved line break in the character content of the The question I have is: does that preserved line break generate a line area? This is a similar case to #190, where the conclusion was that an empty |
Another data point: inspecting the generated As an experiment, replacing the preserved new line with a My conclusion is that the linePadding3 test content creates a zero length line area, to which linePadding should be applied, therefore this code fixes a bug that had not previously been identified. Happy to hear counter-arguments! |
Fixes the linePadding3 render to be the same as before, whether that is right or wrong!
Having thought about this overnight, I think the intent of the linePadding feature is to make text more readable by adding background padding on the ends of lines of text. In this case, of linePadding3, there is no visible text, so there is no readability benefit to drawing a weird empty background blob. Hence I pushed 31ae441 which does not apply line padding when the line has a single span whose bounding client rect has zero width or zero height. |
Fixes a typo that was brokenly not setting left margin properly.
Fixes an issue where linePadding sometimes didn't appear on one side or the other, and reduces the test differences still further.
It is needed to correctly inset when linePadding is applied.
Quick overview of the detail of this PR: span merging algorithm:
The purpose of merging the spans is primarily to ensure that screen readers and layout engines treat blocks of adjacent characters as belonging together; it also provides a small (so far) performance improvement because there are fewer elements over which to iterate in later steps. Currently the only later step is The purpose of steps 3 and 4 is to ensure that the background color is applied to the span that has the correct size (including padding), which is relevant to linePadding and fillLineGap. line padding
Note that the parent line gap filling
|
This pull request does several things:
applyLinePadding
to usepadding
on the line end spans.When comparing renders of the tests, I got this result:
$ python script/refpngcompare.py sandflow/imscJS/renders/imsc1/renders/png/ tests_render/imsc1/renders/png/ /Users/megitn02/Code/sandflow/imscJS/renders/imsc1/renders/png/FillLineGap002/0.000000.png: 0.000225907 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1/renders/png/FillLineGap004/0.000000.png: 0.000468971 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1/renders/png/FillLineGap003/0.000000.png: 0.000728906 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1/renders/png/FillLineGap003/35.000000.png: 0.00154229 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1/renders/png/FillLineGap003/30.000000.png: 0.00171816 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1/renders/png/FillLineGap003/5.000000.png: 0.000773408 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1/renders/png/FillLineGap003/20.000000.png: 0.00144757 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1/renders/png/FillLineGap003/25.000000.png: 0.00014814 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1/renders/png/FillLineGap003/15.000000.png: 0.000651107 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1/renders/png/FillLineGap003/10.000000.png: 0.00137215 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1/renders/png/LinePadding005/0.000000.png: 0.0062804 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1/renders/png/linePadding3/0.000000.png: 0.00014617 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1/renders/png/FillLineGap001/0.000000.png: 0.000507626 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1/renders/png/DisplayAlign004/0.000000.png: 0.000578269 $ python script/refpngcompare.py ~/Code/sandflow/imscJS/renders/imsc1.1/renders/png/ tests_render/imsc1.1/renders/png/ /Users/megitn02/Code/sandflow/imscJS/renders/imsc1.1/renders/png/shear001/0.000000.png: 0.000475705 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1.1/renders/png/shear001/5.000000.png: 0.000519006 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1.1/renders/png/shear001/2.000000.png: 0.000521545 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1.1/renders/png/shear001/4.000000.png: 0.000490956 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1.1/renders/png/shear001/1.000000.png: 0.000475886 /Users/megitn02/Code/sandflow/imscJS/renders/imsc1.1/renders/png/shear001/3.000000.png: 0.00047467
On inspection, I couldn't see anything that would be especially worrisome about these diffs. The largest diff, for
LinePadding005/0.000000.png
is mainly caused by the correct rendering of ligatures in the Arabic text, demonstrating a benefit of this pull request.