mirror of
https://github.com/servo/servo.git
synced 2025-06-09 09:03:23 +00:00
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>
69 lines
1.6 KiB
Rust
69 lines
1.6 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
#![deny(unsafe_code)]
|
|
|
|
mod cell;
|
|
pub mod context;
|
|
pub mod display_list;
|
|
pub mod dom;
|
|
mod dom_traversal;
|
|
mod flexbox;
|
|
pub mod flow;
|
|
mod formatting_contexts;
|
|
mod fragment_tree;
|
|
pub mod geom;
|
|
#[macro_use]
|
|
pub mod layout_debug;
|
|
mod lists;
|
|
mod positioned;
|
|
pub mod query;
|
|
mod replaced;
|
|
mod sizing;
|
|
mod style_ext;
|
|
pub mod table;
|
|
pub mod traversal;
|
|
|
|
use app_units::Au;
|
|
pub use flow::BoxTree;
|
|
pub use fragment_tree::FragmentTree;
|
|
use geom::AuOrAuto;
|
|
use style::logical_geometry::WritingMode;
|
|
use style::properties::ComputedValues;
|
|
use style_ext::ComputedValuesExt;
|
|
|
|
use crate::geom::LogicalVec2;
|
|
|
|
pub struct ContainingBlock<'a> {
|
|
inline_size: Au,
|
|
block_size: AuOrAuto,
|
|
style: &'a ComputedValues,
|
|
}
|
|
|
|
impl<'a> ContainingBlock<'a> {
|
|
pub(crate) fn effective_writing_mode(&self) -> WritingMode {
|
|
self.style.effective_writing_mode()
|
|
}
|
|
}
|
|
|
|
struct DefiniteContainingBlock<'a> {
|
|
size: LogicalVec2<Au>,
|
|
style: &'a ComputedValues,
|
|
}
|
|
|
|
impl<'a> DefiniteContainingBlock<'a> {
|
|
pub(crate) fn effective_writing_mode(&self) -> WritingMode {
|
|
self.style.effective_writing_mode()
|
|
}
|
|
}
|
|
|
|
impl<'a> From<&'_ DefiniteContainingBlock<'a>> for ContainingBlock<'a> {
|
|
fn from(definite: &DefiniteContainingBlock<'a>) -> Self {
|
|
ContainingBlock {
|
|
inline_size: definite.size.inline,
|
|
block_size: AuOrAuto::LengthPercentage(definite.size.block),
|
|
style: definite.style,
|
|
}
|
|
}
|
|
}
|