4 #include "render_item.h"
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
),
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())
27 // call function for parent
28 func(el
, iterator_item_type_start_parent
);
30 // go inside element and process its items
34 // call function for parent
35 func(el
, iterator_item_type_end_parent
);
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
)
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
)
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
)
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
)
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
)