Commit Graph

53215 Commits

Author SHA1 Message Date
Andreas Kling
22a858a0cb LibWeb: Don't parse inline style sheets during HTML fragment parsing
Some websites (like Reddit) like to instantiate "components" by setting
innerHTML to a huge chunk of stuff. Sometimes those huge chunks of stuff
contain inline style sheets (i.e `<style>` elements).

Before this change, we would end up parsing the CSS in those elements
multiple times, because we had no way of knowing that we were within
a fragment parser's temporary document.

This patch avoids the extra CSS parsing work by adding adding a flag to
Document that tells us it's being used by the fragment parser. Then, we
simply avoid parsing CSS for style elements in such documents. The CSS
then gets parsed immediately upon insertion into the proper DOM.
2023-08-09 17:09:28 +02:00
Andreas Kling
97ebfd9f0f LibJS: Make Value::to_string_without_side_effects() infallible
Work towards #20449.
2023-08-09 17:09:16 +02:00
Andreas Kling
b8f78c0adc LibJS: Make JS::number_to_string() infallible
Work towards #20449.
2023-08-09 17:09:16 +02:00
Andreas Kling
09547ec975 LibJS: Make PrimitiveString::deprecated_string() infallible
Work towards #20449.
2023-08-09 17:09:16 +02:00
Andreas Kling
c084269e5f LibJS: Make PrimitiveString::utf8_string() infallible
Work towards #20449.
2023-08-09 17:09:16 +02:00
Andreas Kling
7849950383 LibJS: Make Utf16String & related APIs infallible
Work towards #20449.
2023-08-09 17:09:16 +02:00
Andreas Kling
9708b86d65 LibJS: Make PrimitiveString::resolve_rope_if_needed() infallible
Work towards #20449.
2023-08-09 17:09:16 +02:00
Andreas Kling
1a27c525d5 LibJS: Make PrimitiveString::create() infallible
Work towards #20449.
2023-08-09 17:09:16 +02:00
Bastiaan van der Plaat
b7b02693b9 Ladybird: Remember window position and size on close 2023-08-09 13:47:44 +01:00
Jelle Raaijmakers
bf927344fb Base: Teach ImageViewer and PixelPaint to open JXL, TGA images 2023-08-09 14:40:26 +02:00
Jelle Raaijmakers
1c19c2bc92 PixelPaint: Guess image type based on its filename
We do this in ImageViewer so it understands TGA images; let's do it in
PixelPaint as well :^)
2023-08-09 14:40:26 +02:00
Jelle Raaijmakers
e272f796ad PixelPaint: Remove unused includes and method 2023-08-09 14:40:26 +02:00
Lucas CHOLLET
a35f4bf14e LibGfx/JPEGXL: Honor the orientation parameter
Since the introduction of the JPEG XL decoder, we always read the
`orientation` field in the `ImageMetadata` bundle. This patch allows us
to render the bitmap accordingly to this transformation.
2023-08-09 13:18:40 +01:00
Lucas CHOLLET
3c1be9879f LibGfx: Add ExifOrientedBitmap
The idea behind this class is to provide an abstraction for decoders.
It allows them to use the class as if it was a normal `Bitmap`, however,
under the hood, this class will honor a given orientation, as specified
by the Exif standard. This class is introduced to be used within the
JPEG XL decoder, but it should be possible to use it for every
Exif-compatible format.
2023-08-09 13:18:40 +01:00
Jelle Raaijmakers
d78590fe0d Docs: Use the term 'amend' instead of 'squash' in CONTRIBUTING.md
Hopefully this makes it more clear what the intended action is. For a
lot of people "squashing" means combining multiple commits into one,
which is a common practice when merging to a branch.
2023-08-09 07:28:06 -04:00
Andi Gallo
ada05ab4e4 LibWeb: Implement fixed table layout 2023-08-09 08:33:02 +01:00
Andi Gallo
97512d0c76 LibWeb: Add table-layout CSS property 2023-08-09 08:33:02 +01:00
Lucas CHOLLET
a0ea87ffc6 LibGfx/JPEGXL: Compute the position inside the channel correctly
Turns out I only decoded square images until now, which make this code
work. A bit ashamed to have written that bug.
2023-08-09 08:28:05 +01:00
Bastiaan van der Plaat
bba14f6014 LibWeb: Add Canvas Context2D basic font property support 2023-08-09 05:48:32 +02:00
Bastiaan van der Plaat
b05fe22d39 LibWeb: Split of compute font logic in StyleComputer 2023-08-09 05:48:32 +02:00
Bastiaan van der Plaat
cc1f7d385c LibWeb: Move font stretch width calc from StyleComputer to StyleValue 2023-08-09 05:48:32 +02:00
Lucas CHOLLET
eb6d41d99e LibGfx/JPEGXL: Allow ColourEncoding bundles with custom values
We don't do anything particular with images that contain a custom
ColourEncoding yet, but at least it allows us to know how to decode the
metadata of such images.
2023-08-09 05:43:19 +02:00
Lucas CHOLLET
a8f041ae11 LibGfx/JPEGXL: Add support for complex distribution clustering
Complex distribution - distributions that are encoded using an internal
symbol decoder with a single distribution, are very often used for lz77
compressed images. This is a requirement for the lz77_flower test case.
2023-08-09 05:42:17 +02:00
Lucas CHOLLET
18c511f54c LibGfx/JPEGXL: Support clusters with a single distribution
This type of cluster is an exception and has specific rules (but
simpler) to be read. This is a requirement to support complex
distributions as they use a symbol decoder initialized with a single
distribution.
2023-08-09 05:42:17 +02:00
Jelle Raaijmakers
a8857c06b3 Ports: Update PHP to 8.2.8 2023-08-09 05:40:39 +02:00
Jelle Raaijmakers
ba776390b5 LibC: Define time* macros before definitions
Otherwise, if an application defines its own macros, the implementations
get messed up. This way we redefine those macros if they're set.

This fixes the PHP port build.
2023-08-09 05:40:39 +02:00
Sam Atkins
8356ff283b LibWeb: Implement background-attachment: local
This causes the background to scroll along with the element's contents.
2023-08-09 05:37:43 +02:00
Jelle Raaijmakers
ad859a8d0d Ports: Update ScummVM to 2.7.1
The `glGetIntegerv` patch is now removed since a fix was upstreamed.
2023-08-09 05:37:05 +02:00
Timothy Flynn
3e2449d1fe Browser+WebDriver: Set the initial URL to about:blank from WebDriver
We already do this for headless-browser. There's no need to open any URL
other than about:blank when starting a WebDriver session. We should also
do this from WebDriver code, rather than in special logic in Browser's
main.cpp.
2023-08-09 05:33:24 +02:00
Timothy Flynn
93ffa77370 Ladybird: Remove workaround for initial page load for WebDriver
The issue noted in the removed comment no longer seems to apply. The URL
loaded here is triggered before WebDriver even issues the POST /session
command.
2023-08-09 05:33:24 +02:00
Timothy Flynn
6c7422e8b7 Ladybird: Only load a single URL at launch
When we launch Ladybird, we currently:

1. Create a BrowserWindow, whose constructor navigates to the configured
   new tab page URL.
2. Then navigate to either "about:blank" or whatever URL is provided via
   the command line.

This patch removes step 2 and forwards the URL from the command line (if
any) to BrowserWindow. BrowserWindow's constructor then either navigates
to that URL or the new tab page URL.
2023-08-09 05:33:24 +02:00
Timothy Flynn
27fa029537 Base: Remove FrogFind from the new tab page
Search queries no longer work for this engine, and FireFox even issues a
security warning on their home page.
2023-08-09 05:33:24 +02:00
Timothy Flynn
66e1f8cdab AK: Support serializing opaque hosts
The spec indicates we should support serializing opaque hosts, but we
were assuming the host contained a String. Opaque hosts are represented
with Empty. Return an empty string here instead to prevent crashing on
an invalid variant access.
2023-08-09 05:33:24 +02:00
Zaggy1024
dcfec8bfbe LibC: Expect mutexes to be locked and needing wake when calling futex()
tl;dr: This fixes deadlocks that would occur in most applications in
Serenity when SMP was enabled.

As an optimization to `pthread_mutex_unlock()`, if only one thread
holds a mutex lock, it will avoid calling `futex()` to wake, since no
threads are actually waiting in `futex()`.

If a thread manages to synchronously unlock and relock the same mutex,
the state will be set to indicate that a wake is not needed, regardless
of whether any other threads are waiting for the lock. This should be
fine, as a thread that is waiting will set the mutex to needing a wake
and check if it is unlocked to unblock itself in the same atomic
operation.

However, when `pthread_mutex_lock()` was called with only one thread
holding the mutex lock, instead of telling `futex()` to atomically
sleep the thread if the state is set to indicate that a wake is
needed, the first wait would check if the state was set to indicate a
wake was _not_ needed. This means it is possible for the call to
`futex()` to wait when any subsequent call to `pthread_mutex_unlock()`
would not call `futex()` to wake, causing it to wait forever.

After that, any other thread that tries to take the lock will see that
the lock is taken and also `futex()` wait. Despite the fact that these
other threads would set the state to needing a wake, there will be no
unblocked thread holding the lock to actually wake them.

By making it wait only if the state indicates to other threads that a
wake is needed, heavily contended mutexes should no longer cause
deadlocks. Most applications would encounter these deadlocks due to the
mutex used by `malloc()`, some sooner than others. The worst offenders
(other than Ladybird) were most likely VideoPlayer and SoundPlayer.
2023-08-09 05:31:35 +02:00
Timothy Flynn
601da7e5bd Ladybird: Add the select-all action to the JS console
Also clarify a comment, because it wasn't immediately clear to me what
wouldn't work without the code below it.
2023-08-09 05:13:24 +02:00
Timothy Flynn
59b583329a Ladybird: Close the current tab even if we're closing the window
Currently, if the JS console is open and tied to the last opened tab in
the browser window, it will prevent the main process from exiting when
the last tab is closed. This change explicitly closes that tab before
closing the window (if it's the last tab), allowing Qt to delete the
Tab object.
2023-08-09 05:13:24 +02:00
ronak69
b326a301c3 Userland: Pretty print the help text in BuggieBox
Now, in the help text, the names of all the supported utilities and
aliases are dynamically generated with the macro so that if new
utilities are added in the future they will get included automatically.

These utilities are printed in table-like format for some "aesthetics".
2023-08-09 02:10:02 +02:00
ronak69
06ee4b66d0 Userland: Add aliases to the macro in BuggieBox
Before, the `ENUMERATE_UTILITIES` macro only included utilities, and all
the aliases to the utilities were explicitly handled. This patch
combines utilities and aliases into one macro. This has the benefit of
being able to do operations involving both utilities and aliases without
having to choose which group to operate on first. Currently, aliases are
mixed with utilities while maintaining alphabetical sort.
2023-08-09 02:10:02 +02:00
Sam Atkins
debf38ee9d LibWeb: Add namespaces to Attribute selectors
For now, we parse these, but don't actually consider the namespace when
matching them. `DOM::Element` does not (yet) store attribute namespaces
so we can't check what they are.
2023-08-08 20:49:45 +01:00
Sam Atkins
1858f06881 LibWeb: Add namespaces to Universal and TagName selectors 2023-08-08 20:49:45 +01:00
Sam Atkins
6c2ed0f51b LibWeb: Fix use-after-free in CSSNamespaceRule parsing
Holding the `prefix` as a StringView meant it pointed at string data
held by `token`. `token` gets reassigned shortly afterwards, meaning
`prefix` would hold invalid character data.
2023-08-08 20:49:45 +01:00
Sam Atkins
5042c903be LibWeb: Add SimpleSelector::QualifiedName, with parsing
This is basically a name with a namespace prefix. It will be used for
adding namespaces to Universal, TagName, and Attribute selectors.

For convenience, this can also optionally parse/store the `*` wildcard
character as the name.
2023-08-08 20:49:45 +01:00
Sam Atkins
4b7b726888 LibWeb: Track all namespace rules in a CSSStyleSheet, and expose them 2023-08-08 20:49:45 +01:00
Sam Atkins
a8096d33ec LibWeb: Serialize @namespace using spec algorithms 2023-08-08 20:49:45 +01:00
Lucas CHOLLET
e83b04417b LibGfx/JPEGXL: Implement the ANS decoder
This allows us to read many more images. This decoder is one of the two
possibilities (along Brotli) that can be used for modular images. All
the logic is directly taken from the spec.

One of the image that can now be decoded is "Lucifer's Dominion:
Synthesis" that can be found on `https://jpegxl.info/art/`, it also
makes us pass one more test of the conformance test suite, namely
"alpha_triangles".
2023-08-08 20:03:16 +02:00
Lucas CHOLLET
4da8c45e43 LibGfx/JPEGXL: Store distributions in a Variant
JPEG XL supports two types of entropy encoding: the first one is
Huffman-based (Brotli) and the second one is based on ANS. To introduce
the latter, we start by storing the `Vector` of distributions in a
`Variant`. This will allow us to choose which entropy decoder we use
during execution.
2023-08-08 20:03:16 +02:00
Tim Schumacher
fb4db096cb Ports: Remove the filename entry from files 2023-08-08 19:57:43 +02:00
Tim Schumacher
2732545b4c Ports: Ensure that the download filename matches the URL basename
This is a preparation step for removing support for explicitly setting a
download filename entirely.
2023-08-08 19:57:43 +02:00
Tim Schumacher
c71815bc91 Ports: Move handling for simple downloads into a separate function 2023-08-08 19:57:43 +02:00
Tim Schumacher
a37b95f465 Ports: Do file downloading in a single big loop 2023-08-08 19:57:43 +02:00