
This partially implements CSS-Animations-1 (though there are references to CSS-Animations-2). Current limitations: - Multi-selector keyframes are not supported. - Most animation properties are ignored. - Timing functions are not applied. - Non-absolute values are not interpolated unless the target is also of the same non-absolute type (e.g. 10% -> 25%, but not 10% -> 20px). - The JavaScript interface is left as an exercise for the next poor soul looking at this code. With those said, this commit implements: - Interpolation for most common types - Proper keyframe resolution (including the synthetic from-keyframe containing the initial state) - Properly driven animations, and proper style invalidation Co-Authored-By: Andreas Kling <kling@serenityos.org>
44 lines
1.3 KiB
C++
44 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Function.h>
|
|
#include <AK/NonnullRefPtr.h>
|
|
#include <LibWeb/CSS/CSSRule.h>
|
|
#include <LibWeb/CSS/CSSRuleList.h>
|
|
#include <LibWeb/Forward.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
class CSSGroupingRule : public CSSRule {
|
|
WEB_PLATFORM_OBJECT(CSSGroupingRule, CSSRule);
|
|
|
|
public:
|
|
virtual ~CSSGroupingRule() = default;
|
|
|
|
CSSRuleList const& css_rules() const { return m_rules; }
|
|
CSSRuleList& css_rules() { return m_rules; }
|
|
CSSRuleList* css_rules_for_bindings() { return m_rules; }
|
|
WebIDL::ExceptionOr<u32> insert_rule(StringView rule, u32 index = 0);
|
|
WebIDL::ExceptionOr<void> delete_rule(u32 index);
|
|
|
|
virtual void for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const;
|
|
virtual void for_each_effective_keyframes_at_rule(Function<void(CSSKeyframesRule const&)> const& callback) const;
|
|
|
|
virtual void set_parent_style_sheet(CSSStyleSheet*) override;
|
|
|
|
protected:
|
|
CSSGroupingRule(JS::Realm&, CSSRuleList&);
|
|
|
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
private:
|
|
JS::NonnullGCPtr<CSSRuleList> m_rules;
|
|
};
|
|
|
|
}
|