commit 6960e2c: [Minor] Distinguish inline/block/invisible display

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Jun 18 19:42:05 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-06-18 16:29:14 +0100
URL: https://github.com/rspamd/rspamd/commit/6960e2c762628b74e3342ce26f5a4ba3669307f3

[Minor] Distinguish inline/block/invisible display

---
 src/libserver/css/css_rule.cxx    |  2 +-
 src/libserver/css/css_value.cxx   | 54 +++++++++++++++++++++++----------------
 src/libserver/css/css_value.hxx   |  3 ++-
 src/libserver/html/html_block.hxx |  4 +--
 4 files changed, 37 insertions(+), 26 deletions(-)

diff --git a/src/libserver/css/css_rule.cxx b/src/libserver/css/css_rule.cxx
index d06f0aec0..52003ac23 100644
--- a/src/libserver/css/css_rule.cxx
+++ b/src/libserver/css/css_rule.cxx
@@ -399,7 +399,7 @@ css_declarations_block::compile_to_block(rspamd_mempool_t *pool) const -> rspamd
 		switch (prop) {
 		case css_property_type::PROPERTY_VISIBILITY:
 		case css_property_type::PROPERTY_DISPLAY: {
-			auto disp = vals.back().to_display().value_or(css_display_value::DISPLAY_NORMAL);
+			auto disp = vals.back().to_display().value_or(css_display_value::DISPLAY_INLINE);
 			block->set_display(disp);
 			break;
 		}
diff --git a/src/libserver/css/css_value.cxx b/src/libserver/css/css_value.cxx
index f573e38be..fcca37d8f 100644
--- a/src/libserver/css/css_value.cxx
+++ b/src/libserver/css/css_value.cxx
@@ -298,27 +298,27 @@ auto css_value::maybe_dimension_from_number(const css_parser_token &tok)
 constexpr const auto display_names_map = frozen::make_unordered_map<frozen::string, css_display_value>({
 		{"hidden",             css_display_value::DISPLAY_HIDDEN},
 		{"none",               css_display_value::DISPLAY_HIDDEN},
-		{"inline",             css_display_value::DISPLAY_NORMAL},
-		{"block",              css_display_value::DISPLAY_NORMAL},
-		{"content",            css_display_value::DISPLAY_NORMAL},
-		{"flex",               css_display_value::DISPLAY_NORMAL},
-		{"grid",               css_display_value::DISPLAY_NORMAL},
-		{"inline-block",       css_display_value::DISPLAY_NORMAL},
-		{"inline-flex",        css_display_value::DISPLAY_NORMAL},
-		{"inline-grid",        css_display_value::DISPLAY_NORMAL},
-		{"inline-table",       css_display_value::DISPLAY_NORMAL},
-		{"list-item",          css_display_value::DISPLAY_NORMAL},
-		{"run-in",             css_display_value::DISPLAY_NORMAL},
-		{"table",              css_display_value::DISPLAY_NORMAL},
-		{"table-caption",      css_display_value::DISPLAY_NORMAL},
-		{"table-column-group", css_display_value::DISPLAY_NORMAL},
-		{"table-header-group", css_display_value::DISPLAY_NORMAL},
-		{"table-footer-group", css_display_value::DISPLAY_NORMAL},
-		{"table-row-group",    css_display_value::DISPLAY_NORMAL},
-		{"table-cell",         css_display_value::DISPLAY_NORMAL},
-		{"table-column",       css_display_value::DISPLAY_NORMAL},
-		{"table-row",          css_display_value::DISPLAY_NORMAL},
-		{"initial",            css_display_value::DISPLAY_NORMAL},
+		{"inline",             css_display_value::DISPLAY_INLINE},
+		{"block",              css_display_value::DISPLAY_BLOCK},
+		{"content",            css_display_value::DISPLAY_INLINE},
+		{"flex",               css_display_value::DISPLAY_BLOCK},
+		{"grid",               css_display_value::DISPLAY_INLINE},
+		{"inline-block",       css_display_value::DISPLAY_INLINE},
+		{"inline-flex",        css_display_value::DISPLAY_INLINE},
+		{"inline-grid",        css_display_value::DISPLAY_INLINE},
+		{"inline-table",       css_display_value::DISPLAY_INLINE},
+		{"list-item",          css_display_value::DISPLAY_BLOCK},
+		{"run-in",             css_display_value::DISPLAY_BLOCK},
+		{"table",              css_display_value::DISPLAY_BLOCK},
+		{"table-caption",      css_display_value::DISPLAY_BLOCK},
+		{"table-column-group", css_display_value::DISPLAY_BLOCK},
+		{"table-header-group", css_display_value::DISPLAY_BLOCK},
+		{"table-footer-group", css_display_value::DISPLAY_BLOCK},
+		{"table-row-group",    css_display_value::DISPLAY_BLOCK},
+		{"table-cell",         css_display_value::DISPLAY_BLOCK},
+		{"table-column",       css_display_value::DISPLAY_BLOCK},
+		{"table-row",          css_display_value::DISPLAY_BLOCK},
+		{"initial",            css_display_value::DISPLAY_INLINE},
 });
 
 auto css_value::maybe_display_from_string(const std::string_view &input)
@@ -354,7 +354,17 @@ auto css_value::debug_str() const -> std::string {
 		}
 		else if constexpr (std::is_same_v<T, css_display_value>) {
 			ret += "display: ";
-			ret += (arg == css_display_value::DISPLAY_HIDDEN ? "hidden" : "normal");
+			switch (arg) {
+			case css_display_value::DISPLAY_HIDDEN:
+				ret += "hidden";
+				break;
+			case css_display_value::DISPLAY_BLOCK:
+				ret += "block";
+				break;
+			case css_display_value::DISPLAY_INLINE:
+				ret += "inline";
+				break;
+			}
 		}
 		else if constexpr (std::is_integral_v<T>) {
 			ret += "integral: " + std::to_string(static_cast<int>(arg));
diff --git a/src/libserver/css/css_value.hxx b/src/libserver/css/css_value.hxx
index efb18e20a..d3d06a544 100644
--- a/src/libserver/css/css_value.hxx
+++ b/src/libserver/css/css_value.hxx
@@ -73,7 +73,8 @@ struct css_dimension {
  * Simple enum class for display stuff
  */
 enum class css_display_value : std::uint8_t {
-	DISPLAY_NORMAL,
+	DISPLAY_INLINE,
+	DISPLAY_BLOCK,
 	DISPLAY_HIDDEN
 };
 
diff --git a/src/libserver/html/html_block.hxx b/src/libserver/html/html_block.hxx
index ac6de3200..51f3dbb9d 100644
--- a/src/libserver/html/html_block.hxx
+++ b/src/libserver/html/html_block.hxx
@@ -81,7 +81,7 @@ struct html_block {
 	}
 	auto set_display(bool v) -> void  {
 		if (v) {
-			display = rspamd::css::css_display_value::DISPLAY_NORMAL;
+			display = rspamd::css::css_display_value::DISPLAY_INLINE;
 		}
 		else {
 			display = rspamd::css::css_display_value::DISPLAY_HIDDEN;
@@ -228,7 +228,7 @@ struct html_block {
 						  rspamd::css::css_color::white(),
 						  0, 0,
 						  (fg_color_mask|bg_color_mask|display_mask|font_size_mask),
-						  rspamd::css::css_display_value::DISPLAY_NORMAL,
+						  rspamd::css::css_display_value::DISPLAY_INLINE,
 						  12};
 	}
 	/**


More information about the Commits mailing list