diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-06-14 14:06:56 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-06-14 14:07:29 +0100 |
commit | ea35232b982f8ab4b3af5f286575c30780256168 (patch) | |
tree | 1aef70e2b271930729f45c4284016c67f619e300 /src | |
parent | 26676f385c051affd123a40c5e354a52e64e8fc2 (diff) | |
download | rspamd-ea35232b982f8ab4b3af5f286575c30780256168.tar.gz rspamd-ea35232b982f8ab4b3af5f286575c30780256168.zip |
[Project] Rework html visibility rule
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/html/html_block.hxx | 15 | ||||
-rw-r--r-- | src/lua/lua_html.cxx | 6 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/libserver/html/html_block.hxx b/src/libserver/html/html_block.hxx index 0958debdd..ac6de3200 100644 --- a/src/libserver/html/html_block.hxx +++ b/src/libserver/html/html_block.hxx @@ -41,6 +41,7 @@ struct html_block { constexpr static const auto display_mask = 0x1 << 4; constexpr static const auto font_size_mask = 0x1 << 5; constexpr static const auto invisible_flag = 0x1 << 6; + constexpr static const auto transparent_flag = 0x1 << 7; /* Helpers to set mask when setting the elements */ auto set_fgcolor(const rspamd::css::css_color &c) -> void { @@ -182,7 +183,7 @@ struct html_block { if ((mask & (bg_color_mask|fg_color_mask)) == (bg_color_mask|fg_color_mask)) { if (fg_color.alpha < 10) { /* Too transparent */ - mask |= invisible_flag; + mask |= invisible_flag|transparent_flag; return; } @@ -201,17 +202,21 @@ struct html_block { (ravg * (diff_r - diff_b) / 256.0)) / 256.0; if (diff < 0.1) { - mask |= invisible_flag; + mask |= invisible_flag|transparent_flag; return; } } } - mask &= ~invisible_flag; + mask &= ~(invisible_flag|transparent_flag); + } + + constexpr auto is_visible(void) const -> bool { + return (mask & invisible_flag) == 0; } - auto is_visible(void) const -> bool { - return (mask & invisible_flag) != 0; + constexpr auto is_transparent(void) const -> bool { + return (mask & transparent_flag) != 0; } /** diff --git a/src/lua/lua_html.cxx b/src/lua/lua_html.cxx index 0972fde98..376df9fbb 100644 --- a/src/lua/lua_html.cxx +++ b/src/lua/lua_html.cxx @@ -382,7 +382,11 @@ lua_html_push_block (lua_State *L, const struct rspamd::html::html_block *bl) } lua_pushstring(L, "visible"); - lua_pushboolean(L, (bl->mask & rspamd::html::html_block::invisible_flag) == 0); + lua_pushboolean(L, bl->is_visible()); + lua_settable(L, -3); + + lua_pushstring(L, "transparent"); + lua_pushboolean(L, bl->is_transparent()); lua_settable(L, -3); } |