mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibHTML: Add ComputedStyle::full_margin()
This is an utility to easily get the full margin size (the sum of margin proper, border and padding) of an element in pixels.
This commit is contained in:
parent
a42f4c078e
commit
3be897a3d5
Notes:
sideshowbarker
2024-07-19 11:56:39 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/3be897a3d56 Pull-request: https://github.com/SerenityOS/serenity/pull/609 Reviewed-by: https://github.com/awesomekling ✅
@ -7,3 +7,13 @@ ComputedStyle::ComputedStyle()
|
||||
ComputedStyle::~ComputedStyle()
|
||||
{
|
||||
}
|
||||
|
||||
ComputedStyle::PixelBox ComputedStyle::full_margin() const
|
||||
{
|
||||
return {
|
||||
m_margin.top.to_px() + m_border.top.to_px() + m_padding.top.to_px(),
|
||||
m_margin.right.to_px() + m_border.right.to_px() + m_padding.right.to_px(),
|
||||
m_margin.bottom.to_px() + m_border.bottom.to_px() + m_padding.bottom.to_px(),
|
||||
m_margin.left.to_px() + m_border.left.to_px() + m_padding.left.to_px(),
|
||||
};
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <LibHTML/CSS/LengthBox.h>
|
||||
#include <LibDraw/Color.h>
|
||||
#include <LibDraw/Size.h>
|
||||
#include <LibHTML/CSS/LengthBox.h>
|
||||
|
||||
enum FontStyle {
|
||||
Normal,
|
||||
@ -30,6 +30,15 @@ public:
|
||||
const Size& size() const { return m_size; }
|
||||
Size& size() { return m_size; }
|
||||
|
||||
struct PixelBox {
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
int left;
|
||||
};
|
||||
|
||||
PixelBox full_margin() const;
|
||||
|
||||
private:
|
||||
Color m_text_color;
|
||||
Color m_background_color;
|
||||
|
Loading…
Reference in New Issue
Block a user