Commit graph

30163 commits

Author SHA1 Message Date
Sam Atkins
7089681f68 LibWeb: Manually tile background images
This reimplements image tiling instead of using `Painter::blit_tiled()`,
so that we will be able to handle CSS's more complicated repetition
rules. (Like `background-repeat: space`) Otherwise this does the same as
before. :^)
2021-11-17 22:20:01 +01:00
Sam Atkins
6234e3fcb3 LibWeb: Implement background-clip :^)
We now pass in the Layout Node so that we can read the BoxModelMetrics.
Renamed a couple of variables too for clarity.
2021-11-17 22:20:01 +01:00
Sam Atkins
aa43bee0d1 LibWeb: Store all background properties in BackgroundLayerData
All of this is now passed along to `paint_background()`. :^)

(As always, "all" excludes the background-color since that's not a layer
property.)
2021-11-17 22:20:01 +01:00
Sam Atkins
3d127472ba LibWeb: Remove background_image from NodeWithStyle
We now entirely use the background-layers to check images.
2021-11-17 22:20:01 +01:00
Sam Atkins
a214036509 LibWeb: Remove background-repeat/image fields and getters
These aren't needed now that we render using background_layers instead.
The one casualty is the resolved style for background-repeat, but that
was incorrect anyway.
2021-11-17 22:20:01 +01:00
Sam Atkins
e8b7946732 LibWeb: Paint backgrounds with multiple layers :^) 2021-11-17 22:20:01 +01:00
Sam Atkins
cdeac132dc LibWeb: Store background layers in ComputedValues
Instead of storing these as individual `background-foo` properties, we
combine them together into layers, since that is how they will be
painted. It also makes it more convenient to pass them around.
2021-11-17 22:20:01 +01:00
Sam Atkins
64d805a027 LibWeb: Stop 'no-repeat' from expanding the background area
Previously, a `background-repeat` value of `no-repeat` in a direction
would cause the image to be drawn at exactly that size. This was fine if
the image was smaller than the element, but if it was larger, it would
draw outside its bounds. Now, it behaves itself. :^)
2021-11-17 22:20:01 +01:00
Sam Atkins
ecf1b7f977 LibWeb: Handle multiple backgrounds in StyleComputer
This actually involves doing *less*, because we now just pass the
StyleValueLists through instead of needing to grab their first layer's
value. :^)
2021-11-17 22:20:01 +01:00
Sam Atkins
c052457498 LibWeb: Bring BackgroundStyleValue::to_string() to spec
This now outputs valid CSS representing the background, instead of
confusing debug info.

We can't guarantee that all the longhands have the same number of
values, since while that's always the case when parsing, we also create
BackgroundStyleValues when producing the resolved style, which just
combines the longhands together.
2021-11-17 22:20:01 +01:00
Sam Atkins
72d080b4ba LibWeb: Parse multiple backgrounds :^)
Like the `background-foo` longhand properties (except
`background-color`), `background` allows multiple layers to be defined,
separated by commas. A layer does not necessarily contain something to
actually draw!

This parses as a `BackgroundStyleValue`, holding a `StyleValueList` for
each property. This is mostly to make expansion into longhands simpler -
if we had a list of `BackgroundStyleValue`s instead, one per layer, then
we would have to break it up per-property anyway when computing styles.
2021-11-17 22:20:01 +01:00
Sam Atkins
8fd4678e79 LibWeb: Parse comma-separated lists for most background properties
We now can parse lists of values for these properties:
- `background-attachment`
- `background-clip`
- `background-image`
- `background-origin`
- `background-position`
- `background-repeat`
- `background-size`

This uses two new Parser methods:
`parse_simple_comma_separated_value_list()` for the simple case when
each value is parsed from a single token; and
`parse_comma_separated_value_list()` which takes a lambda for when
parsing each value is more involved.

This also means that any unconsumed tokens at the end will make the
parsing fail as it should, where previously we just ignored them.
2021-11-17 22:20:01 +01:00
Sam Atkins
50b15bdc1d LibWeb: Prevent copying CSS TokenStream
This was leading to confusing bugs where I was accidentally passing it
by value and then wondering why tokens weren't getting consumed!
2021-11-17 22:20:01 +01:00
Sam Atkins
0da014befd LibWeb: Remove CSS Parser method overloads with no TokenStream parameter
These are just clutter. Only one was ever used, in one place, and is
easily replaced by just passing `m_token_stream` to it.
2021-11-17 22:20:01 +01:00
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