1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 09:44:57 +00:00
serenity/Libraries/LibHTML/Layout/LayoutBox.h
Andreas Kling 05b1ecf1b1 LibHTML: Draw each CSS border edge separately with their own style
The borders still look very wrong with any border-width other than 1,
but at least we can see that they have the right color, and end up in
mostly the right place :^)
2019-11-25 13:17:14 +01:00

50 lines
1.4 KiB
C++

#pragma once
#include <LibDraw/FloatRect.h>
#include <LibHTML/Layout/LayoutNode.h>
class LayoutBox : public LayoutNodeWithStyleAndBoxModelMetrics {
public:
const FloatRect& rect() const { return m_rect; }
FloatRect& rect() { return m_rect; }
void set_rect(const FloatRect& rect) { m_rect = rect; }
float x() const { return rect().x(); }
float y() const { return rect().y(); }
float width() const { return rect().width(); }
float height() const { return rect().height(); }
FloatSize size() const { return rect().size(); }
FloatPoint position() const { return rect().location(); }
virtual HitTestResult hit_test(const Point& position) const override;
virtual void set_needs_display() override;
bool is_body() const;
protected:
LayoutBox(const Node* node, NonnullRefPtr<StyleProperties> style)
: LayoutNodeWithStyleAndBoxModelMetrics(node, move(style))
{
}
virtual void render(RenderingContext&) override;
private:
virtual bool is_box() const override { return true; }
enum class Edge {
Top,
Right,
Bottom,
Left,
};
void paint_border(RenderingContext&, Edge, const Rect&, CSS::PropertyID style_property_id, CSS::PropertyID color_property_id, CSS::PropertyID width_property_id);
FloatRect m_rect;
};
template<>
inline bool is<LayoutBox>(const LayoutNode& node)
{
return node.is_box();
}