-
Notifications
You must be signed in to change notification settings - Fork 1
/
iterators.cpp
94 lines (84 loc) · 1.83 KB
/
iterators.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "litehtml/html.h"
#include "litehtml/iterators.h"
#include "litehtml/html_tag.h"
litehtml::element::ptr litehtml::elements_iterator::next(bool ret_parent)
{
next_idx();
while(m_idx < (int) m_el->get_children_count())
{
element::ptr el = m_el->get_child(m_idx);
if( el->get_children_count() && m_go_inside && m_go_inside->select(el) )
{
stack_item si;
si.idx = m_idx;
si.el = m_el;
m_stack.push_back(si);
m_el = el;
m_idx = -1;
if(ret_parent)
{
return el;
}
next_idx();
} else
{
if( !m_select || (m_select && m_select->select(m_el->get_child(m_idx))) )
{
return m_el->get_child(m_idx);
} else
{
next_idx();
}
}
}
return 0;
}
void litehtml::elements_iterator::next_idx()
{
m_idx++;
while(m_idx >= (int) m_el->get_children_count() && m_stack.size())
{
stack_item si = m_stack.back();
m_stack.pop_back();
m_idx = si.idx;
m_el = si.el;
m_idx++;
continue;
}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
bool litehtml::go_inside_inline::select(const element::ptr& el)
{
if(el->get_display() == display_inline || el->get_display() == display_inline_text)
{
return true;
}
return false;
}
bool litehtml::go_inside_table::select(const element::ptr& el)
{
if( el->get_display() == display_table_row_group ||
el->get_display() == display_table_header_group ||
el->get_display() == display_table_footer_group)
{
return true;
}
return false;
}
bool litehtml::table_rows_selector::select(const element::ptr& el)
{
if( el->get_display() == display_table_row)
{
return true;
}
return false;
}
bool litehtml::table_cells_selector::select(const element::ptr& el)
{
if( el->get_display() == display_table_cell)
{
return true;
}
return false;
}