]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Propagate styles for html blocks
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 14 Jun 2021 12:21:44 +0000 (13:21 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 14 Jun 2021 13:07:29 +0000 (14:07 +0100)
src/libserver/html/html.cxx
src/libserver/html/html_tag.hxx

index e727639aa7d1f9cab0d933e6b032b4bca936cda2..eb4d806d7d422266d168e7c18472832e71baa282 100644 (file)
@@ -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;
 }
 
index 906dc15d4e7075520ba5775dfc8974a827d89ff2..189cae8ed80bb8e1c66b2ae49ebf0d2ee84d8909 100644 (file)
@@ -65,7 +65,7 @@ struct html_tag {
        std::vector<html_tag_component> 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<struct html_tag *> children;
        struct html_tag *parent;