summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
AgeCommit message (Collapse)Author
2023-05-23LibWeb: Make LayoutState use HashMap instead of potentially huge VectorAndreas Kling
Before this change, LayoutState essentially had a Vector<UsedValues*> resized to the exact number of layout nodes in the current document. When a nested layout is performed (to calculate the intrinsic size of something), we make a new LayoutState with its own Vector. If an entry is missing in a nested LayoutState, we check the parent chain all the way up to the root. Because each nested LayoutState had to allocate a new Vector with space for all layout nodes, this could get really nasty on very large pages (such as the ECMA262 specification). This patch replaces the Vector with a HashMap. There's now a small cost to lookups, but what we get in return is the ability to handle huge layout trees without spending eternity in page faults.
2023-05-23LibWeb: Use the right DOM node when placing cursor on double-clickAndreas Kling
This fixes a null pointer dereference when double-clicking in text content on some pages.
2023-05-23LibWeb: Don't create mutation record node lists if nobody is interestedAndreas Kling
By deferring allocation of StaticNodeList objects until we know somebody actually wants the MutationRecord, we avoid a *lot* of allocation work. This shaves several seconds off of loading https://tc39.es/ecma262/ At least one other engine (WebKit) skips creating mutation records if nobody is interested, so even if this is observable somehow, we would at least match the behavior of a major engine.
2023-05-23LibWeb: Avoid rebuilding layout tree unless CSS display property changesAndreas Kling
Before this, any style change that mutated a property we consider "layout-affecting" would trigger a complete teardown and rebuild of the layout tree. This isn't actually necessary for the vast majority of CSS properties, so this patch makes the invalidation a bit finer, and we now only rebuild the layout tree when the CSS display property changes. For other layout-affecting properties, we keep the old layout tree (if we have one) and run the layout algorithms over that once again. This is significantly faster, since we don't have to run all the CSS selectors all over again.
2023-05-23LibWeb: Preserve case for key eventsAndi Gallo
Case-preserving behavior matches observed behavior of other browsers and the specification.
2023-05-22LibWeb: Wait for media candidates without endlessly queueing microtasksTimothy Flynn
Rather than queueing microtasks ad nauseam to check if a media element has a new source candidate, let the media element tell us when it might have a new child to inspect. This removes endless CPU churn in cases where there is never a candidate that we can play.
2023-05-22LibWeb: Make sure collapsed margins are not ignored if box creates FCAliaksandr Kalenik
Fixes a bug that if box creates new formatting context then all already collapsed margins are ignored and only margin_top is used.
2023-05-22LibWeb: Propagate children_are_inline in wrap_in_anonymousAndi Gallo
This fixes a crash in box_baseline, due to cells created for display: table expecting a box child and getting the inline node wrapper instead. Fixes #18972.
2023-05-22LibWeb: Set grid-auto-columns/rows in NodeWithStyle::apply_style()Aliaksandr Kalenik
2023-05-22LibWeb: Stub AudioContext constructorLuke Wilde
This is enough to make Discord not throw up "Well this is awkward" on login.
2023-05-22LibWeb: Fire the contextmenu event on right click (if not holding shift)Luke Wilde
This now allows websites such as Discord, YouTube and your favourite "Right Click" xkcd comic to open a custom context menu when you right click. You can bypass this by holding shift, just like Firefox.
2023-05-22LibWeb: Tidy up apply_clip_overflow_rect() a littleMacDue
Avoid possible null optional dereference when creating border radius clipper, and avoid creating clipper if the clip rect is empty (which prevents some debug spam). Also remove an unnecessary lambda.
2023-05-22LibWeb: Support grid-auto-columns and grid-auto-rows properties in GFCAliaksandr Kalenik
Implements assignment of sizes specified in grid-auto-columns/rows for implicitly created tracks.
2023-05-22LibWeb/CSS: Implement parsing of grid-auto-columns and grid-auto-rowsAliaksandr Kalenik
2023-05-22LibWeb: Check if line name is present in GridTrackSizeList::to_string()Aliaksandr Kalenik
Fixes crash in GridTrackSizeList::to_string() when line names are missing.
2023-05-21LibWeb: Don't assume response object isn't null in fetch abort algorithmAndreas Kling
The callee that we're passing it to expects a GCPtr anyway, so there's no need to explicitly dereference this. Fixes a crash when loading https://spotify.com/
2023-05-21LibWeb: Represent OccupationGrid using HashTable in GFCAliaksandr Kalenik
Using HashTable of grid positions to represent OccupationGrid allows to simplify positioning code. For example maybe_add_row() and maybe_add_column() calls are not needed anymore because there is no Vector<Vector<bool>> that need to be resized. No observable changes in grid layout are expected :)
2023-05-21LibWeb: Move SVGElement's dataset construction to initialize()Andreas Kling
It's not safe to allocate new cells while in a cell constructor.
2023-05-21LibWeb: Fix unsafe capture of stack variables in main_fetch()Andreas Kling
2023-05-21LibWeb+LibJS: Don't lazily construct web prototypes in cell constructorsAndreas Kling
It's not safe to allocate from the GC heap while in the constructor of a GC heap cell. (Because if this ends up triggering a collection, we may end up trying to call through an uninitialized vtable). This was already done safely in the initialize() virtual in much of LibJS and LibWeb. This patch moves the logic for prototypes, mixins, and CSSStyleDeclaration as well. Fixes a long-standing GC crash that was pretty easy to reproduce by refreshing https://vercel.com/
2023-05-21LibWeb: Implement table rowspanAndi Gallo
Adjust computing the table height and positioning of cells to account for the rowspan property. Fixes #18952.
2023-05-21LibWeb: Don't crash on percentage values for CSS stroke-widthAndreas Kling
Fixes a crash when loading https://vercel.com/
2023-05-21LibWeb: Use code to size spanning tracks for non-spanning tracks in GFCAliaksandr Kalenik
Since the specifications indicate that the algorithm for sizing tracks without any spanning items is a simplified version of the more general algorithm used for sizing tracks with spanning items, we can reuse the code to size both cases.
2023-05-21LibWeb: Implement more of spanning tracks sizing in GFCAliaksandr Kalenik
Implements more parts of sizing algorithm for tracks with spanning items to archive parity with implementation for sizing of tracks with non-spanning items.
2023-05-21LibWeb: Load external images with image/svg+xml as SVG-as-imageAndreas Kling
2023-05-21LibWeb: Include SVG-as-image isolated contexts in layout/DOM tree dumpsAndreas Kling
This allows us to see the inside of SVG-as-image in layout tests. :^)
2023-05-21LibWeb: Make standalone SVG document roots the size of the viewportAndreas Kling
We have to special-case these, otherwise our normal CSS layout algorithm will see that some SVG roots have width/height assigned, and make those the used width/height. When used in an SVG-as-image context, the outermost viewport must be the authoritative root size.
2023-05-21LibWeb: Calculate intrinsic size and aspect ratio for SVG-as-imageAndreas Kling
This finally makes SVG-as-image show up visually! :^) We should find a way to share this logic with Layout::SVGSVGBox, but that will require some finesse since they have to work at different points in the layout/paint timeline.
2023-05-21LibWeb: Render SVG-as-image into an isolated top-level browsing contextAndreas Kling
In order to separate the SVG content from the rest of the engine, it gets its very own Page, PageClient, top-level browsing context, etc. Unfortunately, we do have to get the palette and CSS/device pixel ratios from the host Page for now, maybe that's something we could refactor in the future. Note that this doesn't work visually yet, since we don't calculate the intrinsic sizes & ratio for SVG images. That comes next. :^)
2023-05-21LibWeb: Have ImageProvider bitmap getter take optional size argumentAndreas Kling
This allows the painting subsystem to request a bitmap with the exact size needed for painting, instead of being limited to "just give me a bitmap" (which was perfectly enough for raster images, but not for vector graphics).
2023-05-21LibWeb: Stub out a new SVGDecodedImageData classAndreas Kling
This class will implement isolated SVG layout and rendering.
2023-05-21LibWeb: Make ImageBox ask ImageProvider for intrinsic size and ratioAndreas Kling
This paves the way for ImageProvider to have something vector-based underneath. :^)
2023-05-21LibWeb: Make DecodedImageData an abstract classAndreas Kling
The existing implementation moves down into a new subclass called AnimatedBitmapDecodedImageData. The purpose of this change is to create an extension point where we can plug in an SVG renderer. :^)
2023-05-20LibWeb: Implement SVG opacity propertiesMacDue
This implements the stop-opacity, fill-opacity, and stroke-opacity properties (in CSS). This replaces the existing more ad-hoc fill-opacity attribute handling.
2023-05-20LibWeb: Support <svg> elements with `display: block`Andreas Kling
There are a couple of things that went into this: - We now calculate the intrinsic width/height and aspect ratio of <svg> elements based on the spec algorithm instead of our previous ad-hoc guesswork solution. - Replaced elements with automatic size and intrinsic aspect ratio but no intrinsic dimensions are now sized with the stretch-fit width formula. - We take care to assign both used width and used height to <svg> elements before running their SVG formatting contexts. This ensures that the inside SVG content is laid out with knowledge of its viewport geometry. - We avoid infinite recursion in tentative_height_for_replaced_element() by using the already-calculated used width instead of calling the function that calculates the used width (since that may call us right back again).
2023-05-19LibWeb: Explicitly mark HashMap copyBen Wiederhake
2023-05-19LibWeb: Use box sampling instead of bilinear scaling when downscalingJelle Raaijmakers
As a heuristic, either the width or height of the scaled image should decrease for box sampling to be used. Otherwise, we use bilinear scaling.
2023-05-19LibWeb: Fix null dereference on SVG element with bogus fill URLAndreas Kling
Fixes a crash seen on YouTube channel pages.
2023-05-19LibWeb: Make sure that margins don't collapse across a nested BFCAndreas Kling
In order to fix this, I also had to reorganize the code so that we create an independent formatting context even for block-level boxes that don't have any children. This accidentally improves a table layout test as well (for empty tables).
2023-05-19Revert "LibWeb: Use box sampling instead of bilinear scaling when downscaling"Andreas Kling
This reverts commit b79fd3d1a90f959d71e8d1b56ad9f8c088681e78.
2023-05-19LibWeb: Push the realm execution context while linking modulesAndreas Kling
If linking fails, we throw a JS exception, and if there's no execution context on the VM stack at that time, we assert in VM::current_realm(). This is a hack to prevent crashing on failed module loads. Long term we need to rewrite module loading since it has been refactored to share code differently between HTML and ECMA262.
2023-05-19LibWeb: Implement the "error to rethrow" mechanism in HTML::ScriptAndreas Kling
This allows JS module loads to fail and throw without crashing the WebContent process due to a TODO() assertion.
2023-05-19LibWeb: Use box sampling instead of bilinear scaling when downscalingJelle Raaijmakers
As a heuristic, either the width or height of the scaled image should decrease for box sampling to be used. Otherwise, we use bilinear scaling.
2023-05-19LibWeb: Resolve grid item fixed size paddings in GFCAliaksandr Kalenik
Adds support for grid items with fixed size paddings. Supporting percentage paddings will probably require to do second pass of tracks layout: second pass is needed to recalculate tracks sizes when final items sizes are known when percentage paddings are already resolved.
2023-05-19LibWeb: Move resolving grid item heights into separate method in GFCAliaksandr Kalenik
2023-05-18LibWeb: Fix "Unsupported main size for flex-basis" spam about calc()Andreas Kling
For flex items with a calc() value for a main size, we can just convert them to a calculation-backed LengthPercentage.
2023-05-18LibWeb: Use grid item used width as available width during track sizingAliaksandr Kalenik
This change addresses the incorrect assumption that the available width inside a grid item is equal to the width of the track it belongs to. For instance, if a grid item has a width of 200px, the available width inside that item is also 200px regardless of its column(s) base size. To solve this issue, it was necessary to move the final resolution of grid items to occur immediately after the final column track sizes are determined. By doing so, it becomes possible to obtain correct available width inside grid items while resolving the row track sizes.
2023-05-18LibWeb: Remove unitless-length quirk from properties that don't need itSam Atkins
A list of every property that has this quirk is available here: https://quirks.spec.whatwg.org/#the-unitless-length-quirk
2023-05-17LibWeb: Add missing call to Base in VideoTrack::visit_edges()Andreas Kling
This fixes a GC crash that happened after a while on the Steam store.
2023-05-17LibWeb: Null-check layout node before dereferencing in HTMLVideoElementAndreas Kling
DOM elements don't always have a corresponding layout node. This fixes a crash soon after loading the Steam store.