mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
LibHTML: Replace StyleProperties::create(StyleProperties) with clone()
This commit is contained in:
@@ -3,6 +3,25 @@
|
||||
#include <LibHTML/FontCache.h>
|
||||
#include <ctype.h>
|
||||
|
||||
StyleProperties::StyleProperties()
|
||||
{
|
||||
}
|
||||
|
||||
StyleProperties::StyleProperties(const StyleProperties& other)
|
||||
: m_property_values(*new HashMap(other.m_property_values))
|
||||
{
|
||||
if (other.m_font) {
|
||||
m_font = other.m_font->clone();
|
||||
} else {
|
||||
m_font = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
NonnullRefPtr<StyleProperties> StyleProperties::clone() const
|
||||
{
|
||||
return adopt(*new StyleProperties(*this));
|
||||
}
|
||||
|
||||
void StyleProperties::set_property(CSS::PropertyID id, NonnullRefPtr<StyleValue> value)
|
||||
{
|
||||
m_property_values.set((unsigned)id, move(value));
|
||||
|
||||
@@ -9,14 +9,13 @@ class Color;
|
||||
|
||||
class StyleProperties : public RefCounted<StyleProperties> {
|
||||
public:
|
||||
StyleProperties();
|
||||
|
||||
explicit StyleProperties(const StyleProperties&);
|
||||
|
||||
static NonnullRefPtr<StyleProperties> create() { return adopt(*new StyleProperties); }
|
||||
static NonnullRefPtr<StyleProperties> create(const StyleProperties& properties) {
|
||||
auto style_properties = new StyleProperties();
|
||||
properties.for_each_property([&](auto property_id, auto& property_value) {
|
||||
style_properties->set_property(property_id, property_value);
|
||||
});
|
||||
return adopt(*style_properties);
|
||||
}
|
||||
|
||||
NonnullRefPtr<StyleProperties> clone() const;
|
||||
|
||||
template<typename Callback>
|
||||
inline void for_each_property(Callback callback) const
|
||||
|
||||
Reference in New Issue
Block a user