commit ab387ef: [Minor] Propagate styles for html blocks

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Jun 14 13:14:05 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-06-14 13:21:44 +0100
URL: https://github.com/rspamd/rspamd/commit/ab387ef08fe91ecc8faa2051e49727a51eb655bb

[Minor] Propagate styles for html blocks

---
 src/libserver/html/html.cxx     | 17 ++++++++++++++++-
 src/libserver/html/html_tag.hxx |  2 +-
 2 files changed, 17 insertions(+), 2 deletions(-)

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<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;
 


More information about the Commits mailing list