Commit Graph

29747 Commits

Author SHA1 Message Date
Matthew Olsson
4efbb10a36 LibWeb: Keep track of associated Animations in AnimationTimeline
This allows the timeline to propagate changes in time to any relevant
animation objects.
2023-11-11 08:58:08 +01:00
Matthew Olsson
0d3c8a1cd9 LibWeb: Implement AnimationEffect's transformed_progress helper 2023-11-11 08:58:08 +01:00
Matthew Olsson
611faf3645 LibWeb: Add a timing function to AnimationEffect 2023-11-11 08:58:08 +01:00
Matthew Olsson
66bd75f2b9 LibWeb: Add a TimingFunction struct implementing the Web Easing spec
This is mostly a copy-paste of the algorithms already in StyleComputer
with spec links and comments. The only thing that really changed is the
handling of values outside of the range [0, 1] in the cubic bezier
function.

The implementation in StyleComputer will be removed in a later commit.
2023-11-11 08:58:08 +01:00
Jesús (gsus) Lapastora
1850652881 LibJS/Bytecode: Check if eval function is a function
When overriding 'eval' to a non-function value, the interpreter would
crash. Now it handles this case swiftly, throwing a TypeError.
2023-11-11 08:56:12 +01:00
Nico Weber
a9ef65e64a LibPDF: For multi-output SampledFunctions, fix output colors
For N outputs, the outputs aren't stored in N independent planes.
Instead, N output values are stored right next to each other in
the stream data.
2023-11-11 08:55:37 +01:00
Nico Weber
ec739460e0 LibPDF: Add test for SampledFunction and fix bugs found by it
* SampledFunction now keeps the StreamObject it gets data from alive
  (doesn't matter too much in practice, but does matter in the test,
  where nothing else keeps the stream alive).

* If a sample is an integer, we would previously sample that value
  twice and then divide by zero when interpolating. Make sure to
  sample 1 unit apart.
2023-11-11 08:55:37 +01:00
Idan Horowitz
e58209e5cf LibJS: Skip an always-false branch in the JIT to_boolean slow case 2023-11-11 08:55:18 +01:00
Timothy Flynn
9421ffd4ec Browser: Implement pasting Web data to the clipboard 2023-11-11 08:54:37 +01:00
Timothy Flynn
306850652f LibWebView+WebContent: Add an IPC hook to insert data into the clipboard 2023-11-11 08:54:37 +01:00
Timothy Flynn
4b94b0b561 LibWeb: Begin implementing the Clipboard API
https://w3c.github.io/clipboard-apis/

This implements enough for navigator.clipboard.writeText(String).
2023-11-11 08:54:37 +01:00
Timothy Flynn
78d455e231 LibWeb: Add an Internals API to trigger a user-activated (trusted) event
Some DOM APIs are restricted to user-activated events. For example, you
can't just invoke `navigator.clipboard.writeText` from JS - it has to be
accompanied by a user gesture, such as a mouse-down event. This adds an
Internals API to simulate such a gesture.
2023-11-11 08:54:37 +01:00
Matthew Olsson
6761791c9a LibIDL: Require the 'attribute' keyword when parsing attributes 2023-11-11 08:52:50 +01:00
Matthew Olsson
b081cf077e LibIDL: Verify inner type of nullable type is valid 2023-11-11 08:52:50 +01:00
Matthew Olsson
1a94241f58 IDL: Add missing #imports 2023-11-11 08:51:51 +01:00
Matthew Olsson
3ff481938e IDL: Fix syntax errors
All attributes must have an "attribute" keyword, and "any?" is invalid
(as "any" includes "null" as well).
2023-11-11 08:51:51 +01:00
Matthew Olsson
26e6c47d0a IDL: Add missing spec links
The only IDL interface without a spec link is Internals
2023-11-11 08:51:51 +01:00
Tim Ledbetter
1eae02a018 LibGfx/OpenType: Add validation for OpenType head table values
Previously, a crash would occur if a font file had an invalid
IndexToLocFormat value.
2023-11-11 08:51:02 +01:00
Shannon Booth
87a4a5b302 LibWeb: Remove FIXMe's for HTML attribute serialization steps
As far as I can tell all of these steps are just equivalent to using the
qualified name. Add some tests which cover some of these cases, and
remove the FIXME's.
2023-11-11 08:50:25 +01:00
Shannon Booth
96fc1741b5 LibWeb: Return an Optional<String> from HTMLToken::attribute
Move away from using a nullable StringView.
2023-11-11 08:50:25 +01:00
Shannon Booth
72bb928dd8 LibWeb: Add spec comments to HTMLParser::handle_in_body
I have been going down into a bit of a rabbit hole trying to figure out
why the namespace is not getting set up properly on certain attributes.
At one stage, I thought the issue might have been around here where
attributes were being adjusted (it is not). I started adding spec
comments to understand what was happening, and by the time I realised it
wasn't in this place, I was already in too deep!

Add a whole bunch of spec comments, and leave one or two minor FIXME's
where the spec seems to have changed since this was originally
implemented.
2023-11-11 08:50:25 +01:00
Shannon Booth
45b63b463a LibWeb: Add Element::for_each_attribute(Function<void(Attr const&)>)
This is useful when you are wanting to interate over attributes and need
more information than just the name and value.
2023-11-11 08:50:25 +01:00
Shannon Booth
a8fd4fab00 LibWeb: Port HTMLParser::serialize_html_fragment from DeprecatedString 2023-11-11 08:50:25 +01:00
Idan Horowitz
f2410071cd LibIDL: Support dictionary types when distinguishing argument indices 2023-11-11 08:48:25 +01:00
Idan Horowitz
f837f02eea LibIDL+LibWeb: Resolve distinguishing argument index at build time
Aside from the obvious performance benefits, this will allow us to
properly handle dictionary types. (whose dictionary-ness is only known
at build-time)

Much of the rest of the overload resolution algorithm steps can (and
should) be evaluated at build-time as well, but this is a good first
step.
2023-11-11 08:48:25 +01:00
Aliaksandr Kalenik
048e179572 LibAccelGfx: Use wrapping functions with error check for OpenGL calls
This change introduces GL.h with error check wrappers for all the
OpenGL functions we used so far.

For now, the error check is simply:
`VERIFY(glGetError() == GL_NO_ERROR);`
but that is better than continuing execution after encounting an error.
2023-11-11 08:47:12 +01:00
Sönke Holz
6824d2a788 Userland+Tests: Add initial riscv64 support 2023-11-10 10:30:08 -07:00
Michiel Visser
c6b2a07326 LibCrypto: Add static_assert to check that A = -3 mod p
This is required for some optimization made in the file. While this
should always be the case for the SECP256r1 curve, it is good to check
it anyway.
2023-11-10 09:54:00 -07:00
Michiel Visser
4f4034d1a4 LibCrypto: Also check Z when checking if point is on the curve 2023-11-10 09:54:00 -07:00
Michiel Visser
399dc211fa LibCrypto: Use simplified u256 constructor when reading big endian data 2023-11-10 09:54:00 -07:00
Michiel Visser
153cd3ecf0 LibCrypto: Use square-and-multiply loop for modular_inverse
Instead of using the hand unrolled version of the square-and-multiply
algorithm, we now simply use a loop.
2023-11-10 09:54:00 -07:00
Michiel Visser
5b658c341c LibCrypto: Change modular_add_order to match modular_add 2023-11-10 09:54:00 -07:00
Michiel Visser
d746c01716 LibCrypto: Simplify modular addition and subtraction
Instead of building the REDUCE_PRIME constant on the fly from the carry
flag, we now simply use the constant in combination with select. This
improves the readablility of the functions significantly.
2023-11-10 09:54:00 -07:00
Michiel Visser
5da070ba5e LibCrypto: Remove many magic constants and calculate them instead
Instead of having a large list of magical constants, we now only have
the curve prime, a, b, and order, which are all taken from the
specification. All the other helper constants are now calculated from
the curve paramters.
2023-11-10 09:54:00 -07:00
Nico Weber
323ba7404c LibPDF: Implement SampledFunction::evaluate() for some sampled functions
Things now work for functions that are all of:
* linear
* 1-D input
* 8 bits per sample
2023-11-10 15:03:30 +00:00
Nico Weber
fd1876441a LibPDF: Implement SampledFunction::create() 2023-11-10 15:03:30 +00:00
Andreas Kling
2520c46224 LibJS/JIT: Resolve the GetCalleeAndThisFromEnvironment cache at JIT time 2023-11-10 14:49:25 +01:00
Nico Weber
ed7549c64f pdf: Add a --json flag that currently affects only --debugging-stats 2023-11-10 14:46:06 +01:00
Nico Weber
cd9f4655ec LibPDF: Tweak implementation of postscript roll op
Since positive offsets roll to the right, it makes more sense
to do the big reverse first. Gets rid of an awkward minus sign.

No behavior change.
2023-11-10 14:45:38 +01:00
Nico Weber
b23ed86889 LibPDF: Implement StitchingFunction::evaluate() 2023-11-10 14:45:16 +01:00
Nico Weber
ba34ddeb21 LibPDF: Implement StitchingFunction creation 2023-11-10 14:45:16 +01:00
Simon Wanner
a3399fa13a LibJS/JIT: Expand Mul fast path to double & i32 combinations
Co-authored-by: Stephan Vedder <vedder@mbits.info>
2023-11-10 11:01:59 +01:00
Simon Wanner
867b8146cf LibJS/JIT: Expand Sub fast path to double & i32 combinations
Co-authored-by: Stephan Vedder <vedder@mbits.info>
2023-11-10 11:01:59 +01:00
Simon Wanner
5edab2679c LibJS/JIT: Expand Add fast path to double & i32 combinations
Co-authored-by: Stephan Vedder <vedder@mbits.info>
2023-11-10 11:01:59 +01:00
Simon Wanner
d91b376393 LibJS/JIT: Add helper for generating combined i32 & double fastpaths
Co-authored-by: Stephan Vedder <vedder@mbits.info>
2023-11-10 11:01:59 +01:00
Simon Wanner
578912aa6c LibJIT: Support unordered double comparison 2023-11-10 11:01:59 +01:00
Simon Wanner
a698c51a5b LibJIT: Add floating-point registers
Co-authored-by: Stephan Vedder <vedder@mbits.info>
2023-11-10 11:01:59 +01:00
Simon Wanner
5557f05bb5 LibX86: Support decoding F2 SSE instructions
Previously the F2 table was generated, but not used by the instruction
decoder.
2023-11-10 11:01:59 +01:00
Ali Mohammad Pur
32e6fd9715 LibTLS: Do not defer flushing alert packets
There's a good chance the TLS socket instance will be deleted before the
deferred invocation fires, and there's no real reason to defer flushes
of alerts anyway as they are usually sent on errors.
Fixes #21800.
2023-11-10 09:02:58 +01:00
iliadsh
94b47ff03b LibJS: Add GetByValue fast path for simple array access 2023-11-10 08:22:44 +01:00
iliadsh
f91c3e9ac3 LibJS: Expose offset to m_indexed_properties 2023-11-10 08:22:44 +01:00
iliadsh
cb933a3e4a LibJS: Expose offset of m_array_size 2023-11-10 08:22:44 +01:00
iliadsh
32364d66aa LibJS: Expose offset of is_simple_storage 2023-11-10 08:22:44 +01:00
iliadsh
d9aebeb372 LibJS: Expose offset of elements in IndexedProperties 2023-11-10 08:22:44 +01:00
iliadsh
eb937631bb LibJS: Expose offset of may_interfere_with_indexed_property_access 2023-11-10 08:22:44 +01:00
iliadsh
ee4948b9e7 LibJS: Devirtualize is_simple_storage() 2023-11-10 08:22:44 +01:00
iliadsh
89da731aa6 LibJS+LibWeb: Devirtualize may_interfere_with_indexed_property_access() 2023-11-10 08:22:44 +01:00
david072
7f501d4d8a Taskbar/QuickLaunchWidget: Ensure config backwards compatibility
The QuickLaunchWidget can now also parse the old config format, so that
we stay compatible with the old format. After loading, it deletes the
old config values and saves them in the new format.
2023-11-09 23:35:52 +01:00
david072
620b3bd492 Taskbar/QuickLaunchWidget: Show a tooltip with the entry's name on hover 2023-11-09 23:35:52 +01:00
david072
2d29a96dbe Taskbar/QuickLaunchWidget: Small cleanup 2023-11-09 23:35:52 +01:00
david072
e100c1458a Taskbar/QuickLaunchWidget: Reorder methods to make .cpp and .h match
This makes it a bit easier to find things in my opinion.
2023-11-09 23:35:52 +01:00
david072
13b98d01c0 Taskbar/QuickLaunchWidget: Properly save Quick Launch Entries
The entries in the QuickLaunchWidget are now saved properly. This means
that the format with which they are saved needed to be changed, since we
now also need to store the order of the entries. To do this, the entries
are now saved using the following value format: "<index>:<path>". When
loading, we simply parse this structure out and sort by the index,
before parsing the path into `QuickLaunchEntry`s.
2023-11-09 23:35:52 +01:00
david072
84340c4ca7 Taskbar/QuickLaunchWidget: Allow reordering the entries :^)
You can now drag the entries in the QuickLaunchWidget to reorder them!
2023-11-09 23:35:52 +01:00
david072
63cac2839d Taskbar/QuickLaunchWidget: Do rendering ourselves
The QuickLaunchWidget now renders the buttons on its own, in preparation
for allowing the user to reorder the widget's entries.
2023-11-09 23:35:52 +01:00
david072
70f7c10ab9 Taskbar+WindowServer: Adding to Quick Launch via windows :^)
You can now add applications to Quick Launch via the context
menu option of their windows. Clicking it creates an event with the
stored PID of the process that created the window. The Taskbar receives
the event and tells the QuickLaunchWidget to add the PID, which then
gets the executable using /sys/kernel/processes. It also looks for an
AppFile using the name from the process object and if there is one, it
uses that, since it should contain a better formatted name.
2023-11-09 23:35:52 +01:00
david072
4386182be1 LibGUI+WindowServer: Store the source process' PID in the Window classes
The "Window" classes in LibGUI and WindowServer now store the PID of the
process that created the window. LibGUI's Window obtains the PID in the
constructor via getpid(), and passes it in Window::show() to
WindowServer via the create_window() IPC route. WindowServer then saves
it in its own Window class.
This allows us to find the process that created a window in order to add
process-specific actions to the window.
2023-11-09 23:35:52 +01:00
david072
124611b256 AppFile: Add helpers for dealing with AppFile paths 2023-11-09 23:35:52 +01:00
Nico Weber
5af6e1c042 LibPDF: Implement DeviceNColorSpace 2023-11-09 23:33:49 +01:00
Nico Weber
0f07049935 LibPDF: Add ColorSpaceFamily::operator==
No behavior change.
2023-11-09 23:33:49 +01:00
Andreas Kling
4f8e915ef8 LibJS: Remove accidentally-committed bytecode caching
This was a hack cache I got from Luke, not ready for prime-time :^)
2023-11-09 21:06:19 +01:00
Bastiaan van der Plaat
1cdbfc2ff1 LibWeb: Add ol start and li value attributes support 2023-11-09 16:10:54 +01:00
Shane Murphy
d2fbc15f5d Terminal: Fix zoom when font size is missing
If Terminal was configured with a typeface that does not have a font
for any given size, the zoom in and out button in the menu bar would
not work because font lookup was exact.

Use Font::AllowInexactMatch::Larger when zooming in and
Font::AllowInexactMatch::Smaller when zooming out to allow finding the
closest font size in the requested direction.
2023-11-09 16:09:18 +01:00
Shane Murphy
0e05614710 LibGfx: Improve tie-breaking in Typeface::get_font
Add two new members to Font::AllowInexactMatch: Larger and Smaller.
This allows callers of FontDatabase::get to specify if they want to
prefer a larger or smaller font in the event of a tie.
2023-11-09 16:09:18 +01:00
Matthew Olsson
1915e603c9 LibWeb: Implement AnimationEffect progress helper functions
This excludes transformed_progress (which is the progress value used to
interpolate CSS values) as it requires a timing function
2023-11-09 16:08:50 +01:00
Matthew Olsson
7f303729f3 LibWeb: Implement AnimationEffect::active_time()
This is split into two functions since there are other places in the
specification that invoke this algorithm with a particular FillMode
(i.e. not the one that the object has in m_fill_mode).
2023-11-09 16:08:50 +01:00
Matthew Olsson
02c4973681 LibWeb: Implement AnimationEffect's phase helpers 2023-11-09 16:08:50 +01:00
Matthew Olsson
6a9c03482f LibWeb: Implement AnimationEffect's active_boundary time getters 2023-11-09 16:08:50 +01:00
Matthew Olsson
baf5220212 LibWeb: Implement some AnimationEffect timing-related helpers
end_time, local_time, and active_duration
2023-11-09 16:08:50 +01:00
Matthew Olsson
d6fb1c24f6 LibWeb: Implement AnimationEffect::animation_direction() 2023-11-09 16:08:50 +01:00
Matthew Olsson
2358f64d00 LibWeb: Implement Animation::set_effect() 2023-11-09 16:08:50 +01:00
Nicolas Ramz
68e916490b LibGfx/JPEGWriter: Fix crash on macOS when csize coefficient is 0
This fixes #21108
2023-11-09 16:07:28 +01:00
Nico Weber
80eec1e16b LibPDF: Implement PostScriptCalculatorFunction
Includes a tokenizer and interpreter for the subset of PostScript
supported in PDF type 4 functions.
2023-11-09 16:06:25 +01:00
Tim Schumacher
e9dda2a5f8 AK: Provide a default set of Traits for const types 2023-11-09 10:05:51 -05:00
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
Sam Atkins
d4e1305413 LibGfx: Make OpenType versioned tables more consistent
Maxp had the shared fields duplicated, and OS2 embedded each version's
struct in the next. Instead, let's use inheritance to avoid duplicating
shared fields while still allowing them to be directly accessed.

While I'm at it, rename the Maxp and GPOS table structs to just be
VersionX_Y, because they're not ambiguous with anything else.

LibGfx: Rename GPOSHeader to HeaderVersion1_0

Because there's a version 1.1 as well, which we'll eventually want to
support.
2023-11-08 09:34:09 +01:00
Sam Atkins
75376d6834 LibGfx: Remove bit casting in OpenType Hmtx table after construction
Store the variable-length data in Spans instead.
2023-11-08 09:34:09 +01:00
Sam Atkins
cef4d4821b LibGfx: Remove bit casting in OpenType Maxp table after construction
Store references to both versions of the struct in a Variant, and reject
versions we don't support.
2023-11-08 09:34:09 +01:00
Sam Atkins
e4b3ee09e2 LibGfx: Remove bit casting in OpenType Hhea table after construction 2023-11-08 09:34:09 +01:00
Sam Atkins
dcbe302f83 LibGfx: Remove bit casting in OpenType Head table after construction 2023-11-08 09:34:09 +01:00
Sam Atkins
72483673d2 LibGfx: Use ErrorOr to report failure to load OpenFont tables 2023-11-08 09:34:09 +01:00
Sam Atkins
1ab03ff963 LibGfx: Read OpenType table directory using structs and streams 2023-11-08 09:34:09 +01:00
Sam Atkins
5455ecf650 LibGfx: Remove OpenType::Font::m_buffer
At first glance this looks like it holds the memory that the various
slices point into... but it actually doesn't own that memory. Nobody
uses m_buffer, so it serves no purpose.
2023-11-08 09:34:09 +01:00
Sam Atkins
984a2c314b LibGfx: Read OpenType TTCHeaderV1 as a struct
Also check that the requested font index actually exists in the font
collection.
2023-11-08 09:34:09 +01:00
Sam Atkins
1a6da4fbf2 LibGfx: Mark OpenType file data structs as packed, and assert sizes
Some of these are odd sizes. We managed not to insert padding because
BigEndian is itself marked as packed, but let's be explicit instead of
relying on that. :^)
2023-11-08 09:34:09 +01:00
Sam Atkins
dfa79ba6d8 LibGfx: Move implementation code for Tables.h into Tables.cpp 2023-11-08 09:34:09 +01:00
Romain Chardiny
61ac554a34 Kernel/Net: Implement TCP_NODELAY 2023-11-08 09:31:54 +01:00
Sergey Bugaev
38a368c8f6 WebContent: Fix checking for accelerated graphics
What matters here is whether or not we can use LibAccelGfx and OpenGL,
not whether the kernel is Linux.
2023-11-08 09:29:59 +01:00
Sergey Bugaev
21b946791e LibJS: Link with libatomic on i*86
Basically, this would be needed on any platform where the compiler
cannot tell at compile time whether or not some atomic size is
lock-free.
2023-11-08 09:29:59 +01:00
Sergey Bugaev
9c6c2284d9 LibJS: Fix build error when some atomics are not lock-free
Normally, we want to avoid accidentally using such atomics, since
they're much slower. In this case however, we're just implementing
another atomics API, it is then up to the JavaScript code to avoid
using the slow atomics.
2023-11-08 09:29:59 +01:00
Lucas CHOLLET
81794df280 LibGfx/TIFF: Add support for images with PackBits compression 2023-11-08 09:28:36 +01:00
Lucas CHOLLET
472a886dfc LibGfx/TIFF: Refactor the decoding loop
This is done to ease the introduction of the support of other
compressions.
2023-11-08 09:28:36 +01:00