Commit graph

53541 commits

Author SHA1 Message Date
Dan Klishch 3556c27d2d AK: Add StringView::count(char) 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 3a42ef4118 Tests/LibWeb: Add ref test for CSS gradients
This has to cheat and use a screenshot but thanks to the "Take Full
Screenshot" feature of Ladybird, it is very easy to update this test.

The steps are documented in the test.
2023-08-18 05:26:04 +02:00
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
Timothy Flynn c0758882c5 WebContent: Convert image/media context menu positions to device pixels
On Serenity and on my Linux machine, we have a 1:1 CSS-to-device pixel
ratio. On macOS, we have a 2:1 ratio. This did not affect the Qt chrome,
because we are ignoring this position and placing the context menu at
the globally-accessible mouse position. The AppKit chrome will be using
this position, though.

This might be what caused the issue worked around by commit 8177ecb.
2023-08-18 05:24:59 +02:00
Timothy Flynn 5287c9aff4 WebContent: Group context menu request definitions together
Having all 4 of these methods together makes it more immediately obvious
that the 2 moved here are not correct (we are not converting the CSS
pixel point to a device pixel point).
2023-08-18 05:24:59 +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 24edb7c97f Ladybird, WebContent: Add option in debug menu to output GC graph dump 2023-08-17 18:27:02 +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
Andreas Kling 258af0fb1b Ladybird/Qt: Turn off web search and autocomplete by default
Anyone who wants this can enable it in the settings window.
2023-08-17 16:49:22 +02:00
Cameron Youell d972338208 Browser: Add more intuitive search 2023-08-17 15:30:23 +01:00
Cameron Youell d68433653a Ladybird: Add autocomplete to LocationEdit 2023-08-17 15:30:23 +01:00
Cameron Youell 8fcf42f684 LibPublicSuffix: Add Library and Generators 2023-08-17 15:30:23 +01:00
Cameron Youell c53d3e7aa4 Ladybird: Simplify the LocationEdit constructor 2023-08-17 15:30:23 +01:00
Cameron Youell 0da5af0eff Ladybird: Pass QIcon by reference in tab_favicon_changed 2023-08-17 15:30:23 +01:00
Cameron Youell 6e40e8316e Ladybird: Convert Browser::Settings to a singleton 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
EWouters 5defca01f0 Mandelbrot: Pledge unix to enable image export 2023-08-17 07:14:54 +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
Tim Ledbetter 3a8e362ab0 Ports/citron: Use correct quote format 2023-08-16 21:40:05 +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
Sam Atkins 12a2750d1e LibWeb: Support multiple values in :lang() selector
Parse them, and also don't give up completely if the first language
listed doesn't match an element.
2023-08-16 18:05:26 +02:00
Sam Atkins 39cba61c2d LibGUI: Fall back to words when double-clicking TextEditor with spans
If we double-click on a TextEditor that has spans, but the click itself
was not on a span, fall back to the without-spans behavior. Previously
the cursor would instead jump to the end of the document.
2023-08-16 16:58:49 +02:00
Sam Atkins 631a988a57 LibWeb: Allow any valid <color> in CSS gradients
We now keep the color value as a StyleValue up until we go to paint the
gradient, which makes `currentColor` work, along with any other color
values that can't be immediately converted into a `Gfx::Color` while
parsing.
2023-08-16 14:51:12 +02:00
Andreas Kling 2971ae59d8 LibGfx/WOFF2: Align all reconstructed glyf entries to 4 bytes
It wasn't enough to do it only for simple glyphs, we need to do it for
composite glyphs as well.

Fixes an issue where some glyph data was misaligned in the output and
thus ended up rendered incorrectly or not at all.
2023-08-16 14:49:59 +02:00
Tim Ledbetter 149ab91040 Ports/citron: Update formatting to be consistent with other ports 2023-08-16 15:32:42 +03:30
Tim Ledbetter 87d8a32f3d Ports/citron: Update to the latest commit 2023-08-16 15:32:42 +03:30