-
Notifications
You must be signed in to change notification settings - Fork 715
[css-transforms-1] transform-origin: 0% not equivalent to 0px is confusing #895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
The CSS Working Group just discussed transform-origin: 0% != 0px, and agreed to the following resolutions:
The full IRC log of that discussion
|
hubot
pushed a commit
to WebKit/WebKit-http
that referenced
this issue
May 22, 2017
https://bugs.webkit.org/show_bug.cgi?id=145783 Reviewed by Dean Jackson. Source/WebCore: Add support for the CSS "transform-box" property, as described at <https://drafts.csswg.org/css-transforms/#transform-box>. This changes the behavior of percentage values in transform-origin in SVG. When these were added in r110532, percentage values in transform-origin were made relative to the bounding box, but absolute values relative to the view box. <w3c/csswg-drafts#895> has concluded that this behavior is confusing. The new behavior is that, for SVG elements, both absolute and percentage values are relative to the reference box, which is specified by the new transform-box property. The initial value for transform-box is border-box, with the svg.css UA stylesheet supplying a default of view-box for the relevant SVG elements per <https://www.w3.org/TR/SVG2/styling.html#UAStyleSheet>. For non-SVG elements, the used value is always border-box, so there is no change in behavior. Tests: fast/css/transform-box-parsing.html svg/transforms/svg-transform-box.html * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator TransformBox): * css/CSSProperties.json: * css/CSSValueKeywords.in: * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): * css/svg.css: (*:not(svg),): (*): Deleted. (html|* > svg): Deleted. * page/animation/AnimationBase.cpp: (WebCore::AnimationBase::computeTransformedExtentViaTransformList): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::applyTransform): The transformOriginX().isPercent() tests were added to support the weird "% values are relative to bounding box" in SVG. Now it's up to the caller to pass a non-zero origin when that matters, and SVGGraphicsElement::animatedLocalTransform() is the only caller that does so. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::hasTransform): (WebCore::RenderStyle::transformBox): (WebCore::RenderStyle::setTransformBox): (WebCore::RenderStyle::initialTransformBox): * rendering/style/RenderStyleConstants.h: * rendering/style/StyleTransformData.cpp: (WebCore::StyleTransformData::StyleTransformData): (WebCore::StyleTransformData::operator==): * rendering/style/StyleTransformData.h: * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::animatedLocalTransform): Consult the transform-box style to compute the reference box as the bounding box, or the view box. Source/WebInspectorUI: Add transform-box to the list of autocompletions. * UserInterface/External/CodeMirror/css.js: LayoutTests: Modify tests that relied on the old "% values relative to the bounding box" behavior, and new tests for parsing and rendering with transform-box. * fast/css/transform-box-parsing.html: Added. * svg/transforms/change-transform-origin-css.xhtml: * svg/transforms/change-transform-origin-presentation-attribute.xhtml: * svg/transforms/percent-transform-values.xhtml: * svg/transforms/svg-transform-box-expected.html: Added. * svg/transforms/svg-transform-box.html: Added. * svg/transforms/transform-origin-css-property.xhtml: * transforms/svg-vs-css.xhtml: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@217236 268f45cc-cd09-0410-ab3c-d52691b4dbfc
I don't think this issue covers anything that's not covered by issue 857. |
ryanhaddad
pushed a commit
to WebKit/WebKit
that referenced
this issue
Dec 22, 2020
https://bugs.webkit.org/show_bug.cgi?id=145783 Reviewed by Dean Jackson. Source/WebCore: Add support for the CSS "transform-box" property, as described at <https://drafts.csswg.org/css-transforms/#transform-box>. This changes the behavior of percentage values in transform-origin in SVG. When these were added in r110532, percentage values in transform-origin were made relative to the bounding box, but absolute values relative to the view box. <w3c/csswg-drafts#895> has concluded that this behavior is confusing. The new behavior is that, for SVG elements, both absolute and percentage values are relative to the reference box, which is specified by the new transform-box property. The initial value for transform-box is border-box, with the svg.css UA stylesheet supplying a default of view-box for the relevant SVG elements per <https://www.w3.org/TR/SVG2/styling.html#UAStyleSheet>. For non-SVG elements, the used value is always border-box, so there is no change in behavior. Tests: fast/css/transform-box-parsing.html svg/transforms/svg-transform-box.html * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator TransformBox): * css/CSSProperties.json: * css/CSSValueKeywords.in: * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): * css/svg.css: (*:not(svg),): (*): Deleted. (html|* > svg): Deleted. * page/animation/AnimationBase.cpp: (WebCore::AnimationBase::computeTransformedExtentViaTransformList): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::applyTransform): The transformOriginX().isPercent() tests were added to support the weird "% values are relative to bounding box" in SVG. Now it's up to the caller to pass a non-zero origin when that matters, and SVGGraphicsElement::animatedLocalTransform() is the only caller that does so. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::hasTransform): (WebCore::RenderStyle::transformBox): (WebCore::RenderStyle::setTransformBox): (WebCore::RenderStyle::initialTransformBox): * rendering/style/RenderStyleConstants.h: * rendering/style/StyleTransformData.cpp: (WebCore::StyleTransformData::StyleTransformData): (WebCore::StyleTransformData::operator==): * rendering/style/StyleTransformData.h: * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::animatedLocalTransform): Consult the transform-box style to compute the reference box as the bounding box, or the view box. Source/WebInspectorUI: Add transform-box to the list of autocompletions. * UserInterface/External/CodeMirror/css.js: LayoutTests: Modify tests that relied on the old "% values relative to the bounding box" behavior, and new tests for parsing and rendering with transform-box. * fast/css/transform-box-parsing.html: Added. * svg/transforms/change-transform-origin-css.xhtml: * svg/transforms/change-transform-origin-presentation-attribute.xhtml: * svg/transforms/percent-transform-values.xhtml: * svg/transforms/svg-transform-box-expected.html: Added. * svg/transforms/svg-transform-box.html: Added. * svg/transforms/transform-origin-css-property.xhtml: * transforms/svg-vs-css.xhtml: Canonical link: https://commits.webkit.org/189361@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217236 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.w3.org/mid/525F2287.8050002@mcc.id.au
I think the behaviour of transform-origin, where lengths mean different
things depending on whether the element is an SVG element or not, isn't
great. It leads to questions like:
Why shouldn't 'transform-origin: 0px 0px' and 'transform-origin: 0%
0%' mean the same thing? Surely 0% of anything is 0, and so that should
be equivalent to 0px.
How do we treat 'transform-origin: calc(0% + 0px) calc(0% + 0px)'?
What about having something in the property value that explicitly opts
in to having values be relative to the SVG viewport rather than the
bounding box? For example:
transform-origin: viewport 50% 50%; /* middle of the viewport /
transform-origin: 50% 50%; / middle of the bbox /
transform-origin: viewport 4px 4px; / relative to viewport origin /
transform-origin: 4px 4px; / relative to the bbox origin */
And then the UA style sheet could set
transform-origin: viewport 0 0;
on SVG elements.
Alternatively, since setting the transform origin to be anything
viewport relative except for the origin isn't that useful -- and could
be handled by translations in the 'transform' property -- we could just
add a single new value which means the viewport origin for SVG elements,
and the bbox origin for other elements:
transform-origin: auto;
This would then be the initial value, no need for a UA style sheet rule.
Percentages and lengths would always be relative to the bbox.
Even if we don't do either of these, and leave the "percentages are
interpreted differently" behaviour, we should define what happens with
calc()s that contain percentages.
The text was updated successfully, but these errors were encountered: