New issue
Advanced search Search tips

Issue 702380 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

Activating an SVG <view> element without viewBox attribute causes SVG viewBox to be ignored

Reported by amelia.b...@gmail.com, Mar 16 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36

Example URL:
http://codepen.io/AmeliaBR/pen/yMPMOm?editors=1000

Steps to reproduce the problem:
1. Create an SVG file with a non-default viewBox attribute on the main <svg>, and a <view> element that changes preserveAspectRatio but not viewBox.
2. Open or embed that SVG file with a # fragment that matches the <view> element's ID.

What is the expected behavior?
The SVG should be displayed with the preserveAspectRatio value from the activated view, but with the viewBox from the <svg> element.

SVG 1.1 spec: https://www.w3.org/TR/SVG11/linking.html#SVGFragmentIdentifiers
SVG 2 spec: https://www.w3.org/TR/SVG2/linking.html#LinksIntoSVG

What went wrong?
In Chrome, (current stable 56 and 59.0.3043.1 canary SyzyASan), the viewBox from the SVG is ignored when the view element is activated, so that the SVG does not scale at all.

This worked previously.  The last time I would have tested was around version 42, when a fix was made for a similar bug with #svgView() fragments (see #444553 ).  That fix has not regressed (as shown in linked CodePen): the new bug is specific to <view> elements.

Does it occur on multiple sites: Yes

Is it a problem with a plugin? N/A 

Did this work before? Yes 42 (I think)

Does this work in other browsers? Yes

Chrome version: 56.0.2924.87  Channel: n/a
OS Version: 10.0
Flash Version: 

The attached file is the SVG used in the CodePen.

PS: only viewBox is affected: a <view> that changes the viewBox does not re-set the preserveAspectRatio attribute from the <svg> (see the other case in the CodePen: if pAR was reset, the shape would be centered in the canvas).
 
club-alternate-views-2.svg
564 bytes Download
Full link to the related bug & patch info (since it didn't happen auto-magically when I mentioned the #):

https://bugs.chromium.org/p/chromium/issues/detail?id=444553

Comment 2 by f...@opera.com, Mar 17 2017

Components: -Blink Blink>SVG
Labels: -OS-Windows
Status: Available (was: Unconfirmed)
Labels: BugSource-User PaintTeamTriaged-20170317
Project Member

Comment 4 by bugdroid1@chromium.org, Mar 18 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d2c24342da278481fc6041e235f8690828e6760d

commit d2c24342da278481fc6041e235f8690828e6760d
Author: fs <fs@opera.com>
Date: Sat Mar 18 01:46:30 2017

Inherit 'viewBox' into view spec if it is valid

When constructing a view spec from a fragment identifier, the
(negated) hasEmptyViewBox() condition was used to determine if the
viewBox value should be set from the element. This condition however
will equate to:

  !(is-valid && is-empty) => !is-valid || !is-empty

meaning that invalid viewBox values would be transferred. In the case
where a <view> element without a 'viewBox' specified was referenced, the
'viewBox' value from the root could be overwritten by an invalid one.

Use only the validity of the 'viewBox' to determine if the value should
be inherited.

BUG= 702380 

Review-Url: https://codereview.chromium.org/2753773009
Cr-Commit-Position: refs/heads/master@{#457921}

[add] https://crrev.com/d2c24342da278481fc6041e235f8690828e6760d/third_party/WebKit/LayoutTests/svg/as-image/resources/green-rect-par-none-view.svg
[add] https://crrev.com/d2c24342da278481fc6041e235f8690828e6760d/third_party/WebKit/LayoutTests/svg/as-image/view-with-preserveaspectratio-only-expected.html
[add] https://crrev.com/d2c24342da278481fc6041e235f8690828e6760d/third_party/WebKit/LayoutTests/svg/as-image/view-with-preserveaspectratio-only.html
[modify] https://crrev.com/d2c24342da278481fc6041e235f8690828e6760d/third_party/WebKit/Source/core/svg/SVGViewSpec.h

Comment 5 by f...@opera.com, Mar 20 2017

Owner: f...@opera.com
Status: Fixed (was: Available)
Will follow up with some possibly related (and tangential) cases in issue 703050.

Sign in to add a comment