Commit Graph

52 Commits

Author SHA1 Message Date
Aliaksandr Kalenik
830b287c46 Everywhere: Remove GPU painter and AccelGfx
GPU painter that uses AccelGfx is slower and way less complete compared
to both default Gfx::Painter and Skia painter. It does not make much
sense to keep it, considering Skia painter already uses Metal backend on
macOS by default and there is an option to enable GPU-accelerated
backend on linux.
2024-07-04 14:47:02 +02:00
Aliaksandr Kalenik
760dfdcc1a LibWeb: Rename CommandExecutor to DisplayListPlayer
Use more widely recognized name among browser engine developers.
2024-06-24 13:22:59 +02:00
Aliaksandr Kalenik
854b269338 LibWeb: Rename RecordingPainter to DisplayListRecorder
Use more widely recognized name among browser engine developers.
2024-06-24 13:22:59 +02:00
Aliaksandr Kalenik
5570e6b648 LibWeb: Rename CommandList to DisplayList
Use more widely recognized name among browser engine developers.
2024-06-24 13:22:59 +02:00
Aliaksandr Kalenik
0b48c1ea3f Everywhere: Remove AffineCommandExecutorCPU
No need to have it after introduction of Skia painter that supports
transforms.
2024-06-19 17:22:30 +03:00
Aliaksandr Kalenik
de6d99e940 LibWeb: Respect selected painter in SVGDecodedImageData
Now SVGDecodedImageData uses Skia painter, if it's selected.
2024-06-19 16:26:37 +03:00
Aliaksandr Kalenik
c7133faf26 LibWeb: Rename Navigable::paint() to record_painting_commands()
This method does not paint, but only records painting commands that
could be passed to painting commands executor, which will perform
actual painting.
2024-06-10 14:30:20 +03:00
Aliaksandr Kalenik
5285e22f2a LibWeb+WebContent: Move scrollbar painting into WebContent
The main intention of this change is to have a consistent look and
behavior across all scrollbars, including elements with
`overflow: scroll` and `overflow: auto`, iframes, and a page.

Before:
- Page's scrollbar is painted by Browser (Qt/AppKit) using the
  corresponding UI framework style,
- Both WebContent and Browser know the scroll position offset.
- WebContent uses did_request_scroll_to() IPC call to send updates.
- Browser uses set_viewport_rect() to send updates.

After:
- Page's scrollbar is painted on WebContent side using the same style as
  currently used for elements with `overflow: scroll` and
  `overflow: auto`. A nice side effects: scrollbars are now painted for
  iframes, and page's scrollbar respects scrollbar-width CSS property.
- Only WebContent knows scroll position offset.
- did_request_scroll_to() is no longer used.
- set_viewport_rect() is changed to set_viewport_size().
2024-06-05 07:03:42 +02:00
Shannon Booth
dd20156010 LibWeb: Fix division by zero on a zero-height viewport SVG image 2024-05-19 07:19:42 +02:00
Shannon Booth
d48316ce15 LibWeb: Fix division by zero on a zero-width viewport SVG image
We were previously crashing by a division by zero due to an aspect ratio
of zero on https://comicbookshop.co.nz/
2024-05-19 07:19:42 +02:00
Aliaksandr Kalenik
376427380e LibWeb: Make NavigationParams be GC-allocated
Fixes GC-leak caused by using JS::Handle for navigable.
2024-04-22 17:10:11 +02:00
Matthew Olsson
31341b280a LibWeb: Add calls to JS_{DECLARE,DEFINE}_ALLOCATOR() 2024-04-09 09:13:06 +02:00
Matthew Olsson
aac873fcec LibWeb: Fix a few "missing visit_edges" warnings from the GC verifier 2024-04-07 07:03:13 +02:00
mobounya
bdb8af94ee LibWeb: Don't load fallback icon for SVG documents
Skip loading a fallback favicon if Document represents a decoded SVG.

Issue: #23405
2024-04-03 09:45:31 -06:00
MacDue
06ed56f4f6 LibWeb: Paint SVGDecodedImageData via Navigable::paint()
Going via the `ViewportPaintable` missed some steps (in particular
computing clip rects), which meant nested SVGs within SVGs-as-images
were completely clipped.
2024-03-30 21:35:22 +01:00
Aliaksandr Kalenik
b590d1b48b LibWeb: Transform SessionHistoryEntry from a struct to a class
No behaviour change intended.
2024-03-27 18:07:07 +01:00
Andreas Kling
df2cd33ccd Revert "LibWeb: Never claim "rendering opportunity" for SVG-as-image documents"
This reverts commit 8aae50f4ee.
2024-03-22 10:23:28 +01:00
Andreas Kling
8aae50f4ee LibWeb: Never claim "rendering opportunity" for SVG-as-image documents
Since we drive painting for SVG-as-image manually anyway, there's no
need for them to say they are "ready to paint", since that just causes
unnecessary extra processing in the HTML event loop.
2024-03-22 06:43:57 +01:00
Aliaksandr Kalenik
e3e6af39bc LibWeb: Add basic implementation of has_a_rendering_opportunity()
Return true only if we are ready to repaint. This fixes the issue where
requestAnimationFrame() was invoked more than once between repaints.
2024-03-19 07:54:14 +01:00
Shannon Booth
e800605ad3 AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
2024-03-18 14:06:28 -04:00
Shannon Booth
9ce8189f21 Everywhere: Use unqualified AK::URL
Now possible in LibWeb now that there is no longer a Web::URL.
2024-02-25 08:54:31 +01:00
Andreas Kling
9759f44faf LibWeb: Allow SVGDecodedImageData to cache bitmaps at different sizes
This avoids constantly re-rendering the same SVG image over and over
during painting when it's being used at a couple of different sizes
(for example when used as a CSS background).
2024-02-24 19:56:08 +01:00
Aliaksandr Kalenik
8ba18dfd40 LibWeb: Schedule repainting from EventLoop::process()
In this change, updating layout and painting are moved to the EventLoop
processing steps. This modification allows the addition of resize
observation dispatching that needs to happen in event loop processing
steps and must occur in the following order relative to layout and
painting:

1. Update layout.
2. Gather and broadcast resize observations.
3. Paint.
2024-02-20 10:55:10 +01:00
Aliaksandr Kalenik
cb97eef2cf LibWeb+WebContent: Remove "Painting" prefix from command executor names
Painting command executors are defined within the "Painting" namespace,
allowing us to remove this prefix from their names.

This commit performs the following renamings:

- Painting::PaintingCommandExecutor to Painting::CommandExecutor
- Painting::PaintingCommandExecutorCPU to Painting::CommandExecutorCPU
- Painting::PaintingCommandExecutorGPU to Painting::CommandExecutorGPU
2024-02-18 18:45:25 +01:00
Aliaksandr Kalenik
11d746a67f LibWeb+WebContent: Separate painting command list from RecordingPainter
Separating the recorder list from the painter will allow us to save it
for later execution without carrying along the painter's state. This
will be useful once we have a separate thread for executing painting
commands, to which we will have to transfer commands from the main
thread.

Preparation for https://github.com/SerenityOS/serenity/pull/23108
2024-02-18 18:45:25 +01:00
Andrew Kaster
53273e2037 LibWeb: Don't navigate() to about:blank when making a fresh Traversable
This matches the behavior of the window open steps, and should probably
be a spec issue :yakplus:
2024-02-08 15:53:46 +01:00
Bastian Neumann
7cd489d6aa LibWeb: Remove early continue in size parsing
Step 5 of parsing was always skipped because step 4 continues.

Running step 5 causes some of the denominators to be 0 and causes
divide by zero error in CSSPixelFraction.

SVG Image with height of 0 will cause divide by zero error when
calculating intrinsic aspect ratio of SVGDecoderImageData.

We also get a divide by zero error in AlignContent::SpaceBetween of the
FlexFormatingContext.

During auto track stretching in GridFormatingContext there is a
possibility for count_of_auto_max_sizing_tracks to stay 0.
2024-01-20 15:22:25 +01:00
Aliaksandr Kalenik
41a3c19cfe LibWeb: Make HTML::DecodedImageData to be GC-allocated
This change fixes GC-leak caused by following mutual dependency:
- SVGDecodedImageData owns JS::Handle for Page.
- SVGDecodedImageData is owned by visited objects.
by making everything inherited from HTML::DecodedImageData and
ListOfAvailableImages to be GC-allocated.

Generally, if visited object has a handle, very likely we leak
everything visited from object in a handle.
2023-12-12 23:01:08 +01:00
Timothy Flynn
a7b98a9761 LibWeb+WebContent+WebWorker: Add an option to skip painting the overlay
This will allow the Inspector to take a screenshot of a DOM node without
the overlay which renders the inspected node outline / box data.
2023-12-07 10:53:12 +01:00
Shannon Booth
0ae5c070c7 LibWeb: Make Web::Page GC-allocated
This is a first step towards removing the various Page& and Page*
we have littering the engine with "trust me bro" safety guarantees.

Co-Authored-By: Andreas Kling <kling@serenityos.org>
2023-12-05 09:38:32 +01:00
Shannon Booth
6e6f3a9a8f LibWeb: Make Web::PageClient GC-allocated
This is a first step towards simplifying the ownership model of
Web::Page. Soon Web::Page will store its WebClient as a
NonnullGCPtr to help solve lifetime issues of the client being
destroyed before the page.
2023-12-05 09:38:32 +01:00
Shannon Booth
f976ec005c LibWeb: Port DOM::Document from DeprecatedString 2023-12-02 22:54:53 +01:00
Andrew Kaster
fbfb70f81a LibWeb+WebContent: Plumb ability for WebContent process to hold N pages
In order for same-origin NavigableContainers (iframe, frame, embed, ...)
and window.open() WindowProxies to have the proper JS access to their
embedder/opener, we need to host multiple top level traversables in the
same WebContent process. As a first step, make WebContent::PageHost hold
a HashMap of PageClient objects, each holding their own Web::Page that
represents a TraversableNavigable's API surface with the UI process.
2023-12-01 20:47:44 +01:00
Aliaksandr Kalenik
f4a5c136c3 LibGfx+LibWeb: Add ImmutableBitmap for images bitmap caching in painter
Before this change, we used Gfx::Bitmap to represent both decoded
images that are not going to be mutated and bitmaps corresponding
to canvases that could be mutated.

This change introduces a wrapper for bitmaps that are not going to be
mutated, so the painter could do caching: texture caching in the case
of GPU painter and potentially scaled bitmap caching in the case of CPU
painter.
2023-11-26 12:55:43 +01:00
Aliaksandr Kalenik
f915aa70cd LibWeb/Painting: Introduce PaintingCommandExecutor
Decoupling painting command executor from RecordingPainter allows to
introduce painters other than CPU Gfx::Painter :)
2023-10-26 11:02:04 +02:00
Aliaksandr Kalenik
063e66cae9 LibWeb: Introduce RecordingPainter to serialize painting commands
This modification introduces a new layer to the painting process. The
stacking context traversal no longer immediately calls the
Gfx::Painter methods. Instead, it writes serialized painting commands
into newly introduced RecordingPainter. Created list of commands is
executed later to produce resulting bitmap.

Producing painting command list will make it easier to add new
optimizations:
- It's simpler to check if the painting result is not visible in the
  viewport at the command level rather than during stacking context
  traversal.
- Run painting in a separate thread. The painting thread can process
  serialized painting commands, while the main thread can work on the
  next paintable tree and safely invalidate the previous one.
- As we consider GPU-accelerated painting support, it would be easier
  to back each painting command rather than constructing an alternative
  for the entire Gfx::Painter API.
2023-10-18 10:58:42 +02:00
Aliaksandr Kalenik
a41f23a0fc LibWeb: Fix document leak in SVGDecodedImageData
The SVGDecodedImageData creates a new Page and replaces its document
with a new one that contains SVG content. This change adds a destroy
call on the replaced document. Without this addition, all tasks
scheduled on the event loop during navigation, initiated while the
page's traversable is being created, will never execute, as the
initial replaced document will become inactive. This leads to a
document leak because the tasks use JS::Handle to hold document
pointer. Making the destroy call resolves the issue because it removes
all tasks associated with the destroyed document from the queue.
2023-09-25 14:31:20 +02:00
Andrew Kaster
dc0f7c4c54 LibWeb: Align NavigationParams and the creation AOs to the spec
And remove assorted spec FIXMEs along the way. Also align
populate_session_history_entry_document to the spec, with a bonus spec
bug to be filed.

This involves creating a new NonFetchSchemeNavigationParams spec, and
having the associated AOs take a Variant rather than Optional to
accomodate the fact that this extra struct could be returned by the
algorithm. We don't actually *do* anything with these params, but the
scaffolding is there now, with less TODOs.
2023-09-22 19:45:11 -06:00
Andreas Kling
51caa14381 LibWeb: Remove FrameLoader
This class is no longer used, now that we've moved to navigables.
2023-09-20 18:29:17 +02:00
Aliaksandr Kalenik
4356d37b2c LibWeb: Update SVGDecodedImageData to use navigables 2023-09-16 16:53:32 +02:00
Aliaksandr Kalenik
359d8a3dc2 LibWeb: Update Document::create_and_initialize() to match latest spec 2023-09-16 16:53:32 +02:00
Zaggy1024
34c5043cbe LibWeb: Use CSSPixelFraction to represent aspect ratios
This allows us to retain perfect precision for aspect ratios derived
from either the intrinsic sizes of replaced elements, or the
`aspect-ratio` CSS property.
2023-09-04 12:40:17 +02:00
Andreas Kling
25375bf1d5 LibWeb: Make Document::paintable() return a ViewportPaintable 2023-08-20 05:02:59 +02:00
Andreas Kling
8bb275f2ea LibWeb: Move painting logic from Layout::Viewport to ViewportPaintable 2023-08-20 05:02:59 +02:00
Aliaksandr Kalenik
8c980cf75b LibWeb: Do not crash inside SVGDecodedImageData on invalid SVG input
Return error when input svg is not valid and SVGSVGElement is not
present in the tree instead of doing svg_root nullptr dereference.

Fixes crash on https://apps.kde.org/en-gb/
2023-06-21 19:10:37 +02:00
Aliaksandr Kalenik
147c3b3d97 LibWeb+WebContent: Forbid access to underlying type of CSSPixels
Although DistinctNumeric, which is supposed to abstract the underlying
type, was used to represent CSSPixels, we have a whole bunch of places
in the layout code that assume CSSPixels::value() returns a
floating-point type. This assumption makes it difficult to replace the
underlying type in CSSPixels with a non-floating type.

To make it easier to transition CSSPixels to fixed-point math, one step
we can take is to prevent access to the underlying type using value()
and instead use explicit conversions with the to_float(), to_double(),
and to_int() methods.
2023-06-13 06:08:27 +02:00
Simon Wanner
b5ba479d65 LibWeb: Render svg-as-image with 1:1 scaling factor
We're passing the SVGDecodedImageData a size in device pixels, so it's
incorrect to apply the host page's device_pixels_per_css_pixels on top
of that.
2023-05-30 21:28:18 +02:00
Andreas Kling
655d9d1462 LibWeb: Make CSSPixels and Length use 64-bit (double) floating point
This fixes a plethora of rounding problems on many websites.
In the future, we may want to replace this with fixed-point arithmetic
(bug #18566) for performance (and consistency with other engines),
but in the meantime this makes the web look a bit better. :^)

There's a lot more things that could be converted to doubles, which
would reduce the amount of casting necessary in this patch.
We can do that incrementally, however.
2023-05-24 14:40:35 +02:00
Andreas Kling
dcc561aa60 LibWeb: Calculate intrinsic size and aspect ratio for SVG-as-image
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-21 07:44:29 +02:00
Andreas Kling
41ab0837fa LibWeb: Render SVG-as-image into an isolated top-level browsing context
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-21 07:44:29 +02:00