]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Distinguish inline/block/invisible display
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 18 Jun 2021 15:29:14 +0000 (16:29 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 18 Jun 2021 19:35:24 +0000 (20:35 +0100)
src/libserver/css/css_rule.cxx
src/libserver/css/css_value.cxx
src/libserver/css/css_value.hxx
src/libserver/html/html_block.hxx

index d06f0aec0ac3834cee8da4cadb2f710d7edec5c1..52003ac236759d3785fc52ed5d27eb6dc832e29d 100644 (file)
@@ -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;
                }
index f573e38beccb741a9ad4e99cb498825163a2a5de..fcca37d8fb2e41bb24f4b6bb52f78b8db632f424 100644 (file)
@@ -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));
index efb18e20aba5044c33ae502a0b5301fdc6225737..d3d06a5442851a54bd2a8ee9e5975ed067920184 100644 (file)
@@ -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
 };
 
index ac6de3200993c33b0cbd4cb53f75b811891ebf1b..51f3dbb9d776983fd60204c0484b49e163eae20a 100644 (file)
@@ -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};
        }
        /**