Skip to content

Commit 12716dc

Browse files
Calme1709AtkinsSJ
authored andcommitted
LibWeb: Avoid including ComputedProperties.h in Element.h
This reduces the size of the recompile when ComputedProperties.h is modified from ~1200 to ~70
1 parent 64f4388 commit 12716dc

File tree

11 files changed

+48
-38
lines changed

11 files changed

+48
-38
lines changed

Libraries/LibWeb/CSS/ComputedValues.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ using CursorData = Variant<NonnullRefPtr<CursorStyleValue const>, CursorPredefin
130130

131131
using ListStyleType = Variant<CounterStyleNameKeyword, String>;
132132

133-
using PaintOrderList = Array<PaintOrder, 3>;
134-
135133
class InitialValues {
136134
public:
137135
static AspectRatio aspect_ratio() { return AspectRatio { true, {} }; }

Libraries/LibWeb/CSS/Length.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <AK/Variant.h>
1111
#include <LibGfx/Font/Font.h>
1212
#include <LibGfx/Rect.h>
13+
#include <LibWeb/CSS/ComputedProperties.h>
1314
#include <LibWeb/CSS/Length.h>
1415
#include <LibWeb/CSS/Percentage.h>
1516
#include <LibWeb/CSS/StyleComputer.h>

Libraries/LibWeb/CSS/StylePropertyMapReadOnly.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <LibWeb/Bindings/Intrinsics.h>
99
#include <LibWeb/Bindings/StylePropertyMapReadOnlyPrototype.h>
1010
#include <LibWeb/CSS/CSSStyleDeclaration.h>
11+
#include <LibWeb/CSS/ComputedProperties.h>
1112
#include <LibWeb/CSS/PropertyNameAndID.h>
1213
#include <LibWeb/DOM/Document.h>
1314
#include <LibWeb/WebIDL/ExceptionOr.h>

Libraries/LibWeb/CSS/StyleValues/StyleValue.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <LibGfx/Font/FontStyleMapping.h>
1212
#include <LibGfx/Font/FontWeight.h>
1313
#include <LibWeb/CSS/CSSStyleValue.h>
14+
#include <LibWeb/CSS/ComputedProperties.h>
1415
#include <LibWeb/CSS/Parser/Parser.h>
1516
#include <LibWeb/CSS/StyleValues/AbstractImageStyleValue.h>
1617
#include <LibWeb/CSS/StyleValues/AnchorSizeStyleValue.h>

Libraries/LibWeb/DOM/Element.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4002,6 +4002,35 @@ Optional<String> Element::lang() const
40024002
return maybe_lang.release_value();
40034003
}
40044004

4005+
template<typename Callback>
4006+
void Element::for_each_numbered_item_owned_by_list_owner(Callback callback)
4007+
{
4008+
for (auto* node = this->first_child(); node != nullptr; node = node->next_in_pre_order(this)) {
4009+
auto* element = as_if<Element>(node);
4010+
if (!element)
4011+
continue;
4012+
4013+
element->m_is_contained_in_list_subtree = true;
4014+
4015+
if (node->is_html_ol_ul_menu_element()) {
4016+
// Skip list nodes and their descendents. They have their own, unrelated ordinals.
4017+
while (node->last_child() != nullptr) // Find the last node (preorder) in the subtree headed by node. O(1).
4018+
node = node->last_child();
4019+
4020+
continue;
4021+
}
4022+
4023+
if (!node->layout_node())
4024+
continue; // Skip nodes that do not participate in the layout.
4025+
4026+
if (!element->computed_properties()->display().is_list_item())
4027+
continue; // Skip nodes that are not list items.
4028+
4029+
if (callback(element) == IterationDecision::Break)
4030+
return;
4031+
}
4032+
}
4033+
40054034
// https://drafts.csswg.org/css-images-4/#element-not-rendered
40064035
bool Element::not_rendered() const
40074036
{

Libraries/LibWeb/DOM/Element.h

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <LibWeb/Bindings/Intrinsics.h>
1616
#include <LibWeb/Bindings/ShadowRootPrototype.h>
1717
#include <LibWeb/CSS/CascadedProperties.h>
18-
#include <LibWeb/CSS/ComputedProperties.h>
1918
#include <LibWeb/CSS/Selector.h>
2019
#include <LibWeb/CSS/StyleInvalidation.h>
2120
#include <LibWeb/CSS/StyleProperty.h>
@@ -495,41 +494,6 @@ class WEB_API Element
495494
void maybe_invalidate_ordinals_for_list_owner(Optional<Element*> skip_node = {});
496495
i32 ordinal_value();
497496

498-
template<typename Callback>
499-
void for_each_numbered_item_owned_by_list_owner(Callback callback) const
500-
{
501-
const_cast<Element*>(this)->for_each_numbered_item_owned_by_list_owner(move(callback));
502-
}
503-
504-
template<typename Callback>
505-
void for_each_numbered_item_owned_by_list_owner(Callback callback)
506-
{
507-
for (auto* node = this->first_child(); node != nullptr; node = node->next_in_pre_order(this)) {
508-
auto* element = as_if<Element>(node);
509-
if (!element)
510-
continue;
511-
512-
element->m_is_contained_in_list_subtree = true;
513-
514-
if (node->is_html_ol_ul_menu_element()) {
515-
// Skip list nodes and their descendents. They have their own, unrelated ordinals.
516-
while (node->last_child() != nullptr) // Find the last node (preorder) in the subtree headed by node. O(1).
517-
node = node->last_child();
518-
519-
continue;
520-
}
521-
522-
if (!node->layout_node())
523-
continue; // Skip nodes that do not participate in the layout.
524-
525-
if (!element->computed_properties()->display().is_list_item())
526-
continue; // Skip nodes that are not list items.
527-
528-
if (callback(element) == IterationDecision::Break)
529-
return;
530-
}
531-
}
532-
533497
bool captured_in_a_view_transition() const { return m_captured_in_a_view_transition; }
534498
void set_captured_in_a_view_transition(bool value) { m_captured_in_a_view_transition = value; }
535499

@@ -590,6 +554,15 @@ class WEB_API Element
590554
Optional<Directionality> contained_text_auto_directionality(bool can_exclude_root) const;
591555
Directionality parent_directionality() const;
592556

557+
template<typename Callback>
558+
void for_each_numbered_item_owned_by_list_owner(Callback callback) const
559+
{
560+
const_cast<Element*>(this)->for_each_numbered_item_owned_by_list_owner(move(callback));
561+
}
562+
563+
template<typename Callback>
564+
void for_each_numbered_item_owned_by_list_owner(Callback callback);
565+
593566
QualifiedName m_qualified_name;
594567
mutable Optional<FlyString> m_html_uppercased_qualified_name;
595568

Libraries/LibWeb/Forward.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ class VisualViewport;
394394
enum class Keyword : u16;
395395
enum class MediaFeatureID : u8;
396396
enum class PropertyID : u16;
397+
enum class PaintOrder : u8;
397398

398399
struct BackgroundLayerData;
399400
struct CalculationContext;
@@ -402,6 +403,8 @@ struct CSSStyleSheetInit;
402403
struct GridRepeatParams;
403404
struct StyleSheetIdentifier;
404405

406+
using PaintOrderList = Array<PaintOrder, 3>;
407+
405408
}
406409

407410
namespace Web::CSS::Parser {

Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include "CanvasTextDrawingStyles.h"
9+
#include <LibWeb/CSS/ComputedProperties.h>
910
#include <LibWeb/CSS/StyleComputer.h>
1011
#include <LibWeb/CSS/StyleValues/FontStyleStyleValue.h>
1112
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>

Libraries/LibWeb/HTML/Navigable.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* SPDX-License-Identifier: BSD-2-Clause
77
*/
88

9+
#include <LibWeb/CSS/ComputedProperties.h>
910
#include <LibWeb/CSS/SystemColor.h>
1011
#include <LibWeb/CSS/VisualViewport.h>
1112
#include <LibWeb/ContentSecurityPolicy/BlockingAlgorithms.h>

Libraries/LibWeb/Layout/BlockFormattingContext.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include <AK/TemporaryChange.h>
9+
#include <LibWeb/CSS/ComputedProperties.h>
910
#include <LibWeb/CSS/Length.h>
1011
#include <LibWeb/CSS/PropertyID.h>
1112
#include <LibWeb/DOM/Element.h>

0 commit comments

Comments
 (0)