Commit graph

28813 commits

Author SHA1 Message Date
Andreas Kling 285484874d LibJS: Avoid ByteBuffer copying in RawBytesToNumeric
4% speed-up on Octane/gbemu.js :^)
2023-10-06 07:32:48 +02:00
Timothy Flynn 03be26317f LibJS: Alphabetize handling some Intl.NumberFormat/PluralRules options
This is a normative change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/5a43090
2023-10-05 17:01:02 +02:00
Timothy Flynn eeb16f03bb LibLocale: Parse day-period hour cycle preferences
For example, the locale "fr-FR" will have the preferred hour cycle list
of "H hB", meaning h23 and h12-with-day-periods. Whether date-times are
actually formatted with day-periods is up to the user, but we need to
parse the hour cycle as h12 to know that the FR region supports h12.

This bug was revealed by LibJS no longer blindly falling back to h12 (if
the `hour12` option is true) or h24 (if the `hour12` option is false).
2023-10-05 17:01:02 +02:00
Timothy Flynn 05e080c4ba LibJS: Correctly resolve locale hour cycles in Intl.DateTimeFormat
This is a normative change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/2f002b2
2023-10-05 17:01:02 +02:00
Timothy Flynn 39be5cb73a LibJS: Allow formatting UTC-offset time zones with Intl.DateTimeFormat
These are normative changes in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/896ffcc
https://github.com/tc39/ecma402/commit/af4ec46
https://github.com/tc39/ecma402/commit/e25c455

(This combines the above commits into one patch as they each do not work
on their own).
2023-10-05 17:01:02 +02:00
Timothy Flynn f31540e419 LibJS: Implement time zone identifier AOs centrally within Date
This is an editorial change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/73926a5

The idea here is to reduce duplication of these AOs between ECMA-262,
ECMA-402, and Temporal. This patch contains only the ECMA-262 changes.
2023-10-05 17:01:02 +02:00
Timothy Flynn 0bc401a1d6 LibTimeZone+Userland: Include Link entries when returning all time zones
We currently only return primary time zones, i.e. time zones that are
not a Link. LibJS will require knowledge of Link entries, and whether
each entry is or is not a Link.
2023-10-05 17:01:02 +02:00
Timothy Flynn ddaba88340 LibJS: Convert Date-related equations into proper AOs
This is an editorial change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/7178fa8
2023-10-05 17:01:02 +02:00
Andreas Kling 021a141b53 LibJS: Make array-like Put access on ordinary objects much faster
This patch adds a fast path to the PutByValue bytecode op that bypasses
a ton of things *if* a set of assumptions hold:

- The property key must be a non-negative Int32
- The base object must not interfere with indexed property access
- The base object must have simple indexed property storage
- The property key must already be present as an own property
- The existing value must not have any accessors defined

If this holds (which it should in many common cases), we can skip all
kinds of checks and poke directly at the property storage, saving time.

16% speed-up on the entire Kraken benchmark :^)
(including: 88% speed-up on Kraken/imaging-desaturate.js)
(including: 55% speed-up on Kraken/audio-fft.js)
(including: 54% speed-up on Kraken/audio-beat-detection.js)
2023-10-05 16:57:45 +02:00
Andreas Kling 27a83f7e5e LibJS: Make array-like Get access on ordinary objects much faster
This patch adds a fast path to the GetByValue bytecode op that bypasses
a ton of things *if* a set of assumptions hold:

- The property key must be a non-negative Int32
- The base object must not interfere with indexed property access
- The property key must already be present as an own property
- The existing value must not have any accessors defined

If this holds (which it should in the common case), we can poke directly
at the indexed property storage and save a boatload of time.

10% speed-up on the entire Kraken benchmark :^)
(including: 31% speed-up on Kraken/audio-dft.js)
(including: 23% speed-up on Kraken/stanford-crypto-aes.js)
2023-10-05 16:57:45 +02:00
Andreas Kling a3ee8ff377 LibJS: Add IndexedProperties::storage() to access the underlying storage
This will be used in GetByValue and PutByValue fast paths.
2023-10-05 16:57:45 +02:00
Andreas Kling 7df1692580 LibJS: Add Object::may_interfere_with_indexed_property_access() virtual
This function must return true if the object may intercept and customize
access to indexed properties (properties where the property name is a
non-negative integer.)

This will be used to implement fast path optimizations for array-like
accesses in subsequent commits.
2023-10-05 16:57:45 +02:00
Gurkirat Singh fb5353e7e2 Utilities: Remove redundant target_link_libraries 2023-10-05 15:19:19 +02:00
kleines Filmröllchen 05af549bad pkg: Parse dependencies as part of the main port entry
The "dependency" lines really belong to the main port entry, it doesn't
make sense logically to represent them separately and handling them
together will also allow easier dependency management later on. This
commit greatly simplifies the port database parsing to facilitate this,
and removes the -d option from the command line. Instead, ports are
listed with their dependencies, if they have any.
2023-10-04 22:28:05 +02:00
kleines Filmröllchen a5f566c2c6 pkg: Always use correct installed.db
The access() check was on the wrong file previously.
2023-10-04 22:28:05 +02:00
Andreas Kling feef542c73 LibJS: Don't worry about deduplicating bytecode string tables
The strings will get deduplicated when actually turned into
PrimitiveString objects at runtime anyway, and keeping the string
tables deduplicated was actually wasting a lot of time.

4.4% speed-up on Kraken/stanford-crypto-ccm.js :^)
2023-10-04 20:10:12 +02:00
Andreas Kling 111622a164 LibJS: Add fast path for multiplying two Int32 values
We can avoid a lot of work here, as long as the result doesn't overflow
the Int32 range.

5% speed-up on Kraken/imaging-gaussian-blur.js :^)
2023-10-04 20:10:12 +02:00
Andreas Kling 14a9cfef4d LibJS: Add fast-path for Int32 values in Math.abs()
This function becomes very simple when the input is already an Int32.

2.3% speed-up on Kraken/imaging-gaussian-blur.js :^)
2023-10-04 20:10:12 +02:00
Sam Atkins b53a633388 Hearts: Paint player names in white when background is a dark color 2023-10-04 20:10:04 +02:00
Sam Atkins 09d42261c7 LibCards: Keep markings visible on very dark or light backgrounds
Color::lightened() and Color::darkened() multiply the color values, so
they don't work for black. So for simplicity, we use a semi-transparent
white or black instead.
2023-10-04 20:10:04 +02:00
Aliaksandr Kalenik 09c1eccb50 LibWeb: Fix crash in XMLHttpRequest::response_xml() if response empty
If response object is empty we should return nullptr.

Fixes crash on https://store.steampowered.com/
2023-10-04 20:09:21 +02:00
Andreas Kling 732b39d120 LibJS: Don't evaluate computed MemberExpression LHS twice in assignments
The following snippet would cause "i" to be incremented twice(!):

    let a = []
    let i = 0
    a[++i] += 0

This patch solves the issue by remembering the base object and property
name for computed MemberExpression LHS in codegen. We the store the
result of the assignment to the same object and property (instead of
computing the LHS again).

3 new passes on test262. :^)
2023-10-04 18:58:29 +02:00
Andreas Kling 2083376618 LibJS: Use MUST instead of TRY for infallible calls to TrimString
When the spec says to call "! TrimString", we should use MUST instead
of TRY. (We were previously using TRY in order to propagate OOM errors,
but we don't care about such OOMs anymore.)
2023-10-04 15:21:37 +02:00
Cubic Love 02913e2184 LibCards: Adjust card design
Alter the card dimensions to be 80x110px with a corner radius of 7px.
This is inspired by the dimensions of physical playing cards. It gives
12px of padding between the illustration and the card's border.

Move the card letter and symbol closer to the edge to make space.

Adjust the Club symbol to have the same dimensions as the other symbols.
2023-10-04 13:46:49 +01:00
Kemal Zebari 355e373ce5 LibWeb/MimeSniff: Add MimeType::is_json() 2023-10-04 09:20:47 +01:00
Kemal Zebari b110e4649e LibWeb/MimeSniff: Add MimeType::is_scriptable() 2023-10-04 09:20:47 +01:00
Kemal Zebari 644cc1d7ee LibWeb/MimeSniff: Add MimeType::is_archive() 2023-10-04 09:20:47 +01:00
Kemal Zebari 99a47b9276 LibWeb/MimeSniff: Add MimeType::is_zip_based() 2023-10-04 09:20:47 +01:00
Kemal Zebari 75c42258f2 LibWeb/MimeSniff: Add MimeType::is_font() 2023-10-04 09:20:47 +01:00
Kemal Zebari 3a0fa0e471 LibWeb/MimeSniff: Add MimeType::is_audio_or_video() 2023-10-04 09:20:47 +01:00
Kemal Zebari d2c88faf00 LibWeb/MimeSniff: Add MimeType::is_image() 2023-10-04 09:20:47 +01:00
Tim Ledbetter 2c0f6d8c7b find: Ensure the terminating ; is present when using -exec
The program now terminates with an error if the command passed to
`-exec` is not terminated with a semicolon.

This commit also ensures that the argument containing the terminating
semicolon must be 1 byte long. Previously, any argument whose first
byte was a semicolon was treated as a valid terminator.
2023-10-04 09:14:15 +01:00
Tim Ledbetter 8f8354d9a0 find: Add the -ok option
This behaves identically to the `-exec` option but prompts the user
for confirmation before executing the specified command.

A command is executed if a line beginning with 'y' or 'Y' is entered
by the user. This matches the behavior of `find` on Linux and FreeBSD
when using the POSIX locale.
2023-10-04 09:14:15 +01:00
Junior Rantila a5b01689f1 LibWeb+LibWebView+WebContent: Add support for meta theme-color 2023-10-03 16:17:43 -06:00
Bastiaan van der Plaat 3c27843cfe LibWeb: Add DOMMatrix fromFloat32Array and fromFloat64Array 2023-10-03 16:15:14 -06:00
Bastiaan van der Plaat 2e122b16e4 LibWeb: Add DOMMatrix toFloat32Array and toFloat64Array 2023-10-03 16:15:14 -06:00
Nicolas Ramz 7b4b5b735b LibGfx/ILBMLoader: Add support for EHB mode 2023-10-03 16:09:55 -06:00
Tim Ledbetter 0b824ab7a6 LibGfx: Check bounds of color table access in TinyVGLoader 2023-10-03 22:59:38 +01:00
Jelle Raaijmakers 3c02e3ba09 Maps: Pad grid size to prevent missing tiles
Previously, we would divide the widget width and height by the tile size
and round up, which did not result in enough tiles to cover the entire
widget. Although this calculation is correct if you starting drawing
tiles in the top left corner, we have an additional offset to account
for.

Now, we take the number of tiles that fit in the widget completely and
pad it with 2 tiles to account for the partial left/right and top/bottom
sides. An additional tile is added to account for the iterator
translating by width / 2, which rounds down again.

The resulting tile rects are always intersected with the widget
dimensions, so even if we're generating more tile coordinates than
strictly necessary, we're not performing the actual download or draw
operations.
2023-10-03 20:25:09 +02:00
Jelle Raaijmakers eb4dd7f896 Maps: Fix spiraling tile iterator end
The `operator++` of the spiraling tile iterator was repeating the first
coordinates (`0, 0`) instead of moving to the next tile on the first
iteration. Swapping the move and check ensures we get to the end of the
iterator, fixing gray tiles that would sometimes pop up in the lower
right.

Since we never return from `operator++` without setting a valid
position, we can drop `current_x` and `current_y` and just use the
`Gfx::Point<T>` directly.
2023-10-03 20:25:09 +02:00
Jelle Raaijmakers 092bb76cd6 Maps: Use bilinear blending for downscaled tiles
Since we divide the width and height of the downscaled tiles by 2,
bilinear blending is identical to box sampling and should be preferred
since it's the simpler one of the two algorithms.
2023-10-03 20:25:09 +02:00
Aliaksandr Kalenik 9df00d0677 LibWeb: Exit event handlers if active document is not fully active
Fixes https://github.com/SerenityOS/serenity/issues/21304
2023-10-03 19:31:17 +02:00
Shannon Booth ff72436448 LibWeb: Add a FlyString version of Element::tag_name
Renaming the DeprecatedString version of this function to
deprecated_tag_name. A FlyString is used here as we often need to
perform equality checks here, and the HTMLParser already has tag_name as
a FlyString.

Remove a FIXME while we're at it - we were already following the spec
there, and we still are :^)
2023-10-03 14:47:53 +01:00
Shannon Booth 9303e9e76f LibWeb: Port Element::local_name and TagNames from Deprecated String
Which pretty much needs to be done together due to the amount of places
where they are compared together.

This also involves porting over StackOfOpenElements over to FlyString
from DeprecatedFly string to prevent a gazillion calls to
`.to_deprecated_fly_string` calls in HTMLParser.
2023-10-03 14:47:53 +01:00
Cr4xy bbfe0d3a82 LibWeb: Implement text-transform: capitalize 2023-10-03 09:47:17 -04:00
Tim Ledbetter 9f7cfb1394 LibArchive: Ensure tar extended header length is within expected range 2023-10-03 15:39:20 +02:00
Aliaksandr Kalenik 5d885e9047 LibWeb/Fetch: Align is_network_error() with the latest specification 2023-10-03 09:41:56 +02:00
Aliaksandr Kalenik 084cb4350e LibWeb/Fetch: Include body and headers in Response for failed requests
Fixes https://github.com/SerenityOS/serenity/issues/21290
2023-10-03 09:41:56 +02:00
Aliaksandr Kalenik b9e0ad4358 LibWeb: Make ResourceLoader pass body and headers in error callback
Pass body and headers of a failed request to callback so caller can
process them.
2023-10-03 09:41:56 +02:00
Shannon Booth 50350fb79c LibWeb: Add a non-DeprecatedString version of Element::get_attribute
Renaming the DeprecatedString version of this function to
Element::get_deprecated_attribute.

While performing this rename, port over functions where it is trivial to
do so to the Optional<String> version of this function.
2023-10-03 09:41:20 +02:00
Shannon Booth ebe01b51c8 LibWeb: Add a non-DeprecatedString version of Element::prefix()
Renaming the old DeprecatedString version of this function to
deprecated_prefix().
2023-10-03 09:41:20 +02:00
Shannon Booth e5e4920e66 LibWeb: Make Element::has_attribute_ns take a StringView
Similar to Element::has_attribute, ideally this would take a
`FlyString const&`, but NamedNodeMap::get_attribute_ns already takes a
StringView. To aid in porting away from DeprecatedString, just take a
StringView for now.
2023-10-03 09:41:20 +02:00
Tim Ledbetter eaa6304aab Userland: Return empty if ImageDecoder client receives an invalid frame
This simplifies error checking for all the users of the ImageDecoder
client.
2023-10-03 08:33:53 +02:00
Tim Ledbetter e6c1429311 LibGfx: Check bounds of color table accesses in BMPLoader
Previously, it was possible to crash the decoder by crafting a file
with invalid color table index values.
2023-10-03 08:33:53 +02:00
Andreas Kling c14db6ab12 LibJS: Make Executable ref-counted and let instruction iterator co-own it
This ensures that the instruction stream pointed at by the instruction
iterator remains valid as long as the iterator exists.
2023-10-03 08:23:33 +02:00
Aliaksandr Kalenik b1ee5c8738 LibWeb: Implement CSS fonts lazy loading
By loading only the fonts actually used on a page, we can often avoid
making a lot of unnecessary requests and style invalidations.

This change makes initial loading of apple.com much faster.

Fixes https://github.com/SerenityOS/serenity/issues/20747
2023-10-03 07:11:40 +02:00
Nico Weber 005bdd210a pdf: Add a --dump-outline flag 2023-10-03 07:11:25 +02:00
Tim Ledbetter 361e29cfc9 LibGUI: Don't enter TableView edit mode when a control key is pressed
A key press, which is an ASCII control character will no longer cause
TableView to begin editing.

This fixes an issue in Spreadsheet where navigating to a cell then
pressing escape would cause a that cell's text to be set to a
non-printable value. Pressing escape after navigating to a cell
now has no effect.
2023-10-02 21:38:09 +02:00
toadkarter 4e2e2027c3 MasterWord: Use GML compiler 2023-10-02 21:31:06 +02:00
Kemal Zebari 18124a5611 SpaceAnalyzer: Port to GML compiler 2023-10-02 21:28:40 +02:00
Ali Mohammad Pur 986130d9ea Shell: Accept IoNumber as a valid redirection target 2023-10-02 21:21:38 +02:00
Ali Mohammad Pur 0214e9b905 Shell: Rewrite 'FOR NAME do ... done' according to Dr.POSIX
Dr.POSIX says this form of the loop is supposed to iterate over exactly
`"$@"`, this commit makes us support that.
2023-10-02 21:21:38 +02:00
Ali Mohammad Pur 764ea6104e Shell: Treat '(' and '{' as operators in POSIX mode 2023-10-02 21:21:38 +02:00
Ali Mohammad Pur 9e978c6cd1 Shell: Recognise the (seemingly) bash-specific <<\WORD heredoc key
Bash eats the backslash in this format (similarly for W\ORD etc.).
Dr.POSIX doesn't specify this anywhere, but it's used all over the
place, so let's support it.
2023-10-02 21:21:38 +02:00
Ali Mohammad Pur 21ea9cedff Shell: Add the POSIX-only 'eval' builtin
This just concatenates its arguments together, and executes it as a
command.
2023-10-02 21:21:38 +02:00
Ali Mohammad Pur e2af20a69b Shell: Correct the continue builtin's count guard
This builtin only supports count = 1 (as the error message says), but we
were looking for count = 0.
2023-10-02 21:21:38 +02:00
Dan Klishch f9d485191d LibCpp: Add some missing accessors to AST nodes 2023-10-02 21:15:08 +02:00
Tim Ledbetter e904f69c26 realpath: Add the -q option to suppress error messages 2023-10-02 20:56:38 +02:00
Tim Ledbetter cbda6e1ff4 realpath: Allow multiple path arguments to be given 2023-10-02 20:56:38 +02:00
Tim Ledbetter dd81bea9ef LibGfx: Don't read past EOF in JPEGLoader
Previously, it was possible to pass JPEGLoader a crafted input which
would read past the end of the stream. We now return an error in such
cases.
2023-10-02 20:09:25 +02:00
Tim Ledbetter c087ba24b9 Assistant: Avoid an unnecessary copy of the results list 2023-10-01 14:34:28 +02:00
Tim Ledbetter 55f4d468ad Assistant: Remember currently selected result when updating results
This fixes an issue where the selected result index would be reset to
0 when the file cache finished building and the results list updated.
2023-10-01 14:34:28 +02:00
Tim Ledbetter 3ee12ffa8f stat: Show the device ID for the given file 2023-10-01 13:34:41 +02:00
kleines Filmröllchen 614ff9c46e Maps: Load tiles starting from center
The information the user is most interested in is usually in the center,
so we should start loading tiles from the center and move outwards.
Since tiles are loaded in draw order, simply drawing them in this order
achieves the desired effect. The current center-outwards loading
algorithm is a basic spiral algorithm, but others may be evaluated
later.
2023-09-30 11:11:05 +02:00
Andreas Kling a54e283901 LibJS: Fix two bugs in the GC fast rejection of possible pointers
- Convert to FlatPtr instead of doing pointer arithmetic on a too-large
  pointer type in find_min_and_max_block_addresses(). This makes the
  range more accurate.

- Untag possible cell pointers in add_possible_value() before doing the
  rejection. Otherwise we end up rejecting most pointers since the tags
  sit in the highest bits!

This fixes a crash when running the Speedometer benchmark.
2023-09-30 09:50:55 +02:00
Andreas Kling f388d2362a LibJS: Pad the capacity of BasicBlock while growing it
Just using Vector::resize() meant that we allocated exact capacity
instead of leaving padding at the end. This patch adds a call to
grow_capacity() before resize(), which ensures that we grow with the
usual extra padding.
2023-09-30 09:33:11 +02:00
Aliaksandr Kalenik e79d4f3462 LibJS: Early reject pointers outside of allocated blocks range in GC
This change adds a check to discard pointers that are lower than the
minimum address of all allocated blocks or higher than the maximum
address of all blocks. By doing this we avoid executing plenty of set()
operations on the HashMap in the add_possible_value().

With this change gather_conservative_roots() run 10x times faster in
Speedometer React-Redux-TodoMVC test.
2023-09-30 08:07:12 +02:00
Sam Atkins a3a5af3fd1 LibWeb: Implement length and item() for ResolvedCSSStyleDeclaration 2023-09-29 20:20:55 +02:00
Sam Atkins 08cf35cf9a LibWeb: Allow indexing into CSSStyleDeclaration by number
The `item(unsigned long index)` method is marked as a getter in IDL, so
let's treat it as such.
2023-09-29 20:20:55 +02:00
Sam Atkins 33e4a35d2d LibWeb: Resolve style for box-shadow and text-shadow 2023-09-29 15:12:09 +01:00
Sam Atkins 44836cd8ed LibWeb: Resolve style for logical-side length properties
For now, we just hard-code the logical sides to physical ones, but at
least the hard-coding is all in one place. :^)
2023-09-29 15:12:09 +01:00
Sam Atkins 2fa1df2ec4 LibWeb: Implement resolved style for line-height 2023-09-29 15:12:09 +01:00
Sam Atkins 30e31d83b6 LibWeb: Construct resolved shorthands from resolved longhands
Recursively call `style_value_for_property()` for the longhands, instead
of duplicating the logic to construct them.
2023-09-29 15:12:09 +01:00
Sam Atkins 737cccec70 LibWeb: Remove manual construction of resolved sided-border values
The automatic shorthand code will handle these just fine.
2023-09-29 15:12:09 +01:00
Sam Atkins 77fb85d27a LibWeb: Add spec comments to style_value_for_property()
Also, re-order things to match. No behaviour changes.

This reveals quite a few properties that are missing here, or which we
implement somewhat incorrectly.
2023-09-29 15:12:09 +01:00
Karol Kosek 9ce2682ce6 Userland: Port lists of mime types to String 2023-09-29 14:40:21 +01:00
Karol Kosek e75d694974 Userland: Compare event MIME type list with a StringView
The following commit will port MIME types to String. Traits<String>
- used in Vector::contains_slow - can't compare String type with char*,
so we need to use StringView instead.
2023-09-29 14:40:21 +01:00
Karol Kosek 2f35348104 Userland: Store MIME keys as String in Core::MimeData 2023-09-29 14:40:21 +01:00
Karol Kosek 4f638d3af2 Userland: Take StringView in MimeData::data() and has_{format,text,urls} 2023-09-29 14:40:21 +01:00
Sam Atkins dcf3bdcb9a LibWeb: Use correct realm when focusing HTMLTextAreaElement
This matches HTMLInputElement, and fixes the crash when focusing a
textarea.
2023-09-29 07:21:43 -04:00
Sam Atkins ca16a1ed08 LibWeb: Store GridSize values as a Variant
A GridSize can't hold both a LengthPercentage and a Flex at the same
time, so let's limit that.
2023-09-28 20:33:20 +01:00
Sam Atkins b66ff21379 LibWeb: Add missing check for flexible grid tracks
Previously this didn't cause issues because the default flex-factor is
0, but once we only store a flex-factor for FlexibleLength-type
GridSizes, this causes a crash.
2023-09-28 20:33:20 +01:00
Sam Atkins 127bfd64a8 LibWeb: Use Flex type in GridSize 2023-09-28 20:33:20 +01:00
Sam Atkins dfd3d9a72d LibWeb: Support flex in typed attr() 2023-09-28 20:33:20 +01:00
Sam Atkins b0317bb3a1 LibWeb: Implement Flex and FlexStyleValue types 2023-09-28 20:33:20 +01:00
Sam Atkins f1d7ea67c0 LibWeb: Add missing check for frequency values 2023-09-28 20:33:20 +01:00
Aliaksandr Kalenik 66b7da4fc7 LibJS: Remove unused make_super_property_reference()
This function is no longer used anywhere after we removed AST
interpreter.
2023-09-28 20:34:47 +02:00
Nico Weber 563bb9d20c ICC: Implement Profile::to_pcs() for grayscale colors
There's probably a nicer way of doing this where we don't need to expand
the gray value into a full Vector3, but for now this is good enough.

Makes PDFs written by macOS 13.5.2's "Save as PDF..." feature show up.
2023-09-28 16:57:31 +01:00
Nico Weber 6b4da8680d ICC: Move a lambda up a bit
No behavior change.
2023-09-28 16:57:31 +01:00
Aliaksandr Kalenik 42e9dfedc2 LibJS: Pre-calculate the number of bindings for function environments
We can use `ensure_capacity` for binding vectors if we know their sizes
in advance. This ensures that binding vectors aren't reallocated during
the `function_declaration_instantiation` execution.

With this change, `try_grow_capacity()` and `shrink_to_fit()` are no
longer visible in the `function_declaration_instantiation()` profiles
when running React-Redux-TodoMVC from Speedometer.
2023-09-28 15:33:43 +02:00
Aliaksandr Kalenik 98f479318a LibJS: Do not create environment bindings for local variables
If variable is local it is not stored in an environment so we don't
need a binding.
2023-09-28 15:33:43 +02:00
Aliaksandr Kalenik 4561469d52 LibJS: Fix BindingPattern::contains_expression() is name is expression
If any of binding pattern entry's name is expession
`contains_expression()` should return true.

For example:
```js
function evalInComputedPropertyKey(
  {[eval("var x = 'inner'")]: ignored}
) {}
```

`contains_expression()` should return true for the binding param in
this function.
2023-09-28 15:33:43 +02:00
Andreas Kling aeb8b5685f LibJS: Make Bytecode::Generator::emit() return void
There are no callers left that use the return value.
2023-09-28 14:52:03 +02:00
Andreas Kling 887183cad6 LibJS: Remove last user of Op::Jump::set_targets() and API itself
This was just a matter of instantiating a BasicBlock earlier so we
can reference it when making the jump.
2023-09-28 14:52:03 +02:00
Andreas Kling bdd21cf9db LibJS: Remove almost all uses of Op::Jump::set_targets()
We should initialize jump targets when constructing the jump instruction
instead of doing it later. This was already the case in all construction
sites but one. This first patch converts all those sites to pass final
targets to the constructor directly.
2023-09-28 14:52:03 +02:00
Andreas Kling 84850700a0 LibJS: Make BC::Generator::emit_with_extra_register_slots() return void
Nobody was using the return value.
2023-09-28 14:52:03 +02:00
Sam Atkins 9e99368694 LibWeb: Track quote-nesting level while building the layout tree
This makes multiple levels of quote actually use different quotation
marks, instead of always the first available pair of them.

Each Layout::Node remembers what the quote-nesting level was before its
content was evaluated, so that we can re-use this number in
`apply_style()`. This is a bit hacky, since we end up converting the
`content` value into a string twice.

`StyleProperties::content()` now takes an initial quote-nesting level,
and returns the final level after that content.
2023-09-28 14:49:10 +02:00
Sam Atkins 493dd5d93c LibWeb: Create ::before pseudo-element before element children
This allows any effects of `content` (eg quotes and counters) to happen
in the right order.

To make it work there are a couple of other changes needed:
- Skip nodes generated by ::before when constructing button layout.
- When in a flex parent, don't merge an inline text node into a previous
  one that is generated from a pseudo-element.
2023-09-28 14:49:10 +02:00
Sam Atkins d431aeed04 LibWeb: Repeat last available quote-type, instead of looping them all
I misunderstood this part of the spec before.
2023-09-28 14:49:10 +02:00
Shannon Booth 2d8b2328fd LibJS: Syntax error for a unary expression followed by exponentiation
This change makes LibJS correctly report a syntax error when a unary
expression is followed by exponentiation, as the spec requires.
Apparently this is due to that expression being ambiguous ordering.

Strangely this check does not seem to apply in the same way for '++' and
'--' for reasons that I don't fully understand. For example

```
let x = 5;
++x ** 2
```

Since `--5` and `++5` on it's own results in a syntax error anyway, it
seems we do not need to perform this exponentiation check in those
places.

Diff Tests:
    +6     -6 
2023-09-28 13:11:11 +02:00
Bastiaan van der Plaat 5e7a82a853 LibWeb: Create canvas bitmap when not existing in toDataURL and toBlob 2023-09-28 13:09:25 +02:00
Andreas Kling d24e07579f LibJS: Use a Vector<u8> for BasicBlock instruction storage
This reduces the minimum size of a basic block from 4 KiB to 0 bytes.
With this change, memory usage at the end of Speedometer is 1.2 GiB,
down from 1.8 GiB.
2023-09-28 11:25:19 +02:00
Aliaksandr Kalenik 32be413f4e LibWeb: Add missing visit_edges() for ImageStyleValue
ImageStyleValue has a visit_edges() method, although it is not a
GC-allocated object. This is necessary because it owns a GC-allocated
ImageRequest that we want to visit, instead of using JS::Handle, to
avoid leaks. In the future, we might want to make StyleValue be
GC-allocated.

For now, this change adds missing visit_edges() calls for objects that
own ImageStyleValue.
2023-09-28 06:11:17 +02:00
Aliaksandr Kalenik b43b3d2f8d LibWeb: Null check container while creating srcdoc navigation params
Fixes https://github.com/SerenityOS/serenity/issues/21205
Fixes https://github.com/SerenityOS/serenity/issues/21240
2023-09-28 06:09:52 +02:00
Andreas Kling feedbd6a01 LibJS: Put __builtin_unreachable() in unused bytecode opcode handlers
For the opcodes that are handled directly in the interpreter loop,
we want the compiler to know that there's nothing to inline here.
2023-09-28 06:09:16 +02:00
Andreas Kling f3606adc58 LibJS: Inline bytecode ops for direct local/register access
These can do a lot less stuff if we put them directly in the interpreter
loop and allow them to access the locals/registers arrays directly.
2023-09-28 06:09:16 +02:00
Andreas Kling ae1ac9871b LibJS: Move all bytecode instruction implementations to Interpreter.cpp
This allows aggressive inlining without LTO.
2023-09-28 06:09:16 +02:00
Andreas Kling e5474c384d LibJS: Inline flow control ops in the bytecode interpreter loop
Instead of calling out to helper functions for flow control (and then
checking control flags on every iteration), we now simply inline those
ops in the interpreter loop directly.
2023-09-28 06:09:16 +02:00
Andreas Kling 39cfb64269 LibJS: Return early from Interpreter on unhandled exception
If we don't have a local unwind context to handle the exception, we can
just return right away. This allows us to remove one check from the
inner loop.
2023-09-28 06:09:16 +02:00
Andreas Kling c9eff35b96 LibJS: Use goto instead of bool will_jump in interpreter loop
This is honestly less spaghetti-ish.
2023-09-28 06:09:16 +02:00
Andreas Kling 9fe38245b2 LibJS: Move bytecode interpreter's inner loop to its own function 2023-09-28 06:09:16 +02:00
Andreas Kling 951a85992b LibJS: Mark the exception path as [[unlikely]] in the interpreter loop 2023-09-28 06:09:16 +02:00
Andreas Kling 031ec98803 LibJS: Streamline InstructionStreamIterator
Nuke all the per-instruction bounds checking when iterating instructions
by using raw pointers instead of indexing into a ReadonlyBytes.

The interpreter loop already checks that we're in-bounds anyway.
2023-09-28 06:09:16 +02:00
Andreas Kling 213b835b57 LibJS: Remove Bytecode::Interpreter::debug_position()
This was only used in one place, and that place is already covered
by a VERIFY anyway.
2023-09-28 06:09:16 +02:00
Andreas Kling 0c746366cc LibJS: Keep return value in a call frame register 2023-09-28 06:09:16 +02:00
Andreas Kling c833885fb5 LibJS: Keep cached this value in a call frame register
Just moving more things to call frame registers..
2023-09-28 06:09:16 +02:00
Andreas Kling 3887b840a3 LibJS: Keep current exception in a call frame register
Instead of keeping it in a Bytecode::Interpreter member, move it into
a dedicated call frame register.
2023-09-28 06:09:16 +02:00
Tim Ledbetter ebb822def9 less: Add the -F option to quit if the input fits on one screen 2023-09-27 20:00:34 +02:00
Tim Ledbetter 938a287d3e ls: Left justify owner and group information in long format 2023-09-27 19:58:17 +02:00
Tim Ledbetter cb1851f3cc ls: Add the -g option to omit owner information in long format 2023-09-27 19:58:17 +02:00
Tim Ledbetter d618ef58fb ls: Display results in long format when -n or -o are used 2023-09-27 19:58:17 +02:00
Aliaksandr Kalenik dc19de58d0 LibWeb: Do not use JS::Handle for "scripts to execute" in DOM::Document
Using JS::Handle in members of GC-allocated object almost always leaks.
Instead we should visit these members in visit_edges().
2023-09-27 19:39:57 +02:00
Aliaksandr Kalenik cad2d2c85b LibWeb: Use JS::HeapFunction for DocumentObserver callbacks
If GC-allocated object wants to own a function it should use
HeapFunction because using SafeFunction will almost always lead to a
leak.
2023-09-27 19:39:57 +02:00
Tim Ledbetter 12adaac08d GameOfLife: Don't toggle cells on mouse move when placing patterns
Previously, it was very easy to inadvertently toggle cells when
placing a pattern by dragging the mouse slightly.
2023-09-27 19:12:14 +02:00
Tim Ledbetter 6eaae726fa GameOfLife: Clear the selected pattern when the game starts running 2023-09-27 19:12:14 +02:00
Tim Ledbetter 4b48757586 GameOfLife: Allow ctrl+click to place multiple patterns 2023-09-27 19:12:14 +02:00
Aliaksandr Kalenik 15629e8925 LibWeb: Do not use JS::Handle for mutation observers
Using JS::Handle in WebEngineCustomData means that mutation observers
will live as long as VM while actually they should be deallocated as
soon as they are no longer used in a script that created them.
2023-09-27 16:33:21 +02:00
Aliaksandr Kalenik e7a3040c9f LibWeb: Do not use JS::Handle for TimerHandler
There is no need to use JS::Handle for timer handler because it is
visited from JS::HeapFunction in HTML::Timer.
2023-09-27 16:33:21 +02:00
Aliaksandr Kalenik 3a1f617fbf LibJS: Use Function as callback type in define_native_function/accessor
There is not need to use SafeFunction because
define_native_function or define_native_accessor will pass callback
forward to NativeFunction that uses HeapFunction to visit it.
2023-09-27 16:33:21 +02:00
circl 3e1a154440 Browser: Add support for color pickers 2023-09-27 12:16:41 +01:00
circl 2995a2e212 LibWeb+LibWebView+WebContent: Add support for <input type="color">
This commit introduces 3 things:
- Support for the color type in HTMLInputElement itself
- A mechanism for handling non event loop blocking dialogs in Page
- The associated plumbing up to ViewImplementation

Frontends may add support for the color picker with the
ViewImplementation.on_request_color_picker function
2023-09-27 12:16:41 +01:00
Andreas Kling 759ad905de LibWeb: Remove FIXME about spec bug in page visibility
Because the spec bug got fixed \o/
2023-09-27 09:31:27 +02:00
Sönke Holz c42e8ddc48 LibELF: Calculate size of relocation table correctly in all cases
RELASZ might include the PLT table as well. Check if that is the case
and correct the size of the non-PLT relocation table.
2023-09-27 03:33:36 +02:00
kleines Filmröllchen 968038aa79 LibAudio: Use mapped files for audio playback
This is 10-20% of a speed increase on platforms with fast I/O (Linux)
and not a slowdown on Serenity. Again, the file system layer is the
limit for us :^)
2023-09-27 03:22:56 +02:00
kleines Filmröllchen d6571f54d8 LibCore: Make MappedFile a Stream
The internal reuse of FixedMemoryStream makes this straightforward.
There alread is one user of the new API, demonstrating the need for this
change beyond what I said out to use it for :^)
2023-09-27 03:22:56 +02:00
kleines Filmröllchen 062e0db46c LibCore: Make MappedFile OwnPtr-based
Since it will become a stream in a little bit, it should behave like all
non-trivial stream classes, who are not primarily intended to have
shared ownership to make closing behavior more predictable. Across all
uses of MappedFile, there is only one use case of shared mapped files in
LibVideo, which now uses the thin SharedMappedFile wrapper.
2023-09-27 03:22:56 +02:00
Tim Ledbetter 09099cc9a3 du: Prevent multiple counting of the same file
Previously, the same file would be counted more than once if its
containing directory was visited multiple times, or there were
multiple hard links pointing to it.

We now keep track of every visited inode to ensure that files aren't
evaluated multiple times. This matches the behavior of `du` on FreeBSD
and Linux.
2023-09-26 21:27:25 +02:00
Aliaksandr Kalenik 46254101f7 LibWeb: Change DOM::Position to be GC-allocated 2023-09-26 21:25:54 +02:00
Aliaksandr Kalenik 35623ad52e LibWeb: Visit IntersectionObserverRegistration instead of using Handle
This fixes GC-leak caused by JS::Handle<IntersectionObserverver>
preventing an element that owns the handle from being deallocated.
2023-09-26 21:25:54 +02:00
Aliaksandr Kalenik ac5c4705fd LibWeb: Do not use JS::Handle for captures of AbortSignal callbacks
There is no need to use JS::Handle for captures because AbortSignal
will visit them anyway because it uses JS::HeapFunction to store the
callback.
2023-09-26 21:25:54 +02:00