
To streamline the layout tree and remove irrelevant data from classes that don't need it, this patch adds two new LayoutNode subclasses. LayoutNodeWithStyleAndBoxModelMetrics should be inherited by any layout node that cares about box model metrics (margin, border, and padding.) LayoutBox should be inherited by any layout node that can have a rect. This makes LayoutText significantly smaller (from 140 to 40 bytes) and clarifies a lot of things about the layout tree. I'm also adding next_sibling() and previous_sibling() overloads to LayoutBlock that return a LayoutBlock*. This is okay since blocks only ever have block siblings. Do also note that the semantics of is<T> slightly change in this patch: is<T>(nullptr) now returns true, to facilitate allowing to<T>(nullptr).
23 lines
634 B
C++
23 lines
634 B
C++
#include <LibHTML/DOM/Element.h>
|
|
#include <LibHTML/Layout/LayoutBox.h>
|
|
|
|
class LayoutReplaced : public LayoutBox {
|
|
public:
|
|
LayoutReplaced(const Element&, NonnullRefPtr<StyleProperties>);
|
|
virtual ~LayoutReplaced() override;
|
|
|
|
const Element& node() const { return to<Element>(*LayoutNode::node()); }
|
|
|
|
virtual bool is_replaced() const final { return true; }
|
|
|
|
private:
|
|
virtual const char* class_name() const override { return "LayoutReplaced"; }
|
|
|
|
virtual void split_into_lines(LayoutBlock& container) override;
|
|
};
|
|
|
|
template<>
|
|
inline bool is<LayoutReplaced>(const LayoutNode& node)
|
|
{
|
|
return node.is_replaced();
|
|
}
|