-
Notifications
You must be signed in to change notification settings - Fork 43
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
Enhanced block rendering: handle RTL direction #312
Conversation
No change in logic and no obvious performance improvement, but it makes the code more readable.
Handle direction in block rendering: - handle direction via dir= attribute, or via CSS 'direction:' property (mostly to allow tweaking it via style tweaks) - handle inheritance/propagation of the direction (which can't be done via styles because of the dir= attribute) - add new flags and store direction in RenderRectAccessor for erm_final and erm_block so it's available after rendering, for drawing and text layout - use that flag in lvtextfm.cpp as the paragraph specified direction, instead of looking for it in upper nodes. - add support for text-align: start/end - correctly position blocks with a reduced width - display list item markers on the right (added renderAsListStylePositionInside() to factorize some common and ugly conditions) - (FlowState: added some preliminary work to handle 'lang=' attribute, which could be used for enhanced typography.)
Handle specified or inherited direction when walking table nodes when rendering. When table direction is RTL: - reverse order of columns and cells - render cell content with the specified or inherited direction Also make text selection work in such RTL tables.
Mostly just to be able to put the in-page footnotes separator on the right for RTL documents. Switch LVRendPageInfo->type to ->flags to store additional info. As text direction might change (albeit rarely) for elements on a page, and as we don't have any global flag for the document global direction (it may change per DocFragment), we just account the nb of 'lines' and RTL 'lines', and flag the page (or footnotes on that page) as RTL if we have > 50% of them RTL.
Added :root, :empty, and :dir(rtl). Also fix matching when a pseudoclass is standalone, which is allowed (previously, a standalone :first-child was considered invalid).
Just invert margin-left/right where they are not balanced.
Just cut & pasting some urls I looked at, for reference: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing jumps out at me. ;-)
Followup to #309, which added support for RTL/bidi text. Some technical notes in #307.
This PR completes support for RTL documents, by handling the
dir=
attribute in block nodes, drawing list item markers on the right of the page, and drawing RTL tables' cells from right to left.See commit messages for details.
Some screenshots:
(/\ source - \/ source)
I'll add to frontend a
Style tweaks> Text> Text direction>
section:which will allow setting direction on any kind of document (needed for plain text files in arabic or hebrew).
Some english page in normal LTR => switched to RTL:
Note that the absence/bad handling of left/right side bearings when in RTL context in getRenderedWidths makes all the perfect fitting stuff we did for LTR, not working so well in RTL:
Except for the getRenderedWidths() (to size table cells or floats) limitations, we should have now proper RTL support.
(I have not added some CSS properties and named values that could help simplifying our .css, like
float: inline-start
ormargin-inline-start: 1em
(that meanleft
in LTR andright
in RTL) because ... well, that's too much work :)One last remaining (minor) issue is the the landscape/dual pages, mode which will still show the first page on the left, while I guess for RTL documents it should show it on the right.