Commit graph

30073 commits

Author SHA1 Message Date
Andreas Kling 481e7b7971 SpiceAgent: Use image decoder plugins instead of deprecated wrappers 2021-11-13 00:55:07 +01:00
Andreas Kling 62ce7653cb LibGUI: Use PNGImageDecoderPlugin for ELF icon extraction
Getting rid of all the remaining calls to load_png_from_memory() and the
related wrappers for each decoder.
2021-11-13 00:55:07 +01:00
Andreas Kling b189c88ec2 Fuzzers: Use ImageDecoders instead of load_FORMAT_from_memory() wrappers 2021-11-13 00:55:07 +01:00
Tom 32d59257d6 WindowServer: Ensure menu visibility after pushing menu to the stack
We need to make sure the menu was pushed to the open menu stack before
calling set_visible, as this may trigger cursor re-evaluation, which
in turn expects the menu to be considered open.

Fixes #10836
2021-11-13 00:38:36 +01:00
Linus Groh 81786f6abe Base: Update synopsis of grep(1) and tr(1) manpages as well 2021-11-12 21:59:25 +00:00
Linus Groh 2a04f1fa80 Base: Add missing options to grep(1) and tr(1) manpages 2021-11-12 21:56:02 +00:00
Tim Schumacher c81cef614a Utilities/grep: Implement line-counting mode 2021-11-12 21:29:18 +00:00
Tim Schumacher 7ce693840b Utilities/tr: Implement squeezing repeated characters 2021-11-12 21:23:29 +00:00
Timothy Flynn 1f2ac0ab41 LibUnicode: Move number formatting code generator to UnicodeNumberFormat 2021-11-12 20:46:38 +00:00
Timothy Flynn 04e6b43f05 LibUnicode: Move (soon-to-be) common code out of GenerateUnicodeLocale
The data used for number formatting is going to grow quite a bit when
the cldr-units package is parsed. To prevent the generated UnicodeLocale
file from growing outrageously large, the number formatting data can go
into its own file. To prepare for this, move code that will be common
between the generators for UnicodeLocale and UnicodeNumberFormat to the
utility header.
2021-11-12 20:46:38 +00:00
Linus Groh a53542e0a3 LibJS: Clear exception after running each queued Promise job
It's not what the spec tells us to do. In fact, the spec tells us the
exact opposite:

    9.5 Jobs and Host Operations to Enqueue Jobs
    https://tc39.es/ecma262/#sec-jobs

    A Job is an Abstract Closure with no parameters that initiates an
    ECMAScript computation when no other ECMAScript computation is
    currently in progress.
    ...
    Their implementations must conform to the following requirements:
    - ...
    - The Abstract Closure must return a normal completion, implementing
      its own handling of errors.

However, this turned out to not be true in all cases. More specifically,
the NewPromiseReactionJob AO returns the completion result of calling a
user-provided function (PromiseCapability's [[Resolve]] / [[Reject]]),
which may be an abrupt completion:

    27.2.2.1 NewPromiseReactionJob ( reaction, argument )
    https://tc39.es/ecma262/#sec-newpromisereactionjob

    1. Let job be a new Job Abstract Closure with no parameters that
       captures reaction and argument and performs the following steps
       when called:
       ...
       h. If handlerResult is an abrupt completion, then
          i. Let status be Call(promiseCapability.[[Reject]],
             undefined, « handlerResult.[[Value]] »).
       i. Else,
          i. Let status be Call(promiseCapability.[[Resolve]],
             undefined, « handlerResult.[[Value]] »).
       j. Return Completion(status).

Interestingly, this case is explicitly handled in the HTML spec's
implementation of jobs as microtasks:

    8.1.5.3.3 HostEnqueuePromiseJob(job, realm)
    https://html.spec.whatwg.org/webappapis.html#hostenqueuepromisejob

    2. Queue a microtask on the surrounding agent's event loop to
       perform the following steps:
       ...
       5. If result is an abrupt completion, then report the exception
          given by result.[[Value]].

This is precisely what all the major engines do - but not only in
browsers; the provided code snippet in the test added in this commit
works just fine in Node.js, for example.

SpiderMonkey:
https://searchfox.org/mozilla-central/rev/25997ce8267ec9e3ea4b727e0973bd9ef02bba79/js/src/builtin/Promise.cpp#6292
https://searchfox.org/mozilla-central/rev/25997ce8267ec9e3ea4b727e0973bd9ef02bba79/js/src/builtin/Promise.cpp#1277
https://searchfox.org/mozilla-central/rev/25997ce8267ec9e3ea4b727e0973bd9ef02bba79/js/src/vm/JSContext.cpp#845

JavaScriptCore:
https://trac.webkit.org/browser/webkit/trunk/Source/JavaScriptCore/builtins/PromiseOperations.js?rev=273718#L562
https://trac.webkit.org/browser/webkit/trunk/Source/JavaScriptCore/runtime/JSMicrotask.cpp?rev=273718#L94

V8:
https://source.chromium.org/chromium/chromium/src/+/main:v8/src/builtins/promise-abstract-operations.tq;l=481;drc=a760f03a6e99bf4863d8d21c5f7896a74a0a39ea
https://source.chromium.org/chromium/chromium/src/+/main:v8/src/builtins/builtins-microtask-queue-gen.cc;l=331;drc=65c9257f1777731d6d0669598f6fe6fe65fa61d3

This should probably be fixed in the ECMAScript spec to relax the rule
that Jobs may not return an abrupt completion, just like in the HTML
spec. The important bit is that those are not surfaced to user code in
any way.
2021-11-12 15:35:03 +02:00
Brendan Coles 754bcea12a Base: Add /res/icons/16x16/sidebar.png icon for PDFViewer 2021-11-12 13:24:35 +00:00
Ali Mohammad Pur c08bfd450b Meta: Update the gdb script for the new RefPtr layout 2021-11-12 13:01:59 +00:00
Ali Mohammad Pur 070d2eaa51 LibJS+LibTest+js: Convert BC::Interpreter::run to ThrowCompletionOr<>
Note that this is just a shallow API change.
2021-11-12 13:01:59 +00:00
Ali Mohammad Pur 3b0bf05fa5 LibJS: Implement async functions as generator functions in BC mode
This applies a simple transformation, and adds a simple wrapper that
translates the generator interface to the async function interface.
2021-11-12 13:01:59 +00:00
Ali Mohammad Pur c604e95993 LibJS: Run the queued promise reaction jobs on bytecode interpreter exit
This is the same as what the AST interpreter does.
2021-11-12 13:01:59 +00:00
Ali Mohammad Pur e4a7f1a696 LibJS: Make Bytecode::Interpreter return the popped frame
And use it to _correctly_ implement state saving for generators.
Prior to this, we were capturing the caller frame, which is completely
irrelevant to the generator frame.
2021-11-12 13:01:59 +00:00
Ali Mohammad Pur b96118b5d1 LibJS: Fix codegen for nodes after try statements without 'finally'
Previously we were just dropping them on the ground :P
2021-11-12 13:01:59 +00:00
Ali Mohammad Pur 5a38f86f1b LibJS: Use a 'Return' completion for generator object body evaluation
The comment a few lines above explains the issue, this one was forgotten
and caused generator functions to return `undefined` when called.
2021-11-12 13:01:59 +00:00
Ali Mohammad Pur 3ec0183b51 LibJS: Use the correct prototype for generator functions 2021-11-12 13:01:59 +00:00
Luke Wilde f65d25682c LibJS: Implement Temporal.ZonedDateTime.prototype.subtract 2021-11-12 09:24:36 +00:00
Luke Wilde 9b8524b463 LibJS: Implement Temporal.ZonedDateTime.prototype.add 2021-11-12 09:24:36 +00:00
Timothy Flynn 89523f70cf LibJS: Begin implementing Intl.NumberFormat.prototype.format
There is quite a lot to be done here so this is just a first pass at
number formatting. Decimal and percent formatting are mostly working,
but only for standard and compact notation (engineering and scientific
notation are not implemented here). Currency formatting is parsed, but
there is more work to be done to handle e.g. using symbols instead of
currency codes ("$" instead of "USD"), and putting spaces around the
currency symbol ("USD 2.00" instead of "USD2.00").
2021-11-12 09:17:08 +00:00
Timothy Flynn 0469006263 LibJS: Change Intl's PatternPartition record to hold a String value
It was previously holding a StringView, which was either a view into a
LibUnicode-generated string or a string passed from the user.

Intl.NumberFormat will need this record to hold internally-created
strings, so a StringView will not suffice (the way the steps are laid
out, that view will ultimately end up dangling).

This shouldn't be too wasteful since the StringView it was holding was
converted to a String eventually anyways.
2021-11-12 09:17:08 +00:00
Timothy Flynn be69eae651 LibUnicode: Precompute the compact scale of each number formatting rule
This will be needed for the ComputeExponentForMagnitude AO for compact
formatting, namely step 5b:

  Let exponent be an implementation- and locale-dependent (ILD) integer
  by which to scale a number of the given magnitude in compact notation
  for the current locale.
2021-11-12 09:17:08 +00:00
Timothy Flynn 230b133ee3 LibUnicode: Parse number formats into zero/positive/negative patterns
A number formatting pattern in the CLDR contains one or two entries,
delimited by a semi-colon. Previously, LibUnicode was just storing the
entire pattern as one string. This changes the generator to split the
pattern on that delimiter and generate the 3 unique patterns expected by
ECMA-402.

The rules for generating the 3 patterns are as follows:

* If the pattern contains 1 entry, it is the zero pattern. The positive
  pattern is the zero pattern prepended with {plusSign}. The negative
  pattern is the zero pattern prepended with {minusSign}.

* If the pattern contains 2 entries, the first is the zero pattern, and
  the second is the negative pattern. The positive pattern is the zero
  pattern prepended with {plusSign}.
2021-11-12 09:17:08 +00:00
Timothy Flynn 1244ebcd4f LibUnicode: Parse and generate standard accounting formatting rules
Also known as "currency-accounting" in some CLDR documentation.
2021-11-12 09:17:08 +00:00
Timothy Flynn 967afc1b84 LibUnicode: Parse and generate standard currency formatting rules 2021-11-12 09:17:08 +00:00
Timothy Flynn bffd73e0d4 LibUnicode: Parse and generate standard decimal formatting rules 2021-11-12 09:17:08 +00:00
Timothy Flynn feb8c22a62 LibUnicode: Parse and generate standard percentage formatting rules 2021-11-12 09:17:08 +00:00
Timothy Flynn 4317a1b552 LibUnicode: Parse and generate compact currency formatting rules 2021-11-12 09:17:08 +00:00
Timothy Flynn 604a596c90 LibUnicode: Parse and generate compact decimal formatting rules 2021-11-12 09:17:08 +00:00
Timothy Flynn 12b468a588 LibUnicode: Begin parsing and generating locale number systems
The number system data in the CLDR contains information on how to format
numbers in a locale-dependent manner. Start parsing this data, beginning
with numeric symbol strings. For example the symbol NaN maps to "NaN" in
the en-US locale, and "非數值" in the zh-Hant locale.
2021-11-12 09:17:08 +00:00
Timothy Flynn d3e83c9934 LibUnicode: Parse alternate default numbering systems
Some locales in the CLDR have alternate default numbering systems listed
under "defaultNumberingSystem-alt-*", e.g.:

    "defaultNumberingSystem": "arab",
    "defaultNumberingSystem-alt-latn": "latn",
    "otherNumberingSystems": {
      "native": "arab"
    },

We were previously only parsing "defaultNumberingSystem" and
"otherNumberingSystems". This odd format appears to be an artifact of
converting from XML.
2021-11-12 09:17:08 +00:00
Timothy Flynn ae66188d43 LibUnicode: Capitialize generated identifiers in lieu of full title case
This isn't particularly important because this generates code that is
quite hidden from outside callers. But when viewing the generated code,
it's a bit nicer to read e.g. enum identifiers such as "MinusSign"
rather than "Minussign".
2021-11-12 09:17:08 +00:00
Jelle Raaijmakers 86a1ff5204 Kernel: Drain I8042 PS/2 keyboard output after enabling
As soon as we enable the first PS/2 port on the I8042 controller, the
output buffer may become full. We need to drain it before attempting
any new commands with the controller (such as enabling the second PS/2
port).

Fixes #10872.
2021-11-12 07:35:18 +01:00
Luke Wilde 5e3fe52fc4 LibJS: Implement Temporal.Duration.compare 2021-11-11 21:06:54 +00:00
Luke Wilde 29072f4b09 LibJS: Implement the required AOs for Temporal.Duration.compare 2021-11-11 21:06:54 +00:00
Lady Gegga 98b9a75591 Base: Add new glyphs to font Tiny Regular
Shavian (48 glyphs)
Symbols for legacy computing (194 glyphs)
Misc (latin, symbols, greek, arrows, dingbats, etc): ~300 glyphs
Braille Patterns (128 glyphs)
Klingon (39 glyphs) F8D0–F8FF*
Braille Extended (61 glyphs) EB60-EB9F*
Aurebesh (49 glyphs) E890–E8DF*
* PUA based on Under-ConScript Unicode Registry
2021-11-11 20:42:20 +01:00
Ali Mohammad Pur bf59d9e824 Userland: Include Vector.h in a few places to make HeaderCheck happy
This header was being transitively pulled in, but that no longer happens
after 5f7d008791.
2021-11-11 20:36:36 +01:00
Ben Wiederhake a59fc324bd Base: Document readonly atexit mitigation 2021-11-11 12:50:18 +00:00
Ben Wiederhake f2ce751a32 Documentation: Update Debian dependency list
Apparently, qemu-system-* changed its name.

On Debian/Ubuntu, genext2fs does not make a difference: The only user of
this command, Meta/build-image-qemu.sh, runs as root anyway, and tries
to do 'mount _disk_image mnt/' first. Debian/Ubuntu always have drivers
for ext2 available, so this command has no good reason to fail, and
trying to use genext2fs might only obscure any problems that mount
encountered.

Finally, Debian Bullseye (released 2021-08-14) contains gcc-10, so the
instructions on how to upgrade are now obsolete.
2021-11-11 12:47:39 +00:00
Timothy Flynn 7cc50d614c LibGfx: Include Vector.h in PNGLoader.cpp
This was being transitively included from Deflate.h on SerenityOS builds
but not on Lagom builds.
2021-11-11 12:46:48 +00:00
Andreas Kling 2bd0ef0c76 LibGfx: Remove now-unused load_gif_from_memory() 2021-11-11 11:45:32 +01:00
Andreas Kling 880fafd2c5 LibGfx: Use ImageDecoder in Bitmap::try_load_from_fd_and_close()
Before this patch, both Bitmap and ImageDecoder had logic for guessing
which image codec to use for a chunk of data. Bitmap now defers to
ImageDecoder so that we only have to do this in one place.

There's room for improvement in the ImageDecoder heuristic, but that's
outside the scope of this change.
2021-11-11 11:43:08 +01:00
Andreas Kling 10add3f4c2 LibGfx: Remove load_FORMAT() image codec wrappers
We had a bunch of old unused wrapper functions for each image codec that
would load a supported image with a given path. Nobody actually used
them, so let's just get rid of load_png(), load_gif(), etc.
2021-11-11 11:32:22 +01:00
Andreas Kling 09780ba7a9 Tests/LibGfx: Actually test image decoders in TestImageDecoder
We were passing raw Gfx::Bitmap objects into the various image decoders
instead of encoded image data. This made all of them fail, but the test
expectations were set up in a way that aligned with this outcome.

With this patch, we now test the codecs for real. Except ICO, since we
don't have an ICO file handy. That's a FIXME.
2021-11-11 11:20:58 +01:00
Tim Schumacher ba29798039 Utilities: cut: Implement field-based cutting 2021-11-11 09:47:41 +01:00
Tim Schumacher 96ea4f71bd Utilities: cut: Split up into file and line processing 2021-11-11 09:47:41 +01:00
Tim Schumacher 4d18b21fb5 Utilities: cut: Work exclusively with ranges 2021-11-11 09:47:41 +01:00