Commit graph

59579 commits

Author SHA1 Message Date
Cubic Love 3bec616893 Base+ImageViewer: Add new icons for ImageViewer
Add ImageViewer application icons (16 and 32px) and matching image
filetype icons.
2024-03-12 08:08:19 +00:00
MacDue 580763e43e Tests/LibWeb: Add SVG maskContentUnits ref test 2024-03-12 08:51:50 +01:00
MacDue 163b6bb401 LibWeb: Special case SVG masks during layout
Rather than try to lay out masks normally, this updates the TreeBuilder
to create layout nodes for masks as a child of their user (i.e. the
masked element). This allows each use of a mask to be laid out
differently, which makes supporting `maskContentUnits=objectBoundingBox`
fairly easy.

The `SVGFormattingContext` is then updated to lay out masks last (as
their sizing may depend on their parent), and treats them like
viewports.

This is pretty ad-hoc, but the SVG specification does not give any
guidance on how to actually implement this.
2024-03-12 08:51:50 +01:00
MacDue 15e3b0ebde LibWeb: Use SVGGraphicsBox for <symbol> and <use> elements
This allows various SVG properties (like masking) to be applied to these
elements.
2024-03-12 08:51:50 +01:00
MacDue 05f42efc06 LibWeb: Support preserveAspectRatio=none for SVGs
This is very easy now all transforms are computed during layout.
2024-03-12 08:51:50 +01:00
mobounya 190a8f948e LibWeb: Don't crash when visiting about:srcdoc
When navigating to about:srcdoc we try to populate the session history
by calling populate_session_history_entry_document, if the resource is
an about:srcdoc this method will rely on the document_resource in the
SessionHistoryEntry to have a String in order for it call the right
method to create navigation params.

However when navigating to about:srcdoc directly, document_resource
will have an Empty, this leads populate_session_history_entry_document
to call the wrong method to create navigation params.

This fixes the issue by populating document_resource with an empty
string if it has an Empty and we're dealing with an about:srcdoc.

Issue: #23216
2024-03-12 00:11:57 -06:00
Andreas Kling 9aefc5c927 LibWeb: Return a dummy value from various SVG getters
Instead of crashing with a TODO() on half of the test cases generated by
Domato, let's just return a zeroed-out SVGAnimatedLength or
SVGAnimatedNumber from getters that return them.

We'll eventually have to implement these correctly, but crashing is not
productive since it blocks us from finding other issues.
2024-03-11 18:29:10 +01:00
Andreas Kling 35f359c51c LibWeb: Fix infinite loop in ChildNode's before() and after()
The loop that was supposed to check the chain of previous or next
siblings had a logic mistake where it would never traverse the chain,
so we would get stuck looking at the immediate sibling forever.
2024-03-11 18:29:10 +01:00
Andreas Kling ad843b6e4a LibWeb: Don't crash when accessing property in detached Window object
After removing an iframe from the DOM, its contentWindow will be
detached from its browsing context, per spec.

Because the contentWindow is still accessible, we cannot assume that
Window objects always have an associated browsing context.

This needs to be fixed in the spec, but let's add a sensible null check
in the meantime.
2024-03-11 18:29:10 +01:00
Andreas Kling 2e0297d703 LibWeb: Handle reference cycles in SVG gradient linking
Since SVG gradients can reference each other, we have to keep track of
visited gradients when traversing the link chain, or we will recurse
infinitely when there's a reference cycle.
2024-03-11 18:29:10 +01:00
Andreas Kling 1b8d8c7bbc LibWeb: Make a Layout::BlockContainer for MathML boxes
Instead of creating a generic Layout::Box, make a BlockContainer. This
allows them to be laid out by BFC, which is better than nothing(?),
even if it's not going to be correct at all.
2024-03-11 18:29:10 +01:00
Andreas Kling 3591a82e8d LibWeb: Look at paintable directly in Element::scroll* APIs
We don't need to go via the layout tree as the element has a link
directly to its paintable where the relevant metrics are stored.
2024-03-11 18:29:10 +01:00
Andreas Kling b98a2be96b LibWeb: Ignore window-forwarded document.body.onfoo in detached DOM
Normally, assigning to e.g document.body.onload will forward to
window.onload. However, in a detached DOM tree, there is no associated
window, so we have nowhere to forward to, making this a no-op.

The bulk of this change is making Document::window() return a nullable
pointer, as documents created by DOMParser or DOMImplementation do not
have an associated window object, and so must be able to return null
from here.
2024-03-11 18:29:10 +01:00
Andreas Kling 7139d5945f LibWeb: Use NonnullGCPtr in EventTarget's event handler map
Null entries are not valid, so let's not allow them.
2024-03-11 18:29:10 +01:00
Andreas Kling 99ca2ccf08 LibWeb: Make DOMImplementation.createHTMLDocument() create HTMLDocument
Prior to this change, this API would actually create an XML Document(!)
2024-03-11 18:29:10 +01:00
Andreas Kling b9bacb3ff4 LibWeb: Don't assume HTMLTableCellElement always has table ancestor
That's not actually a DOM invariant, just something the HTML parser
refuses to build. You can still construct table-less th and td elements
using the DOM API.
2024-03-11 18:29:10 +01:00
Andreas Kling 80547ffc2d Tests/LibWeb: Update rebaseline-libweb-test after libexec binary move 2024-03-11 18:29:10 +01:00
Timothy Flynn 3e1ffc03c4 Ladybird/Qt: Adjust the Inspector context menu by the device pixel ratio
Otherwise, the context menu is very out of position on devices with a
device pixel ratio other than 1.
2024-03-11 16:49:20 +01:00
Timothy Flynn b5e8f0ebfe Ladybird/Qt: Move positional device pixel ratio adjustment to a helper
The code to convert a Gfx::IntPoint to a QPoint adjusted for the device
pixel ratio is a bit of a mouthful, and will be needed outside of Tab,
so move it to a helper that can be reused.
2024-03-11 16:49:20 +01:00
Nico Weber bc42144642 LibGfx/JBIG2: Start implementing the generic region decoding procedure
If the "MMR" bit is set, the generic region decoding procedure just
uses ITU-T T.6 (2D CCITT), which we already have an implementation of.
In practice, this is used almost never in .jbig2 files and in none of
the PDFs I have.

The two files that do use MMR are:

1.) JBIG2_ConformanceData-A20180829/F01_200_TT9.jb2
2) 042_3.jb2 from the ghostpdl tests

The first uses an immediate _lossless_ generic region, which we don't
implement yet (but I think it should just forward to the normal
immediate generic region code? Not in this commit, though). The second
uses a regular immediate generic region, and we can decode it now:

    Build/lagom/bin/image -o out.png \
        path/to/ghostpdl/tests/jbig2/042_3.jb2
2024-03-11 16:48:57 +01:00
Nico Weber e0af3ae8d9 LibGfx/JBIG2: Implement decode_end_of_file() 2024-03-11 16:48:57 +01:00
Nico Weber 323cacc593 LibGfx/JBIG2: Implement decode_end_of_page() 2024-03-11 16:48:57 +01:00
Aliaksandr Kalenik ecce570cb7 LibWeb: Stop animation driver timer after document becomes inactive 2024-03-11 16:44:05 +01:00
Aliaksandr Kalenik fd63ffb8c3 LibWeb: Use Core::Timer instead for animation driver timer
Platform::Timer uses JS::SafeFunction that prevents document from ever
being deallocated because of strong reference.
2024-03-11 16:44:05 +01:00
Aliaksandr Kalenik 2129c5d8b0 LibWeb: Unregister AnimationTimeline from document in finalize()
...instead of destructor because by the time it is executed, document
could already be destroyed.
2024-03-11 16:44:05 +01:00
Aliaksandr Kalenik bcdf4a375d LibWeb: Use resolve_grid_position for abspos boxes layout in GFC
Removes duplicated code that resolves position based on computed
values.

No behaviour change intended.
2024-03-11 15:20:58 +01:00
Bastiaan van der Plaat bd86beb7e4 Maps: Add FavoritesModel and remove hacky misusage of JSONArrayModel 2024-03-11 10:40:23 +00:00
Bastiaan van der Plaat 29026ce965 Maps: Move TileProviders.json to user independent folder 2024-03-11 10:40:23 +00:00
implicitfield 5da9f52b1f LibWeb: Use the parent container's y offset when finding static position
Fixes #18819.
2024-03-10 18:10:01 +01:00
Timothy Flynn bf06d5b634 LibWeb: Disable animations tests that depend on consistent timing
These are flaky on CI, so disable them for now.
2024-03-10 12:13:58 -04:00
Lucas CHOLLET 2b8594dc85 LibGfx: Replace FLATTEN with ALWAYS_INLINE for draw_glyph() overload
While IMO, the change makes sense on its own as flattening this function
will just duplicate the code from `draw_glyph()` with no benefits, this
is not what motivated this patch.

When compiling with debug information and ASAN, GCC 13.2 would issue
this warning:

Userland/Libraries/LibGfx/Painter.cpp: In member function ‘void Gfx::Pai
nter::draw_glyph(Gfx::FloatPoint, u32, Gfx::Color)’:
Userland/Libraries/LibGfx/Painter.cpp:1354:14: note: variable tracking s
ize limit exceeded with ‘-fvar-tracking-assignments’, retrying without
 1354 | FLATTEN void Painter::draw_glyph(FloatPoint point, u32 code_poin
t, Color color)
      |              ^~~~~~~

From what I've read online, this is caused by some limit on the number
of symbols in the compiler's internal data structures. People at Google
have fixed this warning by splitting functions:
https://codereview.chromium.org/1164893003

While getting us rid of the warning, it also drastically improves
compilation time. Going from 1min27 to 59s on my machine.
2024-03-10 10:18:36 -04:00
Timothy Flynn e3b5e24ce0 AK: Iterate the bytes of a URL query with an unsigned type
Otherwise, we percent-encode negative signed chars incorrectly. For
example, https://www.strava.com/login contains the following hidden
<input> field:

    <input name="utf8" type="hidden" value="✓" />

On submitting the form, we would percent-encode that field as:

    utf8=%-1E%-64%-6D

Which would cause us to receive an HTTP 500 response. We now properly
percent-encode that field as:

    utf8=%E2%9C%93

And can login to Strava :^)
2024-03-10 15:17:31 +01:00
Matthew Olsson dc47210360 LibWeb: Add tests for the rest of the Animation properties 2024-03-10 15:13:47 +01:00
Matthew Olsson e91f4dcd79 LibWeb: Use Performance for animation time instead of MonotonicTime
Performance handles the document origin time correctly, and prevents
these times from being unusually large. Also initialize the
DocumentTimeline time in the constructor, since these can be created
from JS.
2024-03-10 15:13:47 +01:00
Nico Weber bdbc21c52d LibGfx/JBIG2: Implement conversion to Gfx::Bitmap and ByteBuffer
With this, `image` can convert any jbig2 file, as long as it's
black (or white), and LibPDF can draw jbig2 files (again, as long
as they only contain a single color stored in just a
PageInformation segment).
2024-03-10 10:10:55 -04:00
Nico Weber be9a6caa0a LibPDF: In Filter::decode_jbig2(), invert bits
See included comment.
2024-03-10 10:10:55 -04:00
Nico Weber 54dcb17062 Tests/LibGfx: Add two more test jbig2 files
I extracted a pure-white jbig2 that has only a PageInformation segment
from a PDF and manually edited the bytes to reduce the bitmap size to
47x23 and to clear all unneded bits (except, in the black version,
the page color bit is set).
2024-03-10 10:10:55 -04:00
Nico Weber 54982857bd LibGfx/JBIG2: Implement decode_page_information()
Also make scan_for_page_size() not early return, so that it has the
same behavior as the main decoding look. (Multiple page information
segments for a single page are likely invalid and don't happen in
practice, so this is mostly an academic change.)

Add a BitBuffer class to store the bit image data, and introduce a
Page struct for storing data associated with a page. We currently
only handle a single page, but a) this makes it easier to decode
multiple pages in the future if we want b) it makes the code easier
to understand.
2024-03-10 10:10:55 -04:00
Nico Weber 4b01f2f158 LibGfx/JBIG2: Implement decode_extension()
Only logs the data to dbgln().

All jb2 files in ghostpdl/tests start with this segment.
2024-03-10 10:10:55 -04:00
Nico Weber 9cd0c5658e LibGfx/JBIG2: Reject files with delayed height information for now
7.4.8.2 Page bitmap height:
"In some cases, this value may not be known at the time that the page
information segment is written. In this case, this field must contain
0xFFFFFFFF, and the actual page height may be communicated later, once
it is known."
2024-03-10 10:10:55 -04:00
Nico Weber f592a2ac72 LibPDF/JBIG2: Print a warning on files with more than one page 2024-03-10 10:10:55 -04:00
Nico Weber 2caf603836 LibGfx/JBIG2: Add scaffolding for interpreting segment data 2024-03-10 10:10:55 -04:00
Nico Weber af20ebe4a0 LibGfx/JBIG2: Scan for page size of page "1"
Sounds like the spec guarantees that that's the number of the first
page.

(In practice, all but one of all jbig2 files I've found contain just
page 1. PDFs almost always contain just page 1, and very rarely a
page 0 for globally shared parameters.)
2024-03-10 10:10:55 -04:00
Timothy Flynn 842caf5e8c LibWeb: Do not shrink the CPU painter's corner clipping vector
If the provided ID is smaller than the corner clipping vector, we would
shrink the vector to match. This causes a crash when we have nested
PaintContext instances (as these IDs are allocated by PaintContext),
each of which perform radius painting.

This is seen on https://www.strava.com/login when it loads a reCAPTCHA.
The outer div has a border radius, which contains the reCAPTCHA in an
iframe. That iframe contains an SVG which also has a border radius.
2024-03-10 00:39:49 +01:00
Timothy Flynn 3a8c81a460 Meta: Port recent changes to the GN build
fceba6a257
8ce8697a66
2024-03-10 00:39:49 +01:00
Aliaksandr Kalenik 33294aea86 LibWeb: Apply shadow root style sheets in StyleComputer
Now, if an element belongs to a shadow tree, we use only the style
sheets from the corresponding shadow root during style computation,
instead of using all available style sheets as was the case
previously.

The only exception is the user agent style sheets, which are still
taken into account for all elements.

Tests/LibWeb/Layout/input/input-element-with-display-inline.html
is affected because style of document no longer affects shadow tree
of input element, like it is supposed to be.

Co-authored-by: Simon Wanner <simon+git@skyrising.xyz>
2024-03-09 16:13:32 +01:00
Aliaksandr Kalenik 91ec1d6f95 LibWeb: Maintain list of allocated shadow roots in Document
Doing that will allow us to get a list of style sheets for each shadow
root from StyleComputer without having to traverse the entire tree in
upcoming changes.
2024-03-09 16:13:32 +01:00
Aliaksandr Kalenik c6e69d501f LibWeb: Add style sheets to the shadow root if applicable
If a style element belongs to a shadow tree, its CSSStyleSheet is now
added to the corresponding ShadowRoot instead of the document.

Co-authored-by: Simon Wanner <simon+git@skyrising.xyz>
2024-03-09 16:13:32 +01:00
Aliaksandr Kalenik 8ce8697a66 LibWeb: Add styleSheets and adoptedStyleSheets attributes in ShadowRoot
Co-authored-by: Simon Wanner <simon+git@skyrising.xyz>
2024-03-09 16:13:32 +01:00
Aliaksandr Kalenik f19c92d78e LibWeb: Add ObservableArray::for_each() 2024-03-09 16:13:32 +01:00