mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 17:24:48 -05:00
LibWeb: Layout standalone SVG document with specified dimensions
Before, standalone SVG documents were stretched to fit the agent viewport.
This commit is contained in:
parent
f4c03d548e
commit
f5e01192cc
Notes:
github-actions[bot]
2024-12-13 15:04:04 +00:00
Author: https://github.com/manuel-za 🔰 Commit: https://github.com/LadybirdBrowser/ladybird/commit/f5e01192cce Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2806 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/awesomekling
1 changed files with 13 additions and 0 deletions
|
@ -18,6 +18,7 @@
|
|||
#include <LibWeb/Layout/SVGGeometryBox.h>
|
||||
#include <LibWeb/Layout/SVGImageBox.h>
|
||||
#include <LibWeb/Layout/SVGMaskBox.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/SVG/SVGAElement.h>
|
||||
#include <LibWeb/SVG/SVGClipPathElement.h>
|
||||
#include <LibWeb/SVG/SVGForeignObjectElement.h>
|
||||
|
@ -179,6 +180,18 @@ void SVGFormattingContext::run(AvailableSpace const& available_space)
|
|||
auto& svg_viewport = dynamic_cast<SVG::SVGViewport const&>(*context_box().dom_node());
|
||||
auto& svg_box_state = m_state.get_mutable(context_box());
|
||||
|
||||
if (!this->context_box().root().document().is_decoded_svg()) {
|
||||
// Overwrite the content width/height with the styled node width/height (from <svg width height ...>)
|
||||
|
||||
// NOTE: If a height had not been provided by the svg element, it was set to the height of the container
|
||||
// (see BlockFormattingContext::layout_viewport)
|
||||
if (svg_box_state.node().computed_values().width().is_length())
|
||||
svg_box_state.set_content_width(svg_box_state.node().computed_values().width().length().to_px(svg_box_state.node()));
|
||||
if (svg_box_state.node().computed_values().height().is_length())
|
||||
svg_box_state.set_content_height(svg_box_state.node().computed_values().height().length().to_px(svg_box_state.node()));
|
||||
// FIXME: In SVG 2, length can also be a percentage. We'll need to support that.
|
||||
}
|
||||
|
||||
// NOTE: We consider all SVG root elements to have definite size in both axes.
|
||||
// I'm not sure if this is good or bad, but our viewport transform logic depends on it.
|
||||
svg_box_state.set_has_definite_width(true);
|
||||
|
|
Loading…
Reference in a new issue