diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2019-09-25 12:45:47 +0300 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-09-28 18:29:42 +0200 |
commit | 6ec625d6f38d93751be44afc79ab713b1cec8f1b (patch) | |
tree | c10c06243179ba637daa1d2a8fa1507dd522e6d8 | |
parent | b9493ba783e833769e04b8276a42be8c18c98339 (diff) | |
download | serenity-6ec625d6f38d93751be44afc79ab713b1cec8f1b.zip |
Userland+LibHTML: Add the html command
This is a simple command that can be used to display HTML from a given
file, or from the standard input, in an HtmlView. It replaces the `tho`
(test HTML output) command.
-rwxr-xr-x | Kernel/build-root-filesystem.sh | 1 | ||||
-rw-r--r-- | Libraries/LibHTML/Makefile | 5 | ||||
-rw-r--r-- | Libraries/LibHTML/Makefile.shared | 7 | ||||
-rw-r--r-- | Userland/Makefile | 2 | ||||
-rw-r--r-- | Userland/html.cpp (renamed from Libraries/LibHTML/test.cpp) | 17 |
5 files changed, 16 insertions, 16 deletions
diff --git a/Kernel/build-root-filesystem.sh b/Kernel/build-root-filesystem.sh index adee3a8a69..703f303ce1 100755 --- a/Kernel/build-root-filesystem.sh +++ b/Kernel/build-root-filesystem.sh @@ -104,7 +104,6 @@ cp ../Servers/AudioServer/AudioServer mnt/bin/AudioServer cp ../Servers/TTYServer/TTYServer mnt/bin/TTYServer cp ../Servers/TelnetServer/TelnetServer mnt/bin/TelnetServer cp ../Shell/Shell mnt/bin/Shell -cp ../Libraries/LibHTML/tho mnt/bin/tho echo "done" echo -n "installing shortcuts... " diff --git a/Libraries/LibHTML/Makefile b/Libraries/LibHTML/Makefile index 1cc579355b..7ff48dd2c5 100644 --- a/Libraries/LibHTML/Makefile +++ b/Libraries/LibHTML/Makefile @@ -2,12 +2,9 @@ include ../../Makefile.common LIBRARY = libhtml.a -all: $(LIBRARY) tho +all: $(LIBRARY) include Makefile.shared -tho: $(TEST_OBJS) $(LIBRARY) - $(LD) -o $@ $(LDFLAGS) -L. $(TEST_OBJS) -lhtml -lgui -ldraw -lcore -lc - $(LIBRARY): $(LIBHTML_OBJS) @echo "LIB $@"; $(AR) rcs $@ $(LIBHTML_OBJS) diff --git a/Libraries/LibHTML/Makefile.shared b/Libraries/LibHTML/Makefile.shared index f55764de55..96d38dd0fc 100644 --- a/Libraries/LibHTML/Makefile.shared +++ b/Libraries/LibHTML/Makefile.shared @@ -26,10 +26,7 @@ LIBHTML_OBJS = \ GENERATED_SOURCES = \ CSS/DefaultStyleSheetSource.cpp -TEST_OBJS = test.o -TEST_PROGRAM = tho - -OBJS = $(EXTRA_OBJS) $(LIBHTML_OBJS) $(TEST_OBJS) +OBJS = $(EXTRA_OBJS) $(LIBHTML_OBJS) LIBRARY = libhtml.a DEFINES += -DUSERLAND @@ -43,5 +40,5 @@ CSS/DefaultStyleSheetSource.cpp: CSS/Default.css Scripts/GenerateStyleSheetSourc -include $(OBJS:%.o=%.d) clean: - @echo "CLEAN"; rm -f $(TEST_PROGRAM) $(LIBRARY) $(OBJS) *.d $(GENERATED_SOURCES) + @echo "CLEAN"; rm -f $(LIBRARY) $(OBJS) *.d $(GENERATED_SOURCES) diff --git a/Userland/Makefile b/Userland/Makefile index 57993debfd..3129a738e0 100644 --- a/Userland/Makefile +++ b/Userland/Makefile @@ -19,7 +19,7 @@ clean: $(APPS) : % : %.o $(OBJS) @echo "LD $@" - @$(LD) -o $@ $(LDFLAGS) $< -lc -lgui -ldraw -laudio -lipc -lthread -lcore -lpcidb -lmarkdown + @$(LD) -o $@ $(LDFLAGS) $< -lc -lhtml -lgui -ldraw -laudio -lipc -lthread -lcore -lpcidb -lmarkdown %.o: %.cpp @echo "CXX $<" diff --git a/Libraries/LibHTML/test.cpp b/Userland/html.cpp index 22f3e3791f..f2d85d51a0 100644 --- a/Libraries/LibHTML/test.cpp +++ b/Userland/html.cpp @@ -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(); |