Commit graph

29564 commits

Author SHA1 Message Date
Tim Schumacher
a2f60911fe AK: Rename GenericTraits to DefaultTraits
This feels like a more fitting name for something that provides the
default values for Traits.
2023-11-09 10:05:51 -05:00
Andreas Kling
ac23ab42b3 LibJS/JIT: Add fast path for cached GetById 2023-11-09 16:02:14 +01:00
Andreas Kling
55e467c359 LibJS/JIT: Add fast path for cached PutById 2023-11-09 16:02:14 +01:00
Andreas Kling
b1b2ca1485 LibJS: Add basic monomorphic caching for PutById property access
This patch makes it possible for JS::Object::internal_set() to populate
a CacheablePropertyMetadata, and uses this to implement a basic
monomorphic cache for the most common form of property write access.
2023-11-09 16:02:14 +01:00
Aliaksandr Kalenik
28118623f5 LibAccelGfx+LibWeb: Add basic line painting support
For now only solid line style is supported.
2023-11-09 10:47:31 +01:00
Aliaksandr Kalenik
f1824a524d LibAccelGfx: Add 1px padding between glyphs in prepare_glyph_texture()
This fixes bug when tiny slice of another glyph appearing along with
the required glyph.
2023-11-09 07:56:45 +01:00
Aliaksandr Kalenik
fd3411c868 LibWeb: Ignore document's box during overflow clip rect calculation
Reduction of bug:
```html
<!DOCTYPE html><style>
html {
    overflow-x: hidden;
    overflow-y: scroll;
}
div {
    background: orange;
    height: 1000px;
    width: 500px;
}
</style><body><div>
```

Fixes https://github.com/SerenityOS/serenity/issues/21690 and painting
on many other websites (null.com, servo.org).
2023-11-09 07:56:34 +01:00
Timothy Flynn
a098b6e371 LibGfx: Ensure const-correctness when reading from the GPOS byte stream
Otherwise, the call to `read_in_place` gives the following error:

    Tried to obtain a non-const span from a read-only FixedMemoryStream
2023-11-08 22:26:36 +00:00
Todderod
bb9230bbcd LibJS: Remove redundant Store op
If the property for GetByValue in Generator::load_from_reference
is a calculated value this would be stored in an allocated
register and returned from the function. Not all callers want
this information however, so now only give it out when asked for.

Reduced the instruction count for Kraken/ai-astar.js function
"neighbours" from 214 to 192.
2023-11-08 22:18:28 +01:00
Stephan Vedder
13726fd3b7 LibJS/JIT: Add fast path for decrement
Generate jitted code for the decrement opcode.
2023-11-08 21:09:44 +01:00
Stephan Vedder
0e69f744df LibJS/JIT: Add increment instruction
Instead of using `Add` with an immediate of 1 use the `Inc` instruction
2023-11-08 21:09:44 +01:00
Timothy Flynn
e122039c99 LibRegex: Support non-ASCII case-insensitive character comparisons
Specifically, when the Unicode flag is set, use Unicode-aware case
folding to case-insensitively compare code points.
2023-11-08 12:54:26 -05:00
Timothy Flynn
6070df40f3 LibUnicode: Define case-insensitive string comparison more generically
The only user is currently String::equals_ignoring_case, but LibRegex
will need to do the same case-folded comparison with UTF-32 data. As it
turns out, the comparison works with all Unicode view types without much
fuss.
2023-11-08 12:54:26 -05:00
Lucas CHOLLET
5e2b049de8 LibCompress/LZW: Use a LittleEndianBitStream
No need to manually implement bit stream logic when we have a helper for
this task.
2023-11-08 18:19:34 +01:00
Lucas CHOLLET
b00476abac AK: Use an enum to specify the open mode instead of a bool
Let's replace this bool with an `enum class` in order to enhance
readability. This is done by repurposing `MappedFile`'s `OpenMode` into
a shared `enum` simply called `Mode`.
2023-11-08 18:19:34 +01:00
Lucas CHOLLET
00ad8419cf LibGfx+LibCompress: Extract the LZW decoder and move it to LibCompress
Let's put this state-of-the-art decoder from the 80's in its own file in
order to reuse it with other formats, such as TIFF or PDF.
2023-11-08 18:19:34 +01:00
Lucas CHOLLET
a86c0ac003 LibGfx/GIF: Use east-side const 2023-11-08 18:19:34 +01:00
Strawby
387decbb01 Spider: Add Manual link to the help-context-menu 2023-11-08 16:26:23 +00:00
Strawby
df6668ff5b Calculator: Add Manual link to the help-context-menu 2023-11-08 16:26:23 +00:00
Strawby
056070ff85 3DFileViewer: Add Manual link to the help-context-menu 2023-11-08 16:26:23 +00:00
Sebastian Bernauer
8eb9c2dc54 LibJS/JIT: Add fast path for number comparisons
So far only less_than was using a fast path. This commits uses the same
path for less_than_equals, greater_than and greater_than_equals.
2023-11-08 14:11:51 +01:00
Tim Ledbetter
ff81513634 Shell: Avoid infinite loop when parsing heredoc entry in POSIX mode
Previously, the shell would enter an infinite loop when attempting to
parse a heredoc entry within a `$(` command substitution.
2023-11-08 15:04:08 +03:30
Aliaksandr Kalenik
c170dd323e LibJS: Make eval() prevent GetGlobal usage less aggressively
Before usage of GetGlobal was prevented whenever eval() is present in
the scope chain.

With this change GetGlobal is emitted for `g` in the following program:
```js
function screw_everything_up() {
    eval("");
}

var g;
g;
```

It makes Octane/mandreel.js benchmark run 2x faster :)
2023-11-08 10:07:56 +01:00
Matthew Olsson
1ca46afa2f LibWeb: Add the Animation IDL object 2023-11-08 09:58:18 +01:00
Matthew Olsson
0df06ce273 LibWeb: Add the AnimationEffect IDL object 2023-11-08 09:58:18 +01:00
Luke Wilde
fc42c75a0c LibWeb: Make Window.postMessage closer to the spec
The main issues are using Structured{Serialize,Deserailize} instead of
Structured{Serialize,Deserialize}WithTransfer and the temporary
execution context usage for StructuredDeserialize.

Allows Discord to load once again, as it uses a postMessage scheduler
to render components, including the main App component. The callback
checked the (previously) non-existent source attribute of the
MessageEvent and returned if it was not the main window.

Fixes the Twitch cookie consent banner saying "failed integrity check"
for unknown reasons, but presumably related to the source and origin
attributes.
2023-11-08 09:55:24 +01:00
Luke Wilde
464cc55b16 LibWeb: Default initialize strings in MessageEventInit 2023-11-08 09:55:24 +01:00
Luke Wilde
1607b2c978 LibWeb: Add MessageEvent.source 2023-11-08 09:55:24 +01:00
Tim Ledbetter
e510d81567 Assistant: Prioritize results which exactly match a query 2023-11-08 09:52:24 +01:00
Tim Ledbetter
e1099a1757 Fuzzers: Use a single fuzzer to test all LibTextCodec encodings
This commit replaces the 5 fuzzers that previously tested LibTextCodec
with a single fuzzer. We now rely on the fuzzer to generate the
encoding and separate it from the encoded data with a magic separator.
This increases the overall coverage of LibTextCodec and eliminates the
possibility of the same error being generated by multiple fuzzers.
2023-11-08 09:39:49 +01:00
Tim Ledbetter
33ad384a7d Fuzzers: Add a DNS packet fuzzer 2023-11-08 09:38:36 +01:00
Tim Ledbetter
2fbaeb9694 LibDNS: Prevent malformed DNS packets from causing buffer overflows 2023-11-08 09:38:36 +01:00
Tim Ledbetter
4e3b59a4bb LibDNS: Prefer spans over raw pointers when parsing DNS packets
This means we don't have to keep track of the pointer and size
separately.
2023-11-08 09:38:36 +01:00
Tim Ledbetter
c1d7a51391 LibGfx/ICC: Avoid buffer overrun when creating TextDescriptionTagData
We now validate that the offsets used cannot overflow, preventing
possible buffer overruns.
2023-11-08 09:37:30 +01:00
Tim Ledbetter
4b995542c4 LibIMAP: Make parsing of atom data fallible
We now return an error where `parse_atom()` would have previously
returned an empty StringView. This is consistent with RFC3501, which
says that an atom consists of one or more characters.

This prevents a few cases where parsing an invalid atom could lead to
an infinite loop.
2023-11-08 09:36:37 +01:00
Tim Ledbetter
b96a5f4265 LibGfx/ILBM: Avoid overflow when creating bitplane data buffer 2023-11-08 09:36:01 +01:00
Tim Ledbetter
5e1017bcf1 LibGfx/ILBM: Avoid buffer overrun when reading bitplane data 2023-11-08 09:36:01 +01:00
Tim Ledbetter
f56ae8c0e9 LibGfx/ILBM: Ensure CMAP chunk size matches expected value
The color map should be 3 bytes per pixel and should contain
`2^nPlanes` pixels. We now return an error if the color map isn't the
size we expect.
2023-11-08 09:36:01 +01:00
Tim Ledbetter
61eb754f63 LibGfx/ILBM: Add validation for header fields
We now exit early if a header field is set to a value that we don't
currently support.
2023-11-08 09:36:01 +01:00
Tim Ledbetter
bed7b33daa LibGfx/ILBM: Don't attempt to decode a BODY chunk without a color map
While this isn't disallowed by the specification, it is not something
we currently support. Instead of crashing we now return an error in
this case.
2023-11-08 09:36:01 +01:00
Tim Ledbetter
75731f9c50 LibGfx/ILBM: Avoid buffer overruns when decompressing data 2023-11-08 09:36:01 +01:00
Tim Ledbetter
ae6c39e501 LibGfx/ILBM: Ensure decompressed body chunk data is the correct length 2023-11-08 09:36:01 +01:00
Sam Atkins
21f2f09df4 LibGfx: Remove bit casting in OpenType CBDT table after construction 2023-11-08 09:34:09 +01:00
Sam Atkins
4e944e676b LibGfx: Use to_underlying() to compare ValueFormat enum values
This means we no longer do a bitwise and of a u16 and i16, which feels a
little sketchy.
2023-11-08 09:34:09 +01:00
Sam Atkins
74e5fff77a LibGfx: Reduce bit casting in OpenType GPOS table after construction
Read the basic lists as spans, and use those when looking for kerning.

Kerning lookup still does bit-casting for now. As for CBLC, the data is
a bit complicated.
2023-11-08 09:34:09 +01:00
Sam Atkins
2a4d7a193e LibGfx: Define and use OpenType data types for struct definitions
A few closely-related changes:
- Move our definitions of the OpenType spec's "data types" into their
  own header file.
- Add definitions for the integer types there too, for completeness.
  (Plus Uint16 matches the spec term, and is less verbose than
  BigEndian<u16>.)
- Include Traits for the non-BigEndian types so that we can read them
  from Streams. (BigEndian<integer-type> already has this.)
- Use the integer types in our struct definitions.

As a bonus, this fixes a bug in Hmtx, which read the left-side bearings
as i16 instead of BigEndian<i16>.
2023-11-08 09:34:09 +01:00
Sam Atkins
a28f035d76 LibGfx: Reduce bit casting in OpenType CBLC table after construction
The subtables are still read at use-time for now. I'm sure we could
build some kind of wrapper structures for them though.
2023-11-08 09:34:09 +01:00
Sam Atkins
3c7d654182 LibGfx: Remove bit casting in OpenType Kern table after construction
Do more checks at load time, including categorizing the subtables and
producing our own directory of them.

The format for Kern is a little complicated, so use a Stream instead of
manual offsets.
2023-11-08 09:34:09 +01:00
Sam Atkins
89b35c6dc8 LibGfx: Remove bit casting in OpenType Name table after construction
Store the name records as a span, and a separate bytes span for the
string data.
2023-11-08 09:34:09 +01:00
Sam Atkins
fe2e1a0282 LibGfx: Remove bit casting in OpenType OS2 table after construction 2023-11-08 09:34:09 +01:00