summaryrefslogtreecommitdiff
path: root/Userland/Libraries
AgeCommit message (Collapse)Author
2021-11-17LibWeb: Parse comma-separated lists for most background propertiesSam Atkins
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-17LibWeb: Prevent copying CSS TokenStreamSam Atkins
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-17LibWeb: Remove CSS Parser method overloads with no TokenStream parameterSam Atkins
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-17LibWeb: Remove ParsingContext parameter from private CSS Parser methodsSam Atkins
This was only needed when they were all static.
2021-11-17LibWeb: Make CSS Parser methods non-staticSam Atkins
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-17LibWeb: Add NodeWithStyleAndBoxModelMetrics to Forward.hSam Atkins
2021-11-17Kernel+LibC: Add msync() system callAndreas Kling
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-17LibJS + js: Rethrow exception on the vm after bytecode interpreter rundavidot
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-17LibJS: Remove fallback value for get_offset_nanoseconds_forLuke Wilde
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-17LibJS/Tests: Fix failing Array.prototype.toLocaleString() testLinus Groh
2021-11-17LibJS: Implement ECMA-402 Array.prototype.toLocaleStringTimothy Flynn
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-17LibJS: Implement ECMA-402 Number.prototype.toLocaleStringTimothy Flynn
2021-11-17AK: Convert AK::Format formatting helpers to returning ErrorOr<void>Andreas Kling
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-17AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)Andreas Kling
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-16LibJS: Implement unit number formattingTimothy Flynn
2021-11-16LibUnicode: Parse and generate CLDR unit data for Intl.NumberFormatTimothy Flynn
The units data is in another CLDR package, cldr-units.
2021-11-16LibUnicode: Tweak the definition of the plurality "many"Timothy Flynn
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-16LibJS+LibUnicode: Support multiple identifiers within format patternTimothy Flynn
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-16LibJS+LibUnicode: Rename the generated compact_identifier to identifierTimothy Flynn
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-16LibJS+LibUnicode: Rename method to select a NumberFormat pluralityTimothy Flynn
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-16LibJS: Fix incorrect use of "modulo" in {hour,min,sec,ms}_from_time()Linus Groh
These all would return incorrect results for negative time values. Also adds a missing floor() in sec_from_time().
2021-11-16LibCore: Don't include crypt.h in Account.cpp on FreeBSDBenjamin S Osenbach
Fixes #10803.
2021-11-16LibCrypto: Fix subtracting two negative `SignedBigInteger`sLinus Groh
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-16LibJS: Use else-if's in Temporal.Duration.prototype.untilLuke Wilde
This is an editorial change in the Temporal spec. See: https://github.com/tc39/proposal-temporal/commit/3dd2397
2021-11-16LibGfx: Remove scale factor option from try_load_from_fd_and_close()Karol Kosek
... 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-16LibJS: Implement Temporal.PlainDate.prototype.sinceLuke Wilde
2021-11-16LibJS: Implement Temporal.PlainDate.prototype.untilLuke Wilde
2021-11-16LibJS: Conditionally ignore [[UseGrouping]] in compact notationTimothy Flynn
2021-11-16LibJS: Remove FIXME comment from PartitionNotationSubPattern AOTimothy Flynn
All possible patterns generated by LibUnicode are now handled. We have a similar VERIFY_NOT_REACHED in PartitionNumberPattern.
2021-11-16LibJS: Implement compact formatting for Intl.NumberFormatTimothy Flynn
2021-11-16LibJS: Cache the number format used for compact notationTimothy Flynn
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-16LibJS+LibUnicode: Fix computation of compact pattern exponentsTimothy Flynn
The compact scale of each formatting rule was precomputed in commit: be69eae651abf0cc3e9cd0906f9586fdfbfb68ef 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-16LibUnicode: Parse compact identifiers and replace them with a format keyTimothy Flynn
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-16LibJS: Unbreak to_iso_day_of_weekNico Weber
481f7d6afa89d 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-15LibJS: Use modulo() function in to_iso_day_of_weekNico Weber
No behavior change.
2021-11-16LibPDF: Check if there is data left before consumingSimon Woertz
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-15LibAudio: Add explanatory comments to the FlacLoaderkleines Filmröllchen
Some nuances in the FLAC loading code can do well with an explanation, as these non-obvious insights are often the result of long and painful debugging and nobody should touch the affected code without careful deliberation. (Of course, secretly I just want people to maintain my loader code.) :^)
2021-11-15Audio: Fix code smells and issues found by static analysiskleines Filmröllchen
This fixes all current code smells, bugs and issues reported by SonarCloud static analysis. Other issues are almost exclusively false positives. This makes much code clearer, and some minor benefits in performance or bug evasion may be gained.
2021-11-15LibJS: Fix leap year check in to_iso_week_of_year() for week < 1Linus Groh
When the resulting week is in the previous year, we need to check if the previous year is a leap year and can potentially have 53 weeks, instead of the given year. Also added a comment to briefly explain what's going on, as it took me a while to figure out.
2021-11-14LibJS: Fix balance_time() for times with negative offset day outcomeLinus Groh
...and change the parameter types from i64 to double, as predicted by a FIXME. The issue here is that integer division with a negative dividend doesn't yield the same result as floating point division wrapped in floor(). Additionally, the `days` variable needs to be signed.
2021-11-14LibJS: Add missing spaces in balance_iso_date() spec commentsLinus Groh
2021-11-14LibJS: Fix incorrect use of "modulo" in balance_iso_year_month()Linus Groh
2021-11-14LibJS: Implement engineering and scientific number formattingTimothy Flynn
2021-11-14LibUnicode: Parse and generate scientific formatting rulesTimothy Flynn
2021-11-14LibJS: Define the "name" property on the number format functionTimothy Flynn
Also add a missing spec link.
2021-11-14LibC: Implement _aligned_malloc and _aligned_freeDaniel Bertalan
C++17 introduced aligned versions of `new` and `delete`, which are automatically called by the compiler when allocating over-aligned objects. As with the regular allocator functions, these are generally thin wrappers around LibC. We did not have support for aligned allocations in LibC, so this was not possible. While libstdc++ has a fallback implementation, libc++ does not, so the aligned allocation function was disabled internally. This made building the LLVM port with Clang impossible. Note that while the Microsoft docs say that aligned_malloc and _aligned_free are declared in `malloc.h`, libc++ doesn't #include that file, but instead relies on the definition coming from `stdlib.h`. Therefore, I chose to declare it in that file instead of creating a new LibC header. I chose not to implement the more Unix-y `memalign`, `posix_memalign`, or the C11 `aligned_alloc`, because that would require us to significantly alter the memory allocator's internals. See the comment in malloc.cpp.
2021-11-14LibJS: Remove redundant exception checks from initialize_constructor()Linus Groh
define_direct_property() simply wraps storage_set(), which cannot throw.
2021-11-14LibJS: Convert push_execution_context() to ThrowCompletionOrLinus Groh
2021-11-14LibJS: Convert prepare_for_ordinary_call() to ThrowCompletionOrLinus Groh
2021-11-14LibJS: Convert TypedArray create() functions to ThrowCompletionOrLinus Groh