Commit graph

49228 commits

Author SHA1 Message Date
Linus Groh 066133d97b LibJS: Add spec comments to StringConstructor 2023-04-13 13:04:44 +02:00
Linus Groh 1b3c3f9777 LibJS: Add spec comments to SetPrototype 2023-04-13 13:04:44 +02:00
Linus Groh 58566d2a3f LibJS: Add spec comments to SetConstructor 2023-04-13 13:04:44 +02:00
Sam Atkins d0f80b40b2 LibWeb: Reimplement CalculatedStyleValue as a calculation node tree
VALUES-4 defines the internal representation of `calc()` as a tree of
calculation nodes. ( https://www.w3.org/TR/css-values-4/#calc-internal )

VALUES-3 lacked any definition here, so we had our own ad-hoc
implementation based around the spec grammar. This commit replaces that
with CalculationNodes representing each possible node in the tree.

There are no intended functional changes, though we do now support
nested calc() which previously did not work. For example:
    `width: calc( 42 * calc(3 + 7) );`

I have added an example of this to our test page.

A couple of the layout tests that used `calc()` now return values that
are 0.5px different from before. There's no visual difference, so I
have updated the tests to use the new results.
2023-04-13 09:53:47 +02:00
Sam Atkins 5f2f780662 LibWeb: Expose type and raw values of basic CSS types
This makes it possible to do arithmetic on them without having to
resolve to their canonical unit, which often requires context
information that is not available until the last minute. For example, a
Length cannot be resolved to px without knowing the font size, parent
element's size, etc.

Only Length currently requires such context, but treating all these
types the same means that code that manipulates them does not need to
know or care if a new unit gets added that does require contextual
information.
2023-04-13 09:53:47 +02:00
Sam Atkins 89e55c5297 AK+Tests: Add Vector::find_first_index_if() 2023-04-13 09:53:47 +02:00
Sam Atkins 1352f8820b LibWeb: Simplify CalculatedStyleValue types to match CSS-VALUES-4 :^)
Level 4 drops the limitations of what types can be a denominator, which
means `<calc-number-sum>`, `<calc-number-product>` and
`<calc-number-value>` all go away.
2023-04-13 09:53:47 +02:00
Sam Atkins bab968867d LibWeb: Move StyleValue::absolutized() back where it belongs
I accidentally moved this when moving the CalculatedStyleValue methods,
and didn't notice because it was hidden in the middle. Oops!
2023-04-13 09:53:47 +02:00
iyush cc301f9861 HackStudio: Set_cursor even if the file is already open
Upon opening already opened file, the cursor was previously not
set to the correct line and column. With this patch, it should
be correctly set.

Fixes a bug where ctrl+clicking a function declaration would not
jump to the line if the file containing the function is already
open.
2023-04-13 09:52:33 +02:00
Linus Groh 742f6f7e26 LibWeb/Streams: Fix inconsistent uses of realm() and vm()
This is not documented yet, but the preferred style is getting both
upfront instead of inlining various kinds of calls in places that use
the realm and vm.
2023-04-13 09:51:48 +02:00
Linus Groh 0a556ae26d LibWeb/URL: Make URL::search_params() return a NonnullGCPtr 2023-04-13 09:51:48 +02:00
Linus Groh 28cf8ba92e LibWeb/URL: Add spec links and comments 2023-04-13 09:51:48 +02:00
Cubic Love 6e14dde97d Base: Add 32px icon for CertificateSettings
Before, the 32px icon was just the 16px icon upscaled.
Now TreuKS has tailor-made a 32px version :)

Co-authored-by: TreuKS <ks2225@protonmail.com>
2023-04-13 07:52:16 +01:00
Tim Schumacher ad60a0b522 Fuzzers: Stop loading audio frames once the end is reached
Previously, the condition was reversed, so we would stop immediately on
a file that has at least one working chunk, and we would infinitely loop
on a file with no chunks.
2023-04-12 14:03:20 -04:00
Tim Schumacher 708387b850 LibAudio: Use read_until_filled to fill a buffer from a Stream
This has the advantage of recognizing when the Stream reaches EOF and
avoids an endless loop.
2023-04-12 14:02:56 -04:00
Tim Schumacher 4098335600 LibCompress: Error on truncated uncompressed DEFLATE blocks 2023-04-12 14:02:13 -04:00
Nico Weber f56b897622 Everywhere: Fix a few typos
Some even user-visible!
2023-04-12 19:37:35 +02:00
Cubic Love 3d10132021 Starfield: Rename starfield_window to starfield_widget
Linus says it should be a widget and not a window!
2023-04-12 19:34:27 +02:00
Cubic Love c3a5618dab Base: Add icons for the Gradient screensaver
Add 32px and 16px application icons for the Gradient screensaver
2023-04-12 19:34:27 +02:00
Cubic Love c6af248909 Demos: Rename GradientScreensaver to Gradient
This brings the name in-line with the naming convention used by the
other screensavers 'Starfield' and 'Tubes'.
2023-04-12 19:34:27 +02:00
Nico Weber 97dc2d1dd5 LibGfx/WebP: Don't assert when size in header is smaller than header
read_webp_first_chunk() sensibly assumes that if decode_webp_header()
succeeds, there are at least sizeof(WebPFileHeader) bytes available.

But if the file size in the header was less than the size of the header,
decode_webp_header() would truncate the data to less than that and
happily report success. Now it no longer does that.

Found by clusterfuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=57843&sort=-opened&can=1&q=proj%3Aserenity
2023-04-12 17:32:00 +02:00
Nico Weber 93f5a6f217 LibGfx/ICC: Use mix() in CurveTagData::evaluate()
No behavior change.

(Well, technically mix() uses the other simple implementation of lerp
and the two have slightly different behavior if the arguments are of
very different magnitude and in various corner cases. But in practice,
for ICC profiles, it shouldn't matter. For a few profiles I tested, it
didn't have a measurable effect.)
2023-04-12 15:23:51 +02:00
Nico Weber 077164ae15 AK: Make grepping for "lerp" find mix() 2023-04-12 15:23:51 +02:00
Liav A 7ca71959e1 Documentation: Remove unnecessary answer to non-asked question in FAQ
By this point of time, we already have x86-64 support and have removed
i686 support too.

Since we are not the only OS project to remove 32-bit support entirely
and 64-bit computing is the norm for modern personal computers, there's
no need to explain this as it's obvious "why we are 64-bit only".
2023-04-12 14:48:49 +02:00
Tim Schumacher adfda6a271 AK: Remove the Endian bytes accessor
This is a remnant from when we didn't have a `read_value` and
`write_value` implementation for `AK::Endian` and instead used the
generic functions for reading a span of bytes. Now that we have a more
ergonomic alternative, remove the helper that is no longer needed.
2023-04-12 07:33:15 -04:00
Tim Schumacher 547a08670e LibWasm: Replace usages of the Endian bytes accessor 2023-04-12 07:33:15 -04:00
Tim Schumacher e11e7309dd LibCompress: Replace usages of the Endian bytes accessor 2023-04-12 07:33:15 -04:00
Tim Schumacher 8370377832 Shell: Add map_fixed to the pledges for command autocompletion 2023-04-12 07:06:54 -04:00
Fabian Dellwing e78db6417a LibTLS: Remove outdated comment about ECC
PR #18166 introduced the ability to parse ECC certificates. If we
now fail here the reason is mostlikely something new and we should
prevent this rabbit hole from happening.
2023-04-12 11:40:06 +03:30
Fabian Dellwing 93232d4e6d LibTLS: Streamline certificate loading
Some refactoring of our root ca loading process:

- Remove duplicate code
- Remove duplicate calls to `parse_root_ca`
- Load user imported certificates in Browser/RequestServer
2023-04-12 11:40:06 +03:30
stelar7 e4481baef9 LibTLS: Dont also include the OID when printing the RDN short name 2023-04-12 11:36:54 +03:30
Tim Ledbetter 0829101eb8 Applications: Use thousands separator for numbers shown in status bar
TextEditor, HackStudio and SQLStudio now print the current line and
column number, as well as the number of currently selected words, with
thousands separators.

TextEditor also uses thousands seperators for the current word and
character count.
2023-04-12 09:03:01 +02:00
Zaggy1024 969c987787 LibVideo: Don't shadow m_playing in ResumingStateHandler classes
StartingStateHandler and SeekingStateHandler were declaring their own
`bool m_playing` fields (from previous code where there was no base
class).

In the case of SeekingStateHandler, this only made the logging wrong.

For StartingStateHandler, however, this meant that it was not using
the boolean passed as a parameter to the constructor to define the
state that would be transitioned to after the Starting state finished.
This meant that when the Stopping state replaced itself with the
Starting state, playback would not resume when Starting state exits.
2023-04-12 07:55:12 +02:00
MacDue 5abffc9c5a Tests: Add layout test for SVG transforms and viewboxes
Now that these are kind of working, lets add a layout test to prevent
future regressions :^)

This test is the same as the previous example (it is copied, though
that seems to have been done for other tests, e.g. Acid 1).
2023-04-12 07:40:22 +02:00
MacDue 8aecd8c7ac Base: Add SVG transform test page 2023-04-12 07:40:22 +02:00
MacDue ba6272a0a0 LibWeb: Don't try to paint SVG elements transformed to zero size
Otherwise, the Gfx::Painter will get choked up on NaNs and start
infinitely splitting paths till it OOMs.
2023-04-12 07:40:22 +02:00
MacDue ba7383d28f LibWeb: Allow floating point values when parsing SVG viewboxes 2023-04-12 07:40:22 +02:00
MacDue f753a4f640 LibWeb: Always use quirks mode when parsing SVG width/height attributes
This is a bit if a hack, but without this unitless values for these
attributes fail to parse with <!DOCTYPE html>.
2023-04-12 07:40:22 +02:00
MacDue 809c15d1ee LibWeb: Use (transformed) path bounding quad for SVG path hit testing
This is needed for hit testing the directional arrows on the Street
View office tour, and generally makes SVG hit testing more precise.

Note: The rough bounding box is hit test first, so this should not
be a load more overhead.
2023-04-12 07:40:22 +02:00
MacDue d0496ae9b8 LibWeb: Apply CSS scaling to SVG elements
Not sure why this was not done before, not now it works easily :^)
2023-04-12 07:40:22 +02:00
MacDue cf23a2b82d LibWeb: Apply SVG transform to path when painting (SVG) elements
This also combines the viewbox mapping into the same transform and
reuses some code by using Path::copy_transformed() rather than manually
mapping each segment of the path.
2023-04-12 07:40:22 +02:00
MacDue 3484db0dc1 LibWeb: Remove SVG sizing hack and fix viewbox scaling
Previously, if you had an SVG with a viewbox and a definite width
and height, then all SVGGeometryBox boxes within that SVG would
have a width and height set to the size of the parent SVG.

This broke hit testing for SVG paths, and didn't make much sense.
It seems like the SVG sizing hack was patching over the incorrect
logic in viewbox_scaling() and the incorrect path sizing (which was
never reached).

Before this change the view box scaling was:
	element_dimension / viewbox_dimension

Which only seemed to work because of the SVG sizing hack that made
all paths the size of the containing SVG.

After this change SVGGeometryBoxes are (in most cases) sized correctly
based on their bounding boxes, which allows hit testing to function,
and the view box scaling is updated now to:
	  containing_SVG_dimension / viewbox_dimension

Which works with one less hack :^)

This now also handles centering the viewbox within the parent SVG
element and applying any tranforms to the bounding box. This still
a bit ad-hoc, but much more closely matches other browsers now.
2023-04-12 07:40:22 +02:00
MacDue 570d71f869 LibWeb: Parse the transform attribute when set on SVGGraphicsElements
This uses the new attribute parser functionality, and then resolves the
transform list into a single Gfx::AffineTransform.

This also adds a .get_transform() function which resolves the final
transform, by applying all parent transforms.
2023-04-12 07:40:22 +02:00
MacDue 6482c306f1 LibWeb: Parse and apply fill-opacity attribute to SVG paths
This is needed to fix the rendering of the Street View directional
controls (which have paths with various levels of opacity set by
this attribute).
2023-04-12 07:40:22 +02:00
MacDue 62f087bd56 LibWeb: Add SVG transform parsing
This parses SVG transforms using the syntax from CSS Transforms
Module Level 1. Note: This looks very similar to CSS tranforms, but
the syntax is not compatible. For example, SVG rotate() is
rotate(<a> <x> <y>) where all parameters are unitless numbers whereas
CSS rotate() is rotate(<angle> unit) along with separate rotateX/Y/Z().

(At the same time AttributeParser is updated to use GenericLexer which
makes for easier string matching).

There is work needed for error handling (which AttributeParser does not
deal with very gracefully right now).
2023-04-12 07:40:22 +02:00
MacDue b8d1fae31f LibGfx: Add AffineTransform::skew_radians() 2023-04-12 07:40:22 +02:00
MacDue 790daa4754 LibGfx: Optimize Painter::draw_scaled_bitmap_with_transform()
This now applies clipping to the destination bounding box before
painting, which cuts out a load of clipped computation and allows
using the faster set_physical_pixel() method.

Alongside this it also combines the source_transform and
inverse_transform outside the hot loop (which might cut things down
a little).

The `destination_quad.contains()` check is also removed in favour
of just checking if the mapped point is inside the source rect,
which takes less work to compute than checking the bounding box.

This takes this method down from 98% of the time to 10% of the
time when painting Google Street View (with no obvious issues).
2023-04-12 07:40:22 +02:00
MacDue 8283e8b88c AK: Don't store parts of URLs percent decoded
As noted in serval comments doing this goes against the WC3 spec,
and breaks parsing then re-serializing URLs that contain percent
encoded data, that was not encoded using the same character set as
the serializer.

For example, previously if you had a URL like:

https:://foo.com/what%2F%2F (the path is what + '//' percent encoded)

Creating URL("https:://foo.com/what%2F%2F").serialize() would return:

https://foo.com/what//

Which is incorrect and not the same as the URL we passed. This is
because the re-serializing uses the PercentEncodeSet::Path which
does not include '/'.

Only doing the percent encoding in the setters fixes this, which
is required to navigate to Google Street View (which includes a
percent encoded URL in its URL).

Seems to fix #13477 too
2023-04-12 07:40:22 +02:00
MacDue d2fc8efd9e LibWeb: Make SC hit testing more closely follow reverse paint order
Previously, we would hit test positioned elements, then stacking
contexts with z-index 0, as two seperate steps. This did not really
follow the reverse paint order, where positioned elements and stacking
contexts with z-index 0 are painted during the same tree transversal.

This commit updates
for_each_in_subtree_of_type_within_same_stacking_context_in_reverse()
to return the stacking contexts it comes across too, but not recurse
into them. This more closely follows the paint order.

This fixes examples such as:

<div id="a" style="width: 10px; height: 10px">
  <div id="b" style="position: absolute; width: 10px; height: 10px">
    <div
     style="position: absolute; width: 10px; height: 10px; z-index: 0"
    >
      <div id="c"
           style="width: 100%; height: 100%; background-color:red;"
           onclick="alert('You Win!')">
      </div>
    </div>
  </div>
</div>

Where previously the onclick on #c would never fire as hit testing
always stopped at #b. This is reduced from Google Street View,
which becomes interactable after this commit.
2023-04-12 07:40:22 +02:00
Luke Wilde 8fa9ca8b7f LibWeb: Create a video document for video/ MIME types on navigation 2023-04-12 01:47:58 +02:00