Commit Graph

19547 Commits

Author SHA1 Message Date
Aliaksandr Kalenik
bdd3a16b16 LibWeb: Make Fetch::Infrastructure::Body be GC allocated
Making the body GC-allocated allows us to avoid using `JS::Handle`
for `m_stream` in its members.
2023-08-19 15:12:00 +02:00
Aliaksandr Kalenik
953c19bdb7 LibWeb: Clear callbacks in SharedImageRequest after request is done
Callbacks registered within the SharedImageRequest can be removed after
the request has been completed. This resolves the GC memory leak issue
that occurs due to a cyclic dependency, where the callback captures the
image request while being owned by the image request at the same time.
2023-08-19 15:10:20 +02:00
Timothy Flynn
9608bfb576 LibWebView+Ladybird: Remove duplicate WebContent callback
We have on_navigate_back + on_back_button and on_navigate_forward +
on_forward_button. Remove the *_button variants.
2023-08-19 05:15:35 +02:00
Daniel Bertalan
1adf06c9f0 LibELF: Cache consecutive lookups for the same symbol
This reduces the startup time of LibWeb by 10%, and eliminates 156'000
of the total 481'000 global symbol lookups during a self-test run.
2023-08-19 05:15:08 +02:00
Aliaksandr Kalenik
9a07ac0b6a LibWeb/Fetch: Use JS::HeapFunction for callback in FetchAlgorithms
In FetchAlgorithms, it is common for callbacks to capture realms. This
can indirectly keep objects alive that hold FetchController with these
callbacks. This creates a cyclic dependency. However, when
JS::HeapFunction is used, this is not a problem, as captured by
callbacks values do not create new roots.
2023-08-19 05:03:17 +02:00
Aliaksandr Kalenik
469aea5a5b AK+LibJS: Introduce JS::HeapFunction
This change introduces HeapFunction, which is intended to be used as a
replacement for SafeFunction. The new type behaves like a regular
GC-allocated object, which means it needs to be visited from
visit_edges, and unlike SafeFunction, it does not create new roots for
captured parameters.

Co-Authored-By: Andreas Kling <kling@serenityos.org>
2023-08-19 05:03:17 +02:00
Hendiadyoin1
b342b4dfb8 LibWeb: Fix a rounding issue on CSSPixels multiplication
Co-Authored-By: ronak69 <ronak69@danwin1210.de>
2023-08-18 17:58:44 +02:00
kleines Filmröllchen
096cecb95e Everywhere: Add RISC-V 64 target to the build system
This is a minimal set of changes to allow `serenity.sh build riscv64` to
successfully generate the build environment and start building. This
includes some, but not all, assembly stubs that will be needed later on;
they are currently empty.
2023-08-18 08:37:43 -06:00
Daniel Bertalan
ad9e674fa0 LibC+LibELF: Support loading shared libraries compiled with dynamic TLS
This is a prerequisite for upstreaming our LLVM patches, as our current
hack forcing `-ftls-model=initial-exec` in the Clang driver is not
acceptable upstream.

Currently, our kernel-managed TLS implementation limits us to only
having a single block of storage for all thread-local variables that's
initialized at load time. This PR merely implements the dynamic TLS
interface (`__tls_get_addr` and TLSDESC) on top of our static TLS
infrastructure. The current model's limitations still stand:
- a single static TLS block is reserved at load time, `dlopen()`-ing
  shared libraries that define thread-local variables might cause us to
  run out of space.
- the initial TLS image is not changeable post-load, so `dlopen()`-ing
  libraries with non-zero-initialized TLS variables is not supported.

The way we repurpose `ti_module` to mean "offset within static TLS
block" instead of "module index" is not ABI-compliant.
2023-08-18 16:20:13 +02:00
Daniel Bertalan
70fcbcf54b LibELF+readelf: Add missing constants for dynamic relocations
These should cover all relocation types we can possibly see in an x86_64
or AArch64 final linked ELF image.
2023-08-18 16:20:13 +02:00
Aliaksandr Kalenik
934afcb9d5 LibWeb: Make HTML::SharedImageRequest GC allocated
This allows to partially solve the problem of cyclic dependency between
HTMLImageElement and SharedImageRequest that prevents all image
elements from being deallocated.
2023-08-18 15:42:44 +02:00
Aliaksandr Kalenik
bbfedf2e5a LibWeb: Make HTML::ImageRequest GC allocated 2023-08-18 15:42:44 +02:00
Poseydon42
d160ff2f8d LibGLSL: Add tests for GLSL parser 2023-08-18 15:29:48 +02:00
Poseydon42
29972876e4 LibGLSL: Add initial GLSL parser implementation 2023-08-18 15:29:48 +02:00
Andi Gallo
65854c3411 LibWeb: Set table wrapper width from the table box
Fixes #20385 and some Wikipedia pages, for example:
https://en.wikipedia.org/wiki/2022%E2%80%9323_UEFA_Champions_League_knockout_phase
2023-08-18 12:52:29 +02:00
camc
174d6f1f51 LibGUI: Replace DeprecatedString usage in Widget 2023-08-18 10:43:37 +01:00
camc
d978dd4af8 LibGUI: Add deprecated suffix to {set_,}tooltip in Widget 2023-08-18 10:43:37 +01:00
Dan Klishch
1079f178cf LibXML: Set parents for text and comment nodes 2023-08-18 08:58:51 +03:30
Dan Klishch
6368e6ca12 LibXML: Record source location for nodes 2023-08-18 08:58:51 +03:30
Dan Klishch
b40ab55830 LibXML: Add helpers for extracting node contents if its type is known 2023-08-18 08:58:51 +03:30
MacDue
6c9f1c396a LibWeb: Don't use CSSPixels when resolving radial gradient color stops
CSSPixels are not precise enough to resolve gradient positions, which
leads to visual artifacts.
2023-08-18 05:26:04 +02:00
MacDue
fa7a2269cd LibWeb: Remove ±1 translations from RadialGradientStyleValue
These were added when Gfx::Rect was made endpoint exclusive, however,
for this code an offset of ±1 makes no visible difference (but makes the
code look a little confusing).
2023-08-18 05:26:04 +02:00
Aliaksandr Kalenik
37bd216c52 LibWeb: Ignore % max-width if box is sized under max-content constraint
When a box is sized under max-content constraint, any percentage value
set for max-width should be considered as if it were infinite. In other
words, it should have no effect on restricting the box's width.
2023-08-18 05:08:52 +02:00
Sam Atkins
0cda97b852 LibWeb: Add some more computed values for CSS properties
- border-spacing
- text-decoration
- text-decoration-color
- text-decoration-thickness
- text-indent
- text-justify
2023-08-17 22:13:00 +01:00
Andreas Kling
10020ba182 LibWeb: Don't override computed font-weight with value from used font
The CSS font-weight is king, even if we load a font that has another
weight value in its OpenType tables.
2023-08-17 20:32:21 +02:00
Andreas Kling
429b2e5860 LibWeb: Make FontCache per-StyleComputer
This effectively makes it per-Document, but we hang it off of
StyleComputer since that's what it's used for.

The purpose of this is to prevent downloaded fonts from escaping the
context that loaded them. There's probably a more elegant solution where
we still share caching of system fonts, but let's start here.
2023-08-17 20:32:21 +02:00
Andreas Kling
69a81243f5 LibWeb: Consider system fonts when looking for inexact weight match
Previously, we only considered loaded (web) fonts.
2023-08-17 20:32:21 +02:00
Andreas Kling
4bb907aa22 LibWeb: Only propagate overflow from document element when it exists 2023-08-17 20:32:21 +02:00
Aliaksandr Kalenik
e9a718ff88 LibWeb/Layout: Replace INFINITY with CSSPixels::min() or max() 2023-08-17 20:03:13 +02:00
Aliaksandr Kalenik
f2a15ecea7 LibWeb/Layout: Replace isfinite() with might_be_saturated()
Since we switched to using fixed-point math for CSSPixels, it cannot
represent infinite values, so we need to check if the value is
saturated instead.
2023-08-17 20:03:13 +02:00
Sam Atkins
c40e441894 LibWeb: Move CSS ParsingContext to its own header
The implementation is already its own file, so having the class defined
in Parser.h feels weird.
2023-08-17 19:39:10 +02:00
Sam Atkins
f176e04323 LibWeb: Move CSS::Parser::Dimension class to a separate file 2023-08-17 19:39:10 +02:00
Sam Atkins
199a931da1 LibWeb: Move gradient parsing code to a separate file 2023-08-17 19:39:10 +02:00
Sam Atkins
8e5b2907f6 LibWeb: Move selector parsing code to a separate file 2023-08-17 19:39:10 +02:00
Sam Atkins
1d6c2cb287 LibWeb: Move media-query parsing code to separate file
Parser.cpp is big and complicated enough to make CLion sluggish and
unhappy, so let's move some code out of it.
2023-08-17 19:39:10 +02:00
Aliaksandr Kalenik
0ff29349e6 LibJS: Add GC graph dumper
This change introduces a very basic GC graph dumper. The `dump_graph()`
function outputs JSON data that contains information about all nodes in
the graph, including their class types and edges.

Root nodes will have a property indicating their root type or source
location if the root is captured by a SafeFunction. It would be useful
to add source location for other types of roots in the future.

Output JSON dump have following format:
```json
    "4908721208": {
        "class_name": "Accessor",
        "edges": [
            "4909298232",
            "4909297976"
        ]
    },
    "4907520440": {
        "root": "SafeFunction Optional Optional.h:137",
        "class_name": "Realm",
        "edges": [
            "4908269624",
            "4924821560",
            "4908409240",
            "4908483960",
            "4924527672"
        ]
    },
    "4908251320": {
        "class_name": "CSSStyleRule",
        "edges": [
            "4908302648",
            "4925101656",
            "4908251192"
        ]
    },
```
2023-08-17 18:27:02 +02:00
Aliaksandr Kalenik
ee29a21ae8 LibJS: Delete unused operator=s in SafeFunction 2023-08-17 18:27:02 +02:00
martinfalisse
70919dbed7 LibWeb: Fix parsing bug for SVG attributes
This doesn't seem to actually have fixed any bugs, as having
FillOpacity instead of StrokeOpacity in the call to parse_css_value
doesn't seem to have actually been causing bugs. But, I still think it's
worthwhile correcting.

The reason that it wasn't causing bugs is that having FillOpacity
instead of StrokeOpacity in the call to parse_css_value means that when
parsing the value is compared to the acceptable values for that property
(for example the value can only be a percentage, or a number, etc.). In
this case both FillOpacity and StrokeOpacity seem to accept the same
values.
2023-08-17 17:48:34 +02:00
martinfalisse
f2047a5c32 LibWeb: Size SVG G container according to children
The SVG G container should have the same size as its children. This
fixes a bug when there was an opacity value on the G element, as in
StackingContext it would try and get a bitmap of the element which would
be empty due to it having no size.
2023-08-17 17:48:34 +02:00
Cameron Youell
8fcf42f684 LibPublicSuffix: Add Library and Generators 2023-08-17 15:30:23 +01:00
Sam Atkins
68dae8ab46 LibWeb: Deduplicate calc-parsing code
We had `parse_calculated_value()` which parsed the contents of `calc()`,
and `parse_dynamic_value()` which parsed any math function, both of
which produce a CalculatedStyleValue, but return a plain StyleValue.
This was confusing, so let's combine them together, and return a
CalculatedStyleValue.

This also makes the other math functions work in
`StyleComputer::expand_unresolved_values()`.
2023-08-17 16:21:42 +02:00
Timothy Flynn
7bc7f376fa LibGfx: Add Point::scaled(T) and Rect::scaled(T)
Note that we already have Size::scaled(T). While subjectively providing
API symmetry, this is mostly to allow using these methods in templated
helpers without caring what the exact underlying type is.
2023-08-17 09:57:30 -04:00
Timothy Flynn
7c4b0b0389 LibGfx+Userland: Rename Size::scaled_by to Size::scaled
Ignoring Size for a second, we currently have:

    Rect::scale_by
    Rect::scaled

    Point::scale_by
    Point::scaled

In Size, before this patch, we have:

    Size::scale_by
    Size::scaled_by

This aligns Size to use the same method name as Rect and Point. While
subjectively providing API symmetry, this is mostly to allow using this
method in templated helpers without caring what the exact underlying
type is.
2023-08-17 09:57:30 -04:00
Andreas Kling
f34cc0b8e3 LibWeb: Null check fonts after parsing them in CRC2D.font assignment
Fixes an issue where setting CRC2D.font to an unparseable value would
assert due to a null dereference.
2023-08-17 10:07:38 +02:00
Andi Gallo
ef6a78518f LibWeb: Remove unused argument of InlineLevelIterator::next
Also remove unused method from LineBuilder.
2023-08-17 09:08:18 +02:00
Andreas Kling
768c35af71 LibWeb: Throw on attempt to create a Worker for now
Trying to run a worker right now just results in the WebContent process
asserting down the road, so let's throw and log a FIXME instead.
This makes it easier to see what's failing. We'll obviously remove this
once we get workers working correctly. :^)
2023-08-17 09:07:44 +02:00
Hendiadyoin1
30cb4cb69b LibWeb: Reject nullptr StyleValues as invalid ColorStops
This would cause a nullptr-deref during painting of invalid
linear-gradients, such as `linear-gradient(top, #f8f9fa, #ececec)`
found in googles sign-in button
2023-08-17 07:11:13 +02:00
Andi Gallo
d5f54956ba LibWeb: Use the auto table width formula if it cannot be resolved
If the width is a percentage but the parent isn't resolved yet, take the
same path as for auto width.
2023-08-17 04:13:46 +02:00
Ali Mohammad Pur
4d27257c45 LibRegex: Treat backwards jumps to IP 0 as normal backwards jumps too
This shows up in something like /\d+|x/, where the `+` ends up jumping
to the start of its own alternative.
2023-08-16 22:20:24 +03:30
Andreas Kling
045880e6c7 LibWeb: Stop whining about WOFF2 errors when trying to guess font format 2023-08-16 18:22:01 +02:00