mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 07:05:06 +00:00
LibHTML: Implement some very simple selector matching.
We walk the entire DOM and check all selectors against all elements. Only id, class and tag name are checked right now. There's no ancestor stack or compound selectors. All in good time :^)
This commit is contained in:
parent
2b4eea5a50
commit
e971f5604c
7 changed files with 109 additions and 29 deletions
|
@ -3,6 +3,7 @@
|
|||
#include <LibHTML/Frame.h>
|
||||
#include <LibHTML/Parser/CSSParser.h>
|
||||
#include <LibHTML/CSS/StyleResolver.h>
|
||||
#include <LibHTML/DOM/Element.h>
|
||||
#include <LibHTML/Parser/HTMLParser.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -29,6 +30,17 @@ int main(int argc, char** argv)
|
|||
|
||||
auto doc_style = resolver.resolve_document_style(*doc);
|
||||
|
||||
Function<void(const ParentNode&)> resolve_style = [&](const ParentNode& node) {
|
||||
node.for_each_child([&](const Node& child) {
|
||||
if (!child.is_element())
|
||||
return;
|
||||
auto style = resolver.resolve_element_style(static_cast<const Element&>(node));
|
||||
printf("Resolved LayoutStyle{%p} for Element{%p}\n", style.ptr(), &node);
|
||||
resolve_style(static_cast<const Element&>(child));
|
||||
});
|
||||
};
|
||||
resolve_style(*doc);
|
||||
|
||||
doc->build_layout_tree();
|
||||
ASSERT(doc->layout_node());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue