Commit graph

4618 commits

Author SHA1 Message Date
Andreas Kling
749e3f0f30 LibHTML: Add LayoutNodeWithStyle class, make LayoutText style-less
Since LayoutText always inherits style, it shouldn't store any style of
its own. This patch adds a LayoutNodeWithStyle class to sit between
LayoutNode and everyone who wants to inherit from LayoutNode except
LayoutText :^)

Since LayoutText can never have children, we also know that the parent
of any LayoutNode is always going to be a LayoutNodeWithStyle.
So this patch makes LayoutNode::parent() return LayoutNodeWithStyle*.
2019-10-07 10:56:44 +02:00
Andreas Kling
15f3e64862 LibHTML: Rename "style_properties" to "style" everywhere 2019-10-07 10:56:44 +02:00
supercomputer7
de49714f36 PartitionTable: Initial GPT Support, Adding Block Limit
Also added a script to handle creation of GPT partitioned disk (with
GRUB config file). Block limit will be used to disallow potential access
to other partitions.
2019-10-07 10:11:39 +02:00
Andreas Kling
b5a043cf42 Browser: Add a simple "Go home" button to the toolbar
Currently this just takes us to /home/anon/www/welcome.html :^)
2019-10-06 22:03:41 +02:00
Andreas Kling
ac3079b433 LibGUI: Add "Go home" to GCommonActions 2019-10-06 22:00:04 +02:00
Andreas Kling
122d12e617 LibDraw: Parse some more color string formats found on the web
This patch adds the 17 color names from CSS2.1, as well as support for
the "#rgb" shorthand where each component is a hex digit that gets
multiplied by 17.
2019-10-06 21:40:14 +02:00
Andreas Kling
66caa7af2b LibHTML: Optionally pass document URL to the HTML parser
This makes the document URL available to all the parse_attributes()
callbacks, in case they need it for anything.
2019-10-06 21:13:24 +02:00
Andreas Kling
a239ef34d5 LibHTML: Add Node::first_ancestor_of_type<T>()
Here's another helper for finding the first ancestor of a Node of a
specific type.
2019-10-06 21:07:36 +02:00
Andreas Kling
03725c6135 GFilePicker: Fix crash in get_save_filepath()
Oops, don't create GFilePickers on the stack! Spotted by Sergey ^)
2019-10-06 21:01:03 +02:00
Andreas Kling
3bee9d3d3c LibHTML: Templatize Node::first_child_of_type<T>()
This is a lot nicer than first_child_with_tag_name(...).

The is<T>(Node) functions are obviously unoptimized at the moment,
and this is about establishing pleasant patterns right now. :^)
2019-10-06 20:47:57 +02:00
Andreas Kling
f52f2736e1 LibHTML: Add is<ElementType> and to<ElementType> helper functions
These will help us write node-type-aware template functions.
2019-10-06 20:38:26 +02:00
Andreas Kling
bedb00603c LibHTML: Add adjacent (+) and general (~) sibling combinators
This patch implements two more selector features:

- "div + p" matches the <p> sibling immediately after a <div>.
- "div ~ p" matches all <p> siblings after a <div>.
2019-10-06 19:59:07 +02:00
Andreas Kling
5a6c36dc91 LibHTML: Add Node::{next,previous}_element_sibling()
These helpers return the next/previous sibling Node that's actually an
element. This will be useful in the CSS engine since CSS doesn't care
about text nodes.
2019-10-06 19:54:50 +02:00
Andreas Kling
cad326f323 LibHTML: Implement immediate-child selectors (#foo > #bar) 2019-10-06 15:41:16 +02:00
Andreas Kling
156b35742a LibHTML: Implement matching for descendant selectors
The CSS engine now correctly matches selectors like "#foo #bar #baz".
2019-10-06 15:34:42 +02:00
Andreas Kling
b587eb2f4d LibHTML: Fall back to the system default font if we can't find a font
Instead of crashing when we don't have some font the CSS wanted,
just go with Font::default_font().
2019-10-06 14:57:49 +02:00
Andreas Kling
769f86ff9c LibHTML: Add a little bit of margin around <hr> elements 2019-10-06 14:44:18 +02:00
Conrad Pankoff
2cf5d69a67 LibHTML: Use current style's text colour for alt text on images 2019-10-06 14:33:00 +02:00
Conrad Pankoff
451730000c LibHTML: Trim image alt text to the right if necessary 2019-10-06 14:33:00 +02:00
Conrad Pankoff
6eef6f4f1d Base: Add a page for image features to the www directory 2019-10-06 14:33:00 +02:00
Conrad Pankoff
b240500107 LibHTML: Support width/height attributes on images 2019-10-06 14:33:00 +02:00
Conrad Pankoff
088237a25f LibHTML: Draw image alt text as black rather than white 2019-10-06 14:33:00 +02:00
Conrad Pankoff
5f6903a714 LibHTML: Use image URL as alt text if alt is missing 2019-10-06 14:33:00 +02:00
Conrad Pankoff
1ef53be2f3 LibHTML: Load image resource when src attribute is set 2019-10-06 14:33:00 +02:00
Conrad Pankoff
ef8b754a46 LibHTML: Add function for invalidating the document layout
This allows any external actor to signal that the document layout may be
stale. This can be used when loading resources, changing the size or
placement of an element, adding/removing nodes, or really any time.
2019-10-06 14:33:00 +02:00
Conrad Pankoff
15a016d3e3 Browser: Support opening a URL from the command line at startup 2019-10-06 14:25:58 +02:00
Conrad Pankoff
c4da2a49a5 LibGUI: Define supported functions for using command line arguments 2019-10-06 14:25:58 +02:00
Andreas Kling
fabc717b39 LibHTML: Make the text-decoration inheritance quirk actually work
Things work better if you spell things correctly, oops!

This fixes an issue in Help where parts of links were missing their
underline decoration.
2019-10-06 11:48:53 +02:00
Andreas Kling
ef0613ea4c LibHTML: Unbreak parsing of standalone declarations
Oops, I forgot to update CSSParser::parse_standalone_declaration()
after making parse_property() return a property (or {} for failure.)
2019-10-06 11:43:38 +02:00
Andreas Kling
b9557bf876 LibHTML: Move font loading from LayoutText to StyleProperties
Since LayoutText inherits all of its style information from its parent
Element anyway, it makes more sense to load the font at a higher level.

And since the font depends only on the style and nothing else, this
patch moves font loading (and caching) into StyleProperties. This could
be made a lot smarter to avoid loading the same font many times, etc.
2019-10-06 11:26:34 +02:00
Andreas Kling
c8e5039418 LibHTML: LayoutInline can only be constructed with an Element
Since LayoutText no longer inherits from LayoutInline, all of the
DOM nodes with a LayoutInline are going to be Elements.
2019-10-06 11:26:34 +02:00
Andreas Kling
1b7aa00768 LibHTML: LayoutText should inherit from LayoutNode directly
There's no need for LayoutText to inherit from LayoutInline.
I had the wrong idea here: I was thinking that everything that can be
laid out inline should inherit from LayoutInline, but that's clearly
not sufficient for something like LayoutReplaced which can be laid out
in either way.
2019-10-06 11:26:31 +02:00
Andreas Kling
2a266db05b LibHTML: Parse descendant relations in CSS selectors
"div p" now generates a Selector with two components where the second
component is a type=TagName, value="p", relation=Descendant.

We still don't handle matching of these, but at least we parse them.
2019-10-06 11:07:57 +02:00
Andreas Kling
847072c2b1 LibHTML: Respect the link color set via <body link>
The default style for "a" tags now has { color: -libhtml-link; }.
We implement this vendor-specific property by querying the containing
document for the appropriate link color.

Currently we only use the basic link color, but in the future this can
be extended to remember visited links, etc.
2019-10-06 10:25:08 +02:00
Andreas Kling
83a6474d82 LibHTML: Parse link, alink and vlink in <body> and pass to Document
This patch adds HTMLBodyElement::parse_attribute() where we extract the
link colors and stash them away on Document.
2019-10-06 10:11:54 +02:00
Andreas Kling
772718b8d8 LibHTML: Add a per-attribute callback for Elements to parse attributes
Elements now have a virtual parse_attribute(name, value) callback that
gets invoked for each one of its attributes.
2019-10-06 10:09:55 +02:00
Andreas Kling
306b9dfb51 LibHTML: Various little improvements to the CSS parser
The parser now kinda recognizes immediate child selectors, !important,
and various other little things.

It's still extremely far from robust and/or correct. :^)
2019-10-06 09:28:58 +02:00
Andreas Kling
48f43a7429 LibHTML: Anonymous blocks *should* inherit some properties
Okay, I got that a bit wrong. Here's what CSS 2.1 says:

"The properties of anonymous boxes are inherited from the enclosing
non-anonymous box. Non-inherited properties have their initial value."

This patch implements a better behavior by only copying the inherited
properties from the parent style.
2019-10-05 23:47:06 +02:00
Andreas Kling
958b395418 LibHTML: Support rendering <img src> with file:// URLs
We can now show images loaded from local file:// URLs. Pretty neat :^)
2019-10-05 23:41:14 +02:00
Andreas Kling
9858e2632c LibHTML: Let's not have anonymous blocks inherit their parent's style
This was introducing a bunch of unwanted margins.
2019-10-05 23:29:01 +02:00
Andreas Kling
ee567cdc3d LibHTML: Implement basic layout for inline <img alt>
LayoutReplaced objects can now participate in inline layout.

It's very hackish, but basically LayoutReplaced will just add itself to
the last line in the containing block.

This patch gets rid of the idea that only LayoutInline subclasses can
be split into lines, by moving the split_into_lines() virtual up to
LayoutNode and overriding it in LayoutReplaced.
2019-10-05 23:29:01 +02:00
Andreas Kling
f150134de9 LibHTML: Make Node::create_layout_node() virtual
Instead of branching on the Node type, let subclasses decide how their
layout nodes get constructed.

This will allow elements to create custom layout nodes if they want.
2019-10-05 23:29:01 +02:00
Andreas Kling
09dccb3224 LibHTML: Flesh out <img> element with LayoutImage and LayoutReplaced
This patch adds parsing of <img> into HTMLImageElement objects.
It also adds LayoutImage and its parent class LayoutReplaced, which is
going to represent CSS "replaced elements."
2019-10-05 23:29:01 +02:00
Vincent Sanders
7162347563 Ports: Add zlib port 2019-10-05 22:37:04 +02:00
Andreas Kling
56d1ae98bc LibHTML: Always fill the entire paint event rect with background
And do the filling before translating the painter.

This fixes a bug where scrolling down in the Help app would render the
bottom part of the page with a different background color.
2019-10-05 21:53:09 +02:00
Andreas Kling
4173c77eb5 Browser: Show the page title in the window title bar :^) 2019-10-05 10:30:49 +02:00
Andreas Kling
a8297657ab LibHTML: Fire the HtmlView::on_title_change hook after a load finishes 2019-10-05 10:30:14 +02:00
Andreas Kling
31e361b827 Base: Add a little welcome page for the browser at ~/www/welcome.html 2019-10-05 10:29:52 +02:00
Andreas Kling
319f0d2d18 LibHTML: Render list markers in the same color as text 2019-10-05 10:27:59 +02:00
Andreas Kling
0a38e0028f Browser: Start working on a simple browser using LibHTML
This was inevitable. :^)
2019-10-05 10:20:17 +02:00