diff --git a/Libraries/LibHTML/CSS/Default.css b/Libraries/LibHTML/CSS/Default.css index b73d249a45..956a63942d 100644 --- a/Libraries/LibHTML/CSS/Default.css +++ b/Libraries/LibHTML/CSS/Default.css @@ -89,3 +89,9 @@ a { color: #0000ff; text-decoration: underline; } + +hr { + border-width: 1; + border-color: #888888; + border-style: inset; +} diff --git a/Libraries/LibHTML/DOM/HTMLHRElement.cpp b/Libraries/LibHTML/DOM/HTMLHRElement.cpp new file mode 100644 index 0000000000..74533fd965 --- /dev/null +++ b/Libraries/LibHTML/DOM/HTMLHRElement.cpp @@ -0,0 +1,10 @@ +#include + +HTMLHRElement::HTMLHRElement(Document& document, const String& tag_name) + : HTMLElement(document, tag_name) +{ +} + +HTMLHRElement::~HTMLHRElement() +{ +} diff --git a/Libraries/LibHTML/DOM/HTMLHRElement.h b/Libraries/LibHTML/DOM/HTMLHRElement.h new file mode 100644 index 0000000000..05f28babea --- /dev/null +++ b/Libraries/LibHTML/DOM/HTMLHRElement.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +class HTMLHRElement : public HTMLElement { +public: + HTMLHRElement(Document&, const String& tag_name); + virtual ~HTMLHRElement() override; +}; diff --git a/Libraries/LibHTML/Layout/LayoutNode.cpp b/Libraries/LibHTML/Layout/LayoutNode.cpp index 79a4173530..e73c791901 100644 --- a/Libraries/LibHTML/Layout/LayoutNode.cpp +++ b/Libraries/LibHTML/Layout/LayoutNode.cpp @@ -56,13 +56,34 @@ void LayoutNode::render(RenderingContext& context) auto border_width_value = style_properties().property("border-width"); auto border_color_value = style_properties().property("border-color"); + auto border_style_value = style_properties().property("border-style"); if (border_width_value.has_value() && border_color_value.has_value()) { int border_width = border_width_value.value()->to_length().to_px(); Color border_color = border_color_value.value()->to_color(); - context.painter().draw_line(padded_rect.top_left(), padded_rect.top_right(), border_color, border_width); - context.painter().draw_line(padded_rect.top_right(), padded_rect.bottom_right(), border_color, border_width); - context.painter().draw_line(padded_rect.bottom_right(), padded_rect.bottom_left(), border_color, border_width); - context.painter().draw_line(padded_rect.bottom_left(), padded_rect.top_left(), border_color, border_width); + + if (border_style_value.has_value() && border_style_value.value()->to_string() == "inset") { + // border-style: inset + auto shadow_color = Color::from_rgb(0x888888); + auto highlight_color = Color::from_rgb(0x5a5a5a); + context.painter().draw_line(padded_rect.top_left(), padded_rect.top_right(), highlight_color, border_width); + context.painter().draw_line(padded_rect.top_right(), padded_rect.bottom_right(), shadow_color, border_width); + context.painter().draw_line(padded_rect.bottom_right(), padded_rect.bottom_left(), shadow_color, border_width); + context.painter().draw_line(padded_rect.bottom_left(), padded_rect.top_left(), highlight_color, border_width); + } else if (border_style_value.has_value() && border_style_value.value()->to_string() == "outset") { + // border-style: outset + auto highlight_color = Color::from_rgb(0x888888); + auto shadow_color = Color::from_rgb(0x5a5a5a); + context.painter().draw_line(padded_rect.top_left(), padded_rect.top_right(), highlight_color, border_width); + context.painter().draw_line(padded_rect.top_right(), padded_rect.bottom_right(), shadow_color, border_width); + context.painter().draw_line(padded_rect.bottom_right(), padded_rect.bottom_left(), shadow_color, border_width); + context.painter().draw_line(padded_rect.bottom_left(), padded_rect.top_left(), highlight_color, border_width); + } else { + // border-style: solid + context.painter().draw_line(padded_rect.top_left(), padded_rect.top_right(), border_color, border_width); + context.painter().draw_line(padded_rect.top_right(), padded_rect.bottom_right(), border_color, border_width); + context.painter().draw_line(padded_rect.bottom_right(), padded_rect.bottom_left(), border_color, border_width); + context.painter().draw_line(padded_rect.bottom_left(), padded_rect.top_left(), border_color, border_width); + } } // TODO: render our border diff --git a/Libraries/LibHTML/Makefile.shared b/Libraries/LibHTML/Makefile.shared index 43a6f33500..0f90ab67d2 100644 --- a/Libraries/LibHTML/Makefile.shared +++ b/Libraries/LibHTML/Makefile.shared @@ -6,6 +6,7 @@ LIBHTML_OBJS = \ DOM/HTMLAnchorElement.o \ DOM/HTMLHeadingElement.o \ DOM/HTMLHeadElement.o \ + DOM/HTMLHRElement.o \ DOM/HTMLHtmlElement.o \ DOM/HTMLStyleElement.o \ DOM/HTMLTitleElement.o \ diff --git a/Libraries/LibHTML/Parser/HTMLParser.cpp b/Libraries/LibHTML/Parser/HTMLParser.cpp index 079d45173b..afb83e0e67 100644 --- a/Libraries/LibHTML/Parser/HTMLParser.cpp +++ b/Libraries/LibHTML/Parser/HTMLParser.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,8 @@ static NonnullRefPtr create_element(Document& document, const String& t return adopt(*new HTMLHtmlElement(document, tag_name)); if (lowercase_tag_name == "head") return adopt(*new HTMLHeadElement(document, tag_name)); + if (lowercase_tag_name == "hr") + return adopt(*new HTMLHRElement(document, tag_name)); if (lowercase_tag_name == "style") return adopt(*new HTMLStyleElement(document, tag_name)); if (lowercase_tag_name == "title")