mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Re-use the TextMetrics data structure in the Layout 2020 fragment tree (#30823)
This data structure has all of the metrics needed to render a font and is in `Au`. We'll need more of these metrics for implementing `vertical-align` and its use doesn't increase the size of the Fragment tree (as the BoxFragment is still larger). In addition, this will be helpful when switching layout to `Au`.
This commit is contained in:
parent
f0b4162328
commit
8ded1072ce
4 changed files with 20 additions and 46 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
use std::sync::Arc;
|
||||
|
||||
use gfx::font::FontMetrics as GfxFontMetrics;
|
||||
use gfx::font::FontMetrics;
|
||||
use gfx::text::glyph::GlyphStore;
|
||||
use gfx_traits::print_tree::PrintTree;
|
||||
use msg::constellation_msg::{BrowsingContextId, PipelineId};
|
||||
|
@ -75,29 +75,6 @@ pub(crate) struct AnonymousFragment {
|
|||
pub scrollable_overflow: PhysicalRect<Length>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Serialize)]
|
||||
pub(crate) struct FontMetrics {
|
||||
pub ascent: Length,
|
||||
pub line_gap: Length,
|
||||
pub underline_offset: Length,
|
||||
pub underline_size: Length,
|
||||
pub strikeout_offset: Length,
|
||||
pub strikeout_size: Length,
|
||||
}
|
||||
|
||||
impl From<&GfxFontMetrics> for FontMetrics {
|
||||
fn from(metrics: &GfxFontMetrics) -> FontMetrics {
|
||||
FontMetrics {
|
||||
ascent: metrics.ascent.into(),
|
||||
line_gap: metrics.line_gap.into(),
|
||||
underline_offset: metrics.underline_offset.into(),
|
||||
underline_size: metrics.underline_size.into(),
|
||||
strikeout_offset: metrics.strikeout_offset.into(),
|
||||
strikeout_size: metrics.strikeout_size.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub(crate) struct TextFragment {
|
||||
pub base: BaseFragment,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue