Commit graph

4429 commits

Author SHA1 Message Date
Andreas Kling
93230386f7 Build: Add Libraries/LibHTML/ to the library search paths
This makes my hacky incremental rebuild commands work for LibHTML.
2019-09-29 16:20:54 +02:00
Andreas Kling
99fc7033b5 AK: Add StringBuilder::length() and trim(int)
Sometimes you want to trim a byte or two off the end.
2019-09-29 16:20:09 +02:00
Andreas Kling
b5c587a106 Base: Add some title attributes to the small HTML test file :^) 2019-09-29 12:26:15 +02:00
Andreas Kling
5b942b519c LibHTML: Add HTMLHeadingElement for <h1> through <h6> 2019-09-29 12:26:15 +02:00
Andreas Kling
f38b0f667e LibHTML: Implement basic HTMLElement.title support
We now show a tooltip for the hovered node's enclosing HTML element's
title attribute, if one is present.

This patch also adds HTMLHeadingElement. The tags h1-h6 will now create
the right kind of objects.
2019-09-29 12:26:13 +02:00
Andreas Kling
92aae72025 LibHTML: Detect link clicks
Clicking on a link in an HtmlView will now call on_link_click(String)
if present, allowing you to implement basic hypertext navigation. :^)
2019-09-29 12:04:02 +02:00
Andreas Kling
b477aff843 LibHTML: Detect hovering over links
HtmlView now calls Node::enclosing_link_element() to find the nearest
ancestor <a> element.

This patch also adds HTMLElement and HTMLAnchorElement.
2019-09-29 11:59:38 +02:00
Andreas Kling
88de955073 LibHTML: Have Document track its hovered Node
This gets set from HtmlView::mousemove_event() at the moment.
2019-09-29 11:50:35 +02:00
Andreas Kling
754e6e0f67 LibHTML: Add LayoutNode::document() for easy access
Every LayoutNode indirectly belongs to some Document. For anonymous
LayoutNodes, we simply traverse the parent chain until we find someone
with a Node from which we can get a Document&.
2019-09-29 11:43:33 +02:00
Andreas Kling
1b8509a0c9 LibHTML: Make sure every DOM Node belongs to a Document 2019-09-29 11:43:07 +02:00
Andreas Kling
13860e4dd8 LibHTML: Make hit testing work for LayoutText
LayoutText can't simply rely on its LayoutNode::rect() for hit testing.
Instead, we have to iterate over the individual runs and see if we're
hitting any of them.

Also, LayoutNode::hit_test() now always recurses into children, since
we can't trust the rect() to tell the truth (inline rects are wrong.)
2019-09-29 11:32:00 +02:00
Brandon Scott
aac8b091a4 LibDraw: Implemented support for more PNG formats (#614)
- Implemented support for more PNG formats including 16-bit per channel
  and 8-bit indexed with palette.
- Made the library a little more resistant to crashes by returning
  false for known but unsupported formats.
2019-09-29 09:55:28 +02:00
Andreas Kling
dba74abe93 Base: Fix minor typos in man pages 2019-09-28 23:06:22 +02:00
Andreas Kling
3de4b99dc3 LibHTML: Implement naive hit testing
We don't have proper line boxes yet, so we can't easily hit test
inline text.
2019-09-28 23:04:59 +02:00
Andreas Kling
3ed41abba4 Base: Add a little hyperlink to the small HTML test page
This will be useful for testing rendering, hit testing, etc.
2019-09-28 23:00:47 +02:00
Andreas Kling
fb4702dd49 LibHTML: Add virtual Node::tag_name()
This is analogous to the DOM's Node.tagName and makes it easy to ask
"hey, what kinda thing is this Node?"
2019-09-28 22:59:16 +02:00
Andreas Kling
a768724270 LibHTML: Make <a> tags blue and underline by default
In the future, this should only apply to "a:link", but since we don't
have pseudo-classes yet, all "a" tags will do for now.
2019-09-28 22:57:46 +02:00
Andreas Kling
8271ad40a5 LibHTML: Implement basic support for "text-decoration: underline" 2019-09-28 22:57:46 +02:00
Andreas Kling
62cbaa74f3 LibHTML: Respect the CSS "color" property for text
Also remove the color values from the ComputedStyle object and get them
via StyleProperties instead.

At the moment, we only handle colors that Color::from_string() parses.
2019-09-28 22:57:46 +02:00
Andreas Kling
b8cab2a934 Meta: Tweak the Qt Creator project updater a bit 2019-09-28 22:57:46 +02:00
Larkin Nickle
ab67f74588 TelnetServer: Accept arbitrary command with -c
For example, this allows you to do something like
`TelnetServer -c /usr/bin/nyancat` to have the TelnetServer run
`/usr/bin/nyancat` instead of `/bin/Shell`.
2019-09-28 22:37:14 +02:00
Sergey Bugaev
801fe7beac SystemMonitor: Display whether an fd is cloexec and blocking 2019-09-28 22:27:45 +02:00
Sergey Bugaev
9a41dda029 Kernel: Expose blocking and cloexec fd flags in ProcFS 2019-09-28 22:27:45 +02:00
Andreas Kling
eb18825fce Base: Add man pages for create_shared_buffer() and share_buffer_with() 2019-09-28 21:16:26 +02:00
Andreas Kling
d43c7d55f4 LibMarkdown: Support escaping of special characters
This allows you to escape function\_names\_like\_this() :^)
2019-09-28 20:51:46 +02:00
Andreas Kling
83f643d43c LibHTML: Make h1 and h2 tags use Pebbleton Bold by default :^) 2019-09-28 19:14:36 +02:00
Andreas Kling
5673ff3694 Base: Add a bold variant of the Pebbleton 11px font 2019-09-28 19:14:23 +02:00
Andreas Kling
09ad58f837 Help: Don't crash on startup when non-md man pages are present :^) 2019-09-28 18:38:27 +02:00
Sergey Bugaev
02ee8cbbe2 Applications: Add a new Help app
This is a neat simple app that can display the Serenity manual ^)
2019-09-28 18:29:42 +02:00
Sergey Bugaev
6ec625d6f3 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.
2019-09-28 18:29:42 +02:00
Sergey Bugaev
b9493ba783 LibHTML: Introduce the HtmlView widget
This is a GWidget that can display contents of an HTML document.
It replaces the Frame class.
2019-09-28 18:29:42 +02:00
Sergey Bugaev
8a2beaf52b LibHTML: Tweak the default CSS style 2019-09-28 18:29:42 +02:00
Sergey Bugaev
db8a1a6aba LibHTML: Parse HTML escape sequences 2019-09-28 18:29:42 +02:00
Sergey Bugaev
6491493e26 LibHTML: Hide debugging output unless HTML_DEBUG is defined 2019-09-28 18:29:42 +02:00
Sergey Bugaev
235dee8c42 LibHTML: Implement rendering 2019-09-28 18:29:42 +02:00
Sergey Bugaev
93003bfda1 LibHTML: Implement LayoutText 2019-09-28 18:29:42 +02:00
Sergey Bugaev
9f8d776c70 LibHTML: Implement LayoutInline::layout()
This currently uses a gross hack where it subtracts 11px from the
previous sibling bottom to calculate its top. This should be fixed
by switching to a proper two-phase line layouting model, were we
first distribute inline elements into lines and figure out their
horizontal positions and heights; then compute the needed line
heights and position inline elements there vertically.
2019-09-28 18:29:42 +02:00
Sergey Bugaev
03cca4510a LibHTML: Fix LayoutDocument height computation 2019-09-28 18:29:42 +02:00
Sergey Bugaev
fa876320eb LibHTML: Fix LayoutBlock vertical position & height computations 2019-09-28 18:29:42 +02:00
Sergey Bugaev
c1ef63379c LibHTML: Add Document::normalize()
This method wraps the document tree in <html> and <body> elements if needed.
2019-09-28 18:29:42 +02:00
Sergey Bugaev
599edba7a3 LibHTML: Move layout tree building to Node
This also fixes another bug with inline wrappers. Namely,
we should only add inline wrappers if a block node has
both non-block (inline or text) and block children.
2019-09-28 18:29:42 +02:00
Sergey Bugaev
841ae44392 LibHTML: Implement basic style inheritance 2019-09-28 18:29:42 +02:00
Sergey Bugaev
3be897a3d5 LibHTML: Add ComputedStyle::full_margin()
This is an utility to easily get the full margin size
(the sum of margin proper, border and padding) of an
element in pixels.
2019-09-28 18:29:42 +02:00
Sergey Bugaev
a42f4c078e LibHTML: Get rid of ComputedStyle::offset()
This is redundant since we already have LayoutNode::rect().
2019-09-28 18:29:42 +02:00
Sergey Bugaev
756bdb2a42 LibHTML: Fix moving inline elements to unrelated block elements
LayoutBlock::inline_wrapper() is supposed to return an inline wrapper,
a special anonymous block element intended to wrap inline children of
a block element that also has block children. Add a check for whether
the existing block child element is anonymous (refers to a DOM node),
and if it's not create a new anonymous wrapper.
2019-09-28 18:29:42 +02:00
Sergey Bugaev
08c751d130 LibHTML: Add StyleProperties::string_or_fallback()
This is an utility to go with the existing length_or_fallback().
2019-09-28 18:29:42 +02:00
Sergey Bugaev
08d9883306 AK: Add StringBuilder::string_view() and StringBuilder::clear()
The former allows you to inspect the string while it's being built.
It's an explicit method rather than `operator StringView()` because
you must remember you can only look at it in between modifications;
appending to the StringBuilder invalidates the StringView.

The latter lets you clear the state of a StringBuilder explicitly, to
start from an empty string again.
2019-09-28 18:29:42 +02:00
Sergey Bugaev
fd0aa5dd43 LibHTML: Get rid of the style tree
We now create a layout tree directly from the DOM tree.
This way we don't actually lose text nodes ^)
2019-09-28 18:29:42 +02:00
Sergey Bugaev
a9ebd676e5 LibHTML: Add install.sh 2019-09-28 18:29:42 +02:00
Sergey Bugaev
fed96f455d Base: Write some initial man pages
It ain't much, but it's honest work!
2019-09-28 18:29:42 +02:00