From: Vsevolod Stakhov Date: Mon, 14 Jun 2021 12:21:44 +0000 (+0100) Subject: [Minor] Propagate styles for html blocks X-Git-Tag: 3.0~307 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ab387ef08fe91ecc8faa2051e49727a51eb655bb;p=rspamd.git [Minor] Propagate styles for html blocks --- diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx index e727639aa..eb4d806d7 100644 --- a/src/libserver/html/html.cxx +++ b/src/libserver/html/html.cxx @@ -1643,14 +1643,29 @@ html_process_input(rspamd_mempool_t *pool, } } + /* Summarize content length from children */ hc->traverse_block_tags([](const html_tag *tag) -> bool { - /* Summarize content length from children */ for (const auto *cld_tag : tag->children) { tag->content_length += cld_tag->content_length; } return true; }, html_content::traverse_type::POST_ORDER); + /* Propagate styles */ + hc->traverse_block_tags([](const html_tag *tag) -> bool { + if (tag->block) { + for (const auto *cld_tag : tag->children) { + if (cld_tag->block) { + cld_tag->block->propagate_block(*tag->block); + } + else { + cld_tag->block = tag->block; + } + } + } + return true; + }, html_content::traverse_type::PRE_ORDER); + return hc; } diff --git a/src/libserver/html/html_tag.hxx b/src/libserver/html/html_tag.hxx index 906dc15d4..189cae8ed 100644 --- a/src/libserver/html/html_tag.hxx +++ b/src/libserver/html/html_tag.hxx @@ -65,7 +65,7 @@ struct html_tag { std::vector parameters; html_tag_extra_t extra; - struct html_block *block = nullptr; /* TODO: temporary, must be handled by css */ + mutable struct html_block *block = nullptr; /* TODO: temporary, must be handled by css */ std::vector children; struct html_tag *parent;