mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Move to_bidi_level
method from Stylo to Servo (#37343)
This method is only used in Servo and is the only reason that `stylo` depends on `unicode-bidi`. Stylo PR: https://github.com/servo/stylo/pull/196
This commit is contained in:
parent
c1ee354c38
commit
7427ea4aed
4 changed files with 29 additions and 17 deletions
|
@ -21,7 +21,7 @@ use crate::formatting_contexts::{
|
|||
IndependentNonReplacedContents,
|
||||
};
|
||||
use crate::layout_box_base::LayoutBoxBase;
|
||||
use crate::style_ext::DisplayGeneratingBox;
|
||||
use crate::style_ext::{ComputedValuesExt, DisplayGeneratingBox};
|
||||
|
||||
/// A builder used for both flex and grid containers.
|
||||
pub(crate) struct ModernContainerBuilder<'a, 'dom> {
|
||||
|
@ -152,7 +152,7 @@ impl<'a, 'dom> ModernContainerBuilder<'a, 'dom> {
|
|||
self.context,
|
||||
true, /* has_first_formatted_line */
|
||||
false, /* is_single_line_text_box */
|
||||
self.info.style.writing_mode.to_bidi_level(),
|
||||
self.info.style.to_bidi_level(),
|
||||
)?;
|
||||
|
||||
let block_formatting_context = BlockFormattingContext::from_block_container(
|
||||
|
|
|
@ -230,7 +230,7 @@ impl<'dom, 'style> BlockContainerBuilder<'dom, 'style> {
|
|||
self.context,
|
||||
!self.have_already_seen_first_line_for_text_indent,
|
||||
self.info.is_single_line_text_input(),
|
||||
self.info.style.writing_mode.to_bidi_level(),
|
||||
self.info.style.to_bidi_level(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -539,7 +539,7 @@ impl<'dom> BlockContainerBuilder<'dom, '_> {
|
|||
builder.split_around_block_and_finish(
|
||||
self.context,
|
||||
!self.have_already_seen_first_line_for_text_indent,
|
||||
self.info.style.writing_mode.to_bidi_level(),
|
||||
self.info.style.to_bidi_level(),
|
||||
)
|
||||
})
|
||||
{
|
||||
|
|
|
@ -28,6 +28,7 @@ use style::values::generics::position::{GenericAspectRatio, PreferredRatio};
|
|||
use style::values::generics::transform::{GenericRotate, GenericScale, GenericTranslate};
|
||||
use style::values::specified::align::AlignFlags;
|
||||
use style::values::specified::{Overflow, WillChangeBits, box_ as stylo};
|
||||
use unicode_bidi::Level;
|
||||
use webrender_api as wr;
|
||||
use webrender_api::units::LayoutTransform;
|
||||
|
||||
|
@ -365,6 +366,7 @@ pub(crate) trait ComputedValuesExt {
|
|||
) -> bool;
|
||||
fn is_inline_box(&self, fragment_flags: FragmentFlags) -> bool;
|
||||
fn overflow_direction(&self) -> OverflowDirection;
|
||||
fn to_bidi_level(&self) -> Level;
|
||||
}
|
||||
|
||||
impl ComputedValuesExt for ComputedValues {
|
||||
|
@ -1017,6 +1019,17 @@ impl ComputedValuesExt for ComputedValues {
|
|||
downward,
|
||||
}
|
||||
}
|
||||
|
||||
/// The default bidirectional embedding level for the writing mode of this style.
|
||||
///
|
||||
/// Returns bidi level 0 if the mode is LTR, or 1 otherwise.
|
||||
fn to_bidi_level(&self) -> Level {
|
||||
if self.writing_mode.is_bidi_ltr() {
|
||||
Level::ltr()
|
||||
} else {
|
||||
Level::rtl()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) enum LayoutStyle<'a> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue