فهرست منبع

LibWeb: Give UsedValues a pointer to containing block UsedValues

This will allow us to skip hash lookups when traversing the containing
block chain and looking at everyone's UsedValues.
Andreas Kling 1 سال پیش
والد
کامیت
8e31bfb83c
2فایلهای تغییر یافته به همراه4 افزوده شده و 0 حذف شده
  1. 1 0
      Userland/Libraries/LibWeb/Layout/LayoutState.cpp
  2. 3 0
      Userland/Libraries/LibWeb/Layout/LayoutState.h

+ 1 - 0
Userland/Libraries/LibWeb/Layout/LayoutState.cpp

@@ -540,6 +540,7 @@ void LayoutState::commit(Box& root)
 void LayoutState::UsedValues::set_node(NodeWithStyle& node, UsedValues const* containing_block_used_values)
 {
     m_node = &node;
+    m_containing_block_used_values = containing_block_used_values;
 
     // NOTE: In the code below, we decide if `node` has definite width and/or height.
     //       This attempts to cover all the *general* cases where CSS considers sizes to be definite.

+ 3 - 0
Userland/Libraries/LibWeb/Layout/LayoutState.h

@@ -45,6 +45,8 @@ struct LayoutState {
         NodeWithStyle const& node() const { return *m_node; }
         void set_node(NodeWithStyle&, UsedValues const* containing_block_used_values);
 
+        UsedValues const* containing_block_used_values() const { return m_containing_block_used_values; }
+
         CSSPixels content_width() const { return m_content_width; }
         CSSPixels content_height() const { return m_content_height; }
         void set_content_width(CSSPixels);
@@ -142,6 +144,7 @@ struct LayoutState {
         CSSPixels border_bottom_collapsed() const { return use_collapsing_borders_model() ? round(border_bottom / 2) : border_bottom; }
 
         JS::GCPtr<Layout::NodeWithStyle> m_node { nullptr };
+        UsedValues const* m_containing_block_used_values { nullptr };
 
         CSSPixels m_content_width { 0 };
         CSSPixels m_content_height { 0 };