Skip to content

[3.0] Theme split (wave 8, part 3) — align text with start and end instead of left and right - #9570

Open
albertlast wants to merge 3 commits into
SimpleMachines:release-3.0from
albertlast:3.0/theme-rtl-textalign
Open

[3.0] Theme split (wave 8, part 3) — align text with start and end instead of left and right#9570
albertlast wants to merge 3 commits into
SimpleMachines:release-3.0from
albertlast:3.0/theme-rtl-textalign

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

Part 3 of wave 8 of the #7933 split. Stacked on #9569, which is stacked on #9568.

text-align: start and text-align: end follow the writing direction, so the eleven
places where rtl.css did nothing except mirror the alignment no longer need an override
at all.

Same rule as part 2: only exact mirrors are converted — the base stylesheet says
left and rtl.css says right, or the reverse.

Left alone on purpose:

  • alignments rtl.css sets where the base sheet has none, which a single logical
    declaration cannot express
  • the deliberate ones. code.bbc_code and pre.file_content stay text-align: left
    in a right-to-left language because code should not be mirrored. That rule is untouched,
    and converting it would have been a real bug rather than a no-op.

Two that needed care rather than a substitution

#main_grid td.days shares a rule with #month_grid td.days, and only the first has a
mirror. It turned out to be safe anyway: the mini calendar re-declares
text-align: center immediately below at equal specificity, so the shared value never
reaches it.

rtl.css aligned #stats tr.windowbg th.lefttext and #stats tr.titlebg th.lefttext
in one rule, and only the windowbg half has a rule to mirror — the titlebg half is
aligned by the generic .lefttext instead. Removing the pair wholesale would have quietly
dropped the flip for titlebg, so that half keeps its override, now standing alone with a
comment explaining why.

How this was checked

Same criterion and method as part 2 — nothing moves in either direction — with
text-align and direction recorded alongside the geometry, on 28 pages, captured back
to back across a stash.

elements differences
left-to-right 8996 119, all the text-align keyword
right-to-left 8995 119, all the text-align keyword

No geometry moved in either direction.

The count is larger than the eleven converted rules because text-align inherits, so
every child reports the new keyword too. In right-to-left the changes read
right -> start and left -> end, which are the same rendering; in left-to-right they
read left -> start and right -> end.

rtl.css goes from 480 lines to 453.

Issues References (Fixes|Related|Closes)

Related to #7933.

rtl.css exists to flip physical properties for right-to-left languages, so
every rule in it is an override of something another stylesheet draws. Sixteen
of them override markup the theme stopped emitting, and have been dead for
some time:

- the event editor was rewritten and now draws no ul at all, which takes out
  the whole "edit event section" block plus the two #event_main rules
- .bbc_standard_quote and .bbc_alternate_quote were checked and kept: those
  class names are built at runtime in BBCodeParser, so grepping for them finds
  nothing even though the markup does emit them
- the rest name ids and classes that appear nowhere in Themes/ or Sources/:
  #postbuttons_upper, .reportlinks, #personal_messages span#author and
  span#topic_title, h3.search_hd, #popularposts, #popularactivity,
  .topic .mod_icons, .stats_icon, .search_results_posts .buttons and
  #helpmain h3.section

Checked by loading 24 pages as an administrator with a right-to-left language
active, including the event editor, the statistics centre, help, search
results and the personal messages area: 7086 elements, and not one of the
removed selectors matches any of them.

.topic .mod_icons is the counterpart of the index.css rule removed in SimpleMachines#9547,
which left this copy behind.

Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
float: inline-start and float: inline-end follow the writing direction on
their own, so a rule that uses them needs no right-to-left counterpart. This
converts the 26 floats where rtl.css was doing nothing more than mirroring the
value, and drops those overrides.

The 26 are the ones where the override is an exact mirror: index.css and
profile.css say left and rtl.css says right, or the other way round. Floats
whose right-to-left value is not the mirror of the left-to-right one are left
alone, because a single logical declaration cannot reproduce two different
values; the same goes for the floats rtl.css adds where the base sheet has
none.

#post_header dt/dd shared a rule with #event_options dt/dd, and only the first
pair has a mirror in rtl.css. Converting the pair together would have started
mirroring the event editor, which is not mirrored today, so the rule is split
and #event_options keeps a physical float with a comment saying why.

Checked by recording float, clear, text-align, the inline margins and padding,
and the bounding rectangle of every element on 26 pages, before and after,
captured back to back so nothing else about the forum could move in between:

- left-to-right: 8018 elements, the only differences are the 82 float keywords
  themselves. No geometry changes at all.
- right-to-left: 8017 elements, 81 float keywords, and again nothing else.

The keyword is expected to differ: getComputedStyle reports inline-start
rather than resolving it to left or right. What matters is that every x, y,
width, height, margin and padding is identical in both directions.

rtl.css goes from 555 lines to 480.

Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
text-align: start and text-align: end follow the writing direction, so the
eleven places where rtl.css did nothing but mirror the alignment no longer
need an override.

As with the floats, only exact mirrors are converted: the base sheet says left
and rtl.css says right, or the reverse. Alignments that rtl.css sets where the
base sheet has none are left alone, and so are the deliberate ones - code
blocks and file contents stay left-aligned in a right-to-left language on
purpose, and that rule is untouched.

Two rules needed care rather than a substitution:

- #main_grid td.days shares its rule with #month_grid td.days, but the mini
  calendar re-declares text-align: center immediately below, so the shared
  value never reaches it and the group is safe to convert.
- rtl.css aligned #stats tr.windowbg th.lefttext and #stats tr.titlebg
  th.lefttext together, and only the windowbg half has a rule to mirror. The
  titlebg half is aligned by .lefttext instead, so it keeps its override, now
  with a comment saying why it is on its own.

Checked the same way as the floats, capturing every element on 28 pages before
and after, back to back, with text-align and direction recorded alongside the
geometry:

- left-to-right: 8996 elements, 119 differences, every one the text-align
  keyword
- right-to-left: 8995 elements, 119 differences, likewise

No geometry moved in either direction. The count is higher than the eleven
converted rules because text-align inherits, so the children report the new
keyword too.

rtl.css goes from 480 lines to 453.

Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants