@@ -175,7 +175,7 @@ static void _buildRun(Style::Computer& c, Gc::Ref<Dom::Text> node, Box& parent)
175175 }
176176 }
177177
178- parent.add ({style, fontFace, std::move (prose)});
178+ parent.add ({style, fontFace, std::move (prose), nullptr });
179179}
180180
181181// MARK: Build Block -----------------------------------------------------------
@@ -188,7 +188,7 @@ void _buildChildren(Style::Computer& c, Gc::Ref<Dom::Node> node, Box& parent) {
188188
189189static void _buildBlock (Style::Computer& c, Rc<Style::Computed> style, Gc::Ref<Dom::Element> el, Box& parent) {
190190 auto font = _lookupFontface (c.fontBook , *style);
191- Box box = {style, font};
191+ Box box = {style, font, el };
192192 _buildChildren (c, el, box);
193193 box.attrs = _parseDomAttr (el);
194194 parent.add (std::move (box));
@@ -207,7 +207,7 @@ static void _buildImage(Style::Computer& c, Gc::Ref<Dom::Element> el, Box& paren
207207 auto img = Karm::Image::load (url).unwrapOrElse ([] {
208208 return Karm::Image::loadOrFallback (" bundle://vaev-driver/missing.qoi" _url).unwrap ();
209209 });
210- parent.add ({style, font, img});
210+ parent.add ({style, font, img, el });
211211}
212212
213213// MARK: Build Table -----------------------------------------------------------
@@ -216,6 +216,7 @@ static void _buildTableChildren(Style::Computer& c, Gc::Ref<Dom::Node> node, Box
216216 Box tableBox{
217217 tableBoxStyle,
218218 tableWrapperBox.fontFace ,
219+ node->is <Dom::Element>()
219220 };
220221
221222 tableBox.style ->display = Display::Internal::TABLE_BOX;
@@ -259,7 +260,7 @@ static void _buildTable(Style::Computer& c, Rc<Style::Computed> style, Gc::Ref<D
259260 wrapperStyle->display = style->display ;
260261 wrapperStyle->margin = style->margin ;
261262
262- Box wrapper = {wrapperStyle, font};
263+ Box wrapper = {wrapperStyle, font, el };
263264 _buildTableChildren (c, el, wrapper, style);
264265 wrapper.attrs = _parseDomAttr (el);
265266
@@ -295,16 +296,14 @@ static void _buildNode(Style::Computer& c, Gc::Ref<Dom::Node> node, Box& parent)
295296 _buildElement (c, *el, parent);
296297 } else if (auto text = node->is <Dom::Text>()) {
297298 _buildRun (c, *text, parent);
298- } else if (auto doc = node->is <Dom::Document>()) {
299- _buildChildren (c, *doc, parent);
300299 }
301300}
302301
303302export Box build (Style::Computer& c, Gc::Ref<Dom::Document> doc) {
304303 if (auto el = doc->documentElement ()) {
305304 auto style = c.computeFor (Style::Computed::initial (), *el);
306305 auto font = _lookupFontface (c.fontBook , *style);
307- Box root = {style, _lookupFontface (c.fontBook , *style)};
306+ Box root = {style, _lookupFontface (c.fontBook , *style), el };
308307 _buildChildren (c, *el, root);
309308 return root;
310309 }
@@ -313,6 +312,7 @@ export Box build(Style::Computer& c, Gc::Ref<Dom::Document> doc) {
313312 return {
314313 style,
315314 _lookupFontface (c.fontBook , *style),
315+ nullptr
316316 };
317317}
318318
@@ -335,10 +335,10 @@ export Box buildForPseudoElement(Text::FontBook& fontBook, Rc<Style::Computed> s
335335 auto prose = makeRc<Text::Prose>(proseStyle);
336336 if (style->content ) {
337337 prose->append (style->content .str ());
338- return {style, fontFace, prose};
338+ return {style, fontFace, prose, nullptr };
339339 }
340340
341- return {style, fontFace};
341+ return {style, fontFace, nullptr };
342342}
343343
344344} // namespace Vaev::Layout
0 commit comments