Просмотр исходного кода

LibWeb: Add debug toggle for dumping gemini documents

Nico Weber 4 лет назад
Родитель
Сommit
fa5217ff4f
1 измененных файлов с 11 добавлено и 2 удалено
  1. 11 2
      Libraries/LibWeb/Loader/FrameLoader.cpp

+ 11 - 2
Libraries/LibWeb/Loader/FrameLoader.cpp

@@ -38,6 +38,8 @@
 #include <LibWeb/Page/Frame.h>
 #include <LibWeb/Page/Frame.h>
 #include <LibWeb/Page/Page.h>
 #include <LibWeb/Page/Page.h>
 
 
+//#define GEMINI_DEBUG 1
+
 namespace Web {
 namespace Web {
 
 
 FrameLoader::FrameLoader(Frame& frame)
 FrameLoader::FrameLoader(Frame& frame)
@@ -115,9 +117,16 @@ static RefPtr<DOM::Document> create_image_document(const ByteBuffer& data, const
 
 
 static RefPtr<DOM::Document> create_gemini_document(const ByteBuffer& data, const URL& url)
 static RefPtr<DOM::Document> create_gemini_document(const ByteBuffer& data, const URL& url)
 {
 {
-    auto gemini_document = Gemini::Document::parse({ (const char*)data.data(), data.size() }, url);
+    StringView gemini_data { data };
+    auto gemini_document = Gemini::Document::parse(gemini_data, url);
+    String html_data = gemini_document->render_to_html();
+
+#if GEMINI_DEBUG
+    dbgln("Gemini data:\n\"\"\"{}\"\"\"", gemini_data);
+    dbgln("Converted to HTML:\n\"\"\"{}\"\"\"", html_data);
+#endif
 
 
-    return HTML::parse_html_document(gemini_document->render_to_html(), url, "utf-8");
+    return HTML::parse_html_document(move(html_data), url, "utf-8");
 }
 }
 
 
 RefPtr<DOM::Document> FrameLoader::create_document_from_mime_type(const ByteBuffer& data, const URL& url, const String& mime_type, const String& encoding)
 RefPtr<DOM::Document> FrameLoader::create_document_from_mime_type(const ByteBuffer& data, const URL& url, const String& mime_type, const String& encoding)