mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-04 15:19:16 +00:00
Before this change, whenever element's attributes changed, we would add a flag to "pending invalidation", indicating that all descendants whose style uses CSS custom properties needed to be recomputed. This resulted in severe overinvalidation, because we would run invalidation regardless of whether any custom property on affected element actually changed. This change takes another approach, and now we decide whether descendant's style needs to be recomputed based on whether ancestor's style recomputation results in a change of custom properties, though this approach adds a little overhead to style computation as now we have to compare old vs new hashmap of custom properties. This brings substantial improvement on discord and x.com where, before this change, advantage of using invalidation sets was lost and we had to recompute all descendants, because almost all of them use custom properties.
21 lines
499 B
C++
21 lines
499 B
C++
/*
|
|
* Copyright (c) 2023, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
|
#include <LibWeb/CSS/StyleProperty.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
StyleProperty::~StyleProperty() = default;
|
|
|
|
bool StyleProperty::operator==(StyleProperty const& other) const
|
|
{
|
|
if (important != other.important || property_id != other.property_id || custom_name != other.custom_name)
|
|
return false;
|
|
return value->equals(*other.value);
|
|
}
|
|
|
|
}
|