Skip to content

Commit c1e5c53

Browse files
committed
vaev-engine: Remove duplicated fontface ptr from Box.
1 parent 8d093a0 commit c1e5c53

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

src/vaev-engine/layout/base.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,17 +354,16 @@ export struct Attrs {
354354

355355
struct Box : Meta::NoCopy {
356356
Rc<Style::SpecifiedValues> style;
357-
Rc<Text::Fontface> fontFace;
358357
Content content = NONE;
359358
Attrs attrs;
360359
Opt<Rc<FormatingContext>> formatingContext = NONE;
361360
Gc::Ptr<Dom::Element> origin;
362361

363-
Box(Rc<Style::SpecifiedValues> style, Rc<Text::Fontface> font, Gc::Ptr<Dom::Element> og)
364-
: style{std::move(style)}, fontFace{font}, origin{og} {}
362+
Box(Rc<Style::SpecifiedValues> style, Gc::Ptr<Dom::Element> og)
363+
: style{std::move(style)}, origin{og} {}
365364

366-
Box(Rc<Style::SpecifiedValues> style, Rc<Text::Fontface> font, Content content, Gc::Ptr<Dom::Element> og)
367-
: style{std::move(style)}, fontFace{font}, content{std::move(content)}, origin{og} {}
365+
Box(Rc<Style::SpecifiedValues> style, Content content, Gc::Ptr<Dom::Element> og)
366+
: style{std::move(style)}, content{std::move(content)}, origin{og} {}
368367

369368
Slice<Box> children() const {
370369
if (auto children = content.is<Vec<Box>>())

src/vaev-engine/layout/builder.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ struct BuilderContext {
216216
style->display = Display{Display::Inside::FLOW, Display::Outside::BLOCK};
217217

218218
auto newInlineBox = InlineBox::fromInterruptedInlineBox(*_rootInlineBox);
219-
_parent.add({style, _parent.fontFace, std::move(*_rootInlineBox), nullptr});
219+
_parent.add({style, std::move(*_rootInlineBox), nullptr});
220220
*_rootInlineBox = std::move(newInlineBox);
221221
}
222222

@@ -403,7 +403,7 @@ void buildSVGElement(Gc::Ref<Dom::Element> el, SVG::Group* group) {
403403
buildSVGAggregate(el, &newSvgRoot);
404404
group->add(std::move(newSvgRoot));
405405
} else if (el->qualifiedName == Svg::FOREIGN_OBJECT_TAG) {
406-
Box box{el->specifiedValues(), el->specifiedValues()->fontFace, el};
406+
Box box{el->specifiedValues(), el};
407407

408408
InlineBox rootInlineBox{_proseStyleFomStyle(
409409
*el->specifiedValues(),
@@ -498,7 +498,7 @@ static void buildBlockFlowFromElement(BuilderContext bc, Gc::Ref<Dom::Element> e
498498
}
499499

500500
static Box createAndBuildBoxFromElement(BuilderContext bc, Rc<Style::SpecifiedValues> style, Gc::Ref<Dom::Element> el, Display display) {
501-
Box box = {style, el->specifiedValues()->fontFace, el};
501+
Box box = {style, el};
502502
InlineBox rootInlineBox{_proseStyleFomStyle(*style, el->specifiedValues()->fontFace)};
503503

504504
auto newBc = display == Display::Inside::FLEX
@@ -531,7 +531,7 @@ struct AnonymousTableBoxWrapper {
531531
rowStyle->inherit(*style);
532532
rowStyle->display = Display::Internal::TABLE_ROW;
533533

534-
rowBox = Box{rowStyle, style->fontFace, nullptr};
534+
rowBox = Box{rowStyle, nullptr};
535535
}
536536

537537
void createCellIfNone(Rc<Style::SpecifiedValues> style) {
@@ -542,7 +542,7 @@ struct AnonymousTableBoxWrapper {
542542
cellStyle->inherit(*style);
543543
cellStyle->display = Display::Internal::TABLE_CELL;
544544

545-
cellBox = Box{cellStyle, style->fontFace, nullptr};
545+
cellBox = Box{cellStyle, nullptr};
546546
rootInlineBoxForCell = InlineBox{_proseStyleFomStyle(*style, style->fontFace)};
547547
}
548548

@@ -642,7 +642,7 @@ static void _buildTableChildrenWhileWrappingIntoAnonymousBox(BuilderContext bc,
642642

643643
// https://www.w3.org/TR/css-tables-3/#fixup-algorithm
644644
static void _buildTableInternal(BuilderContext bc, Gc::Ref<Dom::Element> el, Rc<Style::SpecifiedValues> style, Display display) {
645-
Box tableInternalBox = {style, el->specifiedValues()->fontFace, el};
645+
Box tableInternalBox = {style, el};
646646
tableInternalBox.attrs = _parseDomAttr(el);
647647

648648
switch (display.internal()) {
@@ -706,7 +706,7 @@ static void _buildTableBox(BuilderContext tableWrapperBc, Gc::Ref<Dom::Element>
706706
};
707707

708708
tableBoxStyle->display = Display::Internal::TABLE_BOX;
709-
Box tableBox = {tableBoxStyle, el->specifiedValues()->fontFace, el};
709+
Box tableBox = {tableBoxStyle, el};
710710
tableBox.attrs = _parseDomAttr(el);
711711

712712
bool captionsOnTop = tableBoxStyle->table->captionSide == CaptionSide::TOP;
@@ -731,7 +731,7 @@ static Box _createTableWrapperAndBuildTable(BuilderContext bc, Rc<Style::Specifi
731731
wrapperStyle->display = tableStyle->display;
732732
wrapperStyle->margin = tableStyle->margin;
733733

734-
Box wrapper = {wrapperStyle, tableBoxEl->specifiedValues()->fontFace, tableBoxEl};
734+
Box wrapper = {wrapperStyle, tableBoxEl};
735735
InlineBox rootInlineBox{_proseStyleFomStyle(*wrapperStyle, tableBoxEl->specifiedValues()->fontFace)};
736736

737737
// SPEC: The table wrapper box establishes a block formatting context.
@@ -833,7 +833,7 @@ static void _buildNode(BuilderContext bc, Gc::Ref<Dom::Node> node) {
833833

834834
export Box build(Gc::Ref<Dom::Document> doc) {
835835
if (auto el = doc->documentElement()) {
836-
Box root = {el->specifiedValues(), el->specifiedValues()->fontFace, el};
836+
Box root = {el->specifiedValues(), el};
837837
InlineBox rootInlineBox{_proseStyleFomStyle(*el->specifiedValues(), el->specifiedValues()->fontFace)};
838838

839839
BuilderContext bc{
@@ -849,7 +849,6 @@ export Box build(Gc::Ref<Dom::Document> doc) {
849849
// NOTE: Fallback in case of an empty document
850850
return {
851851
makeRc<Style::SpecifiedValues>(Style::SpecifiedValues::initial()),
852-
Text::Fontface::fallback(),
853852
nullptr
854853
};
855854
}
@@ -860,10 +859,10 @@ export Box buildForPseudoElement(Dom::PseudoElement& el) {
860859
auto prose = makeRc<Text::Prose>(proseStyle);
861860
if (el.specifiedValues()->content) {
862861
prose->append(el.specifiedValues()->content.str());
863-
return {el.specifiedValues(), el.specifiedValues()->fontFace, InlineBox{prose}, nullptr};
862+
return {el.specifiedValues(), InlineBox{prose}, nullptr};
864863
}
865864

866-
return {el.specifiedValues(), el.specifiedValues()->fontFace, nullptr};
865+
return {el.specifiedValues(), nullptr};
867866
}
868867

869868
} // namespace Vaev::Layout

src/vaev-engine/layout/values.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ export struct Resolver {
2626
Au fontSize{16};
2727

2828
Resolver resolver;
29-
resolver.rootFont = Text::Font{tree.root.fontFace, fontSize.cast<f64>()};
30-
resolver.boxFont = Text::Font{box.fontFace, fontSize.cast<f64>()};
29+
resolver.rootFont = Text::Font{tree.root.style->fontFace, fontSize.cast<f64>()};
30+
resolver.boxFont = Text::Font{box.style->fontFace, fontSize.cast<f64>()};
3131
resolver.viewport = tree.viewport;
3232
resolver.boxAxis = mainAxis(box);
3333
return resolver;

0 commit comments

Comments
 (0)