layout: Prepare for bidi by guarding all access to writing-mode (#33082)

We want to selectively enable right-to-left writing modes per layout
context. This change makes that possible by allowing access to
`writing-mode` though an interface that always returns the default
horizontal top-to-bottom (implicitly left-to-right) writing mode.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
This commit is contained in:
Martin Robinson 2024-08-16 13:38:04 +02:00 committed by GitHub
parent 3d3621b652
commit 0d94a8acd2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 129 additions and 88 deletions

View file

@ -165,15 +165,16 @@ impl BoxFragment {
/// Get the baselines for this [`BoxFragment`] if they are compatible with the given [`WritingMode`].
/// If they are not compatible, [`Baselines::default()`] is returned.
pub fn baselines(&self, writing_mode: WritingMode) -> Baselines {
let mut baselines =
if writing_mode.is_horizontal() == self.style.writing_mode.is_horizontal() {
self.baselines
} else {
// If the writing mode of the container requesting baselines is not
// compatible, ensure that the baselines established by this fragment are
// not used.
Baselines::default()
};
let mut baselines = if writing_mode.is_horizontal() ==
self.style.effective_writing_mode().is_horizontal()
{
self.baselines
} else {
// If the writing mode of the container requesting baselines is not
// compatible, ensure that the baselines established by this fragment are
// not used.
Baselines::default()
};
// From the https://drafts.csswg.org/css-align-3/#baseline-export section on "block containers":
// > However, for legacy reasons if its baseline-source is auto (the initial