Fix SVG element inside SVG element rendering - #746
Open
kylehowells wants to merge 7 commits into
Open
kylehowells wants to merge 7 commits into
kylehowells wants to merge 7 commits into
Conversation
Author
|
Most of the noise of this PR comes from: opening the XIB files in the latest Xcode version and being prompted to convert them to the latest XIB format; and adding the new example file to the Demo project. The actual behaviour change is just the change in Before SVGRect frameViewBox = svgSVGElement.viewBox; // the ACTUAL viewbox (may be Uninitalized if none specified in SVG file)
SVGRect frameActualViewport = svgSVGElement.viewport; // the ACTUAL viewport (dictated by the graphics engine; may be Uninitialized if the renderer has too little info to decide on a viewport at all!)
SVGRect frameRequestedViewport = svgSVGElement.requestedViewport; // the default viewport requested in the SVG source file (may be Uninitialized if no svg width or height params in original source file)After SVGRect frameViewBox = svgSVGElement.viewBox; // the ACTUAL viewbox (may be Uninitalized if none specified in SVG file)
SVGRect frameActualViewport;
if ([transformableOrSVGSVGElement isKindOfClass:[SVGSVGElement class]] && [svgSVGElement.parentNode isKindOfClass:[SVGSVGElement class]]) {
frameActualViewport = ((SVGSVGElement*)svgSVGElement.parentNode).viewBox;
}
else {
frameActualViewport = svgSVGElement.viewport; // the ACTUAL viewport (dictated by the graphics engine; may be Uninitialized if the renderer has too little info to decide on a viewport at all!)
}
SVGRect frameRequestedViewport = svgSVGElement.requestedViewport; // the default viewport requested in the SVG source file (may be Uninitialized if no svg width or height params in original source file) |
Contributor
|
Reading the docs on embedded SVG and viewboxes - where 'width' and 'height'
are supposed to default to '100% if not specified', this appears a correct
interpretation to me.
It would be better if we had more explicit calculation of 'what is the
viewport in situation X?' code, perhaps, but for now this looks OK?
…On Tue, Mar 8, 2022 at 3:15 PM Kyle Howells ***@***.***> wrote:
Most of the noise of this PR comes from: opening the XIB files in the
latest Xcode version and being prompted to convert them to the latest XIB
format; and adding the new example file to the Demo project.
The actual behaviour change is just the change in Source/DOM
classes/SVG-DOM/SVGHelperUtilities.m
<#746 (comment)>
.
Before
SVGRect frameViewBox = svgSVGElement.viewBox; // the ACTUAL viewbox (may be Uninitalized if none specified in SVG file)
SVGRect frameActualViewport = svgSVGElement.viewport; // the ACTUAL viewport (dictated by the graphics engine; may be Uninitialized if the renderer has too little info to decide on a viewport at all!)
SVGRect frameRequestedViewport = svgSVGElement.requestedViewport; // the default viewport requested in the SVG source file (may be Uninitialized if no svg width or height params in original source file)
After
SVGRect frameViewBox = svgSVGElement.viewBox; // the ACTUAL viewbox (may be Uninitalized if none specified in SVG file)
SVGRect frameActualViewport;
if ([transformableOrSVGSVGElement isKindOfClass:[SVGSVGElement class]] && [svgSVGElement.parentNode isKindOfClass:[SVGSVGElement class]]) {
frameActualViewport = ((SVGSVGElement*)svgSVGElement.parentNode).viewBox;
}
else {
frameActualViewport = svgSVGElement.viewport; // the ACTUAL viewport (dictated by the graphics engine; may be Uninitialized if the renderer has too little info to decide on a viewport at all!)
}
SVGRect frameRequestedViewport = svgSVGElement.requestedViewport; // the default viewport requested in the SVG source file (may be Uninitialized if no svg width or height params in original source file)
—
Reply to this email directly, view it on GitHub
<#746 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACHL6LLAMKGKN3IAULNR6DU65VJRANCNFSM5QGUBJBQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While working on a new app I need to render arbitrary SVG elements from a web service and found a problem with a large number of the SVG elements returned to my app.
Investigating I found the problem SVGs where one's which were nested.
Web browsers would render the SVG file full size whereas SVGKit was rendering it as a 8 pixel block in the top right corner of an empty 1000px square.
I believe the change I have made:
Fixes the issue while maintaining the internal and existing behaviour for other elements.
I have:
Several other changes have been made to the project, but can be extracted out as a separate PR if desired: