Cogs.Core
el_link.cpp
1#include "html.h"
2#include "el_link.h"
3#include "document.h"
4
5
6litehtml::el_link::el_link(const std::shared_ptr<litehtml::document>& doc) : litehtml::html_tag(doc)
7{
8
9}
10
11litehtml::el_link::~el_link()
12{
13
14}
15
16void litehtml::el_link::parse_attributes()
17{
18 bool processed = false;
19
20 document::ptr doc = get_document();
21
22 const tchar_t* rel = get_attr(_t("rel"));
23 if(rel && !t_strcmp(rel, _t("stylesheet")))
24 {
25 const tchar_t* media = get_attr(_t("media"));
26 const tchar_t* href = get_attr(_t("href"));
27 if(href && href[0])
28 {
29 tstring css_text;
30 tstring css_baseurl;
31 doc->container()->import_css(css_text, href, css_baseurl);
32 if(!css_text.empty())
33 {
34 doc->add_stylesheet(css_text.c_str(), css_baseurl.c_str(), media);
35 processed = true;
36 }
37 }
38 }
39
40 if(!processed)
41 {
42 doc->container()->link(doc, shared_from_this());
43 }
44}