Commit graph

4581 commits

Author SHA1 Message Date
Andreas Kling
19dbfc3153 LibHTML: Move selector matching into a SelectorEngine namespace 2019-10-08 15:35:05 +02:00
Jesse Buhagiar
06b6af61c6 Kernel: Made DiskCache entries a KBuffer
The Cache entries found in `DiskBackedFileSystem` are now stored in a
`KBuffer` object, instead of relying on `kmalloc_eternal`. The number
of entries was exceeding that of the number of bytes allocated to
`kmalloc_eternal`, which in turn caused `mount()` to fail epically
when called.
2019-10-08 11:10:30 +02:00
Andreas Kling
1ce8a175e1 FileManager: Add "Open in TextEditor..." action to context menu 2019-10-07 20:03:19 +02:00
Andreas Kling
5da385c16e Browser: Turn command-line path arguments into file:// URLs 2019-10-07 20:02:29 +02:00
Andreas Kling
90cd363a8e FileManager: Open .html files in Browser instead of "html" 2019-10-07 19:52:35 +02:00
Andreas Kling
6287c2b270 LibHTML: Don't crash when calling set_document(nullptr) 2019-10-07 19:33:06 +02:00
Andreas Kling
edbf09ea29 LibHTML: Make the CSS and HTML parsers take StringViews
This allows us to avoid unnecessary making unnecessary String copies of
all the source text.
2019-10-07 19:11:33 +02:00
Andreas Kling
71e8ddcd1c LibHTML: Start adding support for <link rel="stylesheet">
This patch adds basic support for external stylesheets. It currently
only works with file:// URLs.

We do a synchronous full relayout after loading a stylesheet, which is
definitely on the aggressive side, but it gives us something to work
on improving. :^)
2019-10-07 19:06:47 +02:00
Drew Stratford
c136fd3fe2 Kernel: Send SIGSEGV on seg-fault
Now programs can catch the SIGSEGV signal when they segfault.

This commit also introduced the send_urgent_signal_to_self method,
which is needed to send signals to a thread when handling exceptions
caused by the same thread.
2019-10-07 16:39:47 +02:00
Drew Stratford
7fc903b97a Kernel: Add exception_code to RegisterDump.
Added the exception_code field to RegisterDump, removing the need
for RegisterDumpWithExceptionCode. To accomplish this, I had to
push a dummy exception code during some interrupt entries to properly
pad out the RegisterDump. Note that we also needed to change some code
in sys$sigreturn to deal with the new RegisterDump layout.
2019-10-07 16:39:47 +02:00
supercomputer7
334e039294 PartitionTable: Removing unnecessary declarations from GPT & MBR classes 2019-10-07 11:32:42 +02:00
Andreas Kling
669ee82546 Lagom: Fix TestApp to build after the CObject ref-counting changes 2019-10-07 10:58:23 +02:00
Andreas Kling
a7f538fb63 AK: Make String compile on platforms where size_t==u32
This kind of thing is a bit annoying. On Serenity, size_t is the same
size as u32, but not the same type. Because of "long" or whatever.
This patch makes String not complain about duplicate overloads.
2019-10-07 10:56:44 +02:00
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