Commit graph

28753 commits

Author SHA1 Message Date
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