Commit Graph

29907 Commits

Author SHA1 Message Date
Shannon Booth
04c094343f LibWeb+Meta: Add wrapper for the BufferSource/ArrayBufferView IDL types
These wrappers will make it much easier to do various operations on the
different ArrayBuffer-related classes in LibWeb compared to the current
solution, which is to just accept a Handle<Object> everywhere (and use
"any" in the *.idl files).

Co-Authored-By: Matthew Olsson <mattco@serenityos.org>
2023-11-24 08:43:35 +01:00
Sam Atkins
54d0aafff0 LibGfx: Use FourCC as OpenType::Tag type
The one deviation from the spec here is to use this in the WOFF
TableDirectoryEntry's tag field. However, *not* making that a Tag made
a lot of things more complicated than they need to be.
2023-11-24 08:42:46 +01:00
Sam Atkins
0423225290 LibGfx: Make FourCC more useful
A few small changes that didn't seem to deserve separate commits:
- Mark it as packed to remove compiler complaints when it's a member of
  a packed struct.
- Add a default constructor for places where we fill in a struct
  gradually.
- Restrict the constructor to exactly 4-character string literals.
- Add a to_u32() method for the one place that needs that.
2023-11-24 08:42:46 +01:00
Sam Atkins
2c24192e1f LibGfx: Move FourCC to its own file
These are used in fonts too, so let's not limit them to ImageLoader.
2023-11-24 08:42:46 +01:00
timmot
c713445253 LibWeb: Report when CanvasFillOrStrokeStyle parsing fails 2023-11-24 08:42:18 +01:00
timmot
2ecc1d64d8 LibGfx: Accept decimal numbers when parsing rgb and rgba strings
This will round all numbers and clamp them within the limits of a u8.
This also standardises on returning u8 instead of uint/int.
2023-11-24 08:42:18 +01:00
timmot
da3cfd5bbc AK+LibWeb: Make clamp_to_int generic over all integrals 2023-11-24 08:42:18 +01:00
Andrew Kaster
cf7b13c708 LibWeb: Visit WorkerAgent from Worker 2023-11-24 08:41:38 +01:00
Andrew Kaster
1602663b9e LibWeb+WebWorker: Implement a first cut of post_message for Workers
This implementation completely ignores MessagePorts, and manually plumbs
data through LocalSockets.
2023-11-24 08:41:38 +01:00
Andrew Kaster
05ec93e276 WebWorker: Reuse main thread VM for DedicatedWorker realms
While creating a new VM feels warm and fuzzy from an isolation
perspective, having multiple JS heaps in the same process is a footgun
waiting to happen. Additionally, there are still many places in LibWeb
that reach for the main thread VM to check for the current realm to do
things, such as Web::HTML::incumbent_settings_object().
2023-11-24 08:41:38 +01:00
Andrew Kaster
e30ecacb71 WebWorker: Exit the event loop when the connection from the client dies
This mimics the behavior of other services, and prevents zombie service
processes from sticking around when no longer needed.
2023-11-24 08:41:38 +01:00
Aliaksandr Kalenik
5f7ac559a7 LibAccelGfx+LibWeb: Add support for stacking context opacity
For each stacking context with an opacity less than 1, we create a
separate framebuffer. We then blit the texture attached to this
framebuffer with the specified opacity.

To avoid the performance overhead of reading pixels from the texture
into Gfx::Bitmap, a new method that allows for direct blitting from
the texture is introduced, named blit_scaled_texture().
2023-11-24 08:39:55 +01:00
Aliaksandr Kalenik
cb90daadc7 LibAccelGfx: Add cache for programs
Having programs cache shared between painters would allow us to create
more than one painter without worrying about shaders recompilation.
2023-11-24 08:39:55 +01:00
Aliaksandr Kalenik
d5630fedf1 LibAccelGfx+WebContent: Introduce Canvas that represents framebuffer 2023-11-24 08:39:55 +01:00
Timothy Flynn
c03b69e664 LibWebView+Ladybird: Remove now-unused WebView TreeModel
This was used to provided base functionality for model-based chromes for
viewing the DOM and accessibility trees. All chromes now use the WebView
inspector model for those trees, thus this class is unused.
2023-11-24 08:37:19 +01:00
Timothy Flynn
39e32e80cd Browser: Port the Inspector to the WebView InspectorClient 2023-11-24 08:37:19 +01:00
Timothy Flynn
1fe486cebe LibWebView: Implement a WebView-based Inspector client
This is modeled after a similar implementation for the JS console.

This client takes over an inspector WebView (created by the chrome) to
create the inspector application. Currently, this application includes
the DOM tree and accessibility tree as a first pass. It can later be
extended to included the style tables, the JS console itself, etc.
2023-11-24 08:37:19 +01:00
Timothy Flynn
ffdc2d8add LibWeb+LibWebView+WebContent: Add an Inspector IDL object to the Window
This is an internal object that must be explicitly enabled by the chrome
before it is added to the Window. The Inspector object will be used by a
special WebView that will replace all chrome-specific inspector windows.
The IDL defines methods that this WebView will need to inform the chrome
of various events, such as the user clicking a DOM node.
2023-11-24 08:37:19 +01:00
Timothy Flynn
30e96749de LibWebView+WebContent: Remove unused did_get_dom_node_properties IPC
This is never invoked. The functionality it provides is implemented by
the return value of the `inspect_dom_node` IPC.
2023-11-24 08:37:19 +01:00
Timothy Flynn
fcaa994d4e LibWebView: Extract CSS to highlight HTML source to a constant
We will be re-using (and extending) this style in the WebView-based DOM
inspector.
2023-11-24 08:37:19 +01:00
Timothy Flynn
b5162ceabd LibWeb: Remove special handling of disclosure-open/closed markers
Setting the marker's content width here is causing the text that follows
the marker to be indented a bit too much. This is noticeable when a line
with a disclosure marker is followed by a line with any other marker. It
previously would look something like:

    >    Text inline with disclosure-closed marker
    * Text inline with circle marker
    # Text inline with square marker

Now the disclosure marker line matches other marker types:

    > Text inline with disclosure-closed marker
    * Text inline with circle marker
    # Text inline with square marker
2023-11-24 08:37:19 +01:00
Karol Kosek
963a6b3d3d LibAudio: Speed up WavWriter by buffering output data
We were calling write syscall twice for every sample, which effectively
hurt the writer's performance.

With this change exporting a melody in the Piano app now takes less than
a second, which previously took about 20 seconds on my machine.

Additionally, I've removed an unused `WavWriter::file()` getter.
2023-11-23 18:05:22 -05:00
Andrew Kaster
fbf87299a2 LibWeb: Align choose a navigable AO closer to the spec
This will make window.open a lot easier to implement. As written, the
implementation of Navigable::choose_a_navigable now looks a lot closer
to the old BrowsingContext::choose_a_browsing_context. With the notable
exception that we still crash in many cases, and don't properly handle
multiple top-level traversables in the same WebContent process.
2023-11-23 21:32:45 +01:00
Andrew Kaster
18fc3a1e26 LibWeb: Update window.open to match the current spec steps 2023-11-23 21:32:45 +01:00
Shannon Booth
decc071060 LibWeb: Return a scroll offset of 0 for colgroup elements
Ideally we would not create a layout node at all for these elements so
that every layout node would always have a paintable associated with it.
But for now, to fix the crash, just leave a FIXME and special case this
element.

Also leave a VERIFY to make it easier to debug this type of crash in the
future.

Fixes a crash seen on codecov.io for my 'patch' project.
2023-11-23 13:06:48 +01:00
Nico Weber
eb1c99bd72 LibPDF+LibGfx: Make SMasks on jpeg images work
SMasks are greyscale images that get used as alpha channel for a
different image.

JPEGs in PDFs are stored as streams with /DCTDecode filters, and
we have a separate code path for loading those in the PDF renderer.
That code path just calls our JPEG decoder, which creates bitmaps
with format BGRx8888.

So when we process an SMask for such a bitmap, we have to change
the bitmap's format to BGRA8888 in addition to setting alpha values
on all pixels.
2023-11-23 12:13:03 +01:00
Andreas Kling
ef809eea1e LibWeb: Don't assume IO.unobserve() called on observed element
It's perfectly possible for JavaScript to call unobserve() on an element
that hasn't been observed. Let's stop asserting if that happens. :^)

Fixes #22020
2023-11-23 09:37:12 +01:00
Andreas Kling
21d9da0f3b LibWeb: Unregister IntersectionObserver from registration document
Before this change, there was some confusion possible where an IO would
try to find its way back to the document where we registered it.
This led to an assertion failure in the test I'm adding in the next
commit, so let's fix this first.

IOs now (weakly) remember the document where they are registered, and
only unregister from there.
2023-11-23 09:37:12 +01:00
Nico Weber
57e2b5ef59 LibPDF+Tests: Correctly decode text strings without explicit encoding 2023-11-22 09:08:06 -07:00
Nico Weber
8f47acee6a LibTextCodec: Add PDFDocEncoding decoder 2023-11-22 09:08:06 -07:00
Nico Weber
e39a790c82 LibPDF: Stop converting encodings in object parser
Per 1.7 spec 3.8.1, there are multiple logical text string types:
* text strings
* ASCII strings
* byte strings

Text strings can be in UTF-16BE, PDFDocEncoding, or (since PDF 2.0)
UTF-8.

But byte strings shouldn't be converted but treated as binary
data.

This makes us no longer convert strings used for drawing page text.
TABLE 5.6 "Text-showing operators" lists the operands for text-showing
operators as just "string", not "text string" (even though these strings
confusingly are called "text strings" in the body text), so not doing
this there is correct (and matches other viewers).

We also no longer incorrectly convert strings used for cypto data
(such as passwords), if they start with an UTF-16BE or UTF-8 marker.

No behavior change for outlines and info dict entries.

https://pdfa.org/understanding-utf-8-in-pdf-2-0/ has a good overview of
this.

(ASCII strings only contain ASCII characters and behave the same
anyways.)
2023-11-22 09:08:06 -07:00
Nico Weber
14bcb5219d LibPDF: Tolerate comments before drawing operators
Necessary to be able to render
https://github.com/pdf-association/pdf20examples/blob/master/pdf20-utf8-test.pdf
2023-11-22 08:56:43 +00:00
Nico Weber
9e8cf4fc1a LibPDF: Tolerate comment after last dict item
Necessary to be able to open
https://github.com/pdf-association/pdf20examples/blob/master/pdf20-utf8-test.pdf
2023-11-22 08:56:43 +00:00
Sam Atkins
f69d38a346 LibWeb: Use ComponentValue::is_ident("..."sv) helper 2023-11-22 09:45:51 +01:00
Sam Atkins
6cd6186399 LibWeb: Don't assume grid size is always Function or Token
This stops `grid-template-columns: minmax({},{})` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
1a17b8a304 LibWeb: Don't assume grid-area parts are Tokens
This stops `grid-area: {}` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
ab9d39bf4a LibWeb: Don't assume grid-row/grid-column parts are Tokens
This stops `grid-column: {}` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
314a30b12e LibWeb: Don't assume grid-line parts are Tokens
This stops `grid-row-start: {}` from crashing.

Also tidy up the parsing code a little.
2023-11-22 09:45:51 +01:00
Sam Atkins
1f6e13d8fe LibWeb: Don't assume repeat() contents are Tokens
This stops `grid-template-rows: repeat({})` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
5e54ff1858 LibWeb: Don't assume rect() contents are Tokens
This stops `clip: rect({});` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
aba2946b1e LibWeb: Use ComponentValue::is_function("..."sv) helper 2023-11-22 09:45:51 +01:00
Aliaksandr Kalenik
d9990c6ea9 LibWeb: Remove opacity parameter for DrawScaledBitmap painting command
Every usage of this command specifies opacity equal to 1.
2023-11-21 17:00:56 +01:00
Aliaksandr Kalenik
a5cf875e23 LibWeb: Fix typo in FillEllipse painting command name 2023-11-21 17:00:56 +01:00
Aliaksandr Kalenik
790bfd7ef9 LibAccelGfx: Skip glyphs with missing bitmaps
Fixes crashing when we can't produce a bitmap for a glyph.
2023-11-21 17:00:56 +01:00
Aliaksandr Kalenik
48faa0e706 LibAccelGfx: Ensure capacity of vertices vector in draw_glyph_run() 2023-11-21 17:00:56 +01:00
Aliaksandr Kalenik
2471f07356 LibWeb: Skip painting of empty borders in GPU painter 2023-11-21 17:00:56 +01:00
Aliaksandr Kalenik
01058dac95 LibWeb: Skip execution of painting commands with empty bounding rect 2023-11-21 17:00:56 +01:00
implicitfield
00c1da8cbc LibWeb: Support cellpadding attribute on table elements 2023-11-21 16:54:02 +01:00
implicitfield
3d1fbcb26b LibWeb: Support valign attribute on tr elements 2023-11-21 16:54:02 +01:00
implicitfield
468b2a5ace LibWeb: Support size attribute on font elements 2023-11-21 16:54:02 +01:00