Commit graph

63473 commits

Author SHA1 Message Date
Tim Ledbetter
2c5d626b21 LibWeb: Don't crash when converting small CSS::Ratio to CSSPixelFraction
Previously, a crash would occur in the if `CSSPixelFraction` was given a
denominator value less than the resolution of `CSSPixels` (1/64).

We now divide both parts of the ratio by the denominator in this case.
2024-08-22 13:49:41 +02:00
Gasim Gasimzada
785180dd45 LibJS+WebContent: Implement console.table
- Expose table from console object
- Add new Table log level
- Create a JS object that represents table rows and columns
- Print table as HTML using WebContentConsoleClient
2024-08-22 09:08:50 +01:00
Andreas Kling
a2a9a11466 LibWebView: Update User-Agent spoofing strings with new versions
Also use an OrderedHashMap so they show up in the same order in UI.
2024-08-22 09:39:20 +02:00
Ali Mohammad Pur
a60ecea16a LibWasm+LibWeb+test-wasm: Refcount Wasm::Module for function references
Prior to funcref, a partial chunk of an invalid module was never needed,
but funcref allows a partially instantiated module to modify imported
tables with references to its own functions, which means we need to keep
the second module alive while that function reference is present within
the imported table.
This was tested by the spectests, but very rarely caught as our GC does
not behave particularly predictably, making it so the offending module
remains in memory just long enough to let the tests pass.

This commit makes it so all function references keep their respective
modules alive.
2024-08-22 09:36:40 +02:00
Andreas Kling
5606ce412e LibWeb: Handle document/navigable disconnection during favicon decode
If the document is disconnected from the navigable by the time a favicon
decode completes successfully, we don't want to show the favicon for
whatever document is now loaded in the navigable.

Fix this by deferring getting the navigable until after the decode has
completed.
2024-08-22 09:34:54 +02:00
Andreas Kling
bde2d3dc7b LibWeb: Adjust flex item intrinsic contributions through aspect ratio
When determining the intrinsic cross size contribution of a flex item
with a preferred aspect ratio, we have to account for any min/max
constraints in the main axis.
2024-08-21 13:38:39 +02:00
Francesco Gazzetta
81fbb5ebc2 LibGfx: Fix build with system skia
Compare with Userland/Libraries/LibWeb/CMakeLists.txt:780
2024-08-21 06:28:10 -04:00
Kenneth Myhra
26fe7a628c LibWeb: Capture incoming reason argument
Capture the incoming reason argument to
transform_stream_default_source_cancel_algorithm() on the
on_fulfilled_callback() of WebIDL::react_to_promise() on step 7.
2024-08-21 11:21:54 +01:00
Khaled Lakehal
514a2a1757 LibWeb: Add setter implementation for location.search
This commit implements the setter for `location.search`, allowing
updates to the query string of the URL.
2024-08-21 10:52:19 +01:00
Sam Atkins
5bd585d446 LibWeb/CSS: Add dump method to CalculatedStyleValue
The individual nodes all have dump methods, but there was no way of
calling them from the outside. So now there is.
2024-08-21 10:51:48 +01:00
Sam Atkins
3af6a69f1e LibWeb: Introduce color-function-specific style values
Instead of CSSColorValue holding a Gfx::Color, make it an abstract class
with subclasses for each different color function, to match the Typed-OM
spec. This means moving the color calculations from the parsing code to
the `to_color()` method on the style value.

This lets us have calc() inside a color function, instead of having to
fully resolve the color at parse time. The canvas fillStyle tests have
been updated to reflect this.

The other test change is Screenshot/css-color-functions.html: previously
we produced slightly different colors for an alpha of 0.5 and one of
50%, and this incorrect behavior was baked into the test. So now it's
more correct. :^)
2024-08-21 10:51:48 +01:00
Sam Atkins
27be8678c9 LibWeb/CSS: Introduce helper methods for parsing numeric values
"Parse a style value for <foo>", where we don't care if it's a literal
<foo> or a calculated one, is a really common thing that we previously
didn't have methods for.

A couple of methods we had have been extended to parse calc(), and the
others have been filled in.

The method for parsing the `flex` property's value is renamed
`parse_flex_shorthand_value()` as it conflicted.
2024-08-21 10:51:48 +01:00
Sam Atkins
79bd942dd1 LibWeb/CSS: Inline number/integer parsing
For simplicity in user code, the `parse_foo_value()` methods should
parse anything that is a `<foo>`. In these cases, that means a
number/integer or calculation that resolves to them.

These uses in parse_css_value_for_properties() specifically only want a
literal IntegerStyleValue/NumberStyleValue, as calc-parsing is done
elsewhere. So, do the parsing for them locally.
2024-08-21 10:51:48 +01:00
Sam Atkins
9bc71ab1fe LibWeb/CSS: Stop using parse_color()
Parsing a `Gfx::Color` no longer makes sense, as CSS has many ways of
defining a color, often in a dynamic way where the color value isn't
known until later. This is a small preparatory change before a much
larger color rewrite.
2024-08-21 10:51:48 +01:00
Sam Atkins
37ea4e3b5f LibWeb: Rename CSSColorValue::create() to create_from_color()
Soon, CSSColorValue will be an abstract class, and we'll instead create
a CSSRGB, CSSHSL, or other specific color type from the Typed-OM spec.
However, it's still useful to have an easy "just give me a style value
for this color" method. So change the name to distinguish this from the
usual StyleValue::create() methods.
2024-08-21 10:51:48 +01:00
Sam Atkins
4e48afd9a7 LibWeb: Store ShadowStyleValue's color as a StyleValue
Colors can be specified in a way that `Gfx::Color` can't represent, such
as named system colors, `currentColor`, or functions involving `calc()`.
2024-08-21 10:51:48 +01:00
Sam Atkins
581d00293c LibWeb: Rename ColorStyleValue -> CSSColorValue
This matches the name in the CSS Typed OM spec.
https://drafts.css-houdini.org/css-typed-om-1/#csscolorvalue

This is not (yet) the same as the CSSColorValue, but one step at a time.
2024-08-21 10:51:48 +01:00
Sam Atkins
8952764267 LibWeb/CSS: Introduce CSSNumericValue and CSSUnitValue type stubs
CSS-Typed-OM has the following hierarchy:

CSSStyleValue
- CSSNumericValue
  - CSSUnitValue
  - CSSMathValue
    - ...various math functions...

Somewhat unintuitively, numbers are also stored using CSSUnitValue with
`unit = "number"`.

There are no distinct classes for LengthStyleValue, etc in the spec, but
they're convenient for us, so they are implemented as subclasses of
CSSUnitValue, at least for now.
2024-08-21 10:51:48 +01:00
Tim Ledbetter
4771a08d27 CI: Update MacOS runner XCode version 2024-08-20 21:56:41 -04:00
Tim Ledbetter
fe42e2719f LibWeb: Don't crash when parsing HTMLInputElement invalid time values 2024-08-20 23:30:35 +01:00
Jamie Mansfield
b0fc8b67d6 Ladybird/Qt: Rename convert functions to reflect their new types
This is a follow up to GH-1111 to reflect the new signatures that these
functions have.
2024-08-20 21:40:36 +01:00
Sidicer
c380dcf15e UI/Qt: Move cursor to the front
Fix long URLs showing the end instead of domain
2024-08-20 19:51:14 +01:00
Jelle Raaijmakers
e926b4cbfb LibWeb: Make new ImageData() use unpremultiplied color data
This was already the case for `context.createImageData()`, but I forgot
to do the same for `new ImageData()`. Add a regression test for both
cases.
2024-08-20 20:39:09 +02:00
Jelle Raaijmakers
bd55e85027 LibGfx: Implement Gfx::AlphaType for SkiaPainter
Always assuming unpremultiplied color data only worked for PNGs (which
are specced as unpremultiplied) and bitmaps with alpha set to 100%.
Properly propagate the Gfx::AlphaType of a bitmap to Skia.

The reference tests were updated to reflect this change, but visually
it's practically impossible to see the difference. A new test was added
to clearly expose this issue.

Fixes #1104
2024-08-20 20:39:09 +02:00
Jamie Mansfield
aac342bf74 LibWeb/HTML: Update "can have its URL rewritten" for spec changes
This updates the spec comments and removes a FIXME. Functionally,
this doesn't change anything as a fix was already in place.

See:
 - https://github.com/whatwg/html/commit/89a387c
 - https://github.com/whatwg/html/issues/10551
2024-08-20 20:31:39 +02:00
Andreas Kling
7cf7a4d7aa Ladybird/AppKit: Use sRGB color space when blitting web content
Before this change, we were passing CGColorSpaceCreateDeviceRGB() to
CGImageCreate(), causing the system to assume that the image data is
in a device-specific RGB space without any color profile adjustments.

If your monitor is more vibrant than the assumed profile (for example,
a wide-gamut display), colors may appear over-saturated as there's no
correction applied for how the display actually renders those colors.

We now pass CGColorSpaceCreateWithName(kCGColorSpaceSRGB) instead,
which makes colors look the same in Ladybird as in other browsers. :^)
2024-08-20 20:31:10 +02:00
Aliaksandr Kalenik
bc20e3ac6c LibWeb: Do not allocate mask bitmap for CSS "clip-path" property
Instead, it could be applied directly as a clip path in Skia painter.

As a side bonus, we get rid of some DeprecatedPath and
AntiAliasingPainter usage.
2024-08-20 20:00:56 +02:00
Timothy Flynn
2dbf846ff8 LibWebView: Include the document doctype in the exported Inspector HTML 2024-08-20 12:24:56 -04:00
Timothy Flynn
9f1517492c LibJS: Update spec link to the hashbang comment syntax
The proposal reached stage 4 and was merged into the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/2006dea
2024-08-20 12:24:49 -04:00
Timothy Flynn
caf1606c9f LibJS: Mark a call to DetachArrayBuffer as infallible
Noticed while looking at the merged ArrayBuffer transfer proposal.
2024-08-20 12:24:49 -04:00
Timothy Flynn
bf3e7d3ac4 LibJS: Update spec steps/links for the ArrayBuffer transfer proposal
The proposal reached stage 4 and was merged into the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/44bb0e0
2024-08-20 12:24:49 -04:00
Andreas Kling
4bc3055c0f LibWeb: Only invalidate shadow root when style sheet inside changes
We don't have to invalidate style for the entire document when a style
sheet changes inside of a shadow root.

To make this possible, StyleSheetList now keeps track of which
Document-or-ShadowRoot it corresponds to, instead of just tracking the
containing Document.

This avoids a lot of style recomputation on pages with lots of shadow
DOM content (like GitHub).
2024-08-20 16:10:33 +02:00
Andreas Kling
e71ed67069 LibWeb: Show in dumps when elements represent a pseudo element
You can now tell in DOM dumps that an element represents e.g a text
input ::placeholder pseudo element.
2024-08-20 16:10:33 +02:00
Andreas Kling
62083bf586 LibWeb: Only recompute before and after pseudo element styles
Before this change, we would go through every known pseudo element and
compute style for it whenever recomputing the style of an element.

This led to disastrous performance on pages with selectors like
`::selection` or `::placeholder`, as they'd effectively match every
single element and thus we'd compute multiple additional styles for
every element in the DOM.

The fix is simple: only recompute `before` and `after` pseudo element
styles, since those are the only two pseudo elements that generate
*new* nodes -- other pseudo elements refer to (possibly) existing
nodes or concepts within the DOM (or internal shadow DOM).

This makes style updates take ~40ms on our GitHub repo instead of
~220ms. It's still slower than it should be, but a huge improvement.
2024-08-20 16:10:33 +02:00
Tim Ledbetter
681c0b5d1b CI: Update MacOS runner XCode version 2024-08-20 15:07:02 +01:00
Andreas Kling
2f3128333d LibWasm: Make BytecodeInterpreter overrides final
This gives us free devirtualization of some hot calls inside the
bytecode interpreter. Most notably the did_trap() checks.

Modest performance improvement on the https://figma.com/ landing page.
2024-08-20 12:01:43 +02:00
bbb651
e6a668ad91 HTML: BrowsingContext: Remove m_parent and fix is_ancestor_of
`BrowsingContext::m_parent` has been removed from the spec,
and previously `m_parent` was always null.

`BrowsingContext::is_top_level` was already always returning
true before because of that, and the updated spec algorithm
causes assertions to fail.

This fixes the following example:
```html
<a href="about:blank" target="test">a
<iframe name="test">
```
clicking the link twice no longer causes it to open in a new tab.
2024-08-20 09:36:11 +02:00
bbb651
f82e3345f2 HTML: Update coop-check-access-report to match spec 2024-08-20 09:36:11 +02:00
Andreas Kling
dd1b8de671 Ladybird+LibWeb+LibGfx: Add option to force use of fontconfig
This allows us to get identical metrics on macOS and Linux. Without
this, Skia will use CoreText on macOS and give us slightly different
text metrics. That causes layout tests to be slightly different on
different platforms, which is a huge headache. So let's not do that.

You can now launch Ladybird and headless-browser with --force-fontconfig
to load fonts through fontconfig. Tests run in this mode by default.
2024-08-20 09:30:05 +02:00
Andreas Kling
3ed0381a2a LibGfx: Remove unused font code dealing with left-side bearing 2024-08-20 09:30:05 +02:00
Andreas Kling
d4d7feffca LibWeb: Compensate for CRC2D transform in internal stored path
The CRC2D path should be unaffected by the CRC2D transform changing.
To achieve this, we transform the path to compensate whenever the
CRC2D transform is changed.
2024-08-20 09:30:05 +02:00
Andreas Kling
0d57de4236 LibWeb: Make 2D canvas save/restore perform save/restore on painter
This ensures that any internal state maintained by the painter gets
synchronized appropriately.
2024-08-20 09:30:05 +02:00
Andreas Kling
8540954bf8 LibWeb: Reject non-finite values in 2D canvas transforms 2024-08-20 09:30:05 +02:00
Andreas Kling
7032cb0235 LibWeb: Stop projecting everything through the current 2D canvas matrix
Now that the underlying Gfx::Painter is being transformed as we go,
we don't need to pre-emptively transform geometry before painting it.
2024-08-20 09:30:05 +02:00
Andreas Kling
feae36f218 LibWeb: Flush 2D canvas transformation matrix after making changes to it 2024-08-20 09:30:05 +02:00
Andreas Kling
5aeb8ebebc LibWeb: Clip underlying Painter in CRC2D::clip() 2024-08-20 09:30:05 +02:00
Andreas Kling
57128f489a LibGfx: Remove most of AntiAliasingPainter 2024-08-20 09:30:05 +02:00
Andreas Kling
91737395f3 LibGfx: Remove unused PathClipper 2024-08-20 09:30:05 +02:00
Andreas Kling
aabad3b94e LibGfx: Remove a bunch of no-longer-used OpenType font code
We're not quite ready to remove the old OpenType implementation yet,
but let's carve off some unused stuff.
2024-08-20 09:30:05 +02:00
Andreas Kling
ca2cd86999 Tests/LibWeb: Update screenshot test reference images for Skia changes 2024-08-20 09:30:05 +02:00