6 #include "background.h"
7 #include "css_margins.h"
9 #include "css_selector.h"
10 #include "stylesheet.h"
17 class html_tag
: public element
19 friend class elements_iterator
;
20 friend class el_table
;
21 friend class table_grid
;
22 friend class line_box
;
24 typedef std::shared_ptr
<html_tag
> ptr
;
28 string_vector m_str_classes
;
29 std::vector
<string_id
> m_classes
;
30 litehtml::style m_style
;
32 std::vector
<string_id
> m_pseudo_classes
;
34 void select_all(const css_selector
& selector
, elements_list
& res
) override
;
37 explicit html_tag(const std::shared_ptr
<document
>& doc
);
38 // constructor for anonymous wrapper boxes
39 explicit html_tag(const element::ptr
& parent
, const string
& style
= "display: block");
41 bool appendChild(const element::ptr
&el
) override
;
42 bool removeChild(const element::ptr
&el
) override
;
43 void clearRecursive() override
;
44 string_id
tag() const override
;
45 string_id
id() const override
;
46 const char* get_tagName() const override
;
47 void set_tagName(const char* tag
) override
;
48 void set_data(const char* data
) override
;
50 void set_attr(const char* name
, const char* val
) override
;
51 const char* get_attr(const char* name
, const char* def
= nullptr) const override
;
52 void apply_stylesheet(const litehtml::css
& stylesheet
) override
;
53 void refresh_styles() override
;
55 bool is_white_space() const override
;
56 bool is_body() const override
;
57 bool is_break() const override
;
59 bool on_mouse_over() override
;
60 bool on_mouse_leave() override
;
61 bool on_lbutton_down() override
;
62 bool on_lbutton_up() override
;
63 void on_click() override
;
64 bool set_pseudo_class(string_id cls
, bool add
) override
;
65 bool set_class(const char* pclass
, bool add
) override
;
66 bool is_replaced() const override
;
67 void compute_styles(bool recursive
= true) override
;
68 void draw(uint_ptr hdc
, int x
, int y
, const position
*clip
, const std::shared_ptr
<render_item
> &ri
) override
;
69 void draw_background(uint_ptr hdc
, int x
, int y
, const position
*clip
,
70 const std::shared_ptr
<render_item
> &ri
) override
;
72 template<class Type
, property_type property_value_type
, Type
property_value::* property_value_member
>
73 const Type
& get_property_impl (string_id name
, bool inherited
, const Type
& default_value
, uint_ptr css_properties_member_offset
) const;
74 int get_enum_property (string_id name
, bool inherited
, int default_value
, uint_ptr css_properties_member_offset
) const override
;
75 css_length
get_length_property(string_id name
, bool inherited
, css_length default_value
, uint_ptr css_properties_member_offset
) const override
;
76 web_color
get_color_property (string_id name
, bool inherited
, web_color default_value
, uint_ptr css_properties_member_offset
) const override
;
77 string
get_string_property(string_id name
, bool inherited
, const string
& default_value
, uint_ptr css_properties_member_offset
) const override
;
78 float get_number_property(string_id name
, bool inherited
, float default_value
, uint_ptr css_properties_member_offset
) const override
;
79 string_vector
get_string_vector_property(string_id name
, bool inherited
, const string_vector
& default_value
, uint_ptr css_properties_member_offset
) const override
;
80 int_vector
get_int_vector_property (string_id name
, bool inherited
, const int_vector
& default_value
, uint_ptr css_properties_member_offset
) const override
;
81 length_vector
get_length_vector_property(string_id name
, bool inherited
, const length_vector
& default_value
, uint_ptr css_properties_member_offset
) const override
;
82 size_vector
get_size_vector_property (string_id name
, bool inherited
, const size_vector
& default_value
, uint_ptr css_properties_member_offset
) const override
;
83 string
get_custom_property(string_id name
, const string
& default_value
) const override
;
85 elements_list
& children();
87 int select(const string
& selector
) override
;
88 int select(const css_selector
& selector
, bool apply_pseudo
= true) override
;
89 int select(const css_element_selector
& selector
, bool apply_pseudo
= true) override
;
90 int select_pseudoclass(const css_attribute_selector
& sel
);
91 int select_attribute(const css_attribute_selector
& sel
);
93 elements_list
select_all(const string
& selector
) override
;
94 elements_list
select_all(const css_selector
& selector
) override
;
96 element::ptr
select_one(const string
& selector
) override
;
97 element::ptr
select_one(const css_selector
& selector
) override
;
99 element::ptr
find_ancestor(const css_selector
& selector
, bool apply_pseudo
= true, bool* is_pseudo
= nullptr) override
;
100 element::ptr
find_adjacent_sibling(const element::ptr
& el
, const css_selector
& selector
, bool apply_pseudo
= true, bool* is_pseudo
= nullptr) override
;
101 element::ptr
find_sibling(const element::ptr
& el
, const css_selector
& selector
, bool apply_pseudo
= true, bool* is_pseudo
= nullptr) override
;
102 void get_text(string
& text
) override
;
103 void parse_attributes() override
;
105 void get_content_size(size
& sz
, int max_width
) override
;
106 void add_style(const style
& style
) override
;
108 bool is_nth_child(const element::ptr
& el
, int num
, int off
, bool of_type
) const override
;
109 bool is_nth_last_child(const element::ptr
& el
, int num
, int off
, bool of_type
) const override
;
110 bool is_only_child(const element::ptr
& el
, bool of_type
) const override
;
111 const background
* get_background(bool own_only
= false) override
;
113 string
dump_get_name() override
;
116 void init_background_paint(position pos
, std::vector
<background_paint
>& bg_paint
, const background
* bg
, const std::shared_ptr
<render_item
>& ri
);
117 void init_one_background_paint(int i
, position pos
, background_paint
& bg_paint
, const background
* bg
, const std::shared_ptr
<render_item
>& ri
);
118 void draw_list_marker( uint_ptr hdc
, const position
&pos
);
119 string
get_list_marker_text(int index
);
120 element::ptr
get_element_before(const style
& style
, bool create
);
121 element::ptr
get_element_after(const style
& style
, bool create
);
124 /************************************************************************/
125 /* Inline Functions */
126 /************************************************************************/
128 inline elements_list
& litehtml::html_tag::children()
134 #endif // LH_HTML_TAG_H