瀏覽代碼

LibWeb: Avoid unnecessary padded_rect() call in Box::paint()

We were computing the padded rect of the box during every paint phase,
despite only needing it in the Overlay phase.

Since this is an expensive call, let's take care not to make it
unnecessarily.
Andreas Kling 3 年之前
父節點
當前提交
19c492e976
共有 1 個文件被更改,包括 1 次插入3 次删除
  1. 1 3
      Userland/Libraries/LibWeb/Layout/Box.cpp

+ 1 - 3
Userland/Libraries/LibWeb/Layout/Box.cpp

@@ -28,8 +28,6 @@ void Box::paint(PaintContext& context, PaintPhase phase)
     if (is_fixed_position())
     if (is_fixed_position())
         context.painter().translate(context.scroll_offset());
         context.painter().translate(context.scroll_offset());
 
 
-    auto padded_rect = this->padded_rect();
-
     if (phase == PaintPhase::Background) {
     if (phase == PaintPhase::Background) {
         paint_background(context);
         paint_background(context);
         paint_box_shadow(context);
         paint_box_shadow(context);
@@ -50,7 +48,7 @@ void Box::paint(PaintContext& context, PaintPhase phase)
         margin_rect.set_height(height() + margin_box.top + margin_box.bottom);
         margin_rect.set_height(height() + margin_box.top + margin_box.bottom);
 
 
         context.painter().draw_rect(enclosing_int_rect(margin_rect), Color::Yellow);
         context.painter().draw_rect(enclosing_int_rect(margin_rect), Color::Yellow);
-        context.painter().draw_rect(enclosing_int_rect(padded_rect), Color::Cyan);
+        context.painter().draw_rect(enclosing_int_rect(padded_rect()), Color::Cyan);
         context.painter().draw_rect(enclosing_int_rect(content_rect), Color::Magenta);
         context.painter().draw_rect(enclosing_int_rect(content_rect), Color::Magenta);
     }
     }