mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +00:00
LibHTML: Implement basic support for inline style attributes
You can now style elements with inline styles: <div style="color: #ff0000">This is red!</div> Pretty neat :^)
This commit is contained in:
parent
b2a0d20580
commit
a5e5a3fab7
1 changed files with 11 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
|||
#include <LibHTML/DOM/Document.h>
|
||||
#include <LibHTML/DOM/Element.h>
|
||||
#include <LibHTML/Dump.h>
|
||||
#include <LibHTML/Parser/CSSParser.h>
|
||||
#include <stdio.h>
|
||||
|
||||
StyleResolver::StyleResolver(Document& document)
|
||||
|
@ -74,5 +75,15 @@ StyleProperties StyleResolver::resolve_style(const Element& element, const Style
|
|||
style_properties.set_property(property.name, property.value);
|
||||
}
|
||||
}
|
||||
|
||||
auto style_attribute = element.attribute("style");
|
||||
if (!style_attribute.is_null()) {
|
||||
if (auto declaration = parse_css_declaration(style_attribute)) {
|
||||
for (auto& property : declaration->properties()) {
|
||||
style_properties.set_property(property.name, property.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return style_properties;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue