2#pragma warning(disable: 4100)
3#elif defined(__clang__)
4#pragma clang diagnostic ignored "-Wunused-parameter"
9#include "el_before_after.h"
14litehtml::el_before_after_base::el_before_after_base(
const std::shared_ptr<litehtml::document>& doc,
bool before) : html_tag(doc)
18 set_tagName(_t(
"::before"));
21 set_tagName(_t(
"::after"));
25litehtml::el_before_after_base::~el_before_after_base()
30void litehtml::el_before_after_base::add_style(
const litehtml::style& st)
32 html_tag::add_style(st);
34 tstring content = get_style_property(_t(
"content"),
false, _t(
""));
37 int idx = value_index(content.c_str(), content_property_string);
41 tstring::size_type i = 0;
42 while(i < content.length() && i != tstring::npos)
44 if(content.at(i) == _t(
'"'))
48 tstring::size_type pos = content.find(_t(
'"'), i);
50 if(pos == tstring::npos)
52 txt = content.substr(i);
56 txt = content.substr(i, pos - i);
60 }
else if(content.at(i) == _t(
'('))
65 tstring::size_type pos = content.find(_t(
')'), i);
67 if(pos == tstring::npos)
69 params = content.substr(i);
73 params = content.substr(i, pos - i);
76 add_function(fnc, params);
88void litehtml::el_before_after_base::add_text(
const tstring& txt )
92 for(tstring::size_type i = 0; i < txt.length(); i++)
94 if( (txt.at(i) == _t(
' ')) || (txt.at(i) == _t(
'\t')) || (txt.at(i) == _t(
'\\') && !esc.empty()) )
100 element::ptr el = std::make_shared<el_text>(word.c_str(), get_document());
105 element::ptr el = std::make_shared<el_space>(txt.substr(i, 1).c_str(), get_document());
109 word += convert_escape(esc.c_str() + 1);
111 if(txt.at(i) == _t(
'\\'))
118 if(!esc.empty() || txt.at(i) == _t(
'\\'))
130 word += convert_escape(esc.c_str() + 1);
134 element::ptr el = std::make_shared<el_text>(word.c_str(), get_document());
140void litehtml::el_before_after_base::add_function(
const tstring& fnc,
const tstring& params )
142 int idx = value_index(fnc.c_str(), _t(
"attr;counter;url"));
148 tstring p_name = params;
151 element::ptr el_parent = parent();
154 const tchar_t* attr_value = el_parent->get_attr(p_name.c_str());
157 add_text(attr_value);
168 tstring p_url = params;
172 if(p_url.at(0) == _t(
'\'') || p_url.at(0) == _t(
'\"'))
179 if(p_url.at(p_url.length() - 1) == _t(
'\'') || p_url.at(p_url.length() - 1) == _t(
'\"'))
181 p_url.erase(p_url.length() - 1, 1);
186 element::ptr el = std::make_shared<el_image>(get_document());
187 el->set_attr(_t(
"src"), p_url.c_str());
188 el->set_attr(_t(
"style"), _t(
"display:inline-block"));
189 el->set_tagName(_t(
"img"));
191 el->parse_attributes();
198litehtml::tchar_t litehtml::el_before_after_base::convert_escape(
const tchar_t* txt )
201 return (tchar_t) t_strtol(txt, &sss, 16);
204void litehtml::el_before_after_base::apply_stylesheet(
const litehtml::css& stylesheet )