Commit graph

29564 commits

Author SHA1 Message Date
Shannon Booth
2f009d983b LibWeb: Port Element::get_attribute_value from DeprecatedFlyString 2023-11-07 11:33:41 +01:00
Shannon Booth
3f13a50a20 LibWeb: Return FlyString from CSS::Parser::Token::ident
Instead of a StringView. This allows us to preserve the nice O(1) string
compare property of FlyString, and not needing to allocate when one is
needed.

Ideally all other places in Token should have similar changes done, but
to prevent a huge amount of churn, just change ident for now.
2023-11-07 11:33:41 +01:00
Andreas Kling
1d8ec677a3 LibJS/JIT: Add fast path for cached GetVariable accesses
We can now stay in machine code for environment variable read accesses
as long as they are cached and initialized.

20% speed-up on Octane/zlib.js :^)
2023-11-07 11:33:04 +01:00
Andreas Kling
7826c006c1 LibJS/JIT: Don't crash when dissassembling an empty basic block 2023-11-07 11:33:04 +01:00
Andreas Kling
e1e7e696ac LibJS/JIT: Store the running ExecutionContext& in a dedicated register 2023-11-07 11:33:04 +01:00
Andreas Kling
5479bb6ac9 LibJIT/X86_64: Allow mul32() with immediate operand 2023-11-07 11:33:04 +01:00
iliadsh
24d5070520 LibJS/JIT: Add fast path for UnsignedRightShift 2023-11-07 10:17:04 +01:00
iliadsh
c956316c98 LibJS/JIT: Add fast path for RightShift 2023-11-07 10:17:04 +01:00
iliadsh
1244e91481 LibJS/JIT: Add fast path for LeftShift 2023-11-07 10:17:04 +01:00
Adam Harald Jørgensen
a1cdfe1b54 Shell: Add support for showing shortened prompt path with ellipsis 2023-11-07 07:46:52 +03:30
Adam Harald Jørgensen
4febd31dba Shell: Shorten prompt path if integer is provided with "\w" option 2023-11-07 07:46:52 +03:30
Lucas CHOLLET
8612aee640 Lagom/Fuzzers: Add a fuzzer for our TIFF decoder 2023-11-06 12:29:30 -07:00
Lucas CHOLLET
26a3be17c8 Userland: Register TIFF as a supported image file type
This includes both .tiff and .tif extensions.
2023-11-06 12:29:30 -07:00
Lucas CHOLLET
67c6af8cfe LibGfx: Sort entries of ENUMERATE_IMAGE_FORMATS 2023-11-06 12:29:30 -07:00
Lucas CHOLLET
75caccafa4 LibGfx: Add a TIFF loader 2023-11-06 12:29:30 -07:00
Lucas CHOLLET
dc5bb5a4cc LibGfx: Sort entries in the definition of ImagePluginInitializer 2023-11-06 12:29:30 -07:00
Timothy Flynn
38dd284915 LibLocale: Update to CLDR version 44.0.1
https://cldr.unicode.org/index/downloads/cldr-44

Notable changes that affect us include:

* The Islamic Calendar is now localized as the Hijri Calender (in en-US)
  but has not been updated for all locales. So this patch updates tests
  where possible and removes a few test cases that currently cannot be
  localized.

* The und locale has received more likely subtag data (the und locale is
  basically a pseudo-locale meaning "undetermined").

* The exponential symbol in the Arabic number system was changed from
  U+0627 to U+0623.
2023-11-06 08:31:56 -05:00
Andreas Kling
536b9c29e4 LibJS/JIT: Resolve the EnvironmentVariableCache pointers at JIT time 2023-11-06 13:06:10 +01:00
Andreas Kling
a616a682fe LibJS/JIT: Resolve the GlobalVariableCache pointers at JIT time 2023-11-06 13:06:10 +01:00
Andreas Kling
f03d4a1ffe LibJS/JIT: Resolve the PropertyLookupCache pointers at JIT time
We know where the lookup cache is by the time we're jitting code, so
let's put the pointer directly into the instruction stream.
2023-11-06 13:06:10 +01:00
Andreas Kling
3b6b9b9f25 LibJS: Take VM instead of Interpreter in more common implementations 2023-11-06 13:06:10 +01:00
Andreas Kling
234ed2d466 LibJS/JIT: Resolve the GetGlobal identifier at JIT time 2023-11-06 13:06:10 +01:00
Andreas Kling
c92954db36 LibJS/JIT: Resolve the GetById property name at JIT time
We can resolve the IdentifierTableIndex to a DeprecatedFlyString& once
when jitting the code, instead of every time GetById executes.
2023-11-06 13:06:10 +01:00
Shannon Booth
673e3ec57d LibWeb: Port Element::set_attribute_value from DeprecatedString
Removing the DeprecatedString / DeprecatedFlyString overloads of this
function.
2023-11-06 11:37:08 +01:00
Shannon Booth
96463e947a LibWeb: Remove some now unused deprecated functions from QualifiedName
And related callers in Element.
2023-11-06 11:37:08 +01:00
Shannon Booth
326b34c7c7 LibWeb: Port all callers of Element::namespace to Element::namespace_uri
Removing some more use of DeprecatedFlyString
2023-11-06 11:37:08 +01:00
Shannon Booth
f2e77f7778 LibWeb: Port handle_readonly_attribute from DeprecatedFlyString
It's a little awkward that one caller of this is passing through an
Optional<String> and another an Optional<DeprecatedString>, but that
should be fixed some point in the future with further DeprecatedString
porting.
2023-11-06 11:37:08 +01:00
Shannon Booth
22f6abe5d6 LibWeb: Remove DeprecatedString impls of get_elements_by_tag_name{_ns}
No IDL file pulls in these requiring DeprecatedString support, so we
are now able to remove these functions! :^)

Also leave a FIXME while we are at it, as ideally this function would
take an Optional<FlyString> - but the IDL generator does not currently
support this.
2023-11-06 11:37:08 +01:00
Shannon Booth
c8a4fc6c1a LibWeb: Port HTML parser quirk public IDs to StringView
These were DeprecatedFlyStrings, but had no reason to be. We were not
making use of the O(1) lookup, so instead of porting it over to a
FlyString, just make it a StringView.
2023-11-06 11:37:08 +01:00
Shannon Booth
1f8d72da8e LibWeb: Port HTMLToken::to_deprecated_string to new AK String 2023-11-06 11:37:08 +01:00
Shannon Booth
d00c030fce LibWeb: Port Element::set_attribute_value namespace to FlyString 2023-11-06 11:37:08 +01:00
Shannon Booth
1812221a2d LibWeb: Add FlyString versions of NamedNodeMap::get_attribute_ns
This is the API for NamedNodeMap which we are wanting to eventually use
instead of taking a StringView. Currently we just end up deferring to
the StringView versions of these functions, but at some stage in the
future, this will allow us to have O(1) comparison when making attribute
lookups.

In the meantime, the advantage of this API is that it makes it much less
awkward to use than the StringView variant when you have an
Optional<FlyString> namespace to pass through.
2023-11-06 11:37:08 +01:00
Martin Janiczek
49dbc4b5a5 LibTest: Bump up MAX_GEN_ATTEMPTS_PER_VALUE to 30
The original value 15 was too little: it made our
`weighted_boolean_fair_false` test fail every now and then.

This is because a fair coin (P(false) = 0.5) will hit the same value 15
times in a row with a probability (1/2)^15: around once in a 32k tries.

With the bumped up value, this is now once in 1 billion tries. Should
lower the test flakiness enough (if our random number generator is
truly uniform), while 30 tries is still an OK amount of computation for
randomized tests to do, compared to 15.
2023-11-06 11:35:36 +01:00
Simon Wanner
7e3cfaf08c LibJS/JIT: Include headers before they are used
JIT_ARCH_SUPPORTED is defined in LibJIT/Assembler.h, so we need to
include it first.

This change also moves the non-JIT headers outside the #ifdef
2023-11-06 10:28:05 +01:00
Simon Wanner
64947506da LibJIT: Only include the Assembler header for the current platform 2023-11-06 10:28:05 +01:00
Nikodem Rabuliński
bacbd830fe LibJIT: Make X86_64Assembler::native_call take u64 instead of void*
Now that x86-specific Assembler will be compiled on every architecture
we can't rely on void* being the right width.
It also fixes compilation on targets which have void*
be different length from u64 (WASM in particular).
2023-11-06 10:05:42 +01:00
Nikodem Rabuliński
8aa35f4fab LibJIT+LibJS: Rename Assembler to X86_64Assembler
This is in preparation for making LibJIT support multiple architectures.
Assembler will now be typedefed to the specific assembler
for a particular architecture.
Additionally, there's now JIT_ARCH_SUPPORTED which is defined on
architectures which LibJIT supports.
2023-11-06 10:05:42 +01:00
Nikodem Rabuliński
9f5450527f LibJS+LibJIT: Make Assembler::native_call accept preserved_registers
This makes JS::JIT::Compiler less architecture-specific
and unifies aligning the stack into a single operation,
where previously we were doing it separately for preserved registers
and for stack arguments.
2023-11-06 10:05:42 +01:00
0GreenClover0
8c7b393939 HackStudio: Create a progress bar update callback for each debug session
Instead of moving it out of the Debugger, which would lead to it
being null when trying to create next debug sessions afterwards.
2023-11-06 10:02:16 +01:00
0GreenClover0
eeddbb6fa6 HackStudio: Don't crash on null progress bar update function 2023-11-06 10:02:16 +01:00
Nico Weber
bbd86ee4f3 LibPDF: Implement ExponentialInterpolationFunction 2023-11-06 10:01:05 +01:00
Nico Weber
1aed465efe LibPDF: Implement Fuction::create() 2023-11-06 10:01:05 +01:00
Nico Weber
b78ea81de5 LibPDF: Implement SeparationColorSpace
Requires PDF::Function, which isn't implemented yet, so this has
no visual effect yet.
2023-11-06 10:01:05 +01:00
Nico Weber
9204252d02 LibPDF: Add scaffolding for function objects
See PDF 1.7 Spec, "3.9 Functions".
2023-11-06 10:01:05 +01:00
Nico Weber
21894f1cde LibPDF: Fix typos in DeviceN colorspace scaffolding
* Compare array size to 3 and 4, not 4 and 5
* Fix literal typo in error message

Fixes crash processing 0000906.pdf from 0000.zip from the pdf/a dataset.
2023-11-06 09:54:01 +01:00
Aliaksandr Kalenik
b6da9abfb2 LibWeb: Implement draw_glyph_run in PaintingCommandExecutorGPU 2023-11-06 09:53:11 +01:00
Aliaksandr Kalenik
ee28ba0c93 LibWeb: Use glyph run to store text paint command in RecordingPainter
Representing a text run panting command as a vector of glyphs, rather
than as a string simplifies collecting of unique glyphs which is a
prerequisite for `prepare_glyphs_texture()` call.
2023-11-06 09:53:11 +01:00
Aliaksandr Kalenik
32ea11d45c LibAccelGfx: Introduce glyph run painting support
Text painting operates in two steps:

1. Preparation of a texture that contains all the glyphs required for
   text painting, along with metadata that describes the locations of
   those glyphs within texture beforehand.
2. Blitting glyphs from the prepared texture onto corresponding glyph
   quads.

Users of LibAccelGfx will need to call `prepare_glyphs_texture()`,
passing a set of all unique (font, code_paint) pairs, before painting
any text.
2023-11-06 09:53:11 +01:00
Aliaksandr Kalenik
efdbd8238e LibGfx: Decouple glyph positions calculation from draw_text_run()
This change separates a part of the `draw_text_run()` function, which
is responsible for calculating the positions for glyphs that need to be
painted, into a separate function called `get_glyph_run()`.

It is a part of the preparation for text run painting using OpenGL,
where we can't immediately blit glyph bitmaps but instead need to
prepare a sequence of quads for them in advance.
2023-11-06 09:53:11 +01:00
Timothy Flynn
818471b7a7 BrowserSettings+Ladybird: Convert home / new tab page to resource URIs 2023-11-06 09:39:59 +01:00
Timothy Flynn
aa9387c76c LibCore: Add a Resource method to create a file:// URL from a resource 2023-11-06 09:39:59 +01:00
Timothy Flynn
e9aa72ee98 LibCore: Remove [[nodiscard]] attribute from Resource implementations
This attribute is only needed on the declarations in the header.
2023-11-06 09:39:59 +01:00
Timothy Flynn
98a82565cd LibCore: Do not return an Optional from Resource:::filesystem_path
This API never returns OptionalNone, and all callers already assume as
much.
2023-11-06 09:39:59 +01:00
Nico Weber
30ea218e35 LibPDF: Implement IndexedColorSpace 2023-11-05 14:27:22 -07:00
Nico Weber
0b087c02a3 LibPDF: Add spec link to default_decode() 2023-11-05 14:27:22 -07:00
Nico Weber
3dca11c4e2 LibPDF: Move color space creation from name or array into ColorSpace
No behavior change.
2023-11-05 14:27:22 -07:00
Nico Weber
1dfd49ef99 LibPDF: Implement LabColorSpace 2023-11-05 14:27:22 -07:00
Daniel Bertalan
6f972c190b Everywhere: Work around Clang trunk bug with templated lambda + Variant
Since 2023-09-08, Clang trunk has had a bug which causes a segfault when
evaluating certain `requires` expressions inside templated lambdas.
There isn't an imminent fix on the horizon, so let's work around the
issue by specifying the type of the offending lambda arguments
explicitly.

See https://github.com/llvm/llvm-project/issues/67260
2023-11-05 13:41:13 -07:00
Simon Wanner
eaf8c2e398 LibJS: Improve error messages for primitive strict mode property access
Using ErrorType::ReferencePrimitiveSetProperty the errors for primitives
now look like "Cannot set property 'foo' of number '123'".

The strict-mode-errors test has been adjusted and re-enabled.
2023-11-05 18:44:48 +01:00
Simon Wanner
b9c9315bcb LibJS: Assign getter/setter function names as early as possible
In case of {get func() {}, set func() {}} we were wrongly setting the
function name to 'func' and then later trying to replace an empty name
with 'get func'/'set func' which failed.

Instead, set the name to 'get func'/'set func' right away.
The code in put_by_property_key is kept, for when that is called
by put_by_value.
2023-11-05 18:44:48 +01:00
Simon Wanner
a3f34263fd LibJS: Allow division after this token
This fixes the root cause of #21747, so it makes the clock work on
https://toaruos.org
2023-11-05 18:44:48 +01:00
Simon Wanner
969d9e1fd3 LibJS: Remove expensive dead code in get_source_range
This was forgotten when cleaning up debug prints but has a huge
performance impact (around 1s / 15% on test-js).
2023-11-05 18:44:48 +01:00
Shannon Booth
4821d284c6 LibWeb: Add support for inline SVG element scripts 2023-11-05 11:16:16 +00:00
Shannon Booth
c4efc0a5aa LibWeb: Add Web::XLink::AttributeNames
As defined by the XLink spec.
2023-11-05 11:16:16 +00:00
Shannon Booth
e5d45eeeb1 LibWeb: Properly append attributes to element when creating an Element
The main behavioural difference here is that the full qualified name is
appended to the element, rather than just the local name and value.
2023-11-05 11:16:16 +00:00
Shannon Booth
8fbf72b5bf LibWeb: Port HTMLToken prefix and namespace to Optional<FlyString>
Previously these were DeprecatedStrings that contained a null state.
After the null state was removed, the nullability of these members was
broken. This doesn't seem to cause any problems currently as the HTML
parser is not inserting attributes with their full qualified name, but
after we fix that problem, this bug surfaces.
2023-11-05 11:16:16 +00:00
Shannon Booth
fcde808308 LibWeb: Avoid copy of local_name in HTMLParser::create_element_for 2023-11-05 11:16:16 +00:00
Shannon Booth
19ca6f68ba LibWeb: Expose NamedNodeMap::append_attribute in Element 2023-11-05 11:16:16 +00:00
Shannon Booth
907be5a96e LibWeb: Add spec comment for HTMLParser::adjusted_current_node
I've found myself looking at this function a bunch while debugging.
2023-11-05 11:16:16 +00:00
Andreas Kling
0a8eb59a05 LibWeb: Remove Deprecated*String usage in SelectorEngine 2023-11-05 10:05:24 +01:00
Timothy Flynn
cc316de0ee LibWebView: Remove the now-unused LibGUI model implementations 2023-11-05 09:11:23 +01:00
Timothy Flynn
30fac0abb9 Browser: Convert the inspector widget to the WebView model class
This creates a LibGUI-specific wrapper around the WebView model classes
and uses it for the inspector widget tree / table view models.
2023-11-05 09:11:23 +01:00
Timothy Flynn
0aa375441a Browser: Mark the DOM tree as loaded before selecting any DOM node
The first thing that `set_selection` does is return early if the DOM-
loaded flag is false. Set it to true so it can actually do something.
This fixes inspecting a DOM node from the context menu.
2023-11-05 09:11:23 +01:00
Timothy Flynn
4d356cfca5 LibWebView: Create a PropertyTableModel helper class for table models
We currently have StylePropertiesModel and AriaPropertiesStateModel in
LibWebView. These depend on GUI::Model and GUI::ModelIndex, which is the
only reason that the non-Serenity Ladybird chromes require LibGUI.
Further, these classes are very nearly idenitical.

This creates a PropertyTableModel to provide the base functionality for
all table-based model types used by all Ladybird chromes. It contains
code common to the style / ARIA table models, and handles the slight
differences between the two (namely, just the manner in which the values
are flattened into a list during construction).

The Qt and Serenity chromes can create thin wrappers around this class
to adapt its interface to their chrome-specific model classes (i.e.
QAbstractItemModel and GUI::Model).
2023-11-05 09:11:23 +01:00
Timothy Flynn
3999c74237 LibWebView: Create a TreeModel helper class for DOM/accessibility models
We currently have DOMTreeModel and AccessibilityTreeModel in LibWebView.
These depend on GUI::Model and GUI::ModelIndex, which is the only reason
that the non-Serenity Ladybird chromes require LibGUI. Further, these
classes are very nearly idenitical.

This creates a TreeModel class to provide the base functionality for all
tree-based model types used by all Ladybird chromes. It contains code
common to the DOM / accessibility tree models, and handles the slight
differences between the two (namely, just the formatting of each node's
text for display).

The Qt and Serenity chromes can create thin wrappers around this class
to adapt its interface to their chrome-specific model classes (i.e.
QAbstractItemModel and GUI::Model).
2023-11-05 09:11:23 +01:00
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