Commit graph

15 commits

Author SHA1 Message Date
InvalidUsernameException
9d7689ecd8 LibWeb: Do not stomp over content size of SVGs
When displaying SVGs inside a navigable directly, we want to display
them in the size specified by their width and height attributes instead
of stretching them to the viewport as layout normally would.

However, when doing so, we need to actually check that the SVG we are
laying out is indeed directly inside the navigable. Otherwise we just
blindly overwrite whatever content sizes have been calculated by layout
code for e.g. SVG elements inlined somewhere in an HTML document.

Due to the way this was written originally, the bug was not very
noticable. The code overwrote the content width/height with the computed
width/height, which was often still correct in the sense that those two
had the same value. However, content size may also be the result of
{min,max}-{width,height} constraints, which can make it differ from the
computed values.

This bug was likely a regression introduced in
f5e01192cc.
2025-09-24 11:25:43 +01:00
Tim Ledbetter
7dade36d96 LibWeb: Ensure SVG image element respects viewBox
Previously, any active viewBox was ignored by SVG image elements.
2025-09-01 13:28:35 +01:00
Tim Ledbetter
ea41aba6c7 LibWeb: Move common SVGViewport code into an SVGFitToViewBox class
Special handling for SVGClipPathElement and SVGMaskElement, which use a
a ViewBox and PreserveAspectRatio value internally, has been moved to
`SVGFormattingContext`.
2025-08-28 15:42:56 +02:00
Tim Ledbetter
aadd563592 LibWeb: Replace usages of dynamic_cast with as and as_if 2025-08-22 20:26:09 +02:00
Timothy Flynn
04d32deb52 LibWeb: Port SVGFormattingContext to UTF-16 2025-08-05 15:13:36 +02:00
Andreas Kling
4e23882995 LibWeb: Use foreignObject's own size as available space inside it
This ensures that percentages resolve against the foreignObject's size
instead of the size of its containing block.

This makes user profile pictures clip correctly in the "Friends" view
of the Discord app.
2025-07-12 14:11:41 +02:00
Andreas Kling
aae0b52403 LibWeb: Resolve mask/clip in foreignObject's own coordinate space
We were neglecting to resolve these correctly, which caused them to get
the same metrics as the nearest viewport above the foreignObject.
2025-07-09 14:36:08 +02:00
Andreas Kling
f5f3cd041a LibWeb: Apply SVG viewbox transform to foreignObject elements 2025-07-09 14:36:08 +02:00
Andreas Kling
b4708510fb LibWeb: Layout foreignObject as block-level element with hidden overflow
This is according to the default user-agent style from the SVG2 spec.

In order for this to work correctly, we also have to assign width and
height to foreignObject boxes during SVG layout, since they are handled
manually by SVGFormattingContext.
2025-07-09 14:36:08 +02:00
Aliaksandr Kalenik
8e2d1559ec LibGfx: Join ScaledFont into Font
Since ScaledFont is the only class inherited from Font we could simply
merge them.
2025-04-21 09:51:16 +02:00
Aliaksandr Kalenik
667cb01b60 LibWeb: Fix layout mode propagation in SVGFormattingContext 2025-03-09 18:40:37 +01:00
Timothy Flynn
27478ec7d4 Everywhere: Run clang-format
The following command was used to clang-format these files:

    clang-format-19 -i $(find . \
        -not \( -path "./\.*" -prune \) \
        -not \( -path "./Build/*" -prune \) \
        -not \( -path "./Toolchain/*" -prune \) \
        -type f -name "*.cpp" -o -name "*.mm" -o -name "*.h")
2024-12-28 05:39:32 -08:00
Manuel Zahariev
f5e01192cc LibWeb: Layout standalone SVG document with specified dimensions
Before, standalone SVG documents were stretched to fit the agent
viewport.
2024-12-13 15:02:49 +00:00
Sam Atkins
ebc91686b5 LibWeb/Layout: Add FIXMEs where we're using the wrong font
It's not clear how to address these right now, so add a FIXME to make
them easier to find and address later.
2024-12-06 02:57:34 +01:00
Timothy Flynn
93712b24bf Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
Renamed from Userland/Libraries/LibWeb/Layout/SVGFormattingContext.cpp (Browse further)