From 6c783dbf625149fc5e8a69c51283d082b6787a68 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 25 Jun 2020 23:47:53 +0200 Subject: [PATCH] IRCClient: Use Web::Element::set_inner_html() Instead of invoking the (old) fragment parser directly. --- Applications/IRCClient/IRCLogBuffer.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Applications/IRCClient/IRCLogBuffer.cpp b/Applications/IRCClient/IRCLogBuffer.cpp index f1c877f16f..da5ad1fef0 100644 --- a/Applications/IRCClient/IRCLogBuffer.cpp +++ b/Applications/IRCClient/IRCLogBuffer.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include NonnullRefPtr IRCLogBuffer::create() @@ -70,17 +69,17 @@ void IRCLogBuffer::add_message(char prefix, const String& name, const String& te { auto nick_string = String::format("<%c%s> ", prefix ? prefix : ' ', name.characters()); auto html = String::format( - "
" "%s" "%s" - "%s" - "
", - color.to_string().characters(), + "%s", timestamp_string().characters(), escape_html_entities(nick_string).characters(), escape_html_entities(text).characters()); - auto fragment = parse_html_fragment(*m_document, html); - m_container_element->append_child(fragment->remove_child(*fragment->first_child())); + + auto wrapper = Web::create_element(*m_document, Web::HTML::TagNames::div); + wrapper->set_attribute(Web::HTML::AttributeNames::style, String::format("color: %s", color.to_string().characters())); + wrapper->set_inner_html(html); + m_container_element->append_child(wrapper); m_document->force_layout(); } @@ -94,8 +93,10 @@ void IRCLogBuffer::add_message(const String& text, Color color) color.to_string().characters(), timestamp_string().characters(), escape_html_entities(text).characters()); - auto fragment = parse_html_fragment(*m_document, html); - m_container_element->append_child(fragment->remove_child(*fragment->first_child())); + auto wrapper = Web::create_element(*m_document, Web::HTML::TagNames::div); + wrapper->set_attribute(Web::HTML::AttributeNames::style, String::format("color: %s", color.to_string().characters())); + wrapper->set_inner_html(html); + m_container_element->append_child(wrapper); m_document->force_layout(); }