Commit graph

30149 commits

Author SHA1 Message Date
Sam Atkins 7936f79825 LibWeb: Remove ParsingContext parameter from private CSS Parser methods
This was only needed when they were all static.
2021-11-17 22:20:01 +01:00
Sam Atkins e7d0544500 LibWeb: Make CSS Parser methods non-static
Past me thought making as much static as possible was a good idea, but
it just makes things more verbose, and awkward if anything isn't also
static.
2021-11-17 22:20:01 +01:00
Sam Atkins cf89f86dbd Base: Add additional test cases to backgrounds.html
- Add background color to `background-clip` test
- Add a mixed `background-repeat: space round` test
2021-11-17 22:20:01 +01:00
Sam Atkins 05682f8c66 LibWeb: Add NodeWithStyleAndBoxModelMetrics to Forward.h 2021-11-17 22:20:01 +01:00
Andreas Kling 1f894cee59 Kernel: Automatically sync shared file mappings when unmapped
To make sure we don't lose changes, shared file mappings will now be
fully synced when they are unmapped, whether explicitly or implicitly
(by the program exiting/crashing/etc.)

This can incur a lot of work, since we don't keep track of dirty pages,
but that's something we can optimize down the road. :^)
2021-11-17 19:35:53 +01:00
Andreas Kling af6358e1e1 Kernel: Allow mmap() with PROT_WRITE+MAP_SHARED
Now that we have a way to flush changes back to disk, let's allow this
type of mapping.
2021-11-17 19:35:13 +01:00
Andreas Kling 32aa37d5dc Kernel+LibC: Add msync() system call
This allows userspace to trigger a full (FIXME) flush of a shared file
mapping to disk. We iterate over all the mapped pages in the VMObject
and write them out to the underlying inode, one by one. This is rather
naive, and there's lots of room for improvement.

Note that shared file mappings are currently not possible since mmap()
returns ENOTSUP for PROT_WRITE+MAP_SHARED. That restriction will be
removed in a subsequent commit. :^)
2021-11-17 19:34:15 +01:00
Andreas Kling f2d5548d7a Kernel: Add MemoryManager::copy_physical_page()
This is a handy helper that copies out the full contents of a physical
page into a caller-provided buffer. It uses quickmapping internally
(and takes the MM lock for the duration.)
2021-11-17 19:32:07 +01:00
Lady Gegga c4a78633b0 Base: Add Buhid characters to font Katica Regular 10
1740–175F https://www.unicode.org/charts/PDF/U1740.pdf
2021-11-17 15:55:55 +01:00
davidot 22e679d844 LibJS + js: Rethrow exception on the vm after bytecode interpreter run
When the bytecode interpreter was converted to ThrowCompletionOr<Value>
it then also cleared the vm.exception() making it seem like no exception
was thrown.
Also removed the TRY_OR_DISCARD as that would skip the error handling
parts.
2021-11-17 13:12:05 +00:00
Luke Wilde 3666d2132b LibJS: Remove fallback value for get_offset_nanoseconds_for
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/664f02d

Note that the tests are not comprehensive.
2021-11-17 11:30:13 +00:00
Linus Groh f1784c9c87 LibJS/Tests: Fix failing Array.prototype.toLocaleString() test 2021-11-17 10:00:20 +00:00
Timothy Flynn 39ab1a8999 LibJS: Implement ECMA-402 Array.prototype.toLocaleString
Turns out the only difference between our existing implementation and
the ECMA-402 implementation is we weren't passing the locales and
options list to each element.toLocaleString invocation.

This also adds spec comments to the definition.
2021-11-17 09:01:32 +00:00
Timothy Flynn c19c3205ff LibJS: Implement ECMA-402 Number.prototype.toLocaleString 2021-11-17 09:01:32 +00:00
Andreas Kling 8fe1c1f788 AK: Add missing return in Formatter<unsigned char[Size]>::format()
Caught by ENABLE_ALL_THE_DEBUG_MACROS.
2021-11-17 07:45:10 +01:00
Andreas Kling 216e21a1fa AK: Convert AK::Format formatting helpers to returning ErrorOr<void>
This isn't a complete conversion to ErrorOr<void>, but a good chunk.
The end goal here is to propagate buffer allocation failures to the
caller, and allow the use of TRY() with formatting functions.
2021-11-17 00:21:13 +01:00
Andreas Kling 008355c222 AK: Add failable try_* functions to StringBuilder
These will allow us to start using TRY() with StringBuilder operations.
2021-11-17 00:21:13 +01:00
Andreas Kling 11aad74dce AK: Forward declare Error and ErrorOr in AK/Forward.h 2021-11-17 00:21:12 +01:00
Andreas Kling 587f9af960 AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)
Also add slightly richer parse errors now that we can include a string
literal with returned errors.

This will allow us to use TRY() when working with JSON data.
2021-11-17 00:21:10 +01:00
Daniel Bertalan 304c03f457 Kernel: Reject writable shared file mappings
We have no way of writing changes to memory-mapped files back to disk,
and software relying on this functionality for output would fail
miserably. Let's just return ENOTSUP instead to allow callers to fall
back to standard file IO instead of silently discarding writes.

This makes the LLD port work, which uses memory-mapped files to write
its output by default.
2021-11-17 00:15:30 +01:00
Timothy Flynn a1d5849e67 LibJS: Implement unit number formatting 2021-11-16 23:14:09 +00:00
Timothy Flynn cafb717486 LibUnicode: Parse and generate CLDR unit data for Intl.NumberFormat
The units data is in another CLDR package, cldr-units.
2021-11-16 23:14:09 +00:00
Timothy Flynn 80493908d3 LibUnicode: Tweak the definition of the plurality "many"
As noted at the top of this method, this is a naive implementation of
the Unicode plurality specification. But for now, we should tweak the
defintion of "many" to be "more than 2" (which is what I had in mind
when I wrote this, but forgot about fractions).
2021-11-16 23:14:09 +00:00
Timothy Flynn c24a350a18 LibUnicode: Ignore U+200F when parsing format identifiers
Noticed this while implementing multiple identifier support. We were
errantly parsing U+200F as a lone identifier in some Hebrew formats.
2021-11-16 23:14:09 +00:00
Timothy Flynn 04b8b87c17 LibJS+LibUnicode: Support multiple identifiers within format pattern
This wasn't the case for compact patterns, but unit patterns can contain
multiple (up to 2, really) identifiers that must each be recognized by
LibJS.

Each generated NumberFormat object now stores an array of identifiers
parsed. The format pattern itself is encoded with the index into this
array for that identifier, e.g. the compact format string "0K" will
become "{number}{compactIdentifier:0}".
2021-11-16 23:14:09 +00:00
Timothy Flynn 3b68370212 LibJS+LibUnicode: Rename the generated compact_identifier to identifier
This field is currently used to store the StringView into the compact
name/symbol in the format string. Units will need to store a similar
field, so rename the field to be more generic, and extract the parser
for it.
2021-11-16 23:14:09 +00:00
Timothy Flynn 6d34a0b4e8 LibJS+LibUnicode: Rename method to select a NumberFormat plurality
Instead of currency pattern lookups within select_currency_unit_pattern,
rename the method to select_pattern_with_plurality and accept any list
of patterns. This method will be needed for units.
2021-11-16 23:14:09 +00:00
Lady Gegga fa13ab61e4 Base: Add/adjust glyphs in font Tiny Regular
Maintenance to stabilize the font.

- Added glyph FFFD
- Adjusted multiple glyphs for improved consistency
- Added a few glyphs to current ranges
- Added range Mende Kikakui 1E800-1E8DF (incomplete, I continued my work
  in Katica)
2021-11-16 23:07:43 +00:00
Linus Groh 6b2e004c28 LibJS: Fix incorrect use of "modulo" in {hour,min,sec,ms}_from_time()
These all would return incorrect results for negative time values.
Also adds a missing floor() in sec_from_time().
2021-11-16 19:40:49 +00:00
Benjamin S Osenbach d82e41440c LibCore: Don't include crypt.h in Account.cpp on FreeBSD
Fixes #10803.
2021-11-16 19:06:13 +00:00
Linus Groh 58c6a156bf LibCrypto: Fix subtracting two negative SignedBigIntegers
Currently, we get the following results

    -1 - -2 = -1
    -2 - -1 =  1

Correct would be:

    -1 - -2 =  1
    -2 - -1 = -1

This was already attempted to be fixed in 7ed8970, but that change was
incorrect. This directly translates to LibJS BigInts having the same
incorrect behavior - it even was tested.
2021-11-16 10:06:53 +00:00
Luke Wilde 014840eeca LibJS: Use else-if's in Temporal.Duration.prototype.until
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/3dd2397
2021-11-16 09:10:41 +00:00
Karol Kosek c3256a51cb LibGfx: Remove scale factor option from try_load_from_fd_and_close()
... and bring it back to try_load_from_file().

Prior to this change, changing the scaling option to x2 in the Display
Settings resulted in the following crash:

  WindowServer(15:15): ASSERTION FAILED: bitmap->width() % scale_factor
  == 0 ./Userland/Libraries/LibGfx/Bitmap.cpp:126

That was caused by two minor overlooked yaks:

- First, Bitmap::try_load_from_fd_and_close() tried to respect your
  scale factor.

  While requesting a bitmap from file can make a switcheroo to give you
  a higher resolution bitmap, doing the same when you already have an fd
  might violate the unveil agreement.
  ... but, it didn't do that.

  It read bitmaps from requested fds, but also pretended all system
  bitmaps in /res/ are the HiDPI ones when you enabled that mode.

- d85d741c59 used this function to deduplicate try_load_from_file().

  It actually made this bug a lot easier to replicate!


Closes #10920
2021-11-16 01:07:37 +00:00
Karol Kosek e38b3f526e DisplaySettings: Handle errors when loading wallpaper bitmap
Prior this change, the app crashed if the first file in alphabetical
order in /res/wallpapers couldn't be decoded.
2021-11-16 01:07:37 +00:00
Luke Wilde ac65fb40d9 LibJS: Implement Temporal.PlainDate.prototype.since 2021-11-16 01:06:07 +00:00
Luke Wilde ddec3bc888 LibJS: Implement Temporal.PlainDate.prototype.until 2021-11-16 01:06:07 +00:00
Timothy Flynn 99c15741ba LibJS: Conditionally ignore [[UseGrouping]] in compact notation 2021-11-16 00:56:55 +00:00
Timothy Flynn 14aca03161 LibJS: Remove FIXME comment from PartitionNotationSubPattern AO
All possible patterns generated by LibUnicode are now handled. We have a
similar VERIFY_NOT_REACHED in PartitionNumberPattern.
2021-11-16 00:56:55 +00:00
Timothy Flynn fdae323401 LibJS: Implement compact formatting for Intl.NumberFormat 2021-11-16 00:56:55 +00:00
Timothy Flynn 80b86d20dc LibJS: Cache the number format used for compact notation
Finding the best number format to use for compact notation involves
creating a Vector of all compact formats for the locale and looking for
the one that best matches the number's magnitude. ECMA-402 wants this
number format to be found multiple times, so cache the result for future
use.
2021-11-16 00:56:55 +00:00
Timothy Flynn 1f546476d5 LibJS+LibUnicode: Fix computation of compact pattern exponents
The compact scale of each formatting rule was precomputed in commit:
be69eae651

Using the formula: compact scale = magnitude - pattern scale

This computation was off-by-one.

For example, consider the format key "10000-count-one", which maps to
"00 thousand" in en-US. What we are really after is the exponent that
best represents the string "thousand" for values greater than 10000
and less than 100000 (the next format key). We were previously doing:

    log10(10000) - "00 thousand".count("0") = 2

Which clearly isn't what we want. Instead, if we do:

    log10(10000) + 1 - "00 thousand".count("0") = 3

We get the correct exponent for each format key for each locale.

This commit also renames the generated variable from "compact_scale" to
"exponent" to match the terminology used in ECMA-402.
2021-11-16 00:56:55 +00:00
Timothy Flynn 48d5684780 LibUnicode: Parse compact identifiers and replace them with a format key
For example, in en-US, the decimal, long compact pattern for numbers
between 10,000 and 100,000 is "00 thousand". In that pattern, "thousand"
is the compact identifier, and the generated format pattern is now
"{number} {compactIdentifier}". This also generates that identifier as
its own field in the NumberFormat structure.
2021-11-16 00:56:55 +00:00
Hendiadyoin1 1533123263 Profiler: Stop disassembly on invalid instructions 2021-11-16 00:49:48 +00:00
Hendiadyoin1 134f43ba12 Profiler: Don't try to disassemble empty buffers 2021-11-16 00:49:48 +00:00
Hendiadyoin1 6cb42d8a40 AK: Verify that we are not overreaching in StringView's substring_view() 2021-11-16 00:49:48 +00:00
Nico Weber a164e6ecbb LibJS: Unbreak to_iso_day_of_week
481f7d6afa tried to use `modulo()` here, but missed that the
code used `<=` instead of `<`.

Keep using `modulo()` and add an explicit conditional, which is
arguably clearer.
2021-11-16 00:41:45 +00:00
kleines Filmröllchen 8f8ae5eb53 Piano: Create controller widgets for processor parameters
These widgets attach to a processor parameter and keep the two sides in
sync. They will become very useful for smart processor interfaces.
2021-11-16 00:09:58 +00:00
Nico Weber 481f7d6afa LibJS: Use modulo() function in to_iso_day_of_week
No behavior change.
2021-11-15 23:54:41 +00:00
Simon Woertz b87ab989a3 LibPDF: Check if there is data left before consuming
Add a check to `Parser::consume_eol` to ensure that there is more data
to read before actually consuming any data. Not checking if there is
data left leads to failing an assertion in case of e.g., a truncated
pdf file.
2021-11-16 00:16:57 +01:00
Andrew Kaster f1d8978804 AK+Kernel: Remove implicit conversion from Userspace<T*> to FlatPtr
This feels like it was a refactor transition kind of conversion. The
places that were relying on it can easily be changed to explicitly ask
for the ptr() or a new vaddr() method on Userspace<T*>.

FlatPtr can still implicitly convert to Userspace<T> because the
constructor is not explicit, but there's quite a few more places that
are relying on that conversion.
2021-11-16 00:13:22 +01:00