summaryrefslogtreecommitdiff
path: root/Userland/Libraries
AgeCommit message (Collapse)Author
2022-08-23LibJS+LibWeb: Replace GlobalObject with Realm in Heap::allocate<T>()Linus Groh
This is a continuation of the previous three commits. Now that create() receives the allocating realm, we can simply forward that to allocate(), which accounts for the majority of these changes. Additionally, we can get rid of the realm_from_global_object() in one place, with one more remaining in VM::throw_completion().
2022-08-23LibJS+LibWeb: Replace GlobalObject with Realm in create() functionsLinus Groh
This is a continuation of the previous two commits. As allocating a JS cell already primarily involves a realm instead of a global object, and we'll need to pass one to the allocate() function itself eventually (it's bridged via the global object right now), the create() functions need to receive a realm as well. The plan is for this to be the highest-level function that actually receives a realm and passes it around, AOs on an even higher level will use the "current realm" concept via VM::current_realm() as that's what the spec assumes; passing around realms (or global objects, for that matter) on higher AO levels is pointless and unlike for allocating individual objects, which may happen outside of regular JS execution, we don't need control over the specific realm that is being used there.
2022-08-23LibJS+LibWeb: Replace GlobalObject with Realm in initialize() functionsLinus Groh
This is a continuation of the previous commit. Calling initialize() is the first thing that's done after allocating a cell on the JS heap - and in the common case of allocating an object, that's where properties are assigned and intrinsics occasionally accessed. Since those are supposed to live on the realm eventually, this is another step into that direction.
2022-08-23LibJS+LibWeb: Replace GlobalObject with Realm in object constructorsLinus Groh
No functional changes - we can still very easily get to the global object via `Realm::global_object()`. This is in preparation of moving the intrinsics to the realm and no longer having to pass a global object when allocating any object. In a few (now, and many more in subsequent commits) places we get a realm using `GlobalObject::associated_realm()`, this is intended to be temporary. For example, create() functions will later receive the same treatment and are passed a realm instead of a global object.
2022-08-23LibJS: Fix the prototype of AsyncFunctionDriverWrapper's Promise baseLinus Groh
2022-08-23LibWeb: Fix the prototype of a couple of WebAssembly prototype objectsLinus Groh
Like any other regular, non-inheriting web platform prototype, the prototype's prototype should be Object.prototype, not the global object. Another reason to get rid of "global object (an object) + prototype object (also an object)"-style APIs for allocation :^)
2022-08-23LibWeb: Remove done TODO and fix typoMacDue
2022-08-23LibWeb: Avoid infinite loops in background paintingMacDue
Previously if `background-size` was 0px in any dimension we would go into in infinite loop whilst painting.
2022-08-23LibGUI: Call on_segment_change handler from on_{click,focus_change}networkException
The on_segment_change handler introduced in a00fa793b37550a8b44122192346eeeb1d692bf9 was only getting called by programmatically setting the segment, not by clicking a button or using tab navigation.
2022-08-23LibGUI: Don't call on_segment_change handler if the index did not changenetworkException
This patch makes the handler's behavior closer to what can be expected from it's name by not handling set_selected_segment if the segment is already selected.
2022-08-23LibCore: Fix deadlock in SharedSingleProducerCircularQueuekleines Filmröllchen
This deadlock would incorrectly change the queue from almost empty to full on dequeue because someone else could empty the queue after we had checked its non-emptyness. The test would deadlock on this, which doesn't happen anymore.
2022-08-23LibWeb: Resolve double-position `linear-gradient()` color stopsMacDue
These just resolve to an extra color stop. Something like "red 10% 40%" is just shorthand for "red 10%, red 40%".
2022-08-23LibWeb: Don't regenerate linear gradient data unless size changesMacDue
This is an easy check to add and seems like it makes things a tiny bit smoother.
2022-08-23LibWeb: Add missing checks to LinearGradientStyleValue::equals()MacDue
2022-08-23LibWeb: Parse double-position `linear-gradient()` color stopsMacDue
The only accepted syntax for these seems to be <color> <length percentage> <length percentage>, no other order. But that's just gathered from looking at other browsers as though these are supported by all major browsers, they don't appear in the W3C spec.
2022-08-22ChessEngine: Use reduced Board objects in MCTSTreeLucas CHOLLET
Monte-Carlo methods are known to intensively create nodes and in our case each leaf of the tree stores a board. However, for this use case, we don't need a full board object that also contains game information. This patch adds a `clone_cleared()` method that return a clone without game information and uses it when constructing the tree. It allows the ChessEngine much more possibility before getting out of memory.
2022-08-22LibCards: Remove card-back-image scalingSam Atkins
This was giving wonky results with images that do not fill the entire card - and it's also unnecessary, since the Buggie image we have been using, and the two I will be adding, are all small enough to not need scaling anyway. :^)
2022-08-22LibCards: Make the card back image configurableSam Atkins
`CardPainter::set_background_image_path()` immediately repaints the card back and inverted card back bitmaps if they exist, so users just need to `update()` that part of the screen. This is handled automatically by `CardGame`, but other users will have to do this manually.
2022-08-22LibCards: Centralise card bitmap creationSam Atkins
Instead of each card being responsible for painting its own bitmaps, we now have a CardPainter which is responsible for this. It paints a given card the first time it is requested, and then re-uses that bitmap when requested in the future. This saves memory for duplicate cards (such as in Spider where several sets of the same suit are used) or unused ones (for example, the inverted cards which are only used by Hearts). It also means we don't throw away bitmaps and then re-create identical ones when starting a new game. We get some nice memory savings from this: | | Before | After | Before (Virtual) | After (Virtual) | |:----------|---------:|---------:|-----------------:|----------------:| | Hearts | 12.2 MiB | 9.3 MiB | 25.1 MiB | 22.2 MiB | | Spider | 12.1 MiB | 10.1 MiB | 29.2 MiB | 22.9 MiB | | Solitaire | 16.4 MiB | 9.0 MiB | 25.0 MiB | 21.9 MiB | All these measurements taken from x86_64 build, from a fresh launch of each game after the animation has finished, but without making any moves. The Hearts value will go up once inverted cards start being requested.
2022-08-22LibCards+Games: Replace card "value" int with a Rank enumSam Atkins
Because `card->value() == 11` is a lot less clear than `card->rank() == Cards::Rank::Queen`, and also safer. Put this, along with the `Suit` enum, in the `Cards` namespace directly instead of inside `Cards::Card`. Slightly less typing that way.
2022-08-22LibCards: Add a CardGame base classSam Atkins
For now, the only feature of this is that it sets the background colour from the `Games::Cards::BackgroundColor` config value. Later, other card game configuration and shared behaviour can go here, to save duplicating it in each game.
2022-08-22LibGUI: Clear selected index of Breadcrumbbar if segment is removedJannis Weis
If the segment corresponding to the selected index is removed the index is no longer valid.
2022-08-22LibGUI: Add on_segment_change handler to BreadcrumbbarJannis Weis
This allows programs to respond to any selection changes of the Breadcrumbbar, not just ones made by clicking one of the buttons.
2022-08-21LibWeb: Make window.performance replaceable and configurableLuke Wilde
Required by Discord, which polyfills it by taking the existing native object, polyfilling missing functions and setting window.performance to it. This is a hard requirement as this is done in strict mode with no try/catch and thus causes their JavaScript to stop progressing.
2022-08-20LibJS: Use a synthetic constructor if class with parent doesn't have onedavidot
We already did this but it called the @@iterator method of %Array.prototype% visible to the user for example by overriding that method. This should not be visible so we use a special version of SuperCall now.
2022-08-20LibJS: Add special cases for Math.cosh and add spec commentsdavidot
Although this already works in most cases in non-kvm serenity cases the cosh and other math function tend to return incorrect values for Infinity. This makes sure that whatever the underlying cosh function returns Math.cosh conforms to the spec.
2022-08-20LibGfx: Always lookup emojis without emoji presentation specifiersRyan Liptak
This allows us to treat unqualified, minimally-qualified, and fully-qualified emojis the same as long as emoji filenames are in their least qualified form (with respect to emoji presentation). For example, the transgender flag emoji has 4 possible forms: 1F3F3 FE0F 200D 26A7 FE0F ; fully-qualified # 🏳️‍⚧️ 1F3F3 200D 26A7 FE0F ; unqualified # 🏳‍⚧️ 1F3F3 FE0F 200D 26A7 ; unqualified # 🏳️‍⚧ 1F3F3 200D 26A7 ; unqualified # 🏳‍⚧ In order to treat them all as the same, we now drop all forms down to 1F3F3 200D 26A7 (skipping any FE0F codepoints) and then do the lookup for that form.
2022-08-20Kernel+LibC: Enforce a limit on the number of supplementary group IDsAndreas Kling
This patch adds the NGROUPS_MAX constant and enforces it in sys$setgroups() to ensure that no process has more than 32 supplementary group IDs. The number doesn't mean anything in particular, just had to pick a number. Perhaps one day we'll have a reason to change it.
2022-08-20LibJS: Make IsHTMLDDA non-constructibledavidot
2022-08-18LibGUI: Make Breadcrumbbar remember the selected segment indexAndreas Kling
We had a selected_segment() accessor, but the member it returned was never actually updated.
2022-08-18TextEditor: Change cursor when reaching the ruler areaThomas Symalla
Noticed that mouse-overing the ruler area in the TextEditor does not change the cursor to the default cursor, instead, the beam cursor is used, which does not look nice. This PR extends the mousemove event and introduces a new set_editing_cursor() function that takes care of setting the cursor for the editor area.
2022-08-18LibWeb: Support painting `repeating-linear-gradient()`sMacDue
2022-08-18LibWeb: Avoid NaNs from zero-length gradient color stopsMacDue
2022-08-18LibWeb: Parse `repeating-linear-gradient()`MacDue
Including `-webkit-repeating-linear-gradient()`
2022-08-18LibGfx: Skip useless iterations during PNG::FilterType::Sub unfilteringRyan Liptak
2022-08-18LibGfx: Unfilter PNG data before unpacking it to RGBARyan Liptak
The order of PNG compression is raw pixel data -> filter -> compress. For decompression, the order is reversed, so that means uncompress -> unfilter -> raw pixel data. Previously, the PNG decoder was converting to raw pixel data before unfiltering, which was a problem when using indexed color palettes, since each pixel's palette index could change during unfiltering (e.g. it was unfiltering after already choosing the color from the palette index). This was leading to 'Palette index out of range' errors on files that both: - Had scanlines with some sort of filtering - Didn't use the full range of possible palette indices for their bit depth. Also, because filtering now happens before converting to pixel data, filtering acts on bytes instead of pixels, meaning that the implementation of each filter type now maps much more directly to the specification: http://www.libpng.org/pub/png/spec/1.2/PNG-Filters.html
2022-08-17LibCore: Make EventLoop's connection to InspectorServer work againkleines Filmröllchen
This path was changed to the uid templated version without actually using the template resolver function in Account.
2022-08-17LibJS: Resolve the correct this value for calls in with statementsdavidot
2022-08-17LibJS: Implement tagged literals evaluation like the specdavidot
We cache on the AST node side as this is easier to track a position, we just have to take care to wrap the values in a handle to make sure they are not garbage collected.
2022-08-17LibJS: Allow invalid string in tagged template literalsdavidot
Since tagged template literals can inspect the raw string it is not a syntax error to have invalid escapes. However the cooked value should be `undefined`. We accomplish this by tracking whether parse_string_literal fails and then using a NullLiteral (since UndefinedLiteral is not a thing) and finally converting null in tagged template execution to undefined.
2022-08-17LibJS: Make StringToNumber case sensitive when falling back to strtoddavidot
We use strtod to convert a string to number after checking whether the string is [+-]Infinity, however strtod also checks for either 'inf' or 'infinity' in a case-insensitive. There are still valid cases for strtod to return infinity like 10e100000 so we just check if the "number" contains 'i' or 'I' in which case the strtod infinity is not valid.
2022-08-17LibJS: Don't assume a this argument for function.prototype.binddavidot
Assuming we had at least one argument meant that the ...arg count would underflow causing the bound function to have length 0 instead of the given length when binding with no arguments.
2022-08-17LibJS: Add the HostEnsureCanAddPrivateElement hookdavidot
This hook allows us to reject private elements on certain exotic objects like the window object in browser. Note that per the spec we should only call this hook if the host is a web browser, however because LibJS has no way of knowing whether it is in a web browser environment we just always call the host hook.
2022-08-16LibGUI: Don't let widgets hide tooltips they didn't showDavid Smith
Widget::handle_leave_event() hides the tooltip if one is shown. That's usually fine and hides the widget's tooltip, but it can happen that another widget managed to show a tooltip after the Leave event was triggered and before it's processed. Thus change handle_leave_event() to only hide the tooltip if it was show by the widget. Fixes the case where this could happen in the flame graph in Profiler when moving the mouse over the tooltip window itself #14852.
2022-08-16LibGUI+WindowServer+DisplaySettings: Add Tooltips to SystemEffectsthankyouverycool
Tooltips can now be toggled on and off system-wide.
2022-08-16LibGUI: Put DragOperation dbgln() behind DRAG_DEBUGthankyouverycool
2022-08-16LibCore: Add MIME sniffing for MP3 and WAVkleines Filmröllchen
2022-08-16LibCore: The MIME type is 'audio/flac', not 'extra/flac'kleines Filmröllchen
2022-08-16LibWeb: Render flex line items RTL (reversed items) for FlexEndwatkinsr
This is a basic attempt at trying to handle parent container case justify-content: flex-end. Test-scenario: Head to https://ryanwatkins.me and note that now the header nav is on the right as opposed to the left in-line with how Chrome/Firefox would respectively handle it also, i.e. 'flex-end' Implementation: Move cursor to the end and render in reverse backwards shifting the cursor leftwards.
2022-08-16LibGUI: Retain the active input tracking widget's cursorAndreas Kling
Until the tracking stops, we want to keep displaying the same cursor.