mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 23:59:49 +00:00
LibWeb: Add basic implementation of @page
This doesn't support selectors, and the only descriptors for now are for margins.
This commit is contained in:
parent
1002464322
commit
aaf07ae30d
Notes:
github-actions[bot]
2025-05-15 08:54:53 +00:00
Author: https://github.com/AtkinsSJ
Commit: aaf07ae30d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4735
27 changed files with 471 additions and 20 deletions
122
Libraries/LibWeb/CSS/CSSPageDescriptors.cpp
Normal file
122
Libraries/LibWeb/CSS/CSSPageDescriptors.cpp
Normal file
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/CSSPageDescriptorsPrototype.h>
|
||||
#include <LibWeb/CSS/CSSPageDescriptors.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(CSSPageDescriptors);
|
||||
|
||||
GC::Ref<CSSPageDescriptors> CSSPageDescriptors::create(JS::Realm& realm, Vector<Descriptor> descriptors)
|
||||
{
|
||||
return realm.create<CSSPageDescriptors>(realm, move(descriptors));
|
||||
}
|
||||
|
||||
CSSPageDescriptors::CSSPageDescriptors(JS::Realm& realm, Vector<Descriptor> descriptors)
|
||||
: CSSDescriptors(realm, AtRuleID::Page, move(descriptors))
|
||||
{
|
||||
}
|
||||
|
||||
CSSPageDescriptors::~CSSPageDescriptors() = default;
|
||||
|
||||
void CSSPageDescriptors::initialize(JS::Realm& realm)
|
||||
{
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(CSSPageDescriptors);
|
||||
Base::initialize(realm);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> CSSPageDescriptors::set_margin(StringView value)
|
||||
{
|
||||
return set_property("margin"sv, value, ""sv);
|
||||
}
|
||||
|
||||
String CSSPageDescriptors::margin() const
|
||||
{
|
||||
return get_property_value("margin"sv);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> CSSPageDescriptors::set_margin_top(StringView value)
|
||||
{
|
||||
return set_property("margin-top"sv, value, ""sv);
|
||||
}
|
||||
|
||||
String CSSPageDescriptors::margin_top() const
|
||||
{
|
||||
return get_property_value("margin-top"sv);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> CSSPageDescriptors::set_margin_right(StringView value)
|
||||
{
|
||||
return set_property("margin-right"sv, value, ""sv);
|
||||
}
|
||||
|
||||
String CSSPageDescriptors::margin_right() const
|
||||
{
|
||||
return get_property_value("margin-right"sv);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> CSSPageDescriptors::set_margin_bottom(StringView value)
|
||||
{
|
||||
return set_property("margin-bottom"sv, value, ""sv);
|
||||
}
|
||||
|
||||
String CSSPageDescriptors::margin_bottom() const
|
||||
{
|
||||
return get_property_value("margin-bottom"sv);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> CSSPageDescriptors::set_margin_left(StringView value)
|
||||
{
|
||||
return set_property("margin-left"sv, value, ""sv);
|
||||
}
|
||||
|
||||
String CSSPageDescriptors::margin_left() const
|
||||
{
|
||||
return get_property_value("margin-left"sv);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> CSSPageDescriptors::set_size(StringView value)
|
||||
{
|
||||
return set_property("size"sv, value, ""sv);
|
||||
}
|
||||
|
||||
String CSSPageDescriptors::size() const
|
||||
{
|
||||
return get_property_value("size"sv);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> CSSPageDescriptors::set_page_orientation(StringView value)
|
||||
{
|
||||
return set_property("page-orientation"sv, value, ""sv);
|
||||
}
|
||||
|
||||
String CSSPageDescriptors::page_orientation() const
|
||||
{
|
||||
return get_property_value("page-orientation"sv);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> CSSPageDescriptors::set_marks(StringView value)
|
||||
{
|
||||
return set_property("marks"sv, value, ""sv);
|
||||
}
|
||||
|
||||
String CSSPageDescriptors::marks() const
|
||||
{
|
||||
return get_property_value("marks"sv);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> CSSPageDescriptors::set_bleed(StringView value)
|
||||
{
|
||||
return set_property("bleed"sv, value, ""sv);
|
||||
}
|
||||
|
||||
String CSSPageDescriptors::bleed() const
|
||||
{
|
||||
return get_property_value("bleed"sv);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue