|
@@ -7,6 +7,7 @@
|
|
|
#include <LibHTML/HtmlView.h>
|
|
|
#include <LibHTML/Layout/LayoutBlock.h>
|
|
|
#include <LibHTML/Layout/LayoutInline.h>
|
|
|
+#include <LibHTML/Layout/LayoutNode.h>
|
|
|
#include <LibHTML/Parser/CSSParser.h>
|
|
|
#include <LibHTML/Parser/HTMLParser.h>
|
|
|
#include <stdio.h>
|
|
@@ -15,26 +16,32 @@ int main(int argc, char** argv)
|
|
|
{
|
|
|
GApplication app(argc, argv);
|
|
|
|
|
|
- auto f = CFile::construct(argc == 1 ? "/home/anon/small.html" : argv[1]);
|
|
|
- if (!f->open(CIODevice::ReadOnly)) {
|
|
|
+ auto f = CFile::construct();
|
|
|
+ bool success;
|
|
|
+ if (argc < 2) {
|
|
|
+ success = f->open(STDIN_FILENO, CIODevice::OpenMode::ReadOnly, CFile::ShouldCloseFileDescription::No);
|
|
|
+ } else {
|
|
|
+ f->set_filename(argv[1]);
|
|
|
+ success = f->open(CIODevice::OpenMode::ReadOnly);
|
|
|
+ }
|
|
|
+ if (!success) {
|
|
|
fprintf(stderr, "Error: %s\n", f->error_string());
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
extern const char default_stylesheet_source[];
|
|
|
String css = default_stylesheet_source;
|
|
|
-
|
|
|
auto sheet = parse_css(css);
|
|
|
- dump_sheet(sheet);
|
|
|
|
|
|
String html = String::copy(f->read_all());
|
|
|
auto document = parse_html(html);
|
|
|
- dump_tree(document);
|
|
|
+ document->normalize();
|
|
|
document->add_sheet(*sheet);
|
|
|
|
|
|
auto window = GWindow::construct();
|
|
|
auto widget = HtmlView::construct();
|
|
|
widget->set_document(document);
|
|
|
+ window->set_title("HTML");
|
|
|
window->set_main_widget(widget);
|
|
|
window->show();
|
|
|
|