Przeglądaj źródła

LibWeb: Layout nodes without own style can't be absolutely positioned

The only layout nodes that don't have their own style are LayoutText
(they inherit the style from their parent element since text cannot
be styled by CSS.)

However, it never makes sense for text nodes to have absolute position
so don't claim it.
Andreas Kling 5 lat temu
rodzic
commit
ce3260c6bf
1 zmienionych plików z 4 dodań i 0 usunięć
  1. 4 0
      Libraries/LibWeb/Layout/LayoutNode.cpp

+ 4 - 0
Libraries/LibWeb/Layout/LayoutNode.cpp

@@ -200,12 +200,16 @@ Gfx::FloatPoint LayoutNode::box_type_agnostic_position() const
 
 bool LayoutNode::is_absolutely_positioned() const
 {
+    if (!has_style())
+        return false;
     auto position = style().position();
     return position == CSS::Position::Absolute || position == CSS::Position::Fixed;
 }
 
 bool LayoutNode::is_fixed_position() const
 {
+    if (!has_style())
+        return false;
     return style().position() == CSS::Position::Fixed;
 }