Commit Graph

21396 Commits

Author SHA1 Message Date
Aliaksandr Kalenik
f6a9f613c7 LibAccelGfx+LibWeb: Add basic support for linear gradients painting
Linear gradient painting is implemented in the following way:
1. The rectangle is divided into segments where each segment represents
   a simple linear gradient between an adjacent pair of stops.
2. Each quad is filled separately using a fragment shader that
   interpolates between two colors.

For now `angle` and `repeat_length` parameters are ignored.
2023-11-16 18:02:51 +01:00
Aliaksandr Kalenik
61a2e59d87 LibAccelGfx+WebContent: Add GPU painter support on macOS
With these changes it is now possible to create OpenGL context on macOS
and run GPU-painter. For now only QT client has a CLI param that turns
it on though.
2023-11-16 15:13:16 +01:00
Andreas Kling
ffe304e88b LibJS: Don't create arguments object due to o.arguments access
When deciding whether we need to create a full-blown `arguments` object,
we look at various things, starting as early as in the parser.

Until now, if the parser saw the identifier `arguments`, we'd decide
that it's enough of a clue that we should create the `arguments` object
since somebody is obviously accessing it.

However, that missed the case where someone is just accessing a property
named `arguments` on some object. In such cases (`o.arguments`), we now
hold off on creating an `arguments` object.

~11% speed-up on Octane/typescript.js :^)
2023-11-16 13:26:21 +01:00
Stephan Vedder
32352aa729 LibJS/JIT: Add a fast path for floating point comparisons 2023-11-16 11:43:44 +01:00
Aliaksandr Kalenik
4164af2ca4 LibWeb: Do not compensate padding for abspos boxes with static position
When a box does not have a top, left, bottom, or right, there is no
need to adjust the offset for positioning relative to the padding edge,
because the box remains in the normal flow.
2023-11-15 23:44:05 +01:00
Timothy Flynn
2c1bbf5a99 AK+LibIDL: Put IDL dbgln statement behind a debug flag
This is a bit spammy now that we are performing some overload resolution
at build time. The fallback to an interface has generally worked fine on
the types it warns about (BufferSource, Module, etc.) so let's not warn
about it for every build.
2023-11-15 23:42:53 +01:00
Timothy Flynn
e1092aed3c LibWeb: Don't reject worker scripts with a JavaScript MIME type
The condition for checking if a script has a JS MIME type is currently
flipped. Extract the check to a local to make it a bit easier to reason
about at quick glance.
2023-11-15 11:28:39 -05:00
Andrew Kaster
ea95256f83 LibWeb: Remove unused ResourceLoader::load(URL) overload
With the refactoring of Workers, nobody is calling this LoadRequest-less
overload. All new code should eventually be moved to fetch anyway.
2023-11-15 12:56:33 +01:00
Andrew Kaster
124c378472 LibWeb+WebWorker: Move worker execution into a new WebWorker process
We now create a WorkerAgent for the parent context, which is currently
only a Window. Note that Workers can have Workers per the spec.

The WorkerAgent spawns a WebWorker process to hold the actual
script execution of the Worker. This is modeled with the
DedicatedWorkerHost object in the WebWorker process.
A start_dedicated_worker IPC method in the WebWorker IPC creates the
WorkerHost object. Future different worker types may use different IPC
messages to create their WorkerHost instance.

This implementation cannot yet postMessage between the parent and the
child processes.

Co-Authored-By: Andreas Kling <kling@serenityos.org>
2023-11-15 12:56:33 +01:00
Andrew Kaster
3dbbb5b263 LibWeb: Implement fetch a classic worker script 2023-11-15 12:56:33 +01:00
Andrew Kaster
d7d84ee931 LibWeb: Ensure a Web::Page is associated with local Worker LoadRequests
This is a hack on top of a hack because Workers don't *really* need to
have a Web::Page at all, but the ResourceLoader infra that should be
going away soon ™️ is not quite ready to axe that requirement for
cookies.
2023-11-15 12:56:33 +01:00
Andrew Kaster
5586340cf3 LibWeb: Don't set EventTarget prototype on any WindowOrWorkerGlobalScope
The same limitations regarding construction of Window apply to all
WorkerGlobalScope classes as well.
2023-11-15 12:56:33 +01:00
Andrew Kaster
4fcff01ef3 LibWeb: Clean up assumptions in Bindings::HostDefined
We don't have a 'root execution environment' anymore (thankfully), so
we can make sure that the ESO the HostDefined object holds onto is a
NonnullGCPtr.
2023-11-15 12:56:33 +01:00
Aliaksandr Kalenik
eac7916d2c LibWeb: Use inner available space to calculate auto height of abspos
By using available_inner_space_or_constraints_from(available_space), we
ensure that the available space used to calculate the min/max content
height is constrained by the width specified for the box itself
(I know that at least GFC always expects available width to be
constrained by specified width if there is any).

This change improves layout in "Recent news" block on
https://telegram.org/
2023-11-15 11:26:14 +01:00
Lucas CHOLLET
1e8004734f LibPDF: Don't consider the End of Data code as normal ASCII85 input
Data encoded with ASCII85 is terminated with the EOD code 0x7E3E. This
should not be considered as normal input but rather discarded.
2023-11-14 10:15:15 +01:00
Lucas CHOLLET
59a6d4b7bc LibPDF: Factorize duplicated code in Filter::decode_ascii85() 2023-11-14 10:15:15 +01:00
Lucas CHOLLET
2fe0647c68 LibPDF: Handle pdf-specific white spaces correctly in ASCII85
We were previously only looking the space character but PDF white
spaces is a superset of ascii spaces.
2023-11-14 10:15:15 +01:00
Lucas CHOLLET
db08fe12ec LibPDF: Implement Reader::is_[eol, whitespace](char)
These two static members are now used to implement respective `matches_`
methods but will also be useful to provide a global implementation of
the specified concept of whitespace.
2023-11-14 10:15:15 +01:00
Lucas CHOLLET
dac703a0b8 LibPDF: Avoid an unnecessary copy in Filter::decode_ascii85() 2023-11-14 10:15:15 +01:00
Kemal Zebari
e80d3ff518 LibWeb: Have MimeType::create() match its foward declaration 2023-11-14 10:14:09 +01:00
Kemal Zebari
6b37095ffd LibWeb: Validate MimeType(String, String) arguments correctly
This commit correctly validates the `type` and `subtype` arguments,
instead of checking for http quoted code points, by following how
the spec's MIME type parsing algorithm would validate a MIME type's
type and subtype.

It also uses the move-assigned member variables instead of the
arguments within the constructor body (as using the arguments at
this point will lead to undesired behavior).
2023-11-14 10:14:09 +01:00
MacDue
2248d85894 LibWeb: Remove should_ensure_creation_of_paintable() SVG hack
The elements this hack was being used for were grouping elements, and
can be properly sized: https://svgwg.org/svg2-draft/struct.html#Groups.

Note: Other than one test change the elements here are already covered
by layout tests.
2023-11-14 10:13:10 +01:00
MacDue
9b2b28b612 LibWeb: Use BoundingBox helper in SVGFormattingContext 2023-11-14 10:13:10 +01:00
MacDue
f3c8e88e5e LibGfx: Use BoundingBox helper in Gfx::Path 2023-11-14 10:13:10 +01:00
MacDue
93243283f0 LibGfx: Add BoundingBox helper class
This is a small helper class to compute the bounding box of a set of
points.
2023-11-14 10:13:10 +01:00
Tim Ledbetter
9a8cc5a98d LibDNS: Ensure DNS name and label sizes are within expected limits
Previously, the DNS packet parser would happily parse a DNS packet
containing an arbitrarily large domain name. We now limit each segment
of a domain name to 63 characters and the total domain name length to
253 characters. This is consistent with RFC1035, which specifies that
the maximum name length is 255 octets. This includes the initial length
byte and final null byte, which accounts for the 2 byte difference.
2023-11-14 10:12:44 +01:00
Tim Ledbetter
1793f51bc6 LibDNS: Make DNS packet parsing fallible
Previously, a DNS packet containing an invalid name would be returned
with an empty name. With this change, an error is returned if any error
is encountered during parsing.
2023-11-14 10:12:44 +01:00
Matthew Olsson
95d62822bf LibWeb: Implement KeyframeEffect::set_pseudo_element 2023-11-14 10:12:02 +01:00
Matthew Olsson
5824916f8c LibWeb: Add KeyframeEffect IDL objects 2023-11-14 10:12:02 +01:00
Nico Weber
9b022239c3 LibPDF: Apply all offsets of TJ operator
TJ acts on a list of either strings or numbers.
The strings are drawn, and the numbers are treated as offsets.

Previously, we'd only apply the last-seen number as offset when
we saw a string. That had the effect of us ignoring all but the
last number in front of a string, and ignoring numbers at the
end of the list.

Now, we apply all numbers as offsets.
Our rendering of Tests/LibPDF/text.pdf now matches other PDF viewers.
2023-11-14 10:11:09 +01:00
Nico Weber
1c2b0feb7b LibPDF: Change how CFF optional width prefix is stored
Per 5177.Type2.pdf 3.1 "Type 2 Charstring Organization",
a glyph's charstring looks like:

    w? {hs* vs* cm* hm* mt subpath}? {mt subpath}* endchar

The `w?` is the width of the glyph, but it's optional. So all
possible commands after it (hstem* vstem* cntrmask hintmask
moveto endchar) check if there's an extra number at the start
and interpret it as a width, for the very first command we read.

This was done by having an `is_first_command` local bool that
got set to false after the first command. That didn't work with
subrs: If the first command was a call to a subr that just pushed
a bunch of numbers, then the second command after it is the actual
first command.

Instead, move that bool into the state. Set it to false the
first time we try to read a width, since that means we just read
a command that could've been prefixed by a width.
2023-11-14 10:10:34 +01:00
Bastiaan van der Plaat
d3b3e49e19 LibJS/JIT: Use the x86_64 setcc instruction to remove a branch 2023-11-14 09:54:48 +01:00
Timothy Flynn
1d76738dde LibJS: Change Intl.Locale info APIs from property getters to methods
This is a normative change in the Intl Locale Info spec. See:
https://github.com/tc39/proposal-intl-locale-info/commit/e550152
2023-11-13 20:10:58 +01:00
Timothy Flynn
a357874c77 LibJS: Implement Intl.Locale.prototype.firstDayOfWeek
This is a normative change in the Intl Locale Info spec. See:
https://github.com/tc39/proposal-intl-locale-info/commit/f03a814
2023-11-13 20:10:58 +01:00
Tim Ledbetter
b5875700e2 LibJS: Don't hang when parsing invalid destructuring assignment target
Previously, certain crafted input could cause the JS parser to hang, as
it repeatedly tried to parse an EOF token after hitting an "invalid
destructuring assignment target" error. This change ensures that we
stop parsing after hitting this error condition.
2023-11-13 20:10:36 +01:00
Aliaksandr Kalenik
01d938c77b LibAccelGfx+LibWeb: Implement SetClipRect and ClearClipRect commands 2023-11-13 19:22:27 +01:00
Lucas CHOLLET
9e4d697d23 LibPDF: Detect DCT images correctly
Images can have multiple filters, each one of them is processed
sequentially. Only the last one will be relevant for the image format
(DCT or JPXDecode), so use the last filter instead of the first one to
detect that property.
2023-11-13 10:30:34 -05:00
Nico Weber
f882a3ae37 LibPDF: In ColorSpace creation code, use resolve_to() more
For valid PDFs, this makes no difference.

For invalid PDFs, we now assert during the cast in resolve_to() instead
of returning a PDFError. However, most PDFs are valid, and even for
invalid PDFs, we'd previously keep the old color space around when
getting the PDF error and then usually assert later when the old
color space got passed a color with an unexpected number of components
(since the components were for the new color space).

Doesn't affect any of the > 2000 PDFs I use for testing locally,
is less code, and should make for less surprising asserts when it
does happen.
2023-11-13 10:29:26 -05:00
Stephan Vedder
9c63f9854b LibJS/JIT: Remove incorrect check for empty tag
This check is not required and prevented put_by_value
to take the actual fastpath.
2023-11-13 14:28:27 +01:00
Lucas CHOLLET
9bc25db9a3 LibPDF: Add support for the LZW filter
This allows us to decode the first page of ThinkingInPostScript.pdf :^)
2023-11-13 14:23:23 +01:00
Lucas CHOLLET
048ef11136 LibPDF: Factorize flate parameters handling to its own function
This part will be shared with the LZW filter, so let's factorize it.
2023-11-13 14:23:23 +01:00
Andreas Kling
e8c0cea5f9 LibJS/JIT: Use right shift to extract type tags in equality codegen
7% speed-up on Kraken/ai-astar.js, covers up most of the regression
from adding more fast paths. :^)
2023-11-13 13:49:21 +01:00
iliadsh
ad98834b50 LibJS/JIT: Add more equality fast paths 2023-11-13 13:33:43 +01:00
iliadsh
671cbf6a5b LibJS/JIT: Add GetGlobal fast path 2023-11-13 13:33:43 +01:00
iliadsh
ddea710933 LibJS: Expose various offsets for GetGlobal JIT fast path 2023-11-13 13:33:43 +01:00
iliadsh
c739c931c1 LibJS/JIT: Add PutByValue fast path for simple array access 2023-11-13 13:33:43 +01:00
Nico Weber
bbde3cbc90 LibPDF: Tolerate an indirect object as dict for CIE-based color spaces
Namely, for CalGrayColorSpace, CalRGBColorSpace, LabColorSpace.

Fixes a crash rendering any page of Adobe's 5014.CIDFont_Spec.pdf
(which uses CalRGBColorSpace with an indirect dict: The dict is
object `92 0`, and many color spaces are inline objects referring
to it).
2023-11-13 07:12:05 -05:00
Aliaksandr Kalenik
f7874d03fc LibWeb: Remove redundant flush() call in PaintingCommandExecutorGPU
Since we already call `Painter::flush()` in `PageHost::paint()` we do
not need to do that again in `PaintingCommandExecutorGPU` destructor.

This makes GPU painting run noticeably faster because `flush()` does
expensive `glReadPixels()` call.
2023-11-12 20:21:07 +01:00
Andreas Kling
b532dedc91 LibJS/JIT: Add fast path for GetById of Array.length
Array.length is magical (since it has to reflect the number of elements
in the object's property storage).

We now handle it specially in jitted code, giving us a massive speed-up
on Kraken/ai-astar.js (and probably many other things as well) :^)
2023-11-12 19:57:27 +01:00
Andreas Kling
e41f0d9dec LibJS/JIT: Add fast path for loose equality check between 2 objects
There are more fast paths to be added here, just starting with this
one since it's heavy on Kraken/ai-astar.js :^)
2023-11-12 19:57:27 +01:00