1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:48:11 +00:00

LibHTML: Implement the <br> element for line breaking

The <br> element will produce a special LayoutBreak node in the layout
tree, which forces a break in the line layout whenever encountered.

This patch also makes LayoutBlock use the current line-height as the
minimum effective height for each line box. This ensures that having
multiple <br> elements in a row doesn't create 0-height line boxes.
This commit is contained in:
Andreas Kling 2019-10-12 13:47:49 +02:00
parent bf79b198f6
commit 6242459c0f
9 changed files with 89 additions and 1 deletions

View file

@ -1,5 +1,6 @@
#include <LibHTML/DOM/ElementFactory.h>
#include <LibHTML/DOM/HTMLAnchorElement.h>
#include <LibHTML/DOM/HTMLBRElement.h>
#include <LibHTML/DOM/HTMLBlinkElement.h>
#include <LibHTML/DOM/HTMLBodyElement.h>
#include <LibHTML/DOM/HTMLFontElement.h>
@ -37,6 +38,8 @@ NonnullRefPtr<Element> create_element(Document& document, const String& tag_name
return adopt(*new HTMLImageElement(document, lowercase_tag_name));
if (lowercase_tag_name == "blink")
return adopt(*new HTMLBlinkElement(document, lowercase_tag_name));
if (lowercase_tag_name == "br")
return adopt(*new HTMLBRElement(document, lowercase_tag_name));
if (lowercase_tag_name == "h1"
|| lowercase_tag_name == "h2"
|| lowercase_tag_name == "h3"