Commit graph

8823 commits

Author SHA1 Message Date
Till Mayer
406aabff23 AudioServer: Added ability to get count of samples in the buffer queue
Now the AClientConnection can get the count of samples still in the
buffer queue.
2019-10-19 20:05:13 +02:00
Andreas Kling
025d3b49ab LibHTML: Make "display: inline-block" generate a LayoutBlock for now
We're gonna need some more smarts for this, but this at least gives
us something instead of an assertion.
2019-10-19 19:02:02 +02:00
Andreas Kling
96f34d26c9 LibHTML: Batch style updates and make them start from the root
Use a zero-timer to schedule a style update after invalidating style
on any node. Nodes now have a needs_style_update flag which helps us
batch and coalesce the work.

We also start style updates at the root and work our way through the
document, updating any node that has the needs_style_update flag set.
This is slower than what we were doing before, but far more correct.

There is a ton of room for improvement here. :^)
2019-10-19 19:00:31 +02:00
Andreas Kling
0d8aaaaa44 LibDraw: Store emojis in a HashMap<u32, RefPtr<GraphicsBitmap>>
Get rid of the dedicated Emoji class to make it easier to store a null
value signifying a failed lookup.

This allows us to remember failed lookups, making subsequent failures
for the same codepoint much faster. :^)
2019-10-19 18:36:45 +02:00
Andreas Kling
b3a63e1d50 LibHTML: Add TreeNode<T>::for_each_in_subtree(callback)
This helper invokes a callback for the node and each of its descendants
in pre-order.
2019-10-19 18:14:54 +02:00
Andreas Kling
8acc61f19a LibDraw: Have the PNGImageLoaderPlugin remember if it failed to decode
Instead of trying again when asked repeatedly, just remember if it
didn't work out the first time.
2019-10-19 17:43:47 +02:00
Andreas Kling
fed668f20f LibHTML: Skip over CSS @media rules for now 2019-10-19 17:39:38 +02:00
Andreas Kling
6cbf8a3426 LibHTML: Use the correct inherited color for LayoutListItemMarker 2019-10-19 11:54:28 +02:00
Andreas Kling
5a34225999 LibHTML: Implement basic tiled background image support
It's now possible to set a page background image via <body background>.
Also, HtmlView now officially handles rendering the body element's
background (color, image or both.) LayoutBox is responsible for all
other background rendering.

Note that it's not yet possible to use CSS background-image properties
directly, since we can't parse them yet. :^)
2019-10-19 11:49:46 +02:00
Andreas Kling
96f10c8de2 LibDraw: Rename Painter::blit_tiled() => draw_tiled_bitmap()
Also change the API to take a destination rect instead of a source rect
since internally it was basically creating a destination rect from the
source rect anyway. It was a little confusing.
2019-10-19 11:05:21 +02:00
Andreas Kling
762f20944c LibHTML: Replaced elements should not break lines at start of line
If the current line box already has zero width, there's no point in
inserting a line break to make space, since we'll just be at x=0 after
breaking as well.

This removes an ugly unnecessary line break before images wider than
their containing block. :^)
2019-10-19 09:44:40 +02:00
Andreas Kling
a5f3f332ed LibHTML: Ignore completed image loads for already-destroyed <img>'s
Capture a weak pointer to the element and pass that to the load finish
callback in HTMLImageElement::load_image(). This allows us to ignore
completed loads if the <img> element is no longer around.
2019-10-19 09:43:05 +02:00
Andreas Kling
877ff6bc13 LibHTML: Make TreeNode inherit from Weakable by default
This makes Node and LayoutNode weakable. Frame was already weakable.
2019-10-19 09:42:20 +02:00
Andreas Kling
87d13930ef LibHTML: Allow loading of PNG's directly into the HtmlView
When loading a URL that ends in ".png", we now construct a simple
DOM document to contain the image. It also shows the image dimensions
in the document title.

Because we use <img src> to load the image into the synthetic document,
we end up loading the image resource twice. This issue will go away
once we have a smarter, caching, loader mechanism.
2019-10-19 09:31:52 +02:00
Andreas Kling
60be51f908 LibHTML: Add a simple font cache
The FontCache caches the result of font lookups. The cache key is a
simple object called FontSelector which consists of the font family
and font weight (both strings.)

This drastically reduces time spent in font lookup.
2019-10-18 23:06:03 +02:00
Andreas Kling
07cbe2daa4 LibHTML: Preserve UTF-8 codepoints when collapsing whitespace
This is extremely awkward and I'm sure there are many better ways to
achieve this..
2019-10-18 22:50:44 +02:00
Andreas Kling
39546303da LibHTML: CSS parser should trim whitespace from values
This makes sure that values like "auto !important" don't have a space
character after "auto".
2019-10-18 17:14:25 +02:00
Andreas Kling
2305dee455 LibHTML: Add LayoutNode::first_ancestor_of_type<T>() 2019-10-18 10:16:33 +02:00
Andreas Kling
65ad6c35f0 LibHTML: Add typed child/sibling traversal helpers for LayoutNode
Also add some special variants for the table classes, to make it a bit
more pleasant to write table code. :^)
2019-10-18 09:38:12 +02:00
Andreas Kling
6202a0ab32 LibHTML: Only accumulate Text children's content in inline stylesheets
Some inline stylesheets use HTML comments like "<!--blah blah-->".
The HTML parser currently generates a comment child node of the <style>
element whenever this happens, and we don't want the comment itself to
be interpreted as part of the stylesheet.
2019-10-17 23:54:27 +02:00
Andreas Kling
9ac7b6fad1 LibHTML: Don't assert when encountering an unknown font-weight 2019-10-17 23:54:19 +02:00
Andreas Kling
6c22b46b37 LibHTML: Hard-code LayoutTable to never have inline children
This is a total hack to get around the auto-detection mechanism for
whether a block has inline or block children. We'll say that tables
never have inline children for now, and then anything that actually
turns out to be an inline child will just be ignored by layout.
2019-10-17 23:39:31 +02:00
Andreas Kling
b4c2621ed7 LibHTML: Add is<T> helpers for the table-related LayoutNode subclasses 2019-10-17 23:39:31 +02:00
Andreas Kling
5e29238a49 LibHTML: Make "children are inline" flag imperative
Instead of computing whether a block's children are inline based on the
first child, make it an imperatively-set flag.

This gives us some flexibility to ignore things like text nodes inside
a <table>, for example. I'm still unsure what the "correct" way to deal
with those will be. We'll find out sooner or later. :^)
2019-10-17 23:39:31 +02:00
Andreas Kling
41896ff521 LibHTML: Add stub classes for basic table layout
This class introduces LayoutTable, LayoutTableRow and LayoutTableCell.
These are produced by "display" values table, table-row and table-cell
respectively.

Note that there's no layout happening yet, I'm just adding the classes.
2019-10-17 23:39:31 +02:00
Andreas Kling
14f380f87a LibHTML: Use is_inline() instead of !is_block() when building tree 2019-10-17 23:39:31 +02:00
Andreas Kling
775cbbb422 LibHTML: Add basic keyboard navigation (up/down/pgdn/pgup/home/end/etc) 2019-10-17 23:39:31 +02:00
Jonah Alligood
437c919dda LibC: Better strtok implementation (string.h) 2019-10-17 14:39:57 +02:00
Jonah Alligood
a544fded88 LibC: strtok is now implemented (string.h) 2019-10-17 14:39:57 +02:00
Andreas Kling
c13be2c7ea LibM: Implement various functions.
Path from Anonymous.
2019-10-17 09:32:24 +02:00
Andreas Kling
e51c1aa3d4 LibC: sys_errlist should be const char* const
Patch from Anonymous.
2019-10-17 09:18:01 +02:00
Andreas Kling
06f084fedd LibHTML: Add the <center> element
This is really just "center { display: block; text-align: center; }" in
the default stylesheet, but it totally works!
2019-10-16 20:33:00 +02:00
Andreas Kling
6dbba6ad85 LibHTML: Implement CSS text-align: left/center/right
This was easier than I imagined; we just shift each line box to the
left based on the alignment and the remaining space on each line. :^)
2019-10-16 20:32:17 +02:00
Andreas Kling
2366c330e3 LibDraw: Teach PNGLoader to only decode enough of learn the image size 2019-10-16 20:02:24 +02:00
Till Mayer
4c8341d080 LibAudio: Fixed stuttery playback of audio
When playing an ABuffer, the count of samples were determined by the
size of the SharedBuffer. This caused small pauses of up to 512
samples during the playback, when the size of the shared buffer was
rounded up to a multiple of 4096. This problem was amplified by the
fact that the AResampleHelper was created every time a new chunk of
audio was to be processed, causing inconsistencies in the playback of
wav files.
2019-10-16 16:25:38 +02:00
Andreas Kling
005b416639 LibC: Remove debug spam in gethostbyname() 2019-10-16 12:09:38 +02:00
Andreas Kling
38b55ee067 LibHTML: LayoutBlock::hit_test() was calling the wrong parent class
Oops, we now need to call LayoutBox instead of LayoutNode for blocks
with non-inline children.
2019-10-15 22:02:58 +02:00
Andreas Kling
18fa662eb2 LibHTML: Use ImageLoader for <img> elements to defer bitmap decoding
We now wait until the pixels are actually needed before fully decoding
images in <img> elements.

This needs some more work and is currently a bit memory-wasteful since
we'll hang on to the raw image data forever.
2019-10-15 21:53:08 +02:00
Andreas Kling
b4c0ea89d5 LibHTML: Add the currently visible viewport rect to RenderingContext
This will allow rendering code to skip various things sometimes. :^)
2019-10-15 21:52:01 +02:00
Andreas Kling
1bd2941467 LibDraw: Add ImageLoader, a simple abstraction for image loading
An ImageLoader is a generic interface for loading encoded image data of
any supported format. It has an ImageLoaderPlugin internally that does
all the work.

This patch adds an initial PNGImageLoaderPlugin that knows how to
retrieve the size of a PNG, and the bitmap. The API is divided into
size() and bitmap() to facilitate geometry-only decoding.
This will be useful in places like LibHTML where we need dimensions for
layout purposes but can wait with the bitmap until later.
2019-10-15 21:48:08 +02:00
Andreas Kling
5c2b21705a LibHTML: LayoutNode::set_needs_display() needs to invalidate fragments
If a LayoutNode is split into line box fragments, we need to walk our
fragments and invalidate them. It was not enough to do this only for
LayoutBox nodes.
2019-10-15 20:45:52 +02:00
Andreas Kling
43a9843938 LibCore: Put HTTP debug spam behind FOO_DEBUG macros 2019-10-15 19:51:02 +02:00
Andreas Kling
110b2d52f2 LibHTML: Fix missing backgrounds an borders after LayoutBox refactoring
The render() implementation in both LayoutBlock and LayoutBox need to
be calling the immediate parent class. :^)
2019-10-15 19:12:56 +02:00
Andreas Kling
4814253589 LibHTML: Introduce LayoutBox and LayoutNodeWithStyleAndBoxModelMetrics
To streamline the layout tree and remove irrelevant data from classes
that don't need it, this patch adds two new LayoutNode subclasses.

LayoutNodeWithStyleAndBoxModelMetrics should be inherited by any layout
node that cares about box model metrics (margin, border, and padding.)
LayoutBox should be inherited by any layout node that can have a rect.

This makes LayoutText significantly smaller (from 140 to 40 bytes) and
clarifies a lot of things about the layout tree.

I'm also adding next_sibling() and previous_sibling() overloads to
LayoutBlock that return a LayoutBlock*. This is okay since blocks only
ever have block siblings.

Do also note that the semantics of is<T> slightly change in this patch:
is<T>(nullptr) now returns true, to facilitate allowing to<T>(nullptr).
2019-10-15 16:48:38 +02:00
Andreas Kling
f4f5ede10a LibHTML: Simplify Node::create_layout_node()
There's no need to pass the StyleResolver to this function. Nodes that
need it can just get it from the document.
2019-10-15 15:06:16 +02:00
Andreas Kling
f7cd5662ef LibHTML: Move layout tree building to a LayoutTreeBuilder class
Building a whole layout tree shouldn't be a concern of Node, so this
patch moves it to a separate class.
2019-10-15 14:24:26 +02:00
Andreas Kling
d14b60533f LibHTML: Add is<T> and to<T> helpers for LayoutNode class family 2019-10-15 14:24:26 +02:00
Calvin Buckley
bbee1c5b98 LibC: syslog and lots of compat stuff for it
This is an implementation of syslog with some OpenBSD extensions.
There is no syslogd support (so it only logs to dbgprintf/stderr),
but otherwise is functional.

Many weird defines are always present, because some syslog users in
the wild check for their existence.
2019-10-15 09:52:55 +02:00
Andreas Kling
7dbc13ac88 LibCore: Don't crash in IPC client/server on EAGAIN
Instead, just sched_yield() and try again. This makes the WindowServer
not fall apart whenever clients take a bit too long to respond.

Fixes #656.
2019-10-14 21:49:33 +02:00
Andreas Kling
735f02900b LibHTML: Implement basic partial style invalidation
This patch makes it possible to call Node::invalidate_style() and have
that node and all of its ancestors recompute their style.

We then figure out if the new style is visually different from the old
style, and if so do a paint invalidation with set_needs_display().
Note that the "are they visually different" code is very incomplete!

Use this to make hover effects a lot more efficient. They no longer
cause a full relayout+repaint, but only a style invalidation.
Style invalidations are still quite heavy though, and there's a lot of
room for improvement there. :^)
2019-10-14 18:33:23 +02:00