Move CSS animation values into a mutable overlay on computed properties and make base computed style data immutable after construction. Base style mutation now goes through a builder that is consumed on publish, so installed styles no longer expose mutation APIs. Build new base style data for inherited style updates instead of cloning and mutating installed computed properties. Element-specific computed style adjustments now run before publication, while animation and transition updates continue to mutate only the animated overlay.
72 lines
2.4 KiB
C++
72 lines
2.4 KiB
C++
/*
|
|
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/DOM/Element.h>
|
|
#include <LibWeb/Export.h>
|
|
#include <LibWeb/HTML/GlobalEventHandlers.h>
|
|
#include <LibWeb/HTML/HTMLOrSVGOrMathMLElement.h>
|
|
#include <LibWeb/SVG/SVGAnimatedString.h>
|
|
|
|
namespace Web::SVG {
|
|
|
|
class WEB_API SVGElement
|
|
: public DOM::Element
|
|
, public HTML::GlobalEventHandlers
|
|
, public HTML::HTMLOrSVGOrMathMLElement<SVGElement> {
|
|
WEB_PLATFORM_OBJECT(SVGElement, DOM::Element);
|
|
GC_DECLARE_ALLOCATOR(SVGElement);
|
|
|
|
public:
|
|
virtual bool requires_svg_container() const override { return true; }
|
|
|
|
GC::Ref<SVGAnimatedString> class_name();
|
|
GC::Ptr<SVGSVGElement> owner_svg_element();
|
|
GC::Ptr<SVGElement> viewport_element();
|
|
|
|
bool should_include_in_accessibility_tree() const;
|
|
virtual Optional<ARIA::Role> default_role() const override;
|
|
|
|
GC::Ref<SVGAnimatedLength> fake_animated_length_fixme() const;
|
|
GC::Ref<SVGAnimatedLength> svg_animated_length_for_property(CSS::PropertyID) const;
|
|
|
|
virtual bool is_presentational_hint(FlyString const&) const override;
|
|
virtual void apply_presentational_hints(Vector<CSS::StyleProperty>&) const override;
|
|
|
|
protected:
|
|
SVGElement(DOM::Document&, DOM::QualifiedName);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
|
virtual WebIDL::ExceptionOr<void> cloned(DOM::Node&, bool) const override;
|
|
virtual void children_changed(ChildrenChangedMetadata const&) override;
|
|
virtual void inserted() override;
|
|
virtual void removed_from(IsSubtreeRoot, Node* old_ancestor, Node& old_root) override;
|
|
MUST_UPCALL virtual void adjust_computed_style(CSS::ComputedProperties::Builder&) override;
|
|
|
|
void update_use_elements_that_reference_this();
|
|
void remove_from_use_element_that_reference_this();
|
|
|
|
private:
|
|
// ^HTML::GlobalEventHandlers
|
|
virtual GC::Ptr<DOM::EventTarget> global_event_handlers_to_event_target(FlyString const&) override { return *this; }
|
|
|
|
virtual bool is_svg_element() const final { return true; }
|
|
|
|
GC::Ptr<SVGAnimatedString> m_class_name_animated_string;
|
|
};
|
|
|
|
}
|
|
|
|
namespace Web::DOM {
|
|
|
|
template<>
|
|
inline bool Node::fast_is<SVG::SVGElement>() const { return is_svg_element(); }
|
|
|
|
}
|