Commit graph

3372 commits

Author SHA1 Message Date
Nico Weber
9abafa2d1c LibC: Make setgid() definition protoype match declaration 2020-06-17 15:08:17 +02:00
Sergey Bugaev
0674d9362b LibGUI: Use Core::File::read_link() 2020-06-17 15:02:03 +02:00
Sergey Bugaev
d89843f96f LibCore: Add File::read_link() :^)
This is a convenient wrapper around readlink() that hides away the details
of buffers and buffer sizes, and simply returns a String. The best part is it
doesn't rely on PATH_MAX :D

It comes in two versions, for Serenity, where we can pass non-null-terminated
strings to syscalls, and where sys$readlink() returns the total link size, and
for other systems, where we have to copy out the string, and always have to do
two syscalls.
2020-06-17 15:02:03 +02:00
Sergey Bugaev
47d83800e1 Kernel+LibC: Do not return -ENAMETOOLONG from sys$readlink()
That's not how readlink() is supposed to work: it should copy as many bytes
as fit into the buffer, and return the number of bytes copied. So do that,
but add a twist: make sys$readlink() actually return the whole size, not
the number of bytes copied. We fix up this return value in userspace, to make
LibC's readlink() behave as expected, but this will also allow other code
to allocate a buffer of just the right size.

Also, avoid an extra copy of the link target.
2020-06-17 15:02:03 +02:00
Andreas Kling
6242e029ed LibWeb: Make Element::tag_name() return a const FlyString&
The more generic virtual variant is renamed to node_name() and now only
Element has tag_name(). This removes a huge amount of String ctor/dtor
churn in selector matching.
2020-06-16 19:09:14 +02:00
Hüseyin ASLITÜRK
7abca30f41 LibVT: Replace u8 type to u32 for code point
Replace KeyEvent text attribute usage with code_point.
2020-06-16 13:15:17 +02:00
Hüseyin ASLITÜRK
53227f400c LibGUI: Replace text attribute on KeyEvent with code_point attribute 2020-06-16 13:15:17 +02:00
Hüseyin ASLITÜRK
25e14911c5 LibKeyboard: Replace char data type to u32 for code point 2020-06-16 13:15:17 +02:00
Nico Weber
d81ac80aba LibC: Declare pthread_sigmask() in signal.h.
That's where it's supposed to be declared.
2020-06-16 09:34:00 +02:00
Hüseyin ASLITÜRK
0799835e15 LibGUI: Use new Bitmap::is_path_a_supported_image_format method 2020-06-15 22:42:23 +02:00
Hüseyin ASLITÜRK
56158a4281 LibGfx: Add a new Bitmap::is_path_a_supported_image_format() method
Move the image file detection code to the File class to prevent code duplication.
2020-06-15 22:42:23 +02:00
Kevin Meyer
17aa917073 LibGUI: Don't update cursor, if visual data out-of-date
This fixes https://github.com/SerenityOS/serenity/issues/2498
A nullptr dereference was caused by the visual data beeing out of sync
with the line data, due to a deferred recompute.
2020-06-15 22:32:18 +02:00
Andreas Kling
49cd03be95 LibWeb: Fix broken parsing of </form> during "in body" insertion 2020-06-15 20:31:19 +02:00
Andreas Kling
9bb4020195 LibWeb: Don't load stylesheets with rel="alternate"
We're not supposed to load these by default. Alternate stylesheets can
be offered in a menu or something, if the user is interested.
2020-06-15 20:31:18 +02:00
Andreas Kling
2f26d4c6a1 LibWeb: Fix broken parsing of </select> during "in select" insertion 2020-06-15 19:57:20 +02:00
Andreas Kling
17d26b92f8 LibWeb: Just ignore <script> elements that failed to load the script
We're never gonna be able to run them if we can't load them so just
let it go.
2020-06-15 18:37:48 +02:00
Andreas Kling
84f8c91a6f LibWeb: Use the URL encoder from AK instead of rolling a custom one 2020-06-15 17:56:00 +02:00
Andreas Kling
d883607e8f LibWeb: Force a full relayout if an element's CSS display changes
Not doing this was causing the wrong kind of LayoutNode to stay around
even though we had the final "display" value.
2020-06-15 17:56:00 +02:00
Andreas Kling
308c3ccc44 LibWeb: Allow block children of inlines
Hey, why not. We did all the hard work for display:inline-block already
and now we can just allow this.

This makes <a><h1>Hello friends!</h1></a> work :^)
2020-06-15 17:56:00 +02:00
Andreas Kling
96da15a8a4 LibWeb: Respect CSS z-index property while painting
To support z-ordering when painting, the layout tree now has a parallel
sparse tree of stacking contexts. The rules for which layout boxes
establish a stacking context are a bit complex, but the intent is to
encapsulate the decision making into establishes_stacking_context().

When we paint, we start from the ICB (LayoutDocument) who always has a
StackingContext and then paint the tree of StackingContexts where each
node has its children sorted by z-index.

This is pretty crude, but gets the basic job done. Note that this does
not yet support hit testing; hit testing is still done using a naive
treewalk from the root.
2020-06-15 17:56:00 +02:00
Andreas Kling
ce3260c6bf LibWeb: Layout nodes without own style can't be absolutely positioned
The only layout nodes that don't have their own style are LayoutText
(they inherit the style from their parent element since text cannot
be styled by CSS.)

However, it never makes sense for text nodes to have absolute position
so don't claim it.
2020-06-15 17:56:00 +02:00
Nico Weber
9825f7792b LibC: Add truncate().
Implemented in user space for now.
2020-06-15 17:34:52 +02:00
Andreas Kling
246e0e47ec LibWeb: Make the specificity sort comparator a bit more readable 2020-06-14 22:09:35 +02:00
Andreas Kling
9ad3e6cd8a LibWeb: Don't assert when containing block doesn't know how to place
We can just log that we don't know what to do for now.
2020-06-14 22:07:00 +02:00
Andreas Kling
0072370459 LibWeb: Don't animate images outside the visible viewport :^) 2020-06-14 19:35:10 +02:00
Andreas Kling
73c9f7ebf4 LibWeb: Move "visible in viewport" state tracking to ImageLoader
This should technically apply to any LayoutImage, so let's just move
it to ImageLoader.
2020-06-14 19:32:23 +02:00
Andreas Kling
c45615128b LibWeb: Move bitmap animation from HTMLImageElement to ImageLoader
Since ImageLoader manages the image decoder anyway, let it manage
animation as well.
2020-06-14 19:26:25 +02:00
Andreas Kling
63b1c8e882 LibWeb: Remove some unused functions from LayoutTable 2020-06-14 19:06:02 +02:00
Andreas Kling
ec39f419e5 LibWeb: Remove some unused functions from HTMLImageElement 2020-06-14 19:05:36 +02:00
Andreas Kling
c7d9229a0f LibWeb: Reorganize layout algorithm
Previously, layout recursively performed these steps (roughly):

1. Compute own width
2. Compute own position
3. Layout in-flow children
4. Compute own height
5. Layout absolutely positioned descendants

However, step (2) was pretty inconsistent. Some things computed their
own position, others had their parent do it for them, etc.
To get closer to CSS spec language, and make things easier in general,
this patch reorganizes the algorithm into:

1. Compute own width & height
2. Compute width & height of in-flow managed descendants
3. Move in-flow managed descendants to their final position
4. Layout absolutely positioned descendants

Block layout is now driven by the containing block, which will iterate
the descendants it's responsible for. There are a lot of inefficient
patterns in this logic right now, but they can easily be replaced with
better iteration functions once we settle on a long-term architecture.

Since the ICB (LayoutDocument) is at (0, 0), it doesn't rely on a
containing block to move it into place.

This code is still evolving along with my understanding of CSS layout,
so it's likely that we'll reorganize this again sooner or later. :^)
2020-06-14 19:01:54 +02:00
Andreas Kling
2b47ba6c3f LibWeb: Dump layout node style properties in alphabetical order 2020-06-14 18:47:21 +02:00
Andreas Kling
332c471301 LibWeb: Simplify LayoutBlock::layout_block_children() a little bit
No need to worry about inline children if children are not inline(!)
2020-06-14 16:48:17 +02:00
Andreas Kling
62615dfc31 LibWeb: Add LayoutNode::frame() reference getter
Any live layout tree always has a corresponding live Frame, as we will
never create a layout tree for a frameless document.
2020-06-14 16:45:45 +02:00
Andreas Kling
a93fb7299f LibWeb: Don't choke when trying to render a document-less <iframe>
Just paint it like an empty box if there's no document in the frame.
2020-06-14 15:32:38 +02:00
Luke
a01478c858 LibWeb: Fully implement HTML parser "in table" insertion mode
Also fixes some little mistakes in the "in body" insertion mode
that I found whilst cross-referencing.
2020-06-14 14:07:07 +02:00
Luke
6532c1e2fa LibWeb: Implement HTML parser "in column group" insertion mode 2020-06-14 14:07:07 +02:00
Luke
2241b09cd0 LibWeb: Implement HTML parser "in caption" insertion mode 2020-06-14 14:07:07 +02:00
Luke
a1838f676e LibWeb: Implement all CDATA tokenizer states
Even though we haven't implemented any switches to these states yet,
we may as well have them ready for when we do implement the switches.
2020-06-14 13:47:19 +02:00
Luke
821312729a LibWeb: Fully implement all DOCTYPE tokenizer states
Also fixes TagOpen having a seperate emit and reconsume in
ANYTHING_ELSE.
2020-06-14 13:47:19 +02:00
Luke
ab1df177d8 LibWeb: Fully implement all comment tokenizer states 2020-06-14 13:47:19 +02:00
Andreas Kling
3cc0c477db LibWeb: Add basic <object> element support
This patch implements a simple <object> element with fallback content.
If the URL from the data attribute fails to load (including 404),
we render the DOM tree inside the <object> as fallback content.

This works by generating a different layout tree for the <object>
depending on the state and success of the data load. Since we cannot
currently do incremental layout tree updates, we have to force a
complete layout tree rebuild when the resource load finishes/fails.
2020-06-13 22:24:49 +02:00
Andreas Kling
95d70addd8 LibWeb: Split out image loading logic from HTMLImageElement
Since more DOM nodes are going to want to load images (<object>, ...)
this patch splits out the image loading logic into an ImageLoader class
and then HTMLImageElement simply has an ImageLoader.

LayoutImage is then given a const ImageLoader& at construction and can
then provide layout and rendering for many kinds of DOM nodes.
2020-06-13 22:22:54 +02:00
Andreas Kling
d6d248c328 LibWeb: Add "data" to HTML::AttributeNames 2020-06-13 22:21:25 +02:00
Andreas Kling
1678aaa555 ProtocolServer+LibProtocol: Propagate HTTP status codes to clients
Clients now receive HTTP status codes like 200, 404, etc.
Note that a 404 with content is still considered a "successful"
download from ProtocolServer's perspective. It's up to the client
to interpret the status code.

I'm not sure if this is the best API, but it'll work for now.
2020-06-13 22:20:37 +02:00
Andreas Kling
d9ece296f0 LibWeb: Fix LayoutImage stupidly painting backgrounds over itself
The good boy fix here would be to implement all of the CSS paint phases
but for now, let's at least not paint a background over our image. :^)
2020-06-13 22:18:12 +02:00
Andreas Kling
d51c1c136e LibGfx: Painter::draw_line() can just return early if alpha == 0 2020-06-13 20:38:36 +02:00
Andreas Kling
502b5b76c8 LibWeb: Have DOM nodes start out in "needs style update" state
Otherwise we won't get the first fully styled look until you interact
with the page (e.g via hovering an element.)
2020-06-13 20:10:43 +02:00
Andreas Kling
0e65fc3a6d LibWeb: Expand background:none into background-color:transparent 2020-06-13 20:03:41 +02:00
Andreas Kling
3bba163574 LibGfx: Add Color::Transparent as a named color 2020-06-13 20:03:19 +02:00
Andreas Kling
2650005af8 LibWeb: <link rel> is actually a space-separated list of tokens
...so when we check for rel=stylesheet, we have to split it up into
parts first. :^)
2020-06-13 20:02:36 +02:00