LibWeb: Avoid including ComputedProperties.h in Element.h

This reduces the size of the recompile when ComputedProperties.h is
modified from ~1200 to ~70
This commit is contained in:
Callum Law 2025-10-24 14:27:15 +13:00 committed by Sam Atkins
parent 64f438857b
commit 12716dccf0
Notes: github-actions[bot] 2025-10-27 14:52:30 +00:00
11 changed files with 48 additions and 38 deletions

View file

@ -130,8 +130,6 @@ using CursorData = Variant<NonnullRefPtr<CursorStyleValue const>, CursorPredefin
using ListStyleType = Variant<CounterStyleNameKeyword, String>;
using PaintOrderList = Array<PaintOrder, 3>;
class InitialValues {
public:
static AspectRatio aspect_ratio() { return AspectRatio { true, {} }; }

View file

@ -10,6 +10,7 @@
#include <AK/Variant.h>
#include <LibGfx/Font/Font.h>
#include <LibGfx/Rect.h>
#include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/Length.h>
#include <LibWeb/CSS/Percentage.h>
#include <LibWeb/CSS/StyleComputer.h>

View file

@ -8,6 +8,7 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/StylePropertyMapReadOnlyPrototype.h>
#include <LibWeb/CSS/CSSStyleDeclaration.h>
#include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/PropertyNameAndID.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/WebIDL/ExceptionOr.h>

View file

@ -11,6 +11,7 @@
#include <LibGfx/Font/FontStyleMapping.h>
#include <LibGfx/Font/FontWeight.h>
#include <LibWeb/CSS/CSSStyleValue.h>
#include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/StyleValues/AbstractImageStyleValue.h>
#include <LibWeb/CSS/StyleValues/AnchorSizeStyleValue.h>

View file

@ -4002,6 +4002,35 @@ Optional<String> Element::lang() const
return maybe_lang.release_value();
}
template<typename Callback>
void Element::for_each_numbered_item_owned_by_list_owner(Callback callback)
{
for (auto* node = this->first_child(); node != nullptr; node = node->next_in_pre_order(this)) {
auto* element = as_if<Element>(node);
if (!element)
continue;
element->m_is_contained_in_list_subtree = true;
if (node->is_html_ol_ul_menu_element()) {
// Skip list nodes and their descendents. They have their own, unrelated ordinals.
while (node->last_child() != nullptr) // Find the last node (preorder) in the subtree headed by node. O(1).
node = node->last_child();
continue;
}
if (!node->layout_node())
continue; // Skip nodes that do not participate in the layout.
if (!element->computed_properties()->display().is_list_item())
continue; // Skip nodes that are not list items.
if (callback(element) == IterationDecision::Break)
return;
}
}
// https://drafts.csswg.org/css-images-4/#element-not-rendered
bool Element::not_rendered() const
{

View file

@ -15,7 +15,6 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/ShadowRootPrototype.h>
#include <LibWeb/CSS/CascadedProperties.h>
#include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/Selector.h>
#include <LibWeb/CSS/StyleInvalidation.h>
#include <LibWeb/CSS/StyleProperty.h>
@ -495,41 +494,6 @@ public:
void maybe_invalidate_ordinals_for_list_owner(Optional<Element*> skip_node = {});
i32 ordinal_value();
template<typename Callback>
void for_each_numbered_item_owned_by_list_owner(Callback callback) const
{
const_cast<Element*>(this)->for_each_numbered_item_owned_by_list_owner(move(callback));
}
template<typename Callback>
void for_each_numbered_item_owned_by_list_owner(Callback callback)
{
for (auto* node = this->first_child(); node != nullptr; node = node->next_in_pre_order(this)) {
auto* element = as_if<Element>(node);
if (!element)
continue;
element->m_is_contained_in_list_subtree = true;
if (node->is_html_ol_ul_menu_element()) {
// Skip list nodes and their descendents. They have their own, unrelated ordinals.
while (node->last_child() != nullptr) // Find the last node (preorder) in the subtree headed by node. O(1).
node = node->last_child();
continue;
}
if (!node->layout_node())
continue; // Skip nodes that do not participate in the layout.
if (!element->computed_properties()->display().is_list_item())
continue; // Skip nodes that are not list items.
if (callback(element) == IterationDecision::Break)
return;
}
}
bool captured_in_a_view_transition() const { return m_captured_in_a_view_transition; }
void set_captured_in_a_view_transition(bool value) { m_captured_in_a_view_transition = value; }
@ -590,6 +554,15 @@ private:
Optional<Directionality> contained_text_auto_directionality(bool can_exclude_root) const;
Directionality parent_directionality() const;
template<typename Callback>
void for_each_numbered_item_owned_by_list_owner(Callback callback) const
{
const_cast<Element*>(this)->for_each_numbered_item_owned_by_list_owner(move(callback));
}
template<typename Callback>
void for_each_numbered_item_owned_by_list_owner(Callback callback);
QualifiedName m_qualified_name;
mutable Optional<FlyString> m_html_uppercased_qualified_name;

View file

@ -394,6 +394,7 @@ class VisualViewport;
enum class Keyword : u16;
enum class MediaFeatureID : u8;
enum class PropertyID : u16;
enum class PaintOrder : u8;
struct BackgroundLayerData;
struct CalculationContext;
@ -402,6 +403,8 @@ struct CSSStyleSheetInit;
struct GridRepeatParams;
struct StyleSheetIdentifier;
using PaintOrderList = Array<PaintOrder, 3>;
}
namespace Web::CSS::Parser {

View file

@ -6,6 +6,7 @@
*/
#include "CanvasTextDrawingStyles.h"
#include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/StyleComputer.h>
#include <LibWeb/CSS/StyleValues/FontStyleStyleValue.h>
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>

View file

@ -6,6 +6,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/SystemColor.h>
#include <LibWeb/CSS/VisualViewport.h>
#include <LibWeb/ContentSecurityPolicy/BlockingAlgorithms.h>

View file

@ -6,6 +6,7 @@
*/
#include <AK/TemporaryChange.h>
#include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/Length.h>
#include <LibWeb/CSS/PropertyID.h>
#include <LibWeb/DOM/Element.h>

View file

@ -6,6 +6,7 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/SVGGradientElementPrototype.h>
#include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/Painting/PaintStyle.h>
#include <LibWeb/SVG/AttributeNames.h>