mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:38:11 +00:00
LibHTML: Refactor to go from DOM -> styled tree -> layout tree.
Frame::layout() drives everything now, it takes the DOM contained in the frame and puts it through the tree transformations.
This commit is contained in:
parent
6e95b11395
commit
7eef69ad4b
20 changed files with 132 additions and 131 deletions
|
@ -1,5 +1,5 @@
|
|||
html {
|
||||
display: inline;
|
||||
display: block;
|
||||
font-family: Katica;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ static bool matches(const Selector& selector, const Element& element)
|
|||
NonnullRefPtrVector<StyleRule> StyleResolver::collect_matching_rules(const Element& element) const
|
||||
{
|
||||
NonnullRefPtrVector<StyleRule> matching_rules;
|
||||
for (auto& sheet : m_sheets) {
|
||||
for (auto& sheet : document().stylesheets()) {
|
||||
for (auto& rule : sheet.rules()) {
|
||||
for (auto& selector : rule.selectors()) {
|
||||
if (matches(selector, element)) {
|
||||
|
|
|
@ -18,8 +18,6 @@ public:
|
|||
Document& document() { return m_document; }
|
||||
const Document& document() const { return m_document; }
|
||||
|
||||
void add_sheet(const StyleSheet& sheet) { m_sheets.append(sheet); }
|
||||
|
||||
NonnullRefPtr<StyledNode> create_styled_node(const Element&);
|
||||
NonnullRefPtr<StyledNode> create_styled_node(const Document&);
|
||||
|
||||
|
@ -28,6 +26,4 @@ public:
|
|||
|
||||
private:
|
||||
Document& m_document;
|
||||
|
||||
NonnullRefPtrVector<StyleSheet> m_sheets;
|
||||
};
|
||||
|
|
|
@ -8,3 +8,18 @@ StyledNode::StyledNode(const Node* node)
|
|||
StyledNode::~StyledNode()
|
||||
{
|
||||
}
|
||||
|
||||
Display StyledNode::display() const
|
||||
{
|
||||
auto it = m_property_values.find("display");
|
||||
if (it == m_property_values.end())
|
||||
return Display::Inline;
|
||||
auto value = it->value->to_string();
|
||||
if (value == "none")
|
||||
return Display::None;
|
||||
if (value == "block")
|
||||
return Display::Block;
|
||||
if (value == "inline")
|
||||
return Display::Inline;
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
|
|
@ -8,6 +8,12 @@
|
|||
|
||||
class Node;
|
||||
|
||||
enum class Display {
|
||||
None,
|
||||
Block,
|
||||
Inline,
|
||||
};
|
||||
|
||||
class StyledNode : public TreeNode<StyledNode> {
|
||||
public:
|
||||
static NonnullRefPtr<StyledNode> create(const Node& node)
|
||||
|
@ -44,6 +50,8 @@ public:
|
|||
m_property_values.set(name, move(value));
|
||||
}
|
||||
|
||||
Display display() const;
|
||||
|
||||
protected:
|
||||
explicit StyledNode(const Node*);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue