瀏覽代碼

LibWeb: Make hit testing better for blocks with inline children

If we don't hit one of the inline children, we should still report that
we've hit the block itself.
Andreas Kling 5 年之前
父節點
當前提交
03ec57b271
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      Libraries/LibWeb/Layout/LayoutBlock.cpp

+ 4 - 1
Libraries/LibWeb/Layout/LayoutBlock.cpp

@@ -359,7 +359,10 @@ HitTestResult LayoutBlock::hit_test(const Gfx::Point& position) const
             }
             }
         }
         }
     }
     }
-    return {};
+
+    // FIXME: This should be smarter about the text position if we're hitting a block
+    //        that has text inside it, but `position` is to the right of the text box.
+    return { rect().contains(position.x(), position.y()) ? this : nullptr };
 }
 }
 
 
 NonnullRefPtr<StyleProperties> LayoutBlock::style_for_anonymous_block() const
 NonnullRefPtr<StyleProperties> LayoutBlock::style_for_anonymous_block() const