blob: e4f71012b8156b5dc476ba3643ee625d1e04a205 (
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
|
#include <AK/StringBuilder.h>
#include <LibHTML/DOM/Document.h>
#include <LibHTML/DOM/HTMLStyleElement.h>
#include <LibHTML/DOM/Text.h>
#include <LibHTML/Parser/CSSParser.h>
HTMLStyleElement::HTMLStyleElement(Document& document, const String& tag_name)
: HTMLElement(document, tag_name)
{
}
HTMLStyleElement::~HTMLStyleElement()
{
}
void HTMLStyleElement::inserted_into(Node& new_parent)
{
StringBuilder builder;
for_each_child([&](auto& child) {
if (is<Text>(child))
builder.append(to<Text>(child).text_content());
});
m_stylesheet = parse_css(builder.to_string());
if (m_stylesheet)
document().add_sheet(*m_stylesheet);
HTMLElement::inserted_into(new_parent);
}
void HTMLStyleElement::removed_from(Node& old_parent)
{
if (m_stylesheet) {
// FIXME: Remove the sheet from the document
}
return HTMLElement::removed_from(old_parent);
}
|