Commit graph

57876 commits

Author SHA1 Message Date
Ali Mohammad Pur e265d81277 LibRegex: Correct And/Or and inversion interplay semantics
This commit also fixes an incorrect test case from very early on, our
behaviour now matches the ECMA262 spec in this case.

Fixes #21786.
2024-01-11 11:36:09 +01:00
Nico Weber 89315787ae LibGfx/ICC: Cache presence of various tags
Reduces time spent rendering page 3 of 0000849.pdf from 1.45s to 1.32s
on my machine.

Also reduces the time to run Meta/test_pdf.py on 0000.zip
(without 0000849.pdf) from 58s to 55s.
2024-01-11 08:15:22 +00:00
Nico Weber 3365a92ead LibGfx/ICC: Cache inverted matrix on profile
Reduces time spent rendering page 3 of 0000849.pdf from 1.85s to 1.45s
on my machine.

As determined by running

    time Build/lagom/bin/pdf --page 3 --render out.png \
        ~/Downloads/0000/0000849.pdf

a few times and eyeballing the min time.

Also reduces the time to run Meta/test_pdf.py on 0000.zip
(without 0000849.pdf) from 1m7s to 58s.
2024-01-11 08:15:22 +00:00
Nico Weber 19d434b229 LibGfx/ICC: Extract matrix computation functions
No behavior (or perf) change.
2024-01-11 08:15:22 +00:00
Nico Weber 5c5a24c6b7 LibGfx/ICC: Move some Profile member vars up a bit
...so that they're not below a FIXME that doesn't apply to them.

No behavior change.
2024-01-11 08:15:22 +00:00
Nico Weber 7d796c83f1 image: Fix flag names and grammar in diagnostic texts 2024-01-11 08:00:27 +00:00
ronak69 52340dc78a Mandelbrot: Allow panning with the arrow keys 2024-01-11 08:02:23 +01:00
ronak69 0f33d2a36d Mandelbrot: Only calculate the set in paint event
The set should be calculated only when there is a paint event to keep
the number of times the set is calculated (which is compute expensive)
to the minimum.
2024-01-11 08:02:23 +01:00
ronak69 fa026df892 Mandelbrot: Use renormalized fractional iteration count to smooth colors 2024-01-11 08:02:23 +01:00
Aliaksandr Kalenik 225ed58f7e LibWeb/CSS: Resolve NumericCalculationNode to percentage when requested
When the caller of NumericCalculationNode::resolve() does not provide
a percentage_basis, it expects the method to return a raw percentage
value.

Fixes crashing on https://discord.com/login
2024-01-11 08:01:47 +01:00
Nicolas Ramz 1593ff2d4c LibGfx/ILBMLoader: Don't throw too early when decoding bitplanes
We were (again) throwing even though the image could be decoded.
2024-01-10 23:41:15 +01:00
Ali Mohammad Pur 25eb903a8f LibProtocol: Don't assume request creation will succeed across IPC
Allow it to fail, and return null if it does.
Fixes frequent crashes in unfavourable network conditions.
2024-01-10 23:37:57 +01:00
Lucas CHOLLET f6b86096a5 LibGfx/TIFF: Prevent the CCITT decoder to run on non bilevel image 2024-01-10 23:34:44 +01:00
Lucas CHOLLET 0ef449a588 LibGfx/TIFF: Don't crash on invalid indices inside RGBPalette images
We were previously accessing a Vector's element using a user-provided
value as index input.
2024-01-10 23:34:44 +01:00
Lucas CHOLLET 58bdca96cd LibGfx/TIFF: Use a wider type for palette indices to prevent overflow
We refuse any image with a sample depth greater than 32, storing these
value as `u64` prevent any overflows. This is probably overkill as no
one in their right mind will use a 32 bits color table.
2024-01-10 23:34:44 +01:00
Lucas CHOLLET 4d1c99e414 LibGfx/TIFF: Don't crash on RGBPalette images without a ColorMap 2024-01-10 23:34:44 +01:00
Lucas CHOLLET 25c3f8cd8e LibGfx/TIFF: Prefer a verbal form over a noun 2024-01-10 23:34:44 +01:00
Tim Ledbetter 800cb4eceb SystemMonitor: Don't include the Idle Task in process statistics
The Idle Task is no longer displayed in the Processes tab and is not
included in the process count in the status bar.
2024-01-10 23:28:10 +01:00
Tim Ledbetter 1c1fc67f75 SystemMonitor: Prefer range-based for loop when updating ProcessModel 2024-01-10 23:28:10 +01:00
Shannon Booth faccca7b32 LibWeb: Add ref-tests for 3-value background positions with center 2024-01-10 23:27:28 +01:00
Shannon Booth d95461ebe1 LibWeb: Allow 'center' in 3-value background-positions
The grammar which we implemented did not match the spec, resulting in us
rejecting background positions which contained 'center' position
keywords.

Fixes: #22401
2024-01-10 23:27:28 +01:00
Nico Weber f7fc2df8ac LibPDF: Simplify load_image() a tiny bit
Images can't use Pattern color spaces, so we'll always have a Color.

No behavior (or perf) change.
2024-01-10 23:26:57 +01:00
Timothy Flynn 00510e40d9 LibWeb: Convert the cookie test page to a text test 2024-01-10 23:26:40 +01:00
Timothy Flynn 0989a81a48 headless-browser: Add support for cookies with SQLServer
This will allow us to test cookies and the database during CI.
2024-01-10 23:26:40 +01:00
Timothy Flynn a4f862a869 WebContent: Change the cookie setting IPC to be synchronous
Considering an operation like the following:

    document.cookie = "cookie=value";
    const value = document.cookie;

If the IPC for the cookie setter is asynchronous, the getter can execute
while the browser/SQLServer processes are still handling the setter.
This is often seen when hammering the document with cookie requests.
2024-01-10 23:26:40 +01:00
Timothy Flynn 5c5cbeb491 LibSQL+LibWebView: Do not manually serialize time stamps in CookieJar
LibSQL supports serializing time stamps as of commit
effcd080ca.

However, that commit serializes the timestamps as milliseconds, whereas
the CookieJar was serializing them as seconds. In retrospect, these
should have been updated in unison, along with the SQL heap version (as
this is a serialization change that affects the file format). So this
patch also updates the version, as this is not a backwards compatible
change.
2024-01-10 23:26:40 +01:00
Timothy Flynn 7a912ca891 LibSQL: Reset the highest written block during the zeroth block init
Otherwise, when changing the SQL heap version, the value from the now-
stale heap file will continue to be used.
2024-01-10 23:26:40 +01:00
Timothy Flynn cd0e07f6a4 LibSQL: Add a helper to convert a SQL::Value to a UnixDateTime
Support for constructing a Value from a UnixDateTime was added in commit
effcd080ca.

That constructor just stores the value as the number of milliseconds
since epoch. There's no way for outside users to know this, so this adds
a helper to retrieve the value as a UnixDateTime and let SQL::Value be
the source of truth for how the value is encoded/decoded.
2024-01-10 23:26:40 +01:00
Timothy Flynn 1205d39fc3 LibSQL+SQLServer: Inform SQLServer when the client has processed results
The architecture of SQLServer is currently such that it sends results
over IPC one row at a time. After the rows are exhausted, it sends a
completion IPC. However, it does not wait for the client to finish
processing a row before sending another row or the completion signal.

This can result in clients hanging if the completion comes in while a
row is being processed. At least in the case of WebView::Database, the
result is that the completion signal is dropped, and the browser then
hangs forever waiting for that signal (after it finishes processing the
row).

This patch makes SQLServer asynchronously wait for the client to tell it
that the row has been processed and the next row (or completion) may be
sent. We repurpose the `m_ongoing_executions` in SQLStatement for this
purpose (this member was oddly being written to, but otherwise unused).
2024-01-10 23:26:40 +01:00
Nico Weber df5451a889 LibPDF: Mark text rendering matrix dirty after changing it in text_begin
A certain PDF was drawing some text used `9 0 0 9 474.54 700.6801 Tm`
to set the text matrix to a matrix that scaled by 9 in one text object.

Then, after ending that text object, it had the following new text
object which contained nothing that invalidated the text matrix:

```
BT
/F1 7 Tf
/DeviceRGB CS
0 0 0 SC
10 TL
86.37849 21.908 Td
(Authorized licensed use limited to: ...) Tj
ET
```

`BT` did reset it as required, but since we didn't mark the matrix
as dirty, we never recomputed it and drew the additional text scaled
up 9x.
2024-01-10 19:42:08 +01:00
Andreas Kling 5af02a914c LibWeb: Let parent formatting context determine size of flex containers
Until now, we had implemented flex container sizing by awkwardly doing
exactly what the spec said (basically having FFC size the container)
despite that not really making sense in the big picture. (Parent
formatting contexts should be responsible for sizing and placing their
children)

This patch moves us away from the Flexbox spec text a little bit, by
removing the logic for sizing the flex container in FFC, and instead
making sure that all formatting contexts can set both width and height
of flex container children.

This required changes in BFC and IFC, but it's actually quite simple!
Width was already not a problem, and it turns out height isn't either,
since the automatic height of a flex container is max-content.
With this in mind, we can simply determine the height of flex containers
before transferring control to FFC, and everything flows nicely.

With this change, we can remove all the virtuals and FFC logic for
negotiating container size with the parent formatting context.
We also don't need the "available space for flex container" stuff
anymore either, so that's gone as well.

There are some minor diffs in layout test results from this, but the
new results actually match other browsers more closely, so that's fine.

This should make flex layout, and indeed layout in general, easier to
understand, since this was the main weird special case outside of
BFC/IFC where a formatting context delegates work to its parent instead
of the other way around. :^)
2024-01-10 16:28:12 +01:00
Sam Atkins 5f0230a57e LibGUI: Make NumericInput work well in GML
- Register the widget
- Register property getters and setters
- Rename getters and setters to match the property names, as required by
  the GML compiler. The names min/max/value are chosen to match SpinBox.
- Prevent a crash when the minimum is less than the maximum (which can
  happen while editing the GML).
2024-01-10 13:13:27 +00:00
Sam Atkins da349607a3 LibGUI: Make NumericInput respond to the mouse wheel
Scroll the mouse wheel over a NumericInput to quickly change the value.
This matches the SpinBox behavior.
2024-01-10 13:13:27 +00:00
Sam Atkins 4b96136803 LibGUI: Store NumericInput value as an i64
Moar range = moar better. I'm hoping to use this for a size_t value
later, so this almost covers that.
2024-01-10 13:13:27 +00:00
Sam Atkins ea31c11aff LibGUI+PDFViewer: Move NumericInput into LibGUI
A text box that is restricted to numbers within a range, is generally
useful. Let's make it available for use!
2024-01-10 13:13:27 +00:00
Nico Weber 4fd5d450be LibPDF: Add support for image masks
An image mask is a 1-bit-per-pixel bitmap that's black where the
current color should be painted, and white where it should be
transparent (think: like ink).

load_image() already converts images like this into 8-bit-per-pixel
images that have 0xff, 0xff, 0xff in rgb for opaque (originally 0 bit)
pixels and 0, 0, 0 in rgb for transparent pixels.

So we just move copy the image mask's image data into the alpha
channel and replace rgb with the current color, and then draw
it like a regular bitmap.
2024-01-10 09:10:11 +00:00
Bastiaan van der Plaat 675b242e84 LibWeb: Add missing CSS Transforms Module Level 2 functions 2024-01-10 09:48:25 +01:00
Bastiaan van der Plaat c443f80137 LibWeb: Allow percentages on CSS transform scale functions 2024-01-10 09:48:25 +01:00
Ali Mohammad Pur 57ea3e160a LibCompress: Use a __FILE__-relative path for the brotli dictionary file
This makes it so the generated assembly doesn't depend on
compile-specific search paths, also making it possible to build with
LTO.
2024-01-10 09:40:51 +01:00
Ali Mohammad Pur cd4ebc45a0 RequestServer: Avoid multiple connections to incompatible servers
This really only implements a heuristic, assuming that HTTP/1.0 servers
cannot handle having multiple active connections; this assumption has
lots of false positives, but ultimately HTTP/1.0 is an out-of-date HTTP
version and people using it should just switch to a newer standard
anyway.

Specifically, python's "SimpleHTTPRequestHandler" utilises a
single-threaded HTTP/1.0 server, which means no keepalive and more
importantly, hangs and races with more than a single connection present.
This commit makes it so we serialise all requests to servers that are
known to serve only a single request per connection (aka HTTP/1.0 with
our setup, as we unconditionally request keepalive)
2024-01-10 09:39:51 +01:00
Nico Weber e770cf06b0 LibPDF: Send jpeg data down the same path as all other data
JPEG images now honor decode arrays and color spaces.
2024-01-10 09:39:00 +01:00
Nico Weber d8ada20bae LibGfx: Allow images to report that they are originally grayscale
...and implement it in JPEGLoader.

Since it's easy to get the grayscale data off a Bitmap, don't
add a grayscale_frame() accessor.
2024-01-10 09:39:00 +01:00
Nico Weber 239da5132d LibGfx/JPEG: Make it possible to obtain raw CMYK data from JPEGs
frame() still returns a regular RGB Bitmap (now lazily converted
from internal CMYK data), but JPEGImageDecoderPlugin now also
implements cmyk_frame().
2024-01-10 09:39:00 +01:00
Nico Weber 51d5397e92 LibGfx: Give ImageDecoder an API for getting raw CMYK data
frame() still returns a regular RGB Bitmap, but it's possible to also
get at raw CMYK data instead if desired, for image formats that can
store that.
2024-01-10 09:39:00 +01:00
Nico Weber bc6eebb1d7 LibGfx: Add CMYKBitmap
This is a simple container for 2d CMYK data.

This is a new class instead of a new format in Bitmap because:
* Almost all clients of Bitmap will want to deal with RGB data
* It keeps the ARGB32 typedef working
* Bitmap already does a lot of things

The idea is that a few select places will be able to use
CMYKBitmap and a color profile to do a better CMYK -> RGB conversion
than an image decoder could do, and then store the result in a Bitmap
for later display then.

CMYKBitmap misses some of Bitmap's features, such as shared
memory support, high-dpi scaling capability, etc.
2024-01-10 09:39:00 +01:00
Nico Weber c997ee7b9d LibGfx+ImageViewer: Replace ImageDecoder::is_vector() with an enum
That makes it easier to extend to other special frame formats.
2024-01-10 09:39:00 +01:00
Bastiaan van der Plaat a47edb4ed1 LibWeb: Refactor unsigned to u32 in WebContentServer.ipc
The type u32 is already used almost everywhere in
WebContentServer.ipc except for the mouse and key
events so let's fix that.
2024-01-10 09:38:41 +01:00
Bastiaan van der Plaat 5c00e2bb7f LibWeb: Remove refusing to run script debug line
Many sites load application/json and application/ld+json
content with script elements, so this debug line shows
up on a lot of sites and is not informative.
2024-01-10 09:38:41 +01:00
Nico Weber 7fb32b6682 LibGfx: Fix off-by-some in Painter::draw_scaled_bitmap_with_transform()
Before this, drawing a 1x1 bitmap scaled up to MxN would only fill
M/2 x N/2 pixel, due to source_point going outside (0, 0).
2024-01-10 09:38:13 +01:00
Nico Weber 822b7720e1 Meta: Let test_pdf.py be less dramatic about issue counts
For every issue string, json['issues'][issue_string] contains a list
of (page, count_of_issue_on_this_page) tuples.

To get the total number the issue appears in the current document,
we need to add up all the count_of_issue_on_this_page, not multiply the
page number with count_of_issue_on_this_page and add those (-‸ლ)
2024-01-10 09:36:33 +01:00