Commit graph

4713 commits

Author SHA1 Message Date
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
yuanchen
76e2c08fbf Meta: Fix some typos in ReadMe.md (#671) 2019-10-18 22:52:21 +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
f4e6dae6fe UTF-8: Add Utf8CodepointIterator::codepoint_length_in_bytes()
This allows you to retrieve the length (in bytes) of the codepoint the
iterator is currently pointing at.
2019-10-18 22:49:23 +02:00
Andreas Kling
ab9e6166e8 AK: Add String::hash() 2019-10-18 17:17:47 +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
e08991319a Net: Put a bunch of socket debug logging behind FOO_DEBUG
Also remove an unused Socket::listen() implementation.
2019-10-18 16:50:23 +02:00
Andreas Kling
ec65b8db2e Revert "Kernel: Make DoubleBuffer use a KBuffer instead of kmalloc()ing"
This reverts commit 1cca5142af.

This appears to be causing intermittent triple-faults and I don't know
why yet, so I'll just revert it to keep the tree in decent shape.
2019-10-18 15:58:06 +02:00
Andreas Kling
1cca5142af Kernel: Make DoubleBuffer use a KBuffer instead of kmalloc()ing
Background: DoubleBuffer is a handy buffer class in the kernel that
allows you to keep writing to it from the "outside" while the "inside"
reads from it. It's used for things like LocalSocket and PTY's.
Internally, it has a read buffer and a write buffer, but the two will
swap places when the read buffer is exhausted (by reading from it.)

Before this patch, it was internally implemented as two Vector<u8>
that we would swap between when the reader side had exhausted the data
in the read buffer. Now instead we preallocate a large KBuffer (64KB*2)
on DoubleBuffer construction and use that throughout its lifetime.

This removes all the kmalloc heap traffic caused by DoubleBuffers :^)
2019-10-18 14:55:04 +02:00
Andreas Kling
4027a64fc5 Kernel: VirtualConsole can use kmalloc_eternal() for permanent stuff
Less pressure on kmalloc heap.
2019-10-18 14:14:54 +02:00
Andreas Kling
2f37fa487d Kernel: Keep TTY names in character buffers instead of Strings
Just going over some little unnecessary little kmalloc allocations.
2019-10-18 14:13:43 +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
Andreas Kling
89aaae82a1 Browser: Add basic back/forward history 2019-10-17 23:39:31 +02:00
Andreas Kling
340b524c0d Kernel: Minor cleanup in TCPSocket::send_tcp_packet() 2019-10-17 23:39:31 +02:00
Andreas Kling
f1f928670e URL: Parse URLs that lack a path (e.g "http://serenityos.org") 2019-10-17 23:39:31 +02:00
Nufflee
7b6aba4284 KeyboardDevice: Rename 0xe0 flag for clarity. 2019-10-17 23:39:24 +02:00
Nufflee
0979f372a6 KeyboardDevice: Support whole numpad and Num Lock.
We now support all numpad keys and the Num Lock key.
2019-10-17 23:39:24 +02:00
Nufflee
9d5792b73d KeyboardDevice: Implement Caps Lock handling. 2019-10-17 23:39:24 +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
Tom
00a7c48d6e APIC: Enable APIC and start APs 2019-10-16 19:14:02 +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
7e97e1c5d9 LookupServer: Remove debug spam about /etc/hosts 2019-10-16 12:10:33 +02:00
Andreas Kling
3a4da5aa05 LookupServer: Cache successful DNS lookup responses for 1 minute
This reduces DNS traffic spam during web browsing. We can definitely do
a lot better here, this is just a very low-hanging fruit.
2019-10-16 12:10:16 +02:00
Andreas Kling
005b416639 LibC: Remove debug spam in gethostbyname() 2019-10-16 12:09:38 +02:00