AK+LibWeb: Reduce recompilation impact of DOM/Node.h
Remove includes from Node.h that are only needed for forward declarations (AccessibilityTreeNode.h, XMLSerializer.h, JsonObjectSerializer.h). Extract StyleInvalidationReason and FragmentSerializationMode enums into standalone lightweight headers so downstream headers (CSSStyleSheet.h, CSSStyleProperties.h, HTMLParser.h) can include just the enum they need instead of all of Node.h. Replace Node.h with forward declarations in headers that only use Node by pointer/reference. This breaks the circular dependency between Node.h and AccessibilityTreeNode.h, reducing AccessibilityTreeNode.h's recompilation footprint from ~1399 to ~25 files.
This commit is contained in:
parent
901cc28272
commit
30e4779acb
22 changed files with 108 additions and 69 deletions
|
|
@ -125,6 +125,12 @@ class Function;
|
|||
template<typename Out, typename... In>
|
||||
class Function<Out(In...)>;
|
||||
|
||||
template<typename>
|
||||
class JsonArraySerializer;
|
||||
|
||||
template<typename>
|
||||
class JsonObjectSerializer;
|
||||
|
||||
template<typename T>
|
||||
class NonnullRefPtr;
|
||||
|
||||
|
|
@ -188,7 +194,9 @@ using AK::HashTable;
|
|||
using AK::IPv4Address;
|
||||
using AK::IPv6Address;
|
||||
using AK::JsonArray;
|
||||
using AK::JsonArraySerializer;
|
||||
using AK::JsonObject;
|
||||
using AK::JsonObjectSerializer;
|
||||
using AK::JsonValue;
|
||||
using AK::LexicalPath;
|
||||
using AK::LittleEndianInputBitStream;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||
#include <LibWeb/CSS/GeneratedCSSStyleProperties.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/DOM/StyleInvalidationReason.h>
|
||||
#include <LibWeb/Export.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#include <LibWeb/CSS/CSSRuleList.h>
|
||||
#include <LibWeb/CSS/CSSStyleRule.h>
|
||||
#include <LibWeb/CSS/StyleSheet.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/DOM/StyleInvalidationReason.h>
|
||||
#include <LibWeb/Export.h>
|
||||
#include <LibWeb/WebIDL/Types.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibGC/CellAllocator.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include <AK/Debug.h>
|
||||
#include <AK/GenericLexer.h>
|
||||
#include <AK/InsertionSort.h>
|
||||
#include <AK/JsonObjectSerializer.h>
|
||||
#include <AK/Random.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/TemporaryChange.h>
|
||||
|
|
@ -65,6 +66,7 @@
|
|||
#include <LibWeb/ContentSecurityPolicy/Directives/Directive.h>
|
||||
#include <LibWeb/ContentSecurityPolicy/Policy.h>
|
||||
#include <LibWeb/ContentSecurityPolicy/PolicyList.h>
|
||||
#include <LibWeb/DOM/AccessibilityTreeNode.h>
|
||||
#include <LibWeb/DOM/AdoptedStyleSheets.h>
|
||||
#include <LibWeb/DOM/Attr.h>
|
||||
#include <LibWeb/DOM/CDATASection.h>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <AK/Checked.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/IterationDecision.h>
|
||||
#include <AK/JsonObjectSerializer.h>
|
||||
#include <AK/NumericLimits.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
|
|
@ -84,6 +85,7 @@
|
|||
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
|
||||
#include <LibWeb/HTML/TraversableNavigable.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/HTML/XMLSerializer.h>
|
||||
#include <LibWeb/Infra/CharacterTypes.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
#include <LibWeb/Layout/BlockContainer.h>
|
||||
|
|
|
|||
16
Libraries/LibWeb/DOM/FragmentSerializationMode.h
Normal file
16
Libraries/LibWeb/DOM/FragmentSerializationMode.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2025, Andreas Kling <andreas@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
enum class FragmentSerializationMode {
|
||||
Inner,
|
||||
Outer,
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/HashTable.h>
|
||||
#include <AK/JsonObjectSerializer.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibGC/DeferGC.h>
|
||||
#include <LibIPC/Decoder.h>
|
||||
|
|
@ -20,6 +21,7 @@
|
|||
#include <LibWeb/Bindings/NodePrototype.h>
|
||||
#include <LibWeb/CSS/ComputedProperties.h>
|
||||
#include <LibWeb/CSS/StyleComputer.h>
|
||||
#include <LibWeb/DOM/AccessibilityTreeNode.h>
|
||||
#include <LibWeb/DOM/Attr.h>
|
||||
#include <LibWeb/DOM/CDATASection.h>
|
||||
#include <LibWeb/DOM/Comment.h>
|
||||
|
|
@ -58,6 +60,7 @@
|
|||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||
#include <LibWeb/HTML/Scripting/SimilarOriginWindowAgent.h>
|
||||
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
|
||||
#include <LibWeb/HTML/XMLSerializer.h>
|
||||
#include <LibWeb/Infra/CharacterTypes.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
|
|
|
|||
|
|
@ -9,16 +9,15 @@
|
|||
#include <AK/DistinctNumeric.h>
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/GenericShorthands.h>
|
||||
#include <AK/JsonObjectSerializer.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibWeb/CSS/InvalidationSet.h>
|
||||
#include <LibWeb/DOM/AccessibilityTreeNode.h>
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
#include <LibWeb/DOM/FragmentSerializationMode.h>
|
||||
#include <LibWeb/DOM/NodeType.h>
|
||||
#include <LibWeb/DOM/Slottable.h>
|
||||
#include <LibWeb/DOM/StyleInvalidationReason.h>
|
||||
#include <LibWeb/Export.h>
|
||||
#include <LibWeb/HTML/XMLSerializer.h>
|
||||
#include <LibWeb/TraversalDecision.h>
|
||||
#include <LibWeb/TreeNode.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
|
@ -34,11 +33,6 @@ struct GetRootNodeOptions {
|
|||
bool composed { false };
|
||||
};
|
||||
|
||||
enum class FragmentSerializationMode {
|
||||
Inner,
|
||||
Outer,
|
||||
};
|
||||
|
||||
enum class IsDescendant {
|
||||
No,
|
||||
Yes,
|
||||
|
|
@ -49,55 +43,6 @@ enum class ShouldComputeRole {
|
|||
Yes,
|
||||
};
|
||||
|
||||
#define ENUMERATE_STYLE_INVALIDATION_REASONS(X) \
|
||||
X(AdoptedStyleSheetsList) \
|
||||
X(BaseURLChanged) \
|
||||
X(CSSFontLoaded) \
|
||||
X(CSSImportRule) \
|
||||
X(CSSStylePropertiesRemoveProperty) \
|
||||
X(CSSStylePropertiesSetProperty) \
|
||||
X(CSSStylePropertiesSetPropertyStyleValue) \
|
||||
X(CSSStylePropertiesTextChange) \
|
||||
X(CustomElementStateChange) \
|
||||
X(CustomStateSetChange) \
|
||||
X(DidLoseFocus) \
|
||||
X(DidReceiveFocus) \
|
||||
X(EditingInsertion) \
|
||||
X(EditingDeletion) \
|
||||
X(ElementAttributeChange) \
|
||||
X(ElementSetShadowRoot) \
|
||||
X(HTMLDialogElementSetIsModal) \
|
||||
X(HTMLDetailsOrDialogOpenAttributeChange) \
|
||||
X(HTMLHyperlinkElementHrefChange) \
|
||||
X(HTMLIFrameElementGeometryChange) \
|
||||
X(HTMLInputElementSetChecked) \
|
||||
X(HTMLInputElementSetIsOpen) \
|
||||
X(HTMLInputElementSetType) \
|
||||
X(HTMLObjectElementUpdateLayoutAndChildObjects) \
|
||||
X(HTMLOptionElementSelectedChange) \
|
||||
X(HTMLSelectElementSetIsOpen) \
|
||||
X(MediaListSetMediaText) \
|
||||
X(MediaListAppendMedium) \
|
||||
X(MediaListDeleteMedium) \
|
||||
X(MediaQueryChangedMatchState) \
|
||||
X(NavigableSetViewportSize) \
|
||||
X(NodeInsertBefore) \
|
||||
X(NodeRemove) \
|
||||
X(NodeSetTextContent) \
|
||||
X(Other) \
|
||||
X(SetSelectorText) \
|
||||
X(SettingsChange) \
|
||||
X(StyleSheetDeleteRule) \
|
||||
X(StyleSheetInsertRule) \
|
||||
X(StyleSheetListAddSheet) \
|
||||
X(StyleSheetListRemoveSheet)
|
||||
|
||||
enum class StyleInvalidationReason {
|
||||
#define __ENUMERATE_STYLE_INVALIDATION_REASON(reason) reason,
|
||||
ENUMERATE_STYLE_INVALIDATION_REASONS(__ENUMERATE_STYLE_INVALIDATION_REASON)
|
||||
#undef __ENUMERATE_STYLE_INVALIDATION_REASON
|
||||
};
|
||||
|
||||
#define ENUMERATE_SET_NEEDS_LAYOUT_REASONS(X) \
|
||||
X(CharacterDataReplaceData) \
|
||||
X(FinalizeACrossDocumentNavigation) \
|
||||
|
|
@ -386,9 +331,6 @@ public:
|
|||
void set_entire_subtree_needs_style_update(bool b) { m_entire_subtree_needs_style_update = b; }
|
||||
|
||||
void invalidate_style(StyleInvalidationReason);
|
||||
struct StyleInvalidationOptions {
|
||||
bool invalidate_self { false };
|
||||
};
|
||||
void invalidate_style(StyleInvalidationReason, Vector<CSS::InvalidationSet::Property> const&, StyleInvalidationOptions);
|
||||
|
||||
void set_document(Badge<Document>, Document&);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#include <AK/Error.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibGC/Heap.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include <LibWeb/HTML/HTMLSlotElement.h>
|
||||
#include <LibWeb/HTML/HTMLTemplateElement.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||
#include <LibWeb/HTML/XMLSerializer.h>
|
||||
#include <LibWeb/Layout/BlockContainer.h>
|
||||
#include <LibWeb/TrustedTypes/RequireTrustedTypesForDirective.h>
|
||||
#include <LibWeb/TrustedTypes/TrustedTypePolicy.h>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <LibGC/Heap.h>
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/DOM/StaticNodeList.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/DOM/NodeList.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
|
|
|||
64
Libraries/LibWeb/DOM/StyleInvalidationReason.h
Normal file
64
Libraries/LibWeb/DOM/StyleInvalidationReason.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2025, Andreas Kling <andreas@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
#define ENUMERATE_STYLE_INVALIDATION_REASONS(X) \
|
||||
X(AdoptedStyleSheetsList) \
|
||||
X(BaseURLChanged) \
|
||||
X(CSSFontLoaded) \
|
||||
X(CSSImportRule) \
|
||||
X(CSSStylePropertiesRemoveProperty) \
|
||||
X(CSSStylePropertiesSetProperty) \
|
||||
X(CSSStylePropertiesSetPropertyStyleValue) \
|
||||
X(CSSStylePropertiesTextChange) \
|
||||
X(CustomElementStateChange) \
|
||||
X(CustomStateSetChange) \
|
||||
X(DidLoseFocus) \
|
||||
X(DidReceiveFocus) \
|
||||
X(EditingInsertion) \
|
||||
X(EditingDeletion) \
|
||||
X(ElementAttributeChange) \
|
||||
X(ElementSetShadowRoot) \
|
||||
X(HTMLDialogElementSetIsModal) \
|
||||
X(HTMLDetailsOrDialogOpenAttributeChange) \
|
||||
X(HTMLHyperlinkElementHrefChange) \
|
||||
X(HTMLIFrameElementGeometryChange) \
|
||||
X(HTMLInputElementSetChecked) \
|
||||
X(HTMLInputElementSetIsOpen) \
|
||||
X(HTMLInputElementSetType) \
|
||||
X(HTMLObjectElementUpdateLayoutAndChildObjects) \
|
||||
X(HTMLOptionElementSelectedChange) \
|
||||
X(HTMLSelectElementSetIsOpen) \
|
||||
X(MediaListSetMediaText) \
|
||||
X(MediaListAppendMedium) \
|
||||
X(MediaListDeleteMedium) \
|
||||
X(MediaQueryChangedMatchState) \
|
||||
X(NavigableSetViewportSize) \
|
||||
X(NodeInsertBefore) \
|
||||
X(NodeRemove) \
|
||||
X(NodeSetTextContent) \
|
||||
X(Other) \
|
||||
X(SetSelectorText) \
|
||||
X(SettingsChange) \
|
||||
X(StyleSheetDeleteRule) \
|
||||
X(StyleSheetInsertRule) \
|
||||
X(StyleSheetListAddSheet) \
|
||||
X(StyleSheetListRemoveSheet)
|
||||
|
||||
enum class StyleInvalidationReason {
|
||||
#define __ENUMERATE_STYLE_INVALIDATION_REASON(reason) reason,
|
||||
ENUMERATE_STYLE_INVALIDATION_REASONS(__ENUMERATE_STYLE_INVALIDATION_REASON)
|
||||
#undef __ENUMERATE_STYLE_INVALIDATION_REASON
|
||||
};
|
||||
|
||||
struct StyleInvalidationOptions {
|
||||
bool invalidate_self { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -7,8 +7,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Vector.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/DOM/Range.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/Selection/Selection.h>
|
||||
|
||||
namespace Web::Editing {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/PerformanceTimeline/PerformanceEntry.h>
|
||||
|
||||
namespace Web::EventTiming {
|
||||
|
|
|
|||
|
|
@ -794,6 +794,7 @@ class XMLSerializer;
|
|||
|
||||
enum class AllowMultipleFiles;
|
||||
enum class MediaSeekMode;
|
||||
enum class RequireWellFormed;
|
||||
enum class SandboxingFlagSet;
|
||||
|
||||
struct Agent;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/DOM/FragmentSerializationMode.h>
|
||||
#include <LibWeb/Export.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLTokenizer.h>
|
||||
#include <LibWeb/HTML/Parser/ListOfActiveFormattingElements.h>
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/JsonValue.h>
|
||||
#include <LibGC/Root.h>
|
||||
#include <LibGC/Weak.h>
|
||||
#include <LibGfx/Cursor.h>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include <LibGfx/PaintStyle.h>
|
||||
#include <LibWeb/CSS/URL.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/Export.h>
|
||||
#include <LibWeb/SVG/AttributeParser.h>
|
||||
#include <LibWeb/SVG/SVGAnimatedTransformList.h>
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/HTML/XMLSerializer.h>
|
||||
#include <LibWeb/Infra/ByteSequences.h>
|
||||
#include <LibWeb/Infra/JSON.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
#include <LibWeb/HTML/SelectedFile.h>
|
||||
#include <LibWeb/HTML/TraversableNavigable.h>
|
||||
#include <LibWeb/HTML/WindowProxy.h>
|
||||
#include <LibWeb/HTML/XMLSerializer.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Platform/EventLoopPlugin.h>
|
||||
#include <LibWeb/Platform/Timer.h>
|
||||
|
|
|
|||
Loading…
Reference in a new issue