-
Notifications
You must be signed in to change notification settings - Fork 1
/
el_link.cpp
44 lines (35 loc) · 872 Bytes
/
el_link.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
#include "litehtml/html.h"
#include "litehtml/el_link.h"
#include "litehtml/document.h"
litehtml::el_link::el_link(const std::shared_ptr<litehtml::document>& doc) : litehtml::html_tag(doc)
{
}
litehtml::el_link::~el_link()
{
}
void litehtml::el_link::parse_attributes()
{
bool processed = false;
document::ptr doc = get_document();
const tchar_t* rel = get_attr(_t("rel"));
if(rel && !t_strcmp(rel, _t("stylesheet")))
{
const tchar_t* media = get_attr(_t("media"));
const tchar_t* href = get_attr(_t("href"));
if(href && href[0])
{
tstring css_text;
tstring css_baseurl;
doc->container()->import_css(css_text, href, css_baseurl);
if(!css_text.empty())
{
doc->add_stylesheet(css_text.c_str(), css_baseurl.c_str(), media);
processed = true;
}
}
}
if(!processed)
{
doc->container()->link(doc, shared_from_this());
}
}