blob: aa3bc7659729ea4dd19a6d17011230eb4f72f494 (
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
|
#include "html.h"
#include "el_link.h"
#include "document.h"
litehtml::el_link::el_link(const std::shared_ptr<document>& doc) : litehtml::html_tag(doc)
{
}
void litehtml::el_link::parse_attributes()
{
bool processed = false;
document::ptr doc = get_document();
const char* rel = get_attr("rel");
if(rel && !strcmp(rel, "stylesheet"))
{
const char* media = get_attr("media");
const char* href = get_attr("href");
if(href && href[0])
{
string css_text;
string 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());
}
}
|