فهرست منبع

LibWeb: Make Node::paintable_box() go directly to the paintable

No need to go via the layout tree here, that's a vestige of an earlier
architecture limitation.
Andreas Kling 1 سال پیش
والد
کامیت
b0afe8463a
1فایلهای تغییر یافته به همراه7 افزوده شده و 10 حذف شده
  1. 7 10
      Userland/Libraries/LibWeb/DOM/Node.cpp

+ 7 - 10
Userland/Libraries/LibWeb/DOM/Node.cpp

@@ -43,6 +43,7 @@
 #include <LibWeb/Layout/TextNode.h>
 #include <LibWeb/Layout/Viewport.h>
 #include <LibWeb/Painting/Paintable.h>
+#include <LibWeb/Painting/PaintableBox.h>
 
 namespace Web::DOM {
 
@@ -1521,20 +1522,16 @@ Painting::Paintable* Node::paintable()
 
 Painting::PaintableBox const* Node::paintable_box() const
 {
-    if (!layout_node())
-        return nullptr;
-    if (!layout_node()->is_box())
-        return nullptr;
-    return static_cast<Layout::Box const&>(*layout_node()).paintable_box();
+    if (paintable() && paintable()->is_paintable_box())
+        return static_cast<Painting::PaintableBox const*>(paintable());
+    return nullptr;
 }
 
 Painting::PaintableBox* Node::paintable_box()
 {
-    if (!layout_node())
-        return nullptr;
-    if (!layout_node()->is_box())
-        return nullptr;
-    return static_cast<Layout::Box&>(*layout_node()).paintable_box();
+    if (paintable() && paintable()->is_paintable_box())
+        return static_cast<Painting::PaintableBox*>(paintable());
+    return nullptr;
 }
 
 // https://dom.spec.whatwg.org/#queue-a-mutation-record