mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 15:27:42 +00:00
LibHTML: Replace StyleProperties::create(StyleProperties) with clone()
This commit is contained in:
parent
2dd35916e5
commit
c2e1dd67c9
3 changed files with 26 additions and 8 deletions
|
@ -3,6 +3,25 @@
|
||||||
#include <LibHTML/FontCache.h>
|
#include <LibHTML/FontCache.h>
|
||||||
#include <ctype.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)
|
void StyleProperties::set_property(CSS::PropertyID id, NonnullRefPtr<StyleValue> value)
|
||||||
{
|
{
|
||||||
m_property_values.set((unsigned)id, move(value));
|
m_property_values.set((unsigned)id, move(value));
|
||||||
|
|
|
@ -9,14 +9,13 @@ class Color;
|
||||||
|
|
||||||
class StyleProperties : public RefCounted<StyleProperties> {
|
class StyleProperties : public RefCounted<StyleProperties> {
|
||||||
public:
|
public:
|
||||||
|
StyleProperties();
|
||||||
|
|
||||||
|
explicit StyleProperties(const StyleProperties&);
|
||||||
|
|
||||||
static NonnullRefPtr<StyleProperties> create() { return adopt(*new StyleProperties); }
|
static NonnullRefPtr<StyleProperties> create() { return adopt(*new StyleProperties); }
|
||||||
static NonnullRefPtr<StyleProperties> create(const StyleProperties& properties) {
|
|
||||||
auto style_properties = new StyleProperties();
|
NonnullRefPtr<StyleProperties> clone() const;
|
||||||
properties.for_each_property([&](auto property_id, auto& property_value) {
|
|
||||||
style_properties->set_property(property_id, property_value);
|
|
||||||
});
|
|
||||||
return adopt(*style_properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
inline void for_each_property(Callback callback) const
|
inline void for_each_property(Callback callback) const
|
||||||
|
|
|
@ -165,7 +165,7 @@ void Element::recompute_style()
|
||||||
|
|
||||||
RefPtr<StyleProperties> Element::computed_style()
|
RefPtr<StyleProperties> Element::computed_style()
|
||||||
{
|
{
|
||||||
auto properties = StyleProperties::create(*m_resolved_style);
|
auto properties = m_resolved_style->clone();
|
||||||
if (layout_node() && layout_node()->has_style()) {
|
if (layout_node() && layout_node()->has_style()) {
|
||||||
CSS::PropertyID box_model_metrics[] = {
|
CSS::PropertyID box_model_metrics[] = {
|
||||||
CSS::PropertyID::MarginTop,
|
CSS::PropertyID::MarginTop,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue