Commit graph

3757 commits

Author SHA1 Message Date
Timothy Flynn 60d8852fc2 LibJS: Implement String.prototype.substring with UTF-16 code units 2021-07-22 09:10:44 +02:00
Timothy Flynn 767700d8a1 LibJS: Implement String.prototype.indexOf with UTF-16 code units 2021-07-22 09:10:44 +02:00
Timothy Flynn 70f9c7e1c7 LibJS: Implement String.prototype.includes with UTF-16 code units
This also implements String.prototype.includes more closely to the spec
(such as returning false when the search string is a RegExp object).
2021-07-22 09:10:44 +02:00
Timothy Flynn a05ce330b8 LibJS: Implement String.prototype.codePointAt with UTF-16 code units
This also implements the CodePointAt abstract operation. This is needed
to handle invalid code units specific to the JavaScript spec, rather
than e.g. inserting replacement code units. This abstraction is public
because RegExp.prototype will also need it.
2021-07-22 09:10:44 +02:00
Timothy Flynn 48a28a9a73 LibJS: Implement String.prototype.charCodeAt with UTF-16 code units 2021-07-22 09:10:44 +02:00
Timothy Flynn 5d11614bc7 LibJS: Implement String.prototype.charAt with UTF-16 code units 2021-07-22 09:10:44 +02:00
Timothy Flynn 2bba20d123 LibJS: Report string properties using UTF-16 code units
String length is reported as the number of UTF-16 code units, and string
indices are reported as the UTF-16 code units themselves.
2021-07-22 09:10:44 +02:00
Timothy Flynn 0c42aece36 LibJS: Transcode UTF-8 strings to UTF-16 and add UTF-16 accessors
LibJS parses JavaScript as UTF-8, so when creating a string, we must
transcode it to UTF-16 to handle encoded surrogate pairs.

For example, consider the following string:
    "\ud83d\ude00"

The UTF-8 encoding of this surrogate pair is:
    0xf0 0x9f 0x98 0x80

However, LibJS will currently store the two surrogates individually as
UTF-8 encoded bytes, rather than combining the pair:
    0xed 0xa0 0xb8, 0xed 0xb8 0x80

These are not equivalent. So, as String.prototype becomes UTF-16 aware,
this encoding will no longer work for abstractions like strict equality.
2021-07-22 09:10:44 +02:00
Timothy Flynn 0e25d2393f LibJS: Add UTF-16 tests to String.prototype methods that already work
These methods did not require UTF-16 views, so just add test cases to
ensure they remain correct.

This also adds a couple of FIXME comments on tests that will fail even
with UTF-16 String.prototype support (for reasons such as lack of UTF-16
support in RegExp.prototype and Unicode case folding).
2021-07-22 09:10:44 +02:00
Gunnar Beutner db1c5c4830 LibELF+Utilities: Avoid truncating 64-bit values
This fixes displaying 64-bit addresses in readelf and also fixes
showing backtraces from core dumps on x86_64.
2021-07-22 08:57:01 +02:00
Gunnar Beutner 11e02f222d AK: Add a getter to JsonValue to get machine-native addresses 2021-07-22 08:57:01 +02:00
Gunnar Beutner 36e36507d5 Everywhere: Prefer using {:#x} over 0x{:x}
We have a dedicated format specifier which adds the "0x" prefix, so
let's use that instead of adding it manually.
2021-07-22 08:57:01 +02:00
FrHun 02c0b1f380 LibGUI: Fix multi-line tooltip height
Tooltips had a wrong calculation for the height of a tooltip window,
because they forgot to take into account the line spacing.
2021-07-22 04:33:41 +02:00
Gunnar Beutner 3904541938 LibC: Don't truncate arguments for ioctl() on x86_64
Among other things this makes "less" work on x86_64.
2021-07-22 04:18:39 +04:30
Idan Horowitz d804ce830d LibJS: Implement Temporal.PlainDate.prototype.equals & Required AO 2021-07-21 22:49:37 +01:00
Idan Horowitz cf78efaef5 LibJS: Implement the ToTemporalDate Abstract Operation
This is required by most Temporal.PlainDate.prototype methods.
2021-07-21 22:49:37 +01:00
Idan Horowitz 1e471e2e2f LibJS: Add Temporal.Calendar.prototype.dateFromFields & required AOs
This is required for implementing the DateFromFields PlainDate AO.
2021-07-21 22:49:37 +01:00
Idan Horowitz 7a33a5c9b5 LibJS: Use trunc instead of a static_cast<i64> in is_integral_number
This ensures we return true for integers that do not fit in an i64 aka,
above 9223372036854775807. (2**63 - 1)
2021-07-21 22:49:37 +01:00
Idan Horowitz 44c8e158c1 LibJS: Remove usages of String's null state in Temporal AOs 2021-07-21 22:49:37 +01:00
Idan Horowitz 68aad5d8fa LibJS: Implement Temporal.PlainDate.prototype.valueOf 2021-07-21 22:49:37 +01:00
Karol Kosek 3c62b661f4 LibAudio: Fix UTF-8 decoding logic in FLAC decoding :^)
The problem here was that the multi-byte UTF-8 encoded characters
were taking one byte too much, misaligning the data completely
and eventually crashing the program on the 128th frame.

This change reduces the for loop by one, as it has been already
calculated from the start_byte variable.
2021-07-21 22:12:44 +02:00
Karol Kosek 9c71e43c3f LibAudio: Check if zero-bit padding is actually zero
This might allow the program to return an error a bit quicker.
2021-07-21 22:12:44 +02:00
Andreas Kling 687a12d7fb Userland: Add GUI::Window::add_menu() and use it everywhere
Applications previously had to create a GUI::Menubar object, add menus
to it, and then call GUI::Window::set_menubar().

This patch introduces GUI::Window::add_menu() which creates the menubar
automatically and adds items to it. Application code becomes slightly
simpler as a result. :^)
2021-07-21 21:24:26 +02:00
Ariel Don a4fdb7f029 VimEditingEngine: Prevent crash upon 'x' or 'v' on blank lines
Previously, pressing 'x' for deletion on an otherwise empty line
insinuated a crash in TextEditor because a nonexistent code point was
accessed -- likewise for visual mode.
2021-07-21 21:13:57 +02:00
Andreas Kling cdc1315dc8 LibJS: Use IntrusiveList for keeping track of WeakContainers 2021-07-21 20:17:55 +02:00
Andreas Kling 3fe1be20b7 LibJS: Use IntrusiveList for keeping track of MarkedValueLists 2021-07-21 19:51:19 +02:00
Andreas Kling 746b310061 LibJS: Use IntrusiveList for keeping track of HandleImpls
This allows us to remove a HashTable from heap and cuts down on
some of the malloc traffic when creating handles.
2021-07-21 19:45:21 +02:00
Andreas Kling 3d0c5814d2 LibGfx: Sprinkle [[nodiscard]] on Gfx::Bitmap 2021-07-21 18:09:05 +02:00
Andreas Kling c7d891765c LibGfx: Use "try_" prefix for static factory functions
Also mark them as [[nodiscard]].
2021-07-21 18:02:15 +02:00
Andreas Kling f0409081f5 LibC: Simplify assertion failure dbgln() a bit
There's no need to say USERSPACE(PID) since dbgln() will prefix lines
with that information anyway.
2021-07-21 17:45:24 +02:00
Jamie Mansfield 137d716495 LibLine: Correct spelling mistake in variable name
This corrects the spelling of 'matching' from 'macthing'.
2021-07-21 14:15:24 +02:00
Tom 7e8a5d7323 LibIPC: Fix losing messages when connection is closed
This fixes not processing any messages read up until a connection
close is detected. We were returning from the function despite having
read some messages.
2021-07-21 01:13:45 +02:00
Tom 1ecb725357 LibGfx: Add an algorithm to disperse overlapping rectangles 2021-07-21 00:06:58 +02:00
davidot 295192bf15 LibJS: Add tests for strict mode and strict mode propagation 2021-07-20 23:45:28 +02:00
davidot f8a869f2fc LibJS: Fix that non-existent references are unresolvable in strict mode 2021-07-20 23:45:28 +02:00
davidot a49b47bfe6 LibJS: Fix tests that expected wrong this values 2021-07-20 23:45:28 +02:00
Timothy Flynn c6e9c6d6ab LibJS: Follow the spec more closely when determining the this value
Co-authored-by: davidot <david.tuin@gmail.com>
2021-07-20 23:45:28 +02:00
davidot a394aa5830 LibJS: Fix that vm.in_strict_mode was propagated to eval and functions
For eval it depends on the CallerMode and for a created function it
depends on the function itself.
2021-07-20 23:45:28 +02:00
davidot a6263150be LibJS: Disallow unqualified deletes in strict mode 2021-07-20 23:45:28 +02:00
davidot 697882a7ad LibJS: Disallow multiple __proto__ keys in object expression 2021-07-20 23:45:28 +02:00
davidot 93b57e6d8c LibJS: Disallow static methods named prototype in classes 2021-07-20 23:45:28 +02:00
davidot 40b8689f9b LibJS: Disallow duplicated variable declarations 2021-07-20 23:45:28 +02:00
davidot 5cc518f07a LibJS: Handle strict mode for functions more correctly
If a function is strict (has 'use strict' directive) it cannot have
bindings, cannot have duplicated parameter names and cannot have some
reserved keywords and identifiers as parameter names.
The logic partly applies depending on whether we are already in strict
mode or the function contains 'use strict';
2021-07-20 23:45:28 +02:00
davidot 4485df1405 LibJS: Be more strict about reserved and special identifiers 2021-07-20 23:45:28 +02:00
davidot 2a61b90fef LibJS: Be less strict about 'use strict'
It is allowed to have (bogus) directives e.g.
'does nothing'; 'same'; 'use strict';
Should still trigger strict mode.
2021-07-20 23:45:28 +02:00
Andreas Kling 3652ab8b2a LibGUI: Tweak GUI::GroupBox title text position 2021-07-20 21:50:06 +02:00
Linus Groh feea534dae LibJS/Tests: Fix typo in Temporal.Instant.compare test description 2021-07-20 17:57:50 +01:00
Linus Groh 99662975ed LibJS: Partially revert e3fa32b
This was causing some syntactically wrong inputs to crash and
subsequently broke CI (test262 parser tests).
2021-07-20 17:53:48 +01:00
Andreas Kling e7136399a1 LibX86: Add INT1 instruction (needed for disassembly) 2021-07-20 18:05:05 +02:00
Alexander d528c9c2ee LibWeb: Don't print JavaScript syntax error hints
This uses the new flag in print_errors to not print hints. This
decreases the load time of JavaScript heavy webpages with many errors
significantly.
2021-07-20 16:20:59 +02:00