Commit graph

48604 commits

Author SHA1 Message Date
Timothy Flynn 13573a6c4b AK: Refill a BufferedStream when it has less than the requested size
We currently only fill a buffer when it is empty. So if it has 1 byte
and 16 KB was requested, only that 1 byte would be returned. Instead,
attempt to refill the buffer when it's size is less than the requested
size.
2023-03-30 08:47:22 +02:00
Timothy Flynn 5c38b14045 AK: Remove arbitrary 1 KB limit when filling a BufferedStream's buffer
When reading, we currently only fill a BufferedStream's buffer when it
is empty, and only with 1 KB of data. This means that while the buffer
defaults to a size of 16 KB, at least 15 KB is always unused.
2023-03-30 08:47:22 +02:00
Tim Schumacher 8ff36e5910 LibCompress: Implement proper handling of LZMA end-of-stream markers 2023-03-30 08:45:35 +02:00
Tim Schumacher b6f3b2f116 LibCompress: Move common LZMA end-of-file checks into helper functions 2023-03-30 08:45:35 +02:00
Daniel Bertalan 0016f63547 AK: Fix Clang 16 UBSan issue with zero-length Array
The current implementation of `Array<T, 0>` has a zero-length C array as
its storage type. While this is accepted as a GNU extension, when
compiling with Clang 16, an UBSan error is raised every time an object
is accessed whose only field is a zero-length array.

This is likely a bug in Clang 16's implementation of UBSan, which has
been reported here: https://github.com/llvm/llvm-project/issues/61775
2023-03-29 21:35:53 -04:00
Andreas Kling e77552519e LibWeb: Implement CRC2D.imageSmoothingEnabled
We now select between nearest neighbor and bilinear filtering when
scaling images in CRC2D.drawImage().

This patch also adds CRC2D.imageSmoothingQuality but it's ignored for
now as we don't have a bunch of different quality levels to map it to.

Work towards #17993 (Ruffle Flash Player)
2023-03-29 22:48:04 +02:00
Andreas Kling e4b71495f5 LibWeb: Resolve percentage vertical-align values against line-height
...instead of not resolving them at all. :^)
2023-03-29 18:38:29 +02:00
Timothy Flynn 7447a91d7e LibCompress: Decode non-self-referencing back-references in one shot
We currently decode back-references one byte at a time, while writing
that byte back out to the output buffer. This is only necessary when the
back-reference refers to itself, i.e. when the back-reference distance
is less than its length. In other cases, we can read the entire back-
reference block in one shot.

Using the "enwik8" file as a test (100MB uncompressed, commonly used in
benchmarks: https://www.mattmahoney.net/dc/enwik8.zip), decompression
time decreases from:

    5.8s to 4.89s on Serenity (cold)
    2.3s to 1.72s on Serenity (warm)
    1.6s to 1.06s on Linux
2023-03-29 13:22:11 +01:00
Nico Weber e1f8443db0 AK: Fix build with Xcode 14.2's clang
Else:

    AK/BitStream.h:218:24:
        error: inline function '...::lsb_mask<unsigned char>' is not
               defined [-Werror,-Wundefined-inline]
        static constexpr T lsb_mask(T bits)
                           ^
2023-03-29 06:28:55 -04:00
Timothy Flynn 13bc999173 gunzip: Use a buffered file to read from the input file 2023-03-29 07:19:14 +02:00
Timothy Flynn 5aaefe4e62 LibCompress: Use prefix tables to decode Huffman codes up to 8 bits long
Huffman codes have a useful property in that they are prefix codes. That
is, a set of bits representing a Huffman-coded symbol is never a prefix
of another symbol. This allows us to create a table, where each index in
the table are integers whose prefix is the entry's corresponding Huffman
code.

With Deflate, we can have codes up to 16 bits in length, thus creating a
prefix table with 2^16 entries. So instead of creating a table fit all
possible codes, we use a cutoff of 8-bit codes. Codes larger than 8 bits
fall back to the binary search method.

Using the "enwik8" file as a test (100MB uncompressed, commonly used in
benchmarks: https://www.mattmahoney.net/dc/enwik8.zip), decompression
time decreases from 3.527s to 2.585s on Linux.
2023-03-29 07:19:14 +02:00
Timothy Flynn 8e834d4bb2 AK: Increase LittleEndianInputBitStream's buffer size and remove loops
We current buffer one byte of data from the underlying stream. And when
we pull bits off that buffer, we do so 1 or 8 bits at a time (depending
on whether the buffer is byte aligned). The 1-bit-at-a-time loop is by
far the most common during e.g. GZIP decompression.

This replaces the u8 buffer with a u64. And instead of looping at all,
we perform bitwise operations to extract the desired number of bits.

Using the "enwik8" file as a test (100MB uncompressed, commonly used in
benchmarks: https://www.mattmahoney.net/dc/enwik8.zip), decompression
time decreases from:

    242s to 35s on Serenity
    11.125s to 3.527s on Linux

Note that BigEndianInputBitStream can also use the same techniques,
and some of the methods here may make sense to live in an endianness-
agnostic base class. The focus is GZIP right now though, which only
uses the little endian stream.
2023-03-29 07:19:14 +02:00
Timothy Flynn 20aaab47f9 LibCompress: Use a bit stream for the entire GZIP decompression process
We currently mix normal and bit streams during GZIP decompression, where
the latter is a wrapper around the former. This isn't causing issues now
as the underlying bit stream buffer is a byte, so the normal stream can
pick up where the bit stream left off.

In order to increase the size of that buffer though, the normal stream
will not be able to assume it can resume reading after the bit stream.
The buffer can easily contain more bits than it was meant to read, so
when the normal stream resumes, there may be N bits leftover in the bit
stream that the normal stream was meant to read.

To avoid weird behavior when mixing streams, this changes the GZIP
decompressor to always read from a bit stream.
2023-03-29 07:19:14 +02:00
Timothy Flynn 9423662107 AK: Add NumericLimits::digits to return the number of digits in a type
Analogous to std::numeric_limits<T>::digits.
2023-03-29 07:19:14 +02:00
Timothy Flynn a944eed013 CI: Bump clang used by the Fuzzer build to clang-15
This is required for an upcoming use of a constexpr function.
2023-03-29 07:19:14 +02:00
MacDue bdbea0baeb Ladybird: Add reset zoom level button to toolbar
This is a port of the Browser feature.
2023-03-29 07:17:35 +02:00
MacDue b7f9b316ed Browser: Add reset zoom level button to toolbar
This button shows the current zoom level and when clicked resets
the zoom back to 100%. It is only displayed for zoom levels other
than 100%.
2023-03-29 07:17:35 +02:00
Ali Mohammad Pur 64da05a96d LibWeb+LibWasm: Implement and use the "reset the Memory buffer" steps
This implements the memory object cache and its "reset on grow"
semantics, as the web depends on the exact behaviour.
2023-03-29 07:16:37 +02:00
Luke Wilde 14fb6372c3 LibWeb: Parse Element.style url functions relative to the document
Previously we used a parsing context with no access to the document, so
any URLs in url() functions would become invalid.

Fixes the images on Steam's store carousel, which sets
Element.style.backgroundImage to url() functions.
2023-03-29 07:10:53 +02:00
Andreas Kling 264b9b73ac LibGfx/OpenType: Ignore glyphs with bogus offsets
Some fonts (like the Bootstrap Icons webfont) have bogus glyph offsets
in the `loca` table that point past the end of the `glyf` table.

AFAICT other rasterizers simply ignore these glyphs and treat them as if
they were missing. So let's do the same.

This makes https://changelog.serenityos.org/ actually work! :^)
2023-03-29 07:06:13 +02:00
Tim Schumacher d01ac59b82 Shell: Skip rc files when not running interactively
This makes debugging a bit nicer.
2023-03-29 03:39:09 +03:30
Tim Schumacher 9a6b5a53a7 Shell: Correctly mark the end line of a parsed list 2023-03-29 03:39:09 +03:30
Tim Schumacher 46c22ee49d Shell: Allow appending empty string literals
Otherwise, we just silently drop arguments that are empty strings.
2023-03-29 03:39:09 +03:30
Tim Schumacher c26639eac2 Shell: Properly skip POSIX Fi tokens 2023-03-29 03:39:09 +03:30
Tim Schumacher b1739029ef Shell: Evaluate the program name before parsing arguments
Otherwise, we are too late to catch the "load the POSIX-compatible
shellrc" branch.
2023-03-29 03:39:09 +03:30
sin-ack 0a63e543b7 README: Add a jump section for easy access to documentation
The link to documentation is buried near the bottom of the README,
and most people don't realize that we have documentation within the
repository because of this. This commit adds handy links that take you
to the appropriate parts of the README, which should improve
discoverability by a lot. The idea is inspired by other repositories
having a similar "common links" area at the top of their READMEs.
2023-03-28 21:23:45 +01:00
Andreas Kling c0a7a61288 LibWeb: Clamp fit-content widths in flex layout to min/max-width
In situations where we need a width to calculate the intrinsic height of
a flex item, we use the fit-content width as a stand-in. However, we
also need to clamp it to any min-width and max-width properties present.
2023-03-28 21:08:54 +02:00
Luke Wilde 4c090a9a35 Tests/LibWeb: Add layout test for layout fix in PR #15780
Adds a layout test for the fix in 488a979.
2023-03-28 19:45:00 +01:00
Julian Offenhäuser 5ccb240945 LibGfx: Don't render OpenType glyphs that have no outline
The spec tells us that for glyph offsets in the "loca" table, if an
offset appears twice in a row, the index of the first one refers to a
glyph without an outline (such as the space character). We didn't check
for this, which would cause us to render a glyph outline where there
should have been nothing.
2023-03-28 18:17:17 +02:00
Ali Mohammad Pur a28aba7663 AK: Add DeprecatedString::from_utf8(StringView)
This mirrors String::from_utf8(StringView).
Jakt will use this to construct strings instead of just assuming the
allocation will succeed, lowering the API difference between
Jakt::String and AK::String by one API :^)
2023-03-28 15:55:35 +01:00
Srikavin Ramkumar 4a82f9bd03 LibWeb: Allow attachshadow for elements with valid custom element names 2023-03-28 07:18:09 -04:00
Srikavin Ramkumar 47a466865c LibWeb: Return HTMLElement for valid custom element tag names 2023-03-28 07:18:09 -04:00
Srikavin Ramkumar f2dd878fe7 LibWeb: Implement custom element name validation 2023-03-28 07:18:09 -04:00
Srikavin Ramkumar 149e442c24 LibWeb: Iterate codepoints instead of characters in is_valid_name 2023-03-28 07:18:09 -04:00
Massimo Paladin 1d7bad5347 Meta: Remove SonarCloud cache and threads setup as it is now default
No need to configure the cache and threads anymore,
SonarCloud now has an automatic analysis caching and
threads detection. See:
https://docs.sonarcloud.io/advanced-setup/languages/c-c-objective-c/#analysis-cache
2023-03-28 04:05:01 -06:00
Andrew Kaster 4a70fa052f LibWeb: Declare defaulted style value comparision operators inline
Some versions of clang, such as Apple clang-1400.0.29.202 error out on
the previous out of line operators. Explicitly defaulting comparison
operators out of line is allowed per P2085R0, but was checked in clang
before version 15 in C++20 mode.
2023-03-28 09:18:50 +01:00
Andrew Kaster 840afbb55f Documentation: Add instructions for debugging Ladybird with Xcode 2023-03-28 09:18:50 +01:00
Andrew Kaster 1c01856021 Meta: Diable Wshorten-64-to-32 explicitly to silence Xcode defaults
Xcode will set this by default when creating a new project unless we
set an xcode property to disable it. Instead of doing that, disable
it globally.
2023-03-28 09:18:50 +01:00
Andrew Kaster 4608e4143e Ladybird: Improve Xcode generator experience and copy helpers to bundle
We had a mismatch in the GUI Identifier property, causing warnings in
Xcode. It was also missing the Product Identifier Xcode property on
ladybird itself, causing another warning.

Copy all our helper processes to the ladybird.app bundle directory so
that they can be found by ``open ladybird.app`` and the Xcode debugger.

For the future, we should look in ../Resources for resources on macOS.
Copying resources to that directory requires more CMake-fu.
2023-03-28 09:18:50 +01:00
Andrew Kaster afb3a4a030 LibSQL: Block signals while forking SQLServer in Lagom
When debugging in Xcode, the waitpid() for the initial forked process
would always return EINTR or ECHILD. Work around this by blocking all
signals until we're ready to wait for the initial child.
2023-03-28 09:18:50 +01:00
Andreas Kling af118abdf0 LibWeb: Use fit-content width in place of indefinite flex item widths
In `flex-direction: column` layouts, a flex item's intrinsic height may
depend on its width, but the width is calculated *after* the intrinsic
height is required.

Unfortunately, the specification doesn't tell us exactly what to do here
(missing inputs to intrinsic sizing is a common problem) so we take the
solution that flexbox applies in 9.2.3.C and apply it to all intrinsic
height calculations within FlexFormattingContext: if the used width of
an item is not yet known when its intrinsic height is requested, we
substitute the fit-content width instead.

Note that while this is technically ad-hoc, it's basically extrapolating
the spec's suggestion in one specific case and using it in all cases.
2023-03-27 23:28:07 +02:00
Andreas Kling ca290b27ea LibWeb: Make box content sizes indefinite before intrinsic sizing
When calculating the intrinsic width of a box, we now make its content
width & height indefinite before entering the intrinsic sizing layout.
This ensures that any geometry assigned to the box by its parent
formatting context is ignored.

For intrinsic heights, we only make the content height indefinite.
This is because used content width is a valid (but optional) input
to intrinsic height calculation.
2023-03-27 23:28:07 +02:00
Andreas Kling 7639eccd53 LibWeb: Add default equality operators to Available{Space,Size}
I find myself adding these over and over again while testing.
Let's just have them always there.
2023-03-27 23:28:07 +02:00
Andreas Kling 3b76cc5245 LibWeb: Pass available inner space to inline-level SVG layout 2023-03-27 23:28:07 +02:00
Andreas Kling 4f752ca791 LibWeb: Pass available inner space to BFC root auto height calculation 2023-03-27 23:28:07 +02:00
Aliaksandr Kalenik 1ee99017e2 LibWeb: Fix intrinsic sizing early return condition in TFC
Early return before running full TFC algorithm is only possible when
just table width need to be calculated.
2023-03-27 23:10:16 +02:00
Sam Atkins 97b3f1230b WebServer: Propagate more errors
Use try_append() instead of append().
2023-03-27 20:29:51 +01:00
Sam Atkins 8dd0038f47 LibCore: Add DateTime::to_string()
This is just the contents of to_deprecated_string() with errors
propagated. to_deprecated_string() is now implemented using to_string().
2023-03-27 20:29:51 +01:00
Sam Atkins 7dfe1f9f8f WebServer: Use relative URLs for the directory listing
This fixes an issue found on Linus's hosted WebServer. Now, if WebServer
is hosted at a non-root URL. (eg, `example.com/webserver` instead of
`example.com`) the links will correctly go to
`example.com/webserver/foo` instead of `example.com/foo`.
2023-03-27 20:29:51 +01:00
Sam Atkins cce5e3158f WebServer: Handle incomplete HTTP requests
Mostly by copying the code in LibWeb/WebDriver/Client.cpp
2023-03-27 20:29:51 +01:00