mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:27:45 +00:00
LibWeb: Invalidate element style after setting Element.style.foo
This makes us recompute style for the element so the change actually takes effect. :^)
This commit is contained in:
parent
6c8185151e
commit
cad4cc9a2a
5 changed files with 40 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
@ -44,4 +45,14 @@ String CSSStyleDeclaration::item(size_t index) const
|
|||
return CSS::string_from_property_id(m_properties[index].property_id);
|
||||
}
|
||||
|
||||
ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element)
|
||||
: CSSStyleDeclaration({})
|
||||
, m_element(element.make_weak_ptr<DOM::Element>())
|
||||
{
|
||||
}
|
||||
|
||||
ElementInlineCSSStyleDeclaration::~ElementInlineCSSStyleDeclaration()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,21 +50,36 @@ public:
|
|||
return adopt(*new CSSStyleDeclaration(move(properties)));
|
||||
}
|
||||
|
||||
~CSSStyleDeclaration();
|
||||
virtual ~CSSStyleDeclaration();
|
||||
|
||||
const Vector<StyleProperty>& properties() const { return m_properties; }
|
||||
|
||||
size_t length() const { return m_properties.size(); }
|
||||
String item(size_t index) const;
|
||||
|
||||
protected:
|
||||
explicit CSSStyleDeclaration(Vector<StyleProperty>&&);
|
||||
|
||||
private:
|
||||
friend class Bindings::CSSStyleDeclarationWrapper;
|
||||
|
||||
explicit CSSStyleDeclaration(Vector<StyleProperty>&&);
|
||||
|
||||
Vector<StyleProperty> m_properties;
|
||||
};
|
||||
|
||||
class ElementInlineCSSStyleDeclaration final : public CSSStyleDeclaration {
|
||||
public:
|
||||
static NonnullRefPtr<ElementInlineCSSStyleDeclaration> create(DOM::Element& element) { return adopt(*new ElementInlineCSSStyleDeclaration(element)); }
|
||||
virtual ~ElementInlineCSSStyleDeclaration() override;
|
||||
|
||||
DOM::Element* element() { return m_element.ptr(); }
|
||||
const DOM::Element* element() const { return m_element.ptr(); }
|
||||
|
||||
private:
|
||||
explicit ElementInlineCSSStyleDeclaration(DOM::Element&);
|
||||
|
||||
WeakPtr<DOM::Element> m_element;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue