summaryrefslogtreecommitdiff
path: root/DevTools
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-21 21:53:10 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-21 21:54:30 +0200
commit2ba9e9b9c98c752a10510744f54396280fa5972c (patch)
tree7f60f033db674667c64eb917bcc022c4bd1e50a2 /DevTools
parent1f97897b4087d1ce5e75650cecf007a0eaa9c34a (diff)
downloadserenity-2ba9e9b9c98c752a10510744f54396280fa5972c.zip
HackStudio: Use Web::PageView::load_html() for the documentation popup
Also simplify the way we change the background color a little bit.
Diffstat (limited to 'DevTools')
-rw-r--r--DevTools/HackStudio/Editor.cpp19
1 files changed, 4 insertions, 15 deletions
diff --git a/DevTools/HackStudio/Editor.cpp b/DevTools/HackStudio/Editor.cpp
index 5cdd2b8828..ebe5b35cc1 100644
--- a/DevTools/HackStudio/Editor.cpp
+++ b/DevTools/HackStudio/Editor.cpp
@@ -41,7 +41,6 @@
#include <LibWeb/DOM/HTMLHeadElement.h>
#include <LibWeb/DOM/Text.h>
#include <LibWeb/PageView.h>
-#include <LibWeb/Parser/HTMLParser.h>
// #define EDITOR_DEBUG
@@ -173,22 +172,12 @@ void Editor::show_documentation_tooltip_if_available(const String& hovered_token
auto html_text = man_document->render_to_html();
- auto html_document = Web::parse_html_document(html_text);
- if (!html_document) {
- dbg() << "failed to parse HTML";
- return;
- }
+ m_documentation_page_view->load_html(html_text, {});
- // FIXME: LibWeb needs a friendlier DOM manipulation API. Something like innerHTML :^)
- auto style_element = create_element(*html_document, "style");
- style_element->append_child(adopt(*new Web::Text(*html_document, "body { background-color: #dac7b5; }")));
-
- // FIXME: This const_cast should not be necessary.
- auto* head_element = const_cast<Web::HTMLHeadElement*>(html_document->head());
- ASSERT(head_element);
- head_element->append_child(style_element);
+ if (auto* document = m_documentation_page_view->document()) {
+ const_cast<Web::HTMLElement*>(document->body())->set_attribute(Web::HTML::AttributeNames::style, "background-color: #dac7b5;");
+ }
- m_documentation_page_view->set_document(html_document);
m_documentation_tooltip_window->move_to(screen_location.translated(4, 4));
m_documentation_tooltip_window->show();