2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2019-10-15 07:22:41 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-11-26 17:18:34 -03:00
|
|
|
#include <AK/NonnullRefPtrVector.h>
|
2019-10-15 07:22:41 -03:00
|
|
|
#include <AK/RefPtr.h>
|
2020-07-26 14:37:56 -03:00
|
|
|
#include <LibWeb/Forward.h>
|
2019-10-15 07:22:41 -03:00
|
|
|
|
2020-11-22 11:53:01 -03:00
|
|
|
namespace Web::Layout {
|
2020-03-07 06:27:02 -03:00
|
|
|
|
2020-11-25 16:29:03 -03:00
|
|
|
class TreeBuilder {
|
2019-10-15 07:22:41 -03:00
|
|
|
public:
|
2020-11-25 16:29:03 -03:00
|
|
|
TreeBuilder();
|
2019-10-15 07:22:41 -03:00
|
|
|
|
2020-11-26 17:18:34 -03:00
|
|
|
RefPtr<Layout::Node> build(DOM::Node&);
|
|
|
|
|
|
|
|
|
|
private:
|
2021-08-05 05:26:09 -03:00
|
|
|
struct Context {
|
|
|
|
|
bool has_svg_root = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void create_layout_tree(DOM::Node&, Context&);
|
2020-11-26 17:18:34 -03:00
|
|
|
|
2021-01-06 10:10:53 -03:00
|
|
|
void push_parent(Layout::NodeWithStyle& node) { m_parent_stack.append(&node); }
|
2020-11-26 17:18:34 -03:00
|
|
|
void pop_parent() { m_parent_stack.take_last(); }
|
|
|
|
|
|
2021-01-07 14:00:51 -03:00
|
|
|
template<CSS::Display, typename Callback>
|
|
|
|
|
void for_each_in_tree_with_display(NodeWithStyle& root, Callback);
|
|
|
|
|
|
|
|
|
|
void fixup_tables(NodeWithStyle& root);
|
|
|
|
|
void remove_irrelevant_boxes(NodeWithStyle& root);
|
|
|
|
|
void generate_missing_child_wrappers(NodeWithStyle& root);
|
|
|
|
|
void generate_missing_parents(NodeWithStyle& root);
|
|
|
|
|
|
2020-11-26 17:18:34 -03:00
|
|
|
RefPtr<Layout::Node> m_layout_root;
|
2021-01-06 10:10:53 -03:00
|
|
|
Vector<Layout::NodeWithStyle*> m_parent_stack;
|
2019-10-15 07:22:41 -03:00
|
|
|
};
|
2020-03-07 06:27:02 -03:00
|
|
|
|
|
|
|
|
}
|