aboutsummaryrefslogtreecommitdiffstats
path: root/include/litehtml/stylesheet.h
blob: 923853d768ef1b256994bb022d58288d982e1f4f (plain)
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
#ifndef LH_STYLESHEET_H
#define LH_STYLESHEET_H

#include "style.h"
#include "css_selector.h"

namespace litehtml
{
	class document_container;

	class css
	{
		css_selector::vector	m_selectors;
	public:
		css() = default;
		~css() = default;

		const css_selector::vector& selectors() const
		{
			return m_selectors;
		}

		void clear()
		{
			m_selectors.clear();
		}

		void	parse_stylesheet(const char* str, const char* baseurl, const std::shared_ptr<document>& doc, const media_query_list::ptr& media);
		void	sort_selectors();
		static void	parse_css_url(const string& str, string& url);

	private:
		void	parse_atrule(const string& text, const char* baseurl, const std::shared_ptr<document>& doc, const media_query_list::ptr& media);
		void	add_selector(const css_selector::ptr& selector);
		bool	parse_selectors(const string& txt, const style::ptr& styles, const media_query_list::ptr& media);

	};

	inline void litehtml::css::add_selector( const css_selector::ptr& selector )
	{
		selector->m_order = (int) m_selectors.size();
		m_selectors.push_back(selector);
	}

}

#endif  // LH_STYLESHEET_H