mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-03-03 20:15:53 +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:
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user