Andreas Kling
53fae2af4f
LibHTML: Implement basic border rendering
...
We currently assume the border-style is solid, and simply draw a box
around the padded LayoutNode rect. :^)
2019-10-01 20:31:56 +02:00
Andreas Kling
7573e3c46d
LibHTML: Include padding when rendering background colors
2019-10-01 20:25:31 +02:00
Andreas Kling
86b7dd6d5d
LibHTML: Tweak default CSS to bring it a bit closer to HTML4
2019-10-01 20:16:42 +02:00
Andreas Kling
4bfd4dc6c7
AK: Remove empty files JsonArray.cpp and JsonObject.cpp
2019-10-01 11:24:54 +02:00
Andreas Kling
a5e5a3fab7
LibHTML: Implement basic support for inline style attributes
...
You can now style elements with inline styles:
<div style="color: #ff0000">This is red!</div>
Pretty neat :^)
2019-09-30 20:25:33 +02:00
Andreas Kling
b2a0d20580
LibHTML: Refactor the CSS parser into a class
...
Also added a parser function for standalone style declarations.
2019-09-30 20:24:38 +02:00
Andreas Kling
8d797fc62e
LibHTML: Fix incorrect CSS object model
...
A StyleRule has a StyleDeclaration which has many StyleProperty. :^)
2019-09-30 20:06:17 +02:00
Andreas Kling
c9bab8b870
LibHTML: Reduce debug spam in HtmlView mouse event handlers
2019-09-29 18:10:39 +02:00
Andreas Kling
37a37accd4
LibHTML: Implement basic support for background-color
2019-09-29 18:05:37 +02:00
Andreas Kling
a4fccc02ec
LibHTML: Add a simple <style> element for inline CSS
2019-09-29 17:45:42 +02:00
Andreas Kling
7912592f89
LibHTML: Add inserted_into() and removed_from() TreeNode callbacks
...
These will be called when a Node or LayoutNode is inserted or removed
from a tree. They get the parent node as an argument.
2019-09-29 17:40:39 +02:00
Andreas Kling
402c6de5c9
LibHTML: Make <div> elements display: block
2019-09-29 17:26:52 +02:00
Andreas Kling
830e18e486
LibHTML: Fix broken parsing of ID and class selectors
...
We were forgetting to consume the '#' and '.' characters.
2019-09-29 17:26:05 +02:00
Andreas Kling
ed39e0f6f7
LibHTML: Non-element (Text) Nodes should get style from their parent
...
Text nodes don't have style of their own, so just inherit all the style
from the parent element.
2019-09-29 17:22:44 +02:00
Andreas Kling
b94c7665a9
LibHTML: Add a way to get a Document's title
...
You can now query Document::title() to get a String containing whatever
is inside the document's <title> tag.
In support of this, this patch adds the <html>, <head> and <title>
elements.
2019-09-29 16:24:57 +02:00
Andreas Kling
0c6af2d5b4
LibHTML: Add Node::text_content()
...
This returns a String built from all of a Node's text descendants,
including itself.
2019-09-29 16:23:09 +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
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
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
83f643d43c
LibHTML: Make h1 and h2 tags use Pebbleton Bold by default :^)
2019-09-28 19:14:36 +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
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
Andreas Kling
8d550c174e
LibCore: Convert CFile to ObjectPtr
2019-09-21 20:50:06 +02:00