Support transform-box to switch sizing box in SVG
[WebKit-https.git] / Source / WebCore / ChangeLog
index f9e7b6f..8400ea0 100644 (file)
@@ -1,3 +1,65 @@
+2017-05-22  Simon Fraser  <simon.fraser@apple.com>
+
+        Support transform-box to switch sizing box in SVG
+        https://bugs.webkit.org/show_bug.cgi?id=145783
+
+        Reviewed by Dean Jackson.
+
+        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.
+        <https://github.com/w3c/csswg-drafts/issues/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.
+
 2017-05-22  Chris Dumez  <cdumez@apple.com>
 
         Add support for [LegacyWindowAlias] IDL extended attribute