mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Rename ReplacedContent::layout to make_fragments and simplify its API
This commit is contained in:
parent
b8db9459bc
commit
34e8cda801
4 changed files with 57 additions and 85 deletions
|
@ -17,7 +17,7 @@ use app_units::Au;
|
|||
use gfx::text::text_run::GlyphRun;
|
||||
use servo_arc::Arc;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::{Length, LengthOrAuto, Percentage};
|
||||
use style::values::computed::{Length, Percentage};
|
||||
use style::Zero;
|
||||
use webrender_api::FontInstanceKey;
|
||||
|
||||
|
@ -418,29 +418,13 @@ fn layout_atomic<'box_tree>(
|
|||
let fragment = match atomic.as_replaced() {
|
||||
Ok(replaced) => {
|
||||
// FIXME: implement https://drafts.csswg.org/css2/visudet.html#inline-replaced-width
|
||||
let inline_size = Length::zero();
|
||||
let block_size = Length::zero();
|
||||
let containing_block_for_children = ContainingBlock {
|
||||
inline_size,
|
||||
block_size: LengthOrAuto::LengthPercentage(block_size),
|
||||
mode: atomic.style.writing_mode(),
|
||||
};
|
||||
// https://drafts.csswg.org/css-writing-modes/#orthogonal-flows
|
||||
assert_eq!(
|
||||
ifc.containing_block.mode, containing_block_for_children.mode,
|
||||
"Mixed writing modes are not supported yet"
|
||||
);
|
||||
let independent_layout = replaced.layout(&atomic.style, &containing_block_for_children);
|
||||
let content_rect = Rect {
|
||||
start_corner,
|
||||
size: Vec2 {
|
||||
block: independent_layout.content_block_size,
|
||||
inline: inline_size,
|
||||
},
|
||||
};
|
||||
// and https://drafts.csswg.org/css2/visudet.html#inline-replaced-height
|
||||
let size = Vec2::zero();
|
||||
let fragments = replaced.make_fragments(&atomic.style, size.clone());
|
||||
let content_rect = Rect { start_corner, size };
|
||||
BoxFragment {
|
||||
style: atomic.style.clone(),
|
||||
children: independent_layout.fragments,
|
||||
children: fragments,
|
||||
content_rect,
|
||||
padding,
|
||||
border,
|
||||
|
|
|
@ -516,17 +516,11 @@ fn layout_in_flow_replaced_block_level<'a>(
|
|||
block_start: computed_margin.block_start.auto_is(Length::zero),
|
||||
block_end: computed_margin.block_end.auto_is(Length::zero),
|
||||
};
|
||||
let containing_block_for_children = ContainingBlock {
|
||||
inline_size,
|
||||
block_size: LengthOrAuto::LengthPercentage(block_size),
|
||||
mode,
|
||||
let size = Vec2 {
|
||||
block: block_size,
|
||||
inline: inline_size,
|
||||
};
|
||||
// https://drafts.csswg.org/css-writing-modes/#orthogonal-flows
|
||||
assert_eq!(
|
||||
containing_block.mode, containing_block_for_children.mode,
|
||||
"Mixed writing modes are not supported yet"
|
||||
);
|
||||
let independent_layout = replaced.layout(style, &containing_block_for_children);
|
||||
let fragments = replaced.make_fragments(style, size.clone());
|
||||
let relative_adjustement = relative_adjustement(
|
||||
style,
|
||||
inline_size,
|
||||
|
@ -537,14 +531,11 @@ fn layout_in_flow_replaced_block_level<'a>(
|
|||
block: pb.block_start + relative_adjustement.block,
|
||||
inline: pb.inline_start + relative_adjustement.inline + margin.inline_start,
|
||||
},
|
||||
size: Vec2 {
|
||||
block: block_size,
|
||||
inline: inline_size,
|
||||
},
|
||||
size,
|
||||
};
|
||||
BoxFragment {
|
||||
style: style.clone(),
|
||||
children: independent_layout.fragments,
|
||||
children: fragments,
|
||||
content_rect,
|
||||
padding,
|
||||
border,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue