mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Add BoxFragment::is_inline_box()
(#34233)
A helper function to check for inline boxes. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
ae029242f8
commit
bf75f17348
3 changed files with 10 additions and 10 deletions
|
@ -15,6 +15,7 @@ use style::Zero;
|
|||
use super::{BaseFragment, BaseFragmentInfo, CollapsedBlockMargins, Fragment};
|
||||
use crate::cell::ArcRefCell;
|
||||
use crate::formatting_contexts::Baselines;
|
||||
use crate::fragment_tree::FragmentFlags;
|
||||
use crate::geom::{
|
||||
AuOrAuto, LengthPercentageOrAuto, PhysicalPoint, PhysicalRect, PhysicalSides, ToLogical,
|
||||
};
|
||||
|
@ -325,4 +326,11 @@ impl BoxFragment {
|
|||
|
||||
convert_to_au_or_auto(PhysicalSides::new(top, right, bottom, left))
|
||||
}
|
||||
|
||||
/// Whether this is a non-replaced inline-level box whose inner display type is `flow`.
|
||||
/// <https://drafts.csswg.org/css-display-3/#inline-box>
|
||||
pub(crate) fn is_inline_box(&self) -> bool {
|
||||
self.style.get_box().display.is_inline_flow() &&
|
||||
!self.base.flags.contains(FragmentFlags::IS_REPLACED)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ use super::{ContainingBlockManager, Fragment, Tag};
|
|||
use crate::cell::ArcRefCell;
|
||||
use crate::display_list::StackingContext;
|
||||
use crate::flow::CanvasBackground;
|
||||
use crate::fragment_tree::FragmentFlags;
|
||||
use crate::geom::PhysicalRect;
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -141,9 +140,7 @@ impl FragmentTree {
|
|||
// CSS layout box is inline, return zero." For this check we
|
||||
// also explicitly ignore the list item portion of the display
|
||||
// style.
|
||||
if fragment.style.get_box().display.is_inline_flow() &&
|
||||
!fragment.base.flags.contains(FragmentFlags::IS_REPLACED)
|
||||
{
|
||||
if fragment.is_inline_box() {
|
||||
return Some(Rect::zero());
|
||||
}
|
||||
|
||||
|
|
|
@ -248,12 +248,7 @@ fn resolved_size_should_be_used_value(fragment: &Fragment) -> bool {
|
|||
// https://drafts.csswg.org/css-sizing-3/#preferred-size-properties
|
||||
// > Applies to: all elements except non-replaced inlines
|
||||
match fragment {
|
||||
Fragment::Box(box_fragment) => {
|
||||
!box_fragment.style.get_box().display.is_inline_flow() ||
|
||||
fragment
|
||||
.base()
|
||||
.is_some_and(|base| base.flags.contains(FragmentFlags::IS_REPLACED))
|
||||
},
|
||||
Fragment::Box(box_fragment) => !box_fragment.is_inline_box(),
|
||||
Fragment::Float(_) |
|
||||
Fragment::Positioning(_) |
|
||||
Fragment::AbsoluteOrFixedPositioned(_) |
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue