add support for Ayatana indicator to Notification plugin
[claws.git] / src / plugins / litehtml_viewer / litehtml / iterators.cpp
blob5b3238ad2f5093e0aa0c6571362d63b906747df7
1 #include "html.h"
2 #include "iterators.h"
3 #include "html_tag.h"
4 #include "render_item.h"
5 #include <iterator>
7 litehtml::elements_iterator::elements_iterator(bool return_parents, iterator_selector* go_inside, iterator_selector* select) :
8 m_return_parent(return_parents),
9 m_go_inside(go_inside),
10 m_select(select)
14 bool litehtml::elements_iterator::go_inside(const std::shared_ptr<render_item>& el)
16 return /*!el->children().empty() &&*/ m_go_inside && m_go_inside->select(el);
19 void litehtml::elements_iterator::process(const std::shared_ptr<render_item>& container, const std::function<void (std::shared_ptr<render_item>&, iterator_item_type)>& func)
21 for(auto& el : container->children())
23 if(go_inside(el))
25 if(m_return_parent)
27 // call function for parent
28 func(el, iterator_item_type_start_parent);
30 // go inside element and process its items
31 process(el, func);
32 if(m_return_parent)
34 // call function for parent
35 func(el, iterator_item_type_end_parent);
37 } else
39 // call function for element
40 if(!m_select || m_select->select(el))
42 func(el, iterator_item_type_child);
48 //////////////////////////////////////////////////////////////////////////
49 //////////////////////////////////////////////////////////////////////////
52 bool litehtml::go_inside_inline::select(const std::shared_ptr<render_item>& el)
54 if(el->src_el()->css().get_display() == display_inline && el->src_el()->css().get_float() == float_none)
56 return true;
58 return false;
61 bool litehtml::inline_selector::select(const std::shared_ptr<render_item>& el)
63 if(el->src_el()->css().get_display() == display_inline_text ||
64 el->src_el()->css().get_display() == display_inline_table ||
65 el->src_el()->css().get_display() == display_inline_block ||
66 el->src_el()->css().get_display() == display_inline_flex ||
67 el->src_el()->css().get_float() != float_none)
69 return true;
71 return false;
74 bool litehtml::go_inside_table::select(const std::shared_ptr<render_item>& el)
76 if( el->src_el()->css().get_display() == display_table_row_group ||
77 el->src_el()->css().get_display() == display_table_header_group ||
78 el->src_el()->css().get_display() == display_table_footer_group)
80 return true;
82 return false;
85 bool litehtml::table_rows_selector::select(const std::shared_ptr<render_item>& el)
87 if( el->src_el()->css().get_display() == display_table_row)
89 return true;
91 return false;
94 bool litehtml::table_cells_selector::select(const std::shared_ptr<render_item>& el)
96 if( el->src_el()->css().get_display() == display_table_cell)
98 return true;
100 return false;