Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Resolve percentage in use against the instance's viewport element
https://bugs.webkit.org/show_bug.cgi?id=256702
rdar://problem/109565397

Reviewed by Simon Fraser.

This patch aligns WebKit with Blink / Chromium and Gecko / Firefox.

Merge: https://chromium.googlesource.com/chromium/src/+/b34ff6fe2d5842a63e2c66f68f050f0cf9163010

In RenderSVGTransformableContainer::calculateLocalTransform, 'x' and 'y'
were resolved against the original (corresponding) element. For a `use`
nested within a `symbol`, this would mean that when were going to look
up the viewport element, we would return the outer `symbol` element and thus
fail to get a viewport.
Use the instance element to setup the SVGLengthContext instead.

* Source/WebCore/rendering/svg/LegacyRenderSVGTransformableContainer.cpp:
(LegacyRenderSVGTransformableContainer::calculateLocalTransform): Use 'element' rather than 'useElement'
* LayoutTests/svg/custom/use-nested-symbol-viewport.html: Add Test Case
* LayoutTests/svg/custom/use-nested-symbol-viewport-expected.html: Add Test Case Expectation

Canonical link: https://commits.webkit.org/264596@main
  • Loading branch information
Ahmad-S792 authored and Ahmad Saleem committed May 26, 2023
1 parent b3b7524 commit 590f8fc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
@@ -0,0 +1,2 @@
<!DOCTYPE html>
<div style="width: 100px; height: 100px; background-color: green"></div>
12 changes: 12 additions & 0 deletions LayoutTests/svg/custom/use-nested-symbol-viewport.html
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<svg width="200" height="100">
<rect width="100" height="100" fill="red"/>
<symbol id="inner">
<rect width="100" height="100"/>
</symbol>
<symbol id="outer">
<rect x="50%" width="100" height="100" fill="red"/>
<use xlink:href="#inner" x="50%" fill="green"/>
</symbol>
<use xlink:href="#outer" transform="translate(-100, 0)"/>
</svg>
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
* Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
* Copyright (C) 2009 Google, Inc.
* Copyright (C) 2009-2016 Google, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
Expand Down Expand Up @@ -58,7 +58,7 @@ bool LegacyRenderSVGTransformableContainer::calculateLocalTransform()
}

if (useElement) {
SVGLengthContext lengthContext(useElement);
SVGLengthContext lengthContext(&element);
FloatSize translation(useElement->x().value(lengthContext), useElement->y().value(lengthContext));
if (translation != m_lastTranslation)
m_needsTransformUpdate = true;
Expand Down

0 comments on commit 590f8fc

Please sign in to comment.