Commit graph

29539 commits

Author SHA1 Message Date
Rummskartoffel
dcbb8cf0ac NotificationServer: Make notifications not overlap when they appear
Before this patch, if two or more notifications were created after one
another, they would overlap. This was caused by the previously lowest
notification's m_original_rect being used to calculate the position for
each new notification instead of the notification's actual rect, which
can be different.
This patch makes notifications use each others' rect() method instead,
which makes them appear in the correct position. With that,
m_original_rect has no use anymore, so this patch removes it.
2023-11-05 09:06:33 +01:00
Rummskartoffel
a281fa3902 NotificationServer: Don't shuffle notifications on first hover
Before this patch, hovering with the mouse over one of at least two
newly created notifications would cause all notifications to be
reordered on the screen, when previously they appeared in order of
creation, growing downwards.
This happened because the position of all notifications is updated when
any of them is hovered, in case the hovered notification was resized.
By using an ordered HashMap instead, creation order is preserved.
2023-11-05 09:06:33 +01:00
Tim Ledbetter
438e9e146c LibGfx/JPEG: Refill reservoir if necessary when discarding bits
This condition was hit 157 times out of the 109,233 JPEG images in the
Govdocs1 corpus. This change allows all of these
images to load correctly.
2023-11-05 09:01:15 +01:00
MacDue
4c5d48f861 LibWeb: Support transforms, stroking, gradients, etc for SVG <text>
This makes use of the new Gfx::Path::text() to handle SVG text elements,
with this text is just a regular path, and can be manipulated like any
other graphics element.

This removes the SVGTextPaintable and makes both <text> and geometry
elements use a new (shared) SVGPathPaintable. This is identical to the
old SVGGeometryPaintable. This simplifies painting as once something is
resolved to a Gfx::Path, the painting logic is the same.
2023-11-05 02:46:46 +01:00
MacDue
50d33f79fa LibGfx: Allow extracting paths from fonts and add Gfx::Path::text()
This updates fonts so rather than rastering directly to a bitmap, you
can extract paths for glyphs. This is then used to implement a
Gfx::Path::text("some text", font) API, that if given a vector font
appends the path of the text to your Gfx::Path. This then allows
arbitrary manipulation of the text (rotation, skewing, etc), paving the
way for Word Art in Serenity.
2023-11-05 02:46:46 +01:00
kleines Filmröllchen
b4cabde4a4 LibELF: Add initial RISC-V support
This is an almost-minimal patchset to get RISC-V ELF files to pass
validation. Unlike other architectures, eflags are actually used here.
2023-11-04 22:13:52 +01:00
LevitatingBusinessMan (Rein Fernhout)
edd38358c2 ls: Use indicator for sockets and pipes
= indicator for sockets, | for pipes.
Pipes are now colored yellow like other special files
2023-11-04 22:08:56 +01:00
Nico Weber
4a5136fc8c LibPDF: Implement CalGrayColorSpace
I haven't seen this being used in the wild, but it's used in
Tests/LibPDF/colorspaces.pdf.
2023-11-04 17:02:37 -04:00
Nico Weber
a207ab709a LibPDF: In convert_to_srgb(), also apply sRGB curve (ish)
We did convert from the input space to linear space and then
to linear sRGB, but we forgot to re-apply gamma.

This uses the x^2.2 curve instead of the real sRGB curve for now.
2023-11-04 17:02:37 -04:00
Nico Weber
641365b235 LibPDF: Move colorspace conversion functions up a bit
No code change, no behavior change. Pure code move.
2023-11-04 17:02:37 -04:00
Andreas Kling
3ff81dcb65 LibWeb: Make Web::Namespace::Foo strings be FlyString
This required dealing with a *lot* of fallout, but it's all basically
just switching from DeprecatedFlyString to either FlyString or
Optional<FlyString> in a hundred places to accommodate the change.
2023-11-04 21:28:30 +01:00
Andreas Kling
6b20a109c6 LibWeb: Pass DOM namespace strings as FlyString in more places 2023-11-04 21:28:30 +01:00
Andreas Kling
b341aeb5c1 LibWeb: Switch HTMLToken and HTMLTokenizer to String & FlyString 2023-11-04 21:28:30 +01:00
Andreas Kling
f052823f5f LibWeb: Use FlyString for create_element() namespace strings 2023-11-04 21:28:30 +01:00
Andreas Kling
8f82bd044b LibWeb: Use FlyString for create_element() prefix strings 2023-11-04 21:28:30 +01:00
Dan Klishch
e169d99bec LibCore: Remove strtol call from parse_sockets_from_system_server 2023-11-04 18:06:30 +01:00
Dan Klishch
568e5d5631 LibCore: Port DateTime::parse to GenericLexer
The main motivation is to get rid of pesky `strtol`, which requires zero
termination of a `string` argument. This also somewhat simplifies the
code.
2023-11-04 18:06:30 +01:00
circl
6b30847120 LibWeb: Don't add an extra glyph spacing to width of TextNode
When calculating the width of text using a bitmap font, a glyph spacing
is added at the end of each fragment, including the last one. This meant
that everything was 1 pixel too long. This bug did not affect vector
fonts.
2023-11-04 17:39:04 +01:00
Aliaksandr Kalenik
2660bbb94f LibWeb: Consider colgroups while calculating table grid size
We should take in account <col> elements in column groups while finding
number of columns in a table.
2023-11-04 17:37:38 +01:00
Timothy Flynn
b98864e022 LibAudio: Remove unused TRY-like macro
This was added, unused, in bc4d4f0f95.
2023-11-04 08:36:34 -04:00
Timothy Flynn
cdbde1765a LibWeb: Skip assigning slottables for non-shadow roots
For example, on https://html.spec.whatwg.org, there are hundreds of
thousands of nodes. This method is invoked as each node is inserted.
Traversing the entire tree each time takes a prohibitively long time,
so let's bail early when we know the operation is a no-op.
2023-11-03 20:50:34 +01:00
Timothy Flynn
f3e14d7f64 LibWeb: Use correct variable when handling slottables in node insertion
Errantly copied the variable name from the spec. The `node` variable in
this scope is what we passed to Node::insert_before; `node_to_insert` is
what the spec is actually referring to as `node` here.
2023-11-03 20:50:34 +01:00
Idan Horowitz
58e2fe895c LibJS: Stash thrown exception in a register before executing finalizer
This kills 2 birds with one stone:
1. It makes sure generated check_exception() calls in the finalizer
   don't mis-read the pending exception as caused by their matching
   operation.
2. It implicitly ensures that terminated finally blocks (by a return
   statement) overwrite any pending exceptions, since they will never
   execute the ContinuePendingUnwind operation that restores the
   stashed exception.
This additional logic is required in the JIT (as opposed to the
interpreter), since the JIT uses the exception register to store and
check the possibly-exceptional results from each individual operation,
while the interpreter only modifies it when an operation has thrown an
exception.
2023-11-03 20:27:45 +01:00
Idan Horowitz
aaa81cd3b9 Revert "LibJS/JIT: Clear exception before executing finalizer"
This reverts commit 0daebef727.

Finally blocks do not unconditionally swallow pending exceptions.
This resolves #21759 and fixes the 2 remaining failing test-js tests.
2023-11-03 20:27:45 +01:00
hanaa12G
0391096286 HackStudio: Pass the correct VariableInfo address to create_index
Previously, we tried to store `VariableInfo` to `ModelIndex` internal
data, but accidently stored address of wrapper class `NonnullOwnPtr`.
When we retrieved it later in `VariablesModel::data()` it made
program to crash.

This allows us to run debug normally after setting any break point in
`HackStudio`.
2023-11-03 16:05:46 +00:00
Liav A
55ea2d892c Utilities/beep: Restrict possible capabilities
We can now just unveil the /dev/beep device node, as well as to restrict
the utility functionality for rpath, wpath & stdio related syscalls only
because we don't actually need anything else.
2023-11-03 15:19:33 +01:00
Liav A
26f96d2a42 Kernel+Userland: Add option for duration of /dev/beep producing sound 2023-11-03 15:19:33 +01:00
Liav A
1b00618fd9 Kernel+Userland: Replace the beep syscall with the new /dev/beep device
There's no need to have separate syscall for this kind of functionality,
as we can just have a device node in /dev, called "beep", that allows
writing tone generation packets to emulate the same behavior.

In addition to that, we remove LibC sysbeep function, as this function
was never being used by any C program nor it was standardized in any
way.
Instead, we move the userspace implementation to LibCore.
2023-11-03 15:19:33 +01:00
Liav A
ac70abcb73 DeviceMapper: Add a mechanism to handle pluggable-once char devices 2023-11-03 15:19:33 +01:00
Andreas Kling
24fb009cf5 LibJS+LibJIT: Add fast path for Int32 * Int32 2023-11-03 10:48:02 +01:00
Andreas Kling
0aeb83b03f LibJS+LibJIT: Add fast path for Int32 ^ Int32 2023-11-03 10:48:02 +01:00
Andreas Kling
3a5c177025 LibJS/JIT: Add fast path for Int32 | Int32 2023-11-03 10:48:02 +01:00
Andreas Kling
82635083dc LibJS/JIT: Add fast path for Int32 & Int32 2023-11-03 10:48:02 +01:00
Andreas Kling
17ae6edd8e LibJS+LibJIT: Add fast path for Int32 - Int32 2023-11-03 10:48:02 +01:00
Andreas Kling
56b4586d65 LibJIT: Factor out JO instruction from add32()
Also add a jump_if(Condition, Label) helper. This will make it easier
to add more 32-bit binary ops that branch on overflow.
2023-11-03 10:48:02 +01:00
Simon Wanner
dd466ec83a LibJS/Bytecode: Remove the PushDeclarativeEnvironment instruction 2023-11-03 07:31:11 +01:00
Simon Wanner
c810d4784e LibJS/JIT: Compile the Await instruction 2023-11-03 07:31:11 +01:00
Simon Wanner
4671520c0a LibJS/JIT: Compile the Yield instruction 2023-11-03 07:31:11 +01:00
Simon Wanner
e400682fb1 LibJS/JIT: Support alternative entry point blocks
If Interpreter::run_and_return_frame is called with a specific entry
point we now map that to a native instruction address, which the JIT
code jumps to after the function prologue.
2023-11-03 07:31:11 +01:00
Idan Horowitz
38f3b78a1d LibJS: Store the bytecode accumulator in a dedicated physical register
We now use a dedicated physical register to store the bytecode
accumulator, instead of loading and storing it to the memory everytime.
2023-11-02 22:35:35 +01:00
Andreas Kling
f9cab320e6 LibWeb: Only propagate CSS overflow to the viewport once per tree build
Before this change, we were doing it after every layout, which meant
that already-propagated overflow could be propagated again, which led to
incorrect scrolling behavior.
2023-11-02 20:50:48 +01:00
Andreas Kling
f5771a5789 LibWeb: Check node type first in fast_is<ShadowRoot>()
We know that shadow roots are always document fragments, so we can
check that before calling is_shadow_root() to avoid the cost of
a virtual call.
2023-11-02 17:09:34 +01:00
Andreas Kling
204c46f097 LibWeb: Use Element::id() when deciding whether to update SVG use trees 2023-11-02 17:09:34 +01:00
Andreas Kling
65787fffe4 LibWeb: Use Element::id() when collecting matching CSS rules 2023-11-02 17:09:34 +01:00
Andreas Kling
d0d7e5a782 LibWeb: Use Element::id() in getElementById()
This avoids the O(n) walk of element attributes, although there is still
a huge space for improvement here if we start keeping a lookup cache for
elements-by-ID.
2023-11-02 17:09:34 +01:00
Andreas Kling
e205f93cbb LibWeb: Add missing super call in SVGSymbolElement::attribute_changed()
This would cause subsequent commits to break tests otherwise.
2023-11-02 17:09:34 +01:00
Andreas Kling
83c3490bc4 LibWeb: Use Element::id() in SelectorEngine
This makes ID selector matching O(1) instead of O(n).
2023-11-02 17:09:34 +01:00
Andreas Kling
1c62ee9396 LibWeb: Cache the "id" attribute value on DOM::Element as FlyString
This will allow us to do O(1) checks against the element ID when
matching selectors, etc.
2023-11-02 17:09:34 +01:00
Andreas Kling
6b580d68a3 LibWeb: Rename DOM::Node::id() to unique_id()
The old name was pretty confusing, since it had nothing to do with the
common "id" content attribute.

This makes way for using id() to return the "id" attribute instead. :^)
2023-11-02 17:09:34 +01:00
Simon Wanner
1030776f92 LibJS: Avoid crash on empty stack trace
We were trying to stringify the stack trace without the last element,
leading to a loop bound of (size_t)(0 - 1) and accessing m_traceback[0]
out-of-bounds.

Instead, just return an empty string in that case.

Fixes #21747
2023-11-02 16:12:43 +01:00
Aliaksandr Kalenik
38531ce7cf LibWeb: Do not unload during same-document history step application
See https://github.com/whatwg/html/pull/9904
2023-11-02 16:06:16 +01:00
Nick Hawke
67566e5017 LibJS: Migrate DeprecatedString to String
This changes BasicBlock's constructor and create().
2023-11-02 14:55:12 +01:00
0GreenClover0
4c915a9e67 HackStudio: Add an 'Auto Save before Build or Run' option 2023-11-02 11:08:14 +00:00
Andreas Kling
0e9bdfa822 LibWeb: Avoid QualifiedName copy when matching tag name selectors 2023-11-02 08:09:01 +01:00
Andreas Kling
e4621704ce LibWeb: Avoid unnecessary JS::Handles in Node::queue_mutation_record()
We don't need to make a list of the target node's ancestors before
iterating over them, since nothing happens while iterating them that
can disturb the list anyway (no arbitrary JS execution etc).

The incessant construction and destruction of handles here was showing
up in profiles of basically every website that uses JavaScript to build
some or all of their DOM tree.
2023-11-02 07:48:51 +01:00
Aliaksandr Kalenik
aa6c008450 LibAccelGfx+LibWeb: Implement draw_scaled_bitmap()
Very basic implementation of command to paint bitmap. In the future we
should reuse loaded textures across repaints whenever it is possible.
2023-11-02 07:41:51 +01:00
Aliaksandr Kalenik
b7f8d7e357 LibAccelGfx: Compile all needed shaders during Painter construction
Instead of recompiling shaders on each paint command call we can
compile them once.
2023-11-02 07:41:51 +01:00
Aliaksandr Kalenik
1e85bf221d LibAccelGfx+WebContent: Use the same Painter across page repaints
In the upcoming changes, Painter will be used to store the state of
OpenGL context. For example, if Painter is aware of the shader that
have already been loaded, it will be possible to reuse them across
repaints. Also, it would be possible to manage state of loaded textures
and add/remove them depending on which ones are present in the next
sequence of painting commands.
2023-11-02 07:41:51 +01:00
Simon Wanner
e73a1803ac LibJS/JIT: Avoid crashing while disassembling empty functions 2023-11-02 07:37:41 +01:00
Simon Wanner
68f4d21de2 LibJS: Lazily collect stack trace information
The previous implementation was calling `backtrace()` for every
function call, which is quite slow.

Instead, this implementation provides VM::stack_trace() which unwinds
the native stack, maps it through NativeExecutable::get_source_range
and combines it with source ranges from interpreted call frames.
2023-11-02 07:37:41 +01:00
Simon Wanner
77dc7c4d36 LibJIT: Emit unwindable stack frames
Flip the order from save-registers,enter and leave,restore-registers
to enter,save-register and restore-registers,leave.

This way the return address is next to the saved frame pointer like
unwinding routines expect.
2023-11-02 07:37:41 +01:00
Simon Wanner
93908fcbcb LibJS+Embedders: Unify stack trace format for uncaught errors
Previously these handlers duplicated code and used formats that
were different from the one Error.prototype.stack uses.

Now they use the same Error::stack_string function, which accepts
a new parameter for compacting stack traces with repeating frames.
2023-11-02 07:37:41 +01:00
Aliaksandr Kalenik
2fb0cede9a LibWeb: Account for box-sizing in grid-items width calculation
Visual improvement on (now there is a gap between grid items):
https://twinings.co.uk/collections/earl-grey-tea
2023-11-02 07:37:11 +01:00
Andrew Kaster
2cc6abf309 LibAccelGfx: Don't predicate using EGL/egl.h on Linux
Any platform that has OpenGL and EGL should be able to use the class.
2023-11-01 14:30:30 -06:00
Andrew Kaster
40363f54d8 WebContent: Use the accelerated_graphics CMake helper
Instead of relying on AK_OS_LINUX, actually use the more accurate
HAS_ACCELERATED_GRAPHICS define to figure out if we should try to use
the generic LibAccelGfx GPU painter.
2023-11-01 14:30:30 -06:00
Andrew Kaster
26e5c20cfa LibJS: Don't try to use backtrace(3) on Android below API level 33 2023-11-01 14:30:30 -06:00
Nico Weber
f8799885de LibPDF: Clamp sRGB channels before converting to u8 in CalRGB code
Sometimes the numbers end up just slightly above 1.0f, which previously
caused an overflow.
2023-11-01 11:45:13 -04:00
Nico Weber
bdd2404453 LibPDF: Ignore input whitepoint in convert_to_d65()
CalRGBColorSpace::color() converts into a flat xyz space,
which already takes input whitepoint into account.

It shouldn't be taken into account again when converting from
the flat color space to D65.
2023-11-01 11:45:13 -04:00
Nico Weber
e35a5da2fb LibPDF: Update dead link in a comment 2023-11-01 11:45:13 -04:00
Nico Weber
1fcf0142d2 LibPDF: Fix unfortunate typo in CalRGBColorSpace::create()
We always ignored the /Matrix key in /CalRGB dicts.
2023-11-01 11:45:13 -04:00
Nico Weber
d24289eef4 LibPDF: Always log unhandled type 1 and type 2 font program opcodes
This would've made it easy to see that we were missing flex opcodes for
https://developer.apple.com/library/archive/documentation/mac/pdf/Text.pdf
2023-11-01 11:40:16 -04:00
Nico Weber
e1a743f286 LibPDF: Implement type 2 flex, hflex, hflex1, flex1 operators
This is the type 2 equivalent to type2 othersubr, from what I can tell.

See "4.1 Path Construction Operators" in 5177.Type2.pdf,
"The Type 2 Charstring Format".

Makes text show up alright on
https://developer.apple.com/library/archive/documentation/mac/pdf/Text.pdf
2023-11-01 11:40:16 -04:00
Nico Weber
3e707efdfa LibPDF: Move type1 subr 0 handling into othersubr handler
https://adobe-type-tools.github.io/font-tech-notes/pdfs/T1_SPEC.pdf,
8.4 First Four Subrs Entries:

"""If Flex or hint replacement is used in a Type 1 font program, the
first four entries in the Subrs array in the Private dictionary must be
assigned charstrings that correspond to the following code sequences. If
neither Flex nor hint replacement is used in the font program, then this
requirement is removed, and the first Subrs entry may be a normal
charstring subroutine sequence. The first four Subrs entries contain:

Subrs entry number 0:
3 0 callothersubr pop pop setcurrentpoint return
"""

othersubr handler 0 gets three arguments:
* The flex height (the distance after which the bezier splines
  are replaced with just straight lines)
* The current position after the flex

It pushes that position on the postscript stack, where predefined subr
handler number 0 then pops it from. It then passes it to
setcurrentpoint.

In theory, we now correctly do that setcurrentpoint call, which we
previously weren't.

In practice, that setcurrentpoint call always receives the last point of
the flex -- and our path api apparently gets confused when move_to() is
called on it when the current point is already at that same location.

So tweak the SetCurrentPoint handler to not set the current point on
the path if it's already the path's current point, with a FIXME to
figure out what exactly is happening in Gfx::Path.

No big behavior change if flex is used, but this is more correct if it
isn't.

(This only works because our `return` handler is empty, else we would
have to make the callothersubr handler start a call frame.)
2023-11-01 11:38:41 -04:00
Nico Weber
0bb8249780 LibPDF: Move type1 subr 1 and 2 handling into othersubr handler
https://adobe-type-tools.github.io/font-tech-notes/pdfs/T1_SPEC.pdf,
8.4 First Four Subrs Entries:

"""If Flex or hint replacement is used in a Type 1 font program, the
first four entries in the Subrs array in the Private dictionary must be
assigned charstrings that correspond to the following code sequences. If
neither Flex nor hint replacement is used in the font program, then this
requirement is removed, and the first Subrs entry may be a normal
charstring subroutine sequence. The first four Subrs entries contain:

[...]

Subrs entry number 1:
0 1 callothersubr return

Subrs entry number 2:
0 2 callothersubr return
"""

So subr entry numbers 1 and 2 just call othersubr 1 and and 2, which
means we can just move the handling code over.

No behavior change if flex is used, but more correct if it isn't.

(This only works because our `return` handler is empty, else we would
have to make the callothersubr handler start a call frame.)
2023-11-01 11:38:41 -04:00
david072
53d73b95ce HackStudio: Also ask about unsaved changes when running
HackStudio now also asks about unsaved changes when trying to run,
instead of only on build.
2023-11-01 12:05:57 +00:00
david072
02cc2e0f8f HackStudio: Don't crash when saving is denied on build
When running build while having unsaved changes in HackStudio, it asks
whether you want to save the unsaved files with a separate dialog. When
you click "Yes" to saving the files, but deny the save-file dialog,
HackStudio would crash, since we were expecting there to be a file
to save to. Now, we check whether a file was picked, and if not, we
abort the build.
2023-11-01 12:05:57 +00:00
0GreenClover0
88cc019275 FlappyBug: Unify the way of getting the final score
Previously we would display the score rounded to the nearest integer,
but save the high score by using a static_cast<u32>, which would
always round the score down. This could lead to the final score being
higher than the new high score, when they should be equal.
Now we always round the score to the nearest integer.
2023-11-01 10:43:55 +01:00
Aliaksandr Kalenik
4676b288a2 LibWeb: Set table width to GRIDMAX if calculated value is max-content
If the width of the table container is specified as max-content, then
it seems sensible to resolve it as the sum of the maximum widths of the
columns.
2023-10-31 18:13:14 +01:00
networkException
ff6d7cf3e4 LibJS+LibWeb: Bring script fetching closer to the spec
This patch updates various parts of the script fetching implementation
to match the current specification.

Notably, the implementation of changes to the import assertions /
attributes proposal are not part of this patch(series).
2023-10-31 18:09:14 +01:00
networkException
5b1d0d4d1b LibWeb: Add FetchContext as HostDefined JS::GraphLoadingState field
This patch adds FetchContext as the type to be used in the HostDefined
slot of JS::GraphLoadingState in web script fetching.
2023-10-31 18:09:14 +01:00
networkException
c3b02ae65a LibJS: Add GraphLoadingState Record
This patch adds the GraphLoadingState Record with a struct HostDefined
for use in the HostDefined field.
2023-10-31 18:09:14 +01:00
networkException
dd90ed11b3 LibWeb: Add helper to create default classic script fetch options 2023-10-31 18:09:14 +01:00
networkException
d1c1218d42 LibWeb/Fetch: Implement changes to priority
This patch updates the priority member of fetch requests to be
an enum. The implementation defined struct previously named Priority
has been renamed to InternalPriority in line with the spec.
2023-10-31 18:09:14 +01:00
networkException
5aa7c51956 LibWeb: Pass around JS::HeapFunctions when fetching scripts
This patch replaces the use of JS::SafeFunction for the
OnFetchScriptComplete in various script fetching functions with
JS::HeapFunction. The same applies for callbacks in ModuleMap.

This also removes DescendantFetchingContext, which stashed the
on complete function in fetch_descendants_of_a_module_script
for multiple calls to fetch_internal_module_script_graph
previously.
2023-10-31 18:09:14 +01:00
networkException
33b40eaeed LibJS: Add LoadedModules to Script and CyclicModule 2023-10-31 18:09:14 +01:00
networkException
d60e8c9df5 LibJS: Add ModuleWithSpecifier for LoadedModules
This patch adds ModuleWithSpecifier as the record type to be used in
the LoadedModules field of Realm, Script and Cyclic Module Records.
2023-10-31 18:09:14 +01:00
networkException
7c7ca7f230 LibWeb: Add New as a possible enum variant of ModuleStatus 2023-10-31 18:09:14 +01:00
networkException
89ea444967 LibWeb: Use proper helper for appending to scripts to run after parsing
Instead of appending manually to the
scripts_to_execute_when_parsing_has_finished list, lets use the proper,
currently unused function for this.
2023-10-31 18:09:14 +01:00
Timothy Flynn
99216b2a87 ClockSettings: Use a Vector as the time zone model's container type
The time zones were stored as a static Span until commit 0bc401a1d6, and
are now stored in a Vector. By continuing to tell the ItemListModel that
the container is a Span, we create a temporary Span in its constructor,
which the model tries to hold a constant reference to. Use the default
Vector container type now instead to prevent creating such temporaries.
2023-10-31 15:21:34 +01:00
Tim Ledbetter
a6f9ad6012 LibGfx/OpenType: Ensure offsets are strictly less than the file size
Previously, an offset that was equal to the size of the file would
cause a crash.
2023-10-31 14:15:24 +01:00
Andrew Kaster
49d21619d4 CMake: Use a helper file to find GL and EGL in a platform agnostic way
Also add a flag to turn off accelerated graphics entirely.
2023-10-31 02:32:58 -06:00
Aliaksandr Kalenik
141f56accc LibWeb: Position abspos items inside grid relative to their grid area
Since grid item's containing block is not grid container but
corresponding grid area, it affect positioning of abspos items.
2023-10-31 08:46:17 +01:00
Aliaksandr Kalenik
44001d2178 LibWeb: Separate grid item's area rect calculation in a function in GFC
We would also have to find grid area rect while abspos items layout so
it makes sense to have this code in a separate function.
2023-10-31 08:46:17 +01:00
Uku Loskit
98ad5a7141 LibHTTP: Fix issues with HTTP POST request and requests with a body
The previous implementation created invalid HTTP requests in cases
where the request method was POST or when the request contained a
body. There were two bugs for these cases:

1) the 'Content-Type' header was sent twice
2) a stray CRLF was appended to the request
2023-10-31 07:09:26 +01:00
Aliaksandr Kalenik
549dee4db1 LibWeb: Call prepare_for_replaced_layout() on replaced boxes in GFC
We need to call prepare_for_replaced_layout() on grid items to populate
their natural sizes and aspect ration.
2023-10-31 07:08:30 +01:00
stelar7
a559dca816 LibTLS: Fix supported signature algorithms typo
The ED curve is INTRINSIC/ED25519, not INTRINSIC/ECDSA
2023-10-31 07:07:53 +01:00
Simon Wanner
fb7b4b9c59 LibJS/JIT: Provide source location information for JIT code
This works by walking a backtrace until the currently executing
native executable is found, and then mapping the native address
to its bytecode instruction.
2023-10-31 07:07:17 +01:00
Simon Wanner
112eadc863 LibJS/JIT: Annotate disassembly with bytecode information 2023-10-31 07:07:17 +01:00
Simon Wanner
9f78e56823 LibJS/JIT: Record machine code location to bytecode location mapping 2023-10-31 07:07:17 +01:00
Timothy Flynn
cf93e56833 headless-browser: Use LibWebView to sanitize input URLs
Remove the ad-hoc sanitization in favor of LibWebView. This was missed
after commit 191e20d639.
2023-10-31 07:03:15 +01:00
Tobias Christiansen
e60253d64c LibWeb: Respect offsets always when painting with object-position
Previously we didn't always set the bitmap_intersect correctly when
applying an object-position. This lead to images not correctly being
centered when the axis that it should move along was not the specified
axis.
2023-10-31 07:03:05 +01:00
Tobias Christiansen
6f71b8be1b LibWeb: Use local 'offset' variable in ImagePaintable
We created the local and then did not use it everywhere we could.
2023-10-31 07:03:05 +01:00
Tobias Christiansen
3a4d30dddc LibWeb: Avoid truncation of aspect-ratio-computation in ImagePaintable
The value of the aspect ratio of the bitmap got truncated and this
lead to funky rendering problems when using object-fit and
object-position.
2023-10-31 07:03:05 +01:00
Ali Mohammad Pur
78c04cb8b2 AK+LibPDF: Make Format print floats in a roundtrip-safe way by default
Previously we assumed a default precision of 6, which made the printed
values quite odd in some cases.
This commit changes that default to print them with just enough
precision to produce the exact same float when roundtripped.

This commit adds some new tests that assert exact format outputs, which
have to be modified if we decide to change the default behaviour.
2023-10-31 09:12:35 +03:30
Andrew Kaster
baa26d10a8 LibTLS: Retry sending in TLSv12::flush() on EAGAIN or EINTR
Crashing here is not very helpful.
2023-10-31 00:36:51 +03:30
MacDue
c93d367d95 LibWeb: Layout SVG <text> elements during layout (not while painting)
Previously, all SVG <text> elements were zero-sized boxes, that were
only actually positioned and sized during painting. This led to a number
of problems, the most visible of which being that text could not be
scaled based on the viewBox.

Which this patch, <text> elements get a correctly sized layout box,
that can be hit-tested and respects the SVG viewBox.

To share code with SVGGeometryElement's the PathData (from the prior
commit) has been split into a computed path and computed transforms.
The computed path is specific to geometry elements, but the computed
transforms are shared between all SVG graphics elements.
2023-10-30 19:44:54 +01:00
MacDue
dc9cb449b1 LibWeb: Store computed SVG path data/transforms in LayoutState
This removes the awkward hack to recompute the layout transform at paint
time, and makes it possible for path sizes to be computed during layout.

For example, it's possible to use relative units in SVG shapes (e.g.
<rect>), which can be resolved during layout, but would be hard to
resolve again during painting.
2023-10-30 19:44:54 +01:00
Timothy Flynn
19313945f2 LibWeb: Implement loading a favicon in absence of a <link> icon element
For example, serenityos.org does not contain a <link rel="icon"> element
to indicate its favicon. Before navigables, we implemented attempting to
load a fallback favicon in a rather ad-hoc manner. This implements the
full spec steps to do so after the HTML document is parsed.
2023-10-30 18:31:15 +01:00
Timothy Flynn
b1274a885b LibWeb: Return success when a <link> element decodes a valid favicon 2023-10-30 18:31:15 +01:00
Timothy Flynn
1504469c50 js: Implement the exit builtin without calling the native exit function
If we invoke the exit native function from within the exit builtin, the
native call will then invoke global destructors. This ultimately ends up
deleting the JS::NativeFunction that defines the exit builtin, thus we
try to delete the AK::Function held inside the NativeFunction while that
AK::Function is executing. This is explicitly forbidden by AK::Function.

Instead, simply set a flag to exit the REPL after the builtin executes.
2023-10-30 18:12:17 +01:00
Andrew Kaster
f9386737a6 LibTLS: Add certificate verification for ECDSA with SECP256r1 curves 2023-10-30 10:17:39 -06:00
Michiel Visser
c548dca174 LibTLS: Add ECDSA support with the secp256r1 curve 2023-10-30 10:17:39 -06:00
Michiel Visser
caf533bddf LibCrypto: Add ECDSA signature checking with secp256r1 2023-10-30 10:17:39 -06:00
Simon Wanner
0daebef727 LibJS/JIT: Clear exception before executing finalizer
language/statements/try/S12.14_A13_T2.js                        -> 
language/statements/try/S12.14_A15.js                           -> 
language/statements/try/S12.14_A7_T1.js                         -> 
language/statements/try/S12.14_A7_T2.js                         -> 
language/statements/try/S12.14_A7_T3.js                         -> 
language/statements/try/completion-values-fn-finally-abrupt.js  -> 
language/statements/try/completion-values-fn-finally-return.js  -> 
2023-10-30 15:05:26 +01:00
Simon Wanner
bd62c4763c LibJS/JIT: Flip saved_return_value condition in ContinuePendingUnwind
This did not match the `if (saved_return_value) return else resume`
in Interpreter.

test/built-ins/Promise/all/resolve-poisoned-then.js         -> 
test/built-ins/Promise/all/resolve-thenable.js              -> 
test/built-ins/Promise/allSettled/resolve-poisoned-then.js  -> 
test/built-ins/Promise/allSettled/resolve-thenable.js       -> 
test/built-ins/Promise/race/resolve-self.js                 -> 
test/language/statements/try/S12.14_A7_T1.js                -> 
test/language/statements/try/S12.14_A7_T2.js                -> 
test/language/statements/try/S12.14_A7_T3.js                -> 
2023-10-30 15:05:26 +01:00
Simon Wanner
82c057391e LibJS/JIT: Handle uninitialized bindings in GetLocal
test262: +78     -72     -4 💥
2023-10-30 15:05:26 +01:00
Simon Wanner
5b2c0dfec0 LibJS/JIT: Return result of SuperCallWithArgumentArray
test/language/expressions/optional-chaining/call-expression.js 💥️ -> 
test/language/expressions/super/call-expr-value.js             💥️ -> 
2023-10-30 15:05:26 +01:00
Evgeniy Baskov
da45bd3fde LibJS/JIT: Implement static exception handling 2023-10-30 13:10:08 +01:00
Hendiadyoin1
1341f4438d LibJS: Save scheduled jumps when entering unwind contexts
These are then restored upon `ContinuePendingUnwind`.
This stops us from forgetting where we needed to jump when we do extra
try-catches in finally blocks.

Co-Authored-By: Jesús "gsus" Lapastora <cyber.gsuscode@gmail.com>
2023-10-30 13:10:08 +01:00
Hendiadyoin1
4da5b8ec67 LibJS: Reset scheduled-jump flag when throwing an exception
Otherwise we might attempt to follow the scheduled jump later
2023-10-30 13:10:08 +01:00
Hendiadyoin1
f5645e3c9c LibJS: Use static unwind mappings for unwind related functions 2023-10-30 13:10:08 +01:00
Hendiadyoin1
73f347b75c LibJS: Create static unwind mappings for BasicBlocks
This is currently only used in the bytecode dump to annotate to where
unwinds lead per block, but will be hooked up to the virtual machine in
the next commit.
2023-10-30 13:10:08 +01:00
Tobias Christiansen
647f0ccd3f LibWeb: Add rendering support for 'object-position'
Images now get rendered correctly according to the 'object-position'
property.
2023-10-30 10:40:30 +00:00
Tobias Christiansen
d00c7e55a5 LibWeb: Add plumbing for the new 'object-position' property
Now, the 'object-position' property gets properly parsed and is
provided to the rest of the ecosystem.
In the parser we use the same parsing as for the background-position,
which is not entirely correct but almost a <position>.
2023-10-30 10:40:30 +00:00
Tobias Christiansen
7e11de272f LibWeb: Add 'object-position' property and 'position' enum
This patch adds the 'object-position' CSS property description to the
json for code generation.
Also the 'position' enum is added. The values of this enum are the
valid inputs to the object-position property from CSS Values-4.
2023-10-30 10:40:30 +00:00
Tobias Christiansen
6602b1ddb1 LibWeb: Rename "position" enum to "positioning"
The postitioning enum values are used by the position CSS property.
Unfortunately, the prior naming clashes with the CSS Values-4 type
named position, which will be implemented in a later commit.
2023-10-30 10:40:30 +00:00
Gurkirat Singh
60640fe38d Utilities: Implement slugify using AK/Slugify 2023-10-30 10:39:59 +00:00
Gurkirat Singh
ab2d8c092e LibCore: Implement handler for Vector<String> positional arguments 2023-10-30 10:39:59 +00:00
Gurkirat Singh
da8a3f9ff2 LibMarkdown: Render slugified anchor tag in heading
Because slugify function accepts AK::String, which can hold unicode
code_points as well, heading text is normalised to ensure with NFD
form to ensure same binary respresentation of a particular string.
2023-10-30 10:39:59 +00:00
Andreas Kling
0c6d094a7e LibJS/JIT: Stop logging JIT success by default (but still log failure) 2023-10-30 07:11:43 +01:00
Zaggy1024
dfaf645302 LibJS: Add an inline JIT fast path when ToNumeric has nothing to do
In most cases, this op will do nothing, as it is running on an the
accumulator while it already contains a number. Let's avoid doing that
native call.
2023-10-30 07:10:54 +01:00
Simon Wanner
a2b0154661 LibJS/JIT: Compile the AsyncIteratorClose instruction 2023-10-30 07:10:24 +01:00
Simon Wanner
ac59e982a9 LibJS/JIT: Compile the CopyObjectExcludingProperties instruction 2023-10-30 07:10:24 +01:00
Simon Wanner
9494fbe670 LibJS/JIT: Compile the PutByValueWithThis instruction 2023-10-30 07:10:24 +01:00
Simon Wanner
847889343f LibJS/JIT: Compile the New##ErrorName instructions 2023-10-30 07:10:24 +01:00
Simon Wanner
fd059d4e4a LibJS/JIT: Compile the JumpUndefined instruction 2023-10-30 07:10:24 +01:00
Simon Wanner
a16082c6a5 LibJS/JIT: Compile the HasPrivateId instruction 2023-10-30 07:10:24 +01:00
Simon Wanner
712c89dacf LibJS/JIT: Compile the GetNewTarget instruction 2023-10-30 07:10:24 +01:00
Simon Wanner
19045d6431 LibJS/JIT: Compile the GetMethod instruction 2023-10-30 07:10:24 +01:00
Simon Wanner
06ea4cfc4f LibJS/JIT: Compile the DeleteVariable instruction 2023-10-30 07:10:24 +01:00
Simon Wanner
cd18bc9d55 LibJS/JIT: Compile the GetImportMeta instruction 2023-10-30 07:10:24 +01:00
Simon Wanner
c0c40110c1 LibJS/JIT: Compile the ImportCall instruction 2023-10-30 07:10:24 +01:00
Simon Wanner
ac43d3f6db LibJS/JIT: Compile the PutPrivateById instruction 2023-10-29 22:57:19 +01:00
Simon Wanner
81697549b7 LibJS/JIT: Compile the PutByIdWithThis instruction 2023-10-29 22:57:19 +01:00
Simon Wanner
38d5d7979b LibJS/JIT: Compile the DeleteByIdWithThis instruction 2023-10-29 22:57:19 +01:00
Simon Wanner
b53277110e LibJS/JIT: Compile the GetByValueWithThis instruction 2023-10-29 22:57:19 +01:00
Simon Wanner
569ca57e22 LibJS/JIT: Compile the GetByIdWithThis instruction 2023-10-29 22:57:19 +01:00
Simon Wanner
ad81f49b02 LibJS/JIT: Compile the ResolveSuperBase instruction 2023-10-29 22:57:19 +01:00
Simon Wanner
4e9edb8c53 LibJS/JIT: Compile the GetPrivateById instruction 2023-10-29 22:57:19 +01:00
Simon Wanner
4ce2878394 LibJS/JIT: Compile the GetObjectPropertyIterator instruction 2023-10-29 22:57:19 +01:00
Simon Wanner
ad81bf47bb LibJS: Move GetObjectPropertyIterator impl to CommonImplementations 2023-10-29 22:57:19 +01:00
Tim Schumacher
25642dfe87 LibCompress: Implement correct validation of last filters 2023-10-29 22:00:59 +01:00
Tim Schumacher
786e654dfd LibCompress: Implement the XZ delta filter 2023-10-29 22:00:59 +01:00
Tim Schumacher
f0b08e9dea LibCompress: Process XZ filters in reverse order
XZ writes filters in the order that they are used during compression, so
we need to process them in the reverse order while decompression.

This wasn't noticed earlier because we only supported the LZMA2 filter.
2023-10-29 22:00:59 +01:00
Jakub Berkop
6a7b9b85a4 LibJS/JIT: Compile the DeleteByValueWithThis instruction 2023-10-29 21:51:46 +01:00
Jakub Berkop
0776404e03 LibJS/JIT: Compile the DeleteByValue instruction 2023-10-29 21:51:46 +01:00
Jakub Berkop
f5fcd4596c LibJS/JIT: Compile the DeleteById instruction 2023-10-29 21:51:46 +01:00
Bastiaan van der Plaat
0104225d9b LibWeb: Add TextEncoder encodeInto 2023-10-29 21:44:53 +01:00
Bastiaan van der Plaat
f1ead552ce LibWeb: Add constructor options to TextDecoder 2023-10-29 21:44:53 +01:00
Tim Ledbetter
9ed8c0b183 LibGfx/JPEG: Propagate errors when creating JPEGLoadingContext
This allows the JPEG fuzzer to make progress.
2023-10-29 21:39:29 +01:00
Hendiadyoin1
a42d849ec1 LibJIT: Widen allowed argument range for add32 and use REX if necessary
The REX prefix is elided when it is not needed, so no change in code
size is to be expected
2023-10-29 20:28:04 +01:00
Hendiadyoin1
248782461c LibJIT: Introduce and use REX prefix helper
This makes the code a bit more readable and in conjunction with the
ModRM helper should prevent some operand ordering bugs.
This also includes one incidental bugfix:
`sign_extend_32_to_64_bits`, was not setting the `REX.R` bit when
appropriate,
And one size obvious optimization:
We may now elide the REX prefix on `xor eax, eax` as storing to a 32 bit
register clears the upper 32 bit of said register, which is wanted here.
2023-10-29 20:28:04 +01:00
Hendiadyoin1
540963fbe3 LibJIT: Use ModRM helpers where applicable
This also widens the argument coverage of some helpers, to allow
memory offsets, this also consolidates the displacement size choosing.
This also stops us from some out argument ordering bugs, as we now just
need to look up the correct calling convention and call the correct
function.
2023-10-29 20:28:04 +01:00
Hendiadyoin1
b46c5545f1 LibJIT: Add ModRM helpers for argument encoding 2023-10-29 20:28:04 +01:00
Andrew Kaster
86ce502ae2 LibGfx+Utilities: Add helpers to load vector fonts from Core::Resources 2023-10-29 13:12:28 -06:00
Andrew Kaster
286dc6df7f LibGfx: Remove ability to load fonts directly from a file path
Users must now either pass a Core::Resource, a resource:// URI, or
a Core::MappedFile
2023-10-29 13:12:28 -06:00
Andrew Kaster
1567332e34 Userland+Tests: Remove uses of direct file loading for BitmapFont
Route them through Core::Resource APIs instead.
2023-10-29 13:12:28 -06:00
Andrew Kaster
d587bd0a04 LibGfx: Add helpers to load BitmapFont from Core::Resource 2023-10-29 13:12:28 -06:00
Andrew Kaster
897f4d05eb LibGfx: Add abstraction to load BitmapFont from a FixedMemoryStream
We'll use this to load from a Core::Resource in a later commit.
2023-10-29 13:12:28 -06:00
Andrew Kaster
a4c7d9a374 LibCore: Add helper to load a possibly-relative path into a Resource 2023-10-29 13:12:28 -06:00
FalseHonesty
2285dfb80e LibWeb: Resolve block max-width percentage against containing block 2023-10-29 19:35:02 +01:00
Simon Wanner
40064d872f LibJS/JIT: Compile the Append instruction 2023-10-29 17:36:09 +01:00
Simon Wanner
516bb01082 LibJS/Bytecode: Move Append impl to CommonImplementations 2023-10-29 17:36:09 +01:00
Simon Wanner
3dc5c8d28e LibJS/JIT: Compile the IteratorToArray instruction 2023-10-29 17:36:09 +01:00
Simon Wanner
5179ff5fc9 LibJS/Bytecode: Move IteratorToArray impl to CommonImplementations 2023-10-29 17:36:09 +01:00
Simon Wanner
c697ff61f6 LibJS/JIT: Compile the IteratorClose instruction 2023-10-29 17:36:09 +01:00
Simon Wanner
233502a10c LibJS/JIT: Compile the IteratorResultValue instruction 2023-10-29 17:36:09 +01:00
Simon Wanner
e7fdf9c7e5 LibJS/JIT: Compile the ThrowIfNullish instruction 2023-10-29 17:36:09 +01:00
Simon Wanner
9e2edc3085 LibJS/JIT: Compile the ThrowIfNotObject instruction 2023-10-29 17:36:09 +01:00
Simon Wanner
39deb365d2 LibJS/JIT: Compile the IteratorResultDone instruction 2023-10-29 17:36:09 +01:00
Simon Wanner
045a1386d8 LibJS/JIT: Compile the IteratorNext instruction 2023-10-29 17:36:09 +01:00
Simon Wanner
661dbbc83d LibJS/Bytecode: Move object_to_iterator to CommonImplementations 2023-10-29 17:36:09 +01:00
Simon Wanner
4f8f8b7792 LibJS/JIT: Compile the GetIterator instruction 2023-10-29 17:36:09 +01:00
Simon Wanner
d416cef9bb LibJS/Bytecode: Move iterator_to_object to CommonImplementations 2023-10-29 17:36:09 +01:00
Simon Wanner
d247744a3e LibJS/JIT: Compile the SuperCallWithArgumentArray instruction 2023-10-29 17:36:09 +01:00
Simon Wanner
1eee110575 LibJS: Move SuperCallWithArgumentArray impl to CommonImplementations 2023-10-29 17:36:09 +01:00
Simon Wanner
09dce5f1bd LibJS/JIT: Compile the BlockDeclarationInstantiation instruction 2023-10-29 17:36:09 +01:00
Simon Wanner
a28d6291ad LibJS/JIT: Generate switch cases using X macro 2023-10-29 17:36:09 +01:00
Simon Wanner
f89bfb3f27 LibJS/JIT: Declare compile_* methods using X macro 2023-10-29 17:36:09 +01:00
Aliaksandr Kalenik
92461a2618 LibWeb: Use FillRect command in RecordingPainter if corners radius is 0
This change makes RecordingPainter to emit a FillRect command instead
of FillRectWithRoundedCorners if all corners have a radius = 0.

`fill_rect_with_rounded_corners()` in LibGfx already has a similar
optimization. But now when we also have LibAccelGfx, which does not
support painting rectangles with rounded corners yet, it makes sense to
emit FillRect whenever possible.
2023-10-29 17:13:23 +01:00
Aliaksandr Kalenik
b6732b0234 Ladybird+WebContent: Add option to use GPU painter
Adds `--enable-gpu-painting` param to enable painting command executor
that uses LibAccelGfx.
2023-10-29 17:13:23 +01:00
Aliaksandr Kalenik
7d26cbf523 LibWeb: Add painting command executor that uses LibAccelGfx
This change introduces a command executor for RecordingPainter that
utilizes LibAccelGfx.
2023-10-29 17:13:23 +01:00
Aliaksandr Kalenik
95c154d9bd LibAccelGfx+Meta: Introduce OpenGL painting library
This change introduces a new 2D graphics library that uses OpenGL to
perform painting operations. For now, it has extremely limited
functionality and supports only rectangle painting, but we have to
start somewhere.

Since this library is intended to be used by LibWeb, where the
WebContent process does not have an associated window, painting occurs
in an offscreen buffer created using EGL.

For now it is only possible to compile this library on linux.
Offscreen context creation on SerenityOS and MacOS will have to be
implemented separately in the future.

Co-Authored-By: Andreas Kling <awesomekling@gmail.com>
2023-10-29 17:13:23 +01:00
Zaggy1024
56e8f52cb3 LibJIT/LibJS: Remove jump_if_***() in favor of jump_if()
The `jump_if()` function implements all the conditions already in use
and more, so let's avoid encouraging more wrapper functions.
2023-10-29 17:11:04 +01:00
Zaggy1024
288aff01cd LibJIT: Emit all Jcc jump instructions from one function
Since all conditional instructions use a certain number of bits to
encode the condition type (from my observation of `Jcc`, `SETcc` and
`CMOVcc`), let's abuse that to deduplicate some code!

This adds a `Condition` enum that defines the type of condition we are
jumping based on, whose underlying values are the values that must be
encoded to trigger each condition.
2023-10-29 17:11:04 +01:00
Zaggy1024
e717961000 LibJIT: Use test x, x instead of cmp x, 0 in all cases
The `test` instruction will have the same result as `cmp` when
comparing to zero, so let's always emit that code. This has no effect
until the following commit.
2023-10-29 17:11:04 +01:00
Karol Kosek
bf16ddfbb0 LibWeb: Bail parsing transform-origin if the parsed value is null
Passing a value of a type different than number or length-percentage
to transform-origin returned a null pointer, and we didn't take care
of that path before.

This patch fixes a crash caused by an incorrect CSS declaration, such as
`transform-origin: "center"`.

Fixes #21609
2023-10-29 11:22:53 +01:00
Aliaksandr Kalenik
d22aa851cf LibWeb: Float property should be ignored for grid items 2023-10-29 09:43:13 +01:00
Aliaksandr Kalenik
5ef94f0ba8 LibWeb/Painting: Fix translation for FIllRect command
After 4318bcf447 RecordingPainter
is suppoed to write commands in coordinate system of stacking context.

This commit adds missing translation for FillRect command.
2023-10-29 08:48:34 +01:00
Aliaksandr Kalenik
f75186ec8f LibWeb: Add support for grid item's min-height and max-height in GFC 2023-10-29 08:46:51 +01:00