mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:27:45 +00:00
LibWeb: Allow creating Lengths from CSSPixels
This commit is contained in:
parent
8a5c50f59d
commit
56422e37e0
2 changed files with 14 additions and 0 deletions
|
@ -15,6 +15,7 @@
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/HTML/BrowsingContext.h>
|
#include <LibWeb/HTML/BrowsingContext.h>
|
||||||
#include <LibWeb/HTML/HTMLHtmlElement.h>
|
#include <LibWeb/HTML/HTMLHtmlElement.h>
|
||||||
|
#include <LibWeb/PixelUnits.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
@ -28,6 +29,11 @@ Length::Length(float value, Type type)
|
||||||
, m_value(value)
|
, m_value(value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Length::Length(CSSPixels value, Type type)
|
||||||
|
: m_type(type)
|
||||||
|
, m_value(value.value())
|
||||||
|
{
|
||||||
|
}
|
||||||
Length::~Length() = default;
|
Length::~Length() = default;
|
||||||
|
|
||||||
Length Length::make_auto()
|
Length Length::make_auto()
|
||||||
|
@ -40,6 +46,11 @@ Length Length::make_px(float value)
|
||||||
return Length(value, Type::Px);
|
return Length(value, Type::Px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Length Length::make_px(CSSPixels value)
|
||||||
|
{
|
||||||
|
return Length(value.value(), Type::Px);
|
||||||
|
}
|
||||||
|
|
||||||
Length Length::make_calculated(NonnullRefPtr<CalculatedStyleValue> calculated_style_value)
|
Length Length::make_calculated(NonnullRefPtr<CalculatedStyleValue> calculated_style_value)
|
||||||
{
|
{
|
||||||
Length length { 0, Type::Calculated };
|
Length length { 0, Type::Calculated };
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <AK/DeprecatedString.h>
|
#include <AK/DeprecatedString.h>
|
||||||
#include <LibGfx/Forward.h>
|
#include <LibGfx/Forward.h>
|
||||||
#include <LibWeb/Forward.h>
|
#include <LibWeb/Forward.h>
|
||||||
|
#include <LibWeb/PixelUnits.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
@ -40,10 +41,12 @@ public:
|
||||||
// this file already. To break the cyclic dependency, we must move all method definitions out.
|
// this file already. To break the cyclic dependency, we must move all method definitions out.
|
||||||
Length(int value, Type type);
|
Length(int value, Type type);
|
||||||
Length(float value, Type type);
|
Length(float value, Type type);
|
||||||
|
Length(CSSPixels value, Type type);
|
||||||
~Length();
|
~Length();
|
||||||
|
|
||||||
static Length make_auto();
|
static Length make_auto();
|
||||||
static Length make_px(float value);
|
static Length make_px(float value);
|
||||||
|
static Length make_px(CSSPixels value);
|
||||||
static Length make_calculated(NonnullRefPtr<CalculatedStyleValue>);
|
static Length make_calculated(NonnullRefPtr<CalculatedStyleValue>);
|
||||||
Length percentage_of(Percentage const&) const;
|
Length percentage_of(Percentage const&) const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue