mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
layout: Shape text only once (#31146)
Shape text during InlineFormattingContext construction rather than doing it twice during fragment tree construction. This is a step on the way toward proper font fallback. This also moves all `TextRun` related code into `text_run.rs` to try to trim down the size of `inline.rs`. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because this should only have performance impacts. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
parent
bb04c97f15
commit
094f7845b1
6 changed files with 289 additions and 268 deletions
|
@ -12,7 +12,11 @@ use crate::cell::ArcRefCell;
|
|||
use crate::context::LayoutContext;
|
||||
use crate::dom::{BoxSlot, LayoutBox, NodeExt};
|
||||
use crate::dom_traversal::{Contents, NodeAndStyleInfo, NonReplacedContents, TraversalHandler};
|
||||
use crate::formatting_contexts::IndependentFormattingContext;
|
||||
use crate::flow::BlockFormattingContext;
|
||||
use crate::formatting_contexts::{
|
||||
IndependentFormattingContext, NonReplacedFormattingContext,
|
||||
NonReplacedFormattingContextContents,
|
||||
};
|
||||
use crate::positioned::AbsolutelyPositionedBox;
|
||||
use crate::style_ext::DisplayGeneratingBox;
|
||||
|
||||
|
@ -143,20 +147,29 @@ where
|
|||
let mut children = std::mem::take(&mut self.jobs)
|
||||
.into_par_iter()
|
||||
.map(|job| match job {
|
||||
FlexLevelJob::TextRuns(runs) => ArcRefCell::new(FlexLevelBox::FlexItem(
|
||||
IndependentFormattingContext::construct_for_text_runs(
|
||||
&self
|
||||
.info
|
||||
.new_replacing_style(anonymous_style.clone().unwrap()),
|
||||
runs.into_iter().map(|run| crate::flow::inline::TextRun {
|
||||
base_fragment_info: (&run.info).into(),
|
||||
text: run.text.into(),
|
||||
parent_style: run.info.style,
|
||||
has_uncollapsible_content: false,
|
||||
}),
|
||||
FlexLevelJob::TextRuns(runs) => ArcRefCell::new(FlexLevelBox::FlexItem({
|
||||
let runs = runs.into_iter().map(|run| crate::flow::text_run::TextRun {
|
||||
base_fragment_info: (&run.info).into(),
|
||||
text: run.text.into(),
|
||||
parent_style: run.info.style,
|
||||
has_uncollapsible_content: false,
|
||||
shaped_text: None,
|
||||
});
|
||||
let bfc = BlockFormattingContext::construct_for_text_runs(
|
||||
runs,
|
||||
self.context,
|
||||
self.text_decoration_line,
|
||||
),
|
||||
)),
|
||||
);
|
||||
let info = &self
|
||||
.info
|
||||
.new_replacing_style(anonymous_style.clone().unwrap());
|
||||
IndependentFormattingContext::NonReplaced(NonReplacedFormattingContext {
|
||||
base_fragment_info: info.into(),
|
||||
style: info.style.clone(),
|
||||
content_sizes: None,
|
||||
contents: NonReplacedFormattingContextContents::Flow(bfc),
|
||||
})
|
||||
})),
|
||||
FlexLevelJob::Element {
|
||||
info,
|
||||
display,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue