haikuwebkit/LayoutTests/svg/transforms/transform-origin-css-proper...

64 lines
2.3 KiB
HTML
Raw Permalink Normal View History

SVG should support transform-origin and relative values https://bugs.webkit.org/show_bug.cgi?id=79068 Patch by Hans Muller <hmuller@adobe.com> on 2012-03-12 Reviewed by Dirk Schulze. Source/WebCore: Added SVG support for the CSS 'transform-origin' property and for percentage values in the transform translate function. The changes conform to http://dev.w3.org/csswg/css3-transforms/. Tests: svg/transforms/percent-transform-values.xhtml svg/transforms/transform-origin-css-property.xhtml * css/svg.css: (*): (html|* > svg): Default transform-origin for SVG elements is 0 0. * platform/Length.h: (WebCore::Length::calcFloatValue): Added a calcFloatValue overload whose max parameter (for percent lengths) is a float. The original version will be obsolete when the sub-pixel layout support is completed. * rendering/style/RenderStyle.cpp: * rendering/style/RenderStyle.h: (WebCore): (WebCore::requireTransformOrigin): Transforms that only include translations don't depend on the transform-origin. (WebCore::RenderStyle::applyTransform): SVG elements interpret non-percentage/keyword transform-origin values relative to their viewport, unlike HTML which interprets all transform-origin values relative to the element's origin. The new FloatRect applyTransform() function handles SVG semantics. Similarly, SVG elements interpret percentage/keyword transform-origin values relative to the origin of their objectBoundingBox(), HTML uses the borderBox. All this per http://dev.w3.org/csswg/css3-transforms/. * svg/SVGStyledTransformableElement.cpp: (WebCore::SVGStyledTransformableElement::animatedLocalTransform): LayoutTests: Added tests for SVG CSS transform-origin property support and for CSS translations specified with percentages and applied to an SVG element. * svg/transforms/change-transform-origin-css-expected.xhtml: Added. * svg/transforms/change-transform-origin-css.xhtml: Added. * svg/transforms/change-transform-origin-presentation-attribute-expected.xhtml: Added. * svg/transforms/change-transform-origin-presentation-attribute.xhtml: Added. * svg/transforms/percent-transform-values-expected.txt: Added. * svg/transforms/percent-transform-values.xhtml: Added. * svg/transforms/transform-origin-css-property-expected.xhtml: Added. * svg/transforms/transform-origin-css-property.xhtml: Added. Canonical link: https://commits.webkit.org/98109@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@110532 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-03-13 02:45:38 +00:00
<html xmlns="http://www.w3.org/1999/xhtml">
<style>
#svgRoot {
position: absolute;
top: 0;
left: 0;
Adapt inline SVG sizing behavior to Firefox and Blink https://bugs.webkit.org/show_bug.cgi?id=132569 Reviewed by Dean Jackson. Source/WebCore: This patch is ported from Blink CR 308992. Thanks to David Vest for helping with back porting his Blink patch. From the commit message: "The basis of this change is to map explicit width and height attributes to CSS properties, essentially promoting them to presentation attributes. Note that implicit "100%" width and height are not mapped. This enables us to remove the concept of "percentage intrinsic size" and rely on normal CSS rules to resolve percentage values. The change has been approved by the SVG WG and the spec is being updated. Minutes here: http://www.w3.org/2014/04/07-svg-minutes.html#item03" The new model was indeed approved by the SVG WG and is basically following the CSS 2.1 model for replaced elements. With this patch WebKit, Firefox and Blink have the same behavior for inline SVG. This is the first successful approach to unify the sizing behavior of SVG across UAs. Tests: svg/as-object/sizing/svg-in-object-placeholder-height-auto.html svg/as-object/sizing/svg-in-object-placeholder-height-fixed.html svg/as-object/sizing/svg-in-object-placeholder-height-percentage.html svg/in-html/sizing/svg-inline.html * css/svg.css: Root SVG elements still need to be sized with height: 100% and width: 100%. This is necessary since width and height are presentation attributes now. (svg:root): * rendering/RenderBox.h: (WebCore::RenderBox::computeIntrinsicRatioInformation): Remove all special behavior for intrinsic and percentage based sizes in SVG. This simplifies and unifies the code a lot. Most of the logic that is used is in RenderBox and RenderReplaced now. RenderSVGRoot was cleaned up a lot and is much lighter. And so it SVGSVGElement. * rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::hasAutoHeightOrContainingBlockWithAutoHeight): (WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions): * rendering/RenderImage.cpp: (WebCore::RenderImage::computeIntrinsicRatioInformation): * rendering/RenderImage.h: * rendering/RenderReplaced.cpp: (WebCore::RenderReplaced::computeAspectRatioInformationForRenderBox): (WebCore::RenderReplaced::computeIntrinsicRatioInformation): (WebCore::RenderReplaced::computeReplacedLogicalWidth): (WebCore::RenderReplaced::computeReplacedLogicalHeight): (WebCore::RenderReplaced::computePreferredLogicalWidths): * rendering/RenderReplaced.h: * rendering/svg/RenderSVGRoot.cpp: (WebCore::RenderSVGRoot::computeIntrinsicRatioInformation): (WebCore::RenderSVGRoot::computeReplacedLogicalWidth): (WebCore::RenderSVGRoot::computeReplacedLogicalHeight): (WebCore::RenderSVGRoot::hasRelativeDimensions): (WebCore::RenderSVGRoot::hasRelativeIntrinsicLogicalWidth): Deleted. (WebCore::RenderSVGRoot::hasRelativeLogicalHeight): Deleted. * rendering/svg/RenderSVGRoot.h: * svg/SVGElement.h: (WebCore::SVGElement::invalidateSVGPresentationAttributeStyle): * svg/SVGSVGElement.cpp: (WebCore::SVGSVGElement::isPresentationAttribute): (WebCore::SVGSVGElement::collectStyleForPresentationAttribute): (WebCore::SVGSVGElement::svgAttributeChanged): (WebCore::SVGSVGElement::currentViewportSize): (WebCore::SVGSVGElement::hasIntrinsicWidth): (WebCore::SVGSVGElement::hasIntrinsicHeight): (WebCore::SVGSVGElement::intrinsicWidth): (WebCore::SVGSVGElement::intrinsicHeight): (WebCore::SVGSVGElement::widthAttributeEstablishesViewport): Deleted. (WebCore::SVGSVGElement::heightAttributeEstablishesViewport): Deleted. * svg/SVGSVGElement.h: * svg/graphics/SVGImage.cpp: (WebCore::SVGImage::containerSize): * xml/XMLErrors.cpp: If an error occurs in a stand alone SVG file, we create an XHTML document with the error message and append the SVG file. This SVG file now follows the CSS sizing behavior as inline SVG. Therefore, we need to set width and height to 100% explicitly. (WebCore::XMLErrors::insertErrorMessageBlock): LayoutTests: The new sizing behavior for inline SVG causes different DRT outputs for about 40 test cases. This is expected but for most tests an improvement since the SVGs fit into the documents and scrollbars disappear or the general size gets smaller. Some tests needed to be updated. The size was either not set at all or not properly. svg-in-object.js and svg-inline.js contain dozens of new tests to check the correct sizing behavior. The tests were written by David Vest from Opera as part of CR 308992. Many of the -expected updates are caused by SVG size changes in turn affecting where line breaks are inserted. * TestExpectations: * accessibility/svg-image-expected.txt: * css3/flexbox/flexitem.html: * fast/css/infinite-floating-value-expected.txt: * fast/css/remove-fixed-resizer-crash-expected.txt: * fast/css3-text/css3-word-spacing-percentage/word-spacing-crash-expected.txt: * fast/repaint/moving-shadow-on-container.html: * fast/repaint/moving-shadow-on-path.html: * fast/repaint/svg-layout-root-style-attr-update.html: * fast/shapes/shape-outside-floats/shape-outside-relative-size-svg-expected.html: * fast/shapes/shape-outside-floats/shape-outside-relative-size-svg.html: * http/tests/xmlviewer/dumpAsText/svg-expected.txt: * platform/mac/svg/batik/filters/feTile-expected.txt: * platform/mac/svg/batik/masking/maskRegions-expected.txt: * platform/mac/svg/batik/paints/patternRegions-positioned-objects-expected.txt: * platform/mac/svg/batik/text/longTextOnPath-expected.txt: * platform/mac/svg/batik/text/textDecoration-expected.txt: * platform/mac/svg/batik/text/textEffect-expected.txt: * platform/mac/svg/batik/text/textLength-expected.txt: * platform/mac/svg/batik/text/textOnPath-expected.txt: * platform/mac/svg/batik/text/textPosition-expected.txt: * platform/mac/svg/batik/text/verticalText-expected.txt: * platform/mac/svg/batik/text/verticalTextOnPath-expected.txt: * platform/mac/svg/custom/bug45331-expected.txt: * platform/mac/svg/custom/junk-data-expected.txt: * platform/mac/svg/custom/missing-xlink-expected.txt: * platform/mac/svg/custom/object-sizing-height-50p-on-target-svg-absolute-expected.png: Removed. * platform/mac/svg/custom/object-sizing-height-50p-on-target-svg-expected.png: Removed. * platform/mac/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute-expected.png: Removed. * platform/mac/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-expected.png: Removed. * platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.png: Removed. * platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.txt: Removed. * platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.png: Removed. * platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.txt: Removed. * platform/mac/svg/custom/object-sizing-width-50p-on-target-svg-absolute-expected.png: Removed. * platform/mac/svg/custom/object-sizing-width-50p-on-target-svg-expected.png: Removed. * platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute-expected.png: Removed. * platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.png: Removed. * platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.txt: Removed. * platform/mac/svg/custom/path-bad-data-expected.txt: * platform/mac/svg/custom/svg-fonts-in-html-expected.txt: * platform/mac/svg/custom/use-font-face-crash-expected.txt: * platform/mac/svg/foreignObject/svg-document-in-html-document-expected.txt: * platform/mac/svg/hixie/error/012-expected.txt: * platform/mac/svg/hixie/intrinsic/001-expected.png: Removed. * platform/mac/svg/hixie/intrinsic/001-expected.txt: Removed. * platform/mac/svg/hixie/intrinsic/002-expected.png: Removed. * platform/mac/svg/hixie/intrinsic/002-expected.txt: Removed. * platform/mac/svg/in-html/circle-expected.txt: * platform/mac/svg/text/non-bmp-positioning-lists-expected.txt: * platform/mac/svg/transforms/animated-path-inside-transformed-html-expected.txt: * platform/mac/svg/transforms/text-with-pattern-inside-transformed-html-expected.txt: * platform/mac/svg/wicd/rightsizing-grid-expected.txt: * platform/mac/svg/wicd/test-rightsizing-b-expected.txt: * platform/mac/svg/zoom/page/zoom-background-image-tiled-expected.txt: * platform/mac/svg/zoom/page/zoom-background-images-expected.txt: * platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt: * platform/mac/svg/zoom/page/zoom-img-preserveAspectRatio-support-1-expected.txt: * platform/mac/svg/zoom/page/zoom-svg-as-relative-image-expected.txt: * platform/mac/svg/zoom/page/zoom-svg-float-border-padding-expected.txt: * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.txt: * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.txt: * platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.txt: * platform/mac/svg/zoom/page/zoom-svg-through-object-with-override-size-expected.txt: * platform/mac/svg/zoom/page/zoom-svg-through-object-with-percentage-size-expected.txt: * platform/mac/svg/zoom/page/zoom-zoom-coords-expected.txt: * platform/mac/svg/zoom/text/zoom-foreignObject-expected.txt: * svg/animations/animate-css-xml-attributeType-expected.txt: * svg/as-image/image-respects-deviceScaleFactor.html: * svg/as-image/image-respects-pageScaleFactor.html: * svg/as-image/svg-as-image-with-relative-size-expected.html: * svg/as-image/svg-as-relative-image.html: * svg/as-object/sizing/svg-in-object-placeholder-height-auto-expected.txt: Added. * svg/as-object/sizing/svg-in-object-placeholder-height-auto.html: Added. * svg/as-object/sizing/svg-in-object-placeholder-height-fixed-expected.txt: Added. * svg/as-object/sizing/svg-in-object-placeholder-height-fixed.html: Added. * svg/as-object/sizing/svg-in-object-placeholder-height-percentage-expected.txt: Added. * svg/as-object/sizing/svg-in-object-placeholder-height-percentage.html: Added. * svg/as-object/sizing/svg-in-object.js: Added. (.): (.addAttr): (.generateSVGURI): (buildDemo): (.doCombinationTestRecursive): (doCombinationTest): (debugHint): (.debugHint): (testSVGInObjectWithPlaceholderHeightAttr.): (testSVGInObjectWithPlaceholderHeightAttr): * svg/css/composite-shadow-example.html: * svg/css/composite-shadow-with-opacity.html: * svg/css/max-width-2.html: * svg/css/stars-with-shadow.html: * svg/custom/absolute-sized-content-with-resources.xhtml: * svg/custom/altglyph.svg: * svg/custom/document-all-includes-svg-expected.txt: * svg/custom/external-paintserver-reference-expected.txt: * svg/custom/external-paintserver-reference.svg: * svg/custom/get-text-element-transform-crash-expected.txt: * svg/custom/linking-base-external-reference-expected.txt: * svg/custom/linking-base-external-reference.xhtml: * svg/custom/object-sizing-height-50p-on-target-svg-absolute-expected.txt: Removed. * svg/custom/object-sizing-height-50p-on-target-svg-absolute.xhtml: Removed. * svg/custom/object-sizing-height-50p-on-target-svg-expected.txt: Removed. * svg/custom/object-sizing-height-50p-on-target-svg.xhtml: Removed. * svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute-expected.txt: Removed. * svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute.xhtml: Removed. * svg/custom/object-sizing-width-50p-height-50p-on-target-svg-expected.txt: Removed. * svg/custom/object-sizing-width-50p-height-50p-on-target-svg.xhtml: Removed. * svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.txt: Removed. * svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute.xhtml: Removed. * svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.txt: Removed. * svg/custom/object-sizing-width-50p-height-75p-on-target-svg.xhtml: Removed. * svg/custom/object-sizing-width-50p-on-target-svg-absolute-expected.txt: Removed. * svg/custom/object-sizing-width-50p-on-target-svg-absolute.xhtml: Removed. * svg/custom/object-sizing-width-50p-on-target-svg-expected.txt: Removed. * svg/custom/object-sizing-width-50p-on-target-svg.xhtml: Removed. * svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute-expected.txt: Removed. * svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute.xhtml: Removed. * svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.txt: Removed. * svg/custom/object-sizing-width-75p-height-50p-on-target-svg.xhtml: Removed. * svg/custom/pending-resource-after-removal.xhtml: * svg/custom/percentage-of-html-parent.xhtml: * svg/custom/relative-sized-content-with-resources.xhtml: * svg/custom/relative-sized-content.xhtml: * svg/custom/relative-sized-deep-shadow-tree-content.xhtml: * svg/custom/relative-sized-image.xhtml: * svg/custom/relative-sized-inner-svg.xhtml: * svg/custom/relative-sized-shadow-tree-content-with-symbol.xhtml: * svg/custom/relative-sized-shadow-tree-content.xhtml: * svg/custom/relative-sized-use-on-symbol.xhtml: * svg/custom/relative-sized-use-without-attributes-on-symbol.xhtml: * svg/custom/tref-with-progress-tag-setpseudo-assert-expected.txt: * svg/custom/unicode-in-tspan-multi-svg-crash-expected.txt: * svg/custom/use-invalid-html-expected.txt: * svg/custom/window-named-item-lookup-expected.txt: * svg/dom/SVGViewSpec-invalid-ref-crash-expected.txt: * svg/dom/parent-view-layout-crash-expected.txt: * svg/dom/stylesheet-candidate-node-crash-main-expected.txt: * svg/dom/svg-root-lengths.html: * svg/foreignObject/absolute-position-foreign-object-child-crash-expected.txt: * svg/hixie/intrinsic/001-expected.png: Removed. * svg/hixie/intrinsic/001-expected.txt: Removed. * svg/hixie/intrinsic/001.html: Removed. * svg/hixie/intrinsic/002-expected.png: Removed. * svg/hixie/intrinsic/002-expected.txt: Removed. * svg/hixie/intrinsic/002.html: Removed. * svg/hixie/intrinsic/resources/001.svg: Removed. * svg/hixie/intrinsic/resources/002.svg: Removed. * svg/in-html/sizing/svg-inline-expected.txt: Added. * svg/in-html/sizing/svg-inline.html: Added. * svg/in-html/sizing/svg-inline.js: Added. (.): (setupSVGElement): (buildDemo): (.doCombinationTestRecursive): (doCombinationTest): (debugHint): (.debugHint): * svg/path-arc-invalid-expected.txt: * svg/repaint/repaint-webkit-svg-shadow-container-expected.txt: * svg/text/append-text-node-to-tspan.html: * svg/text/kerning.svg: * svg/text/modify-text-node-in-tspan.html: * svg/text/multichar-glyph.svg: * svg/text/remove-text-node-from-tspan.html: * svg/text/remove-tspan-from-text.html: * svg/text/svg-rtl-text-crash-expected.txt: * svg/text/text-block-child-crash-expected.txt: * svg/transforms/animated-path-inside-transformed-html.xhtml: * svg/transforms/svg-css-transforms-clip-path.xhtml: * svg/transforms/transform-origin-css-property.xhtml: * svg/zoom/page/zoom-foreignObject.svg: * svg/zoom/page/zoom-svg-as-relative-image.html: * svg/zoom/text/zoom-foreignObject.svg: Canonical link: https://commits.webkit.org/150625@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168350 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-05-06 06:06:28 +00:00
width: 100%;
height: 100%;
SVG should support transform-origin and relative values https://bugs.webkit.org/show_bug.cgi?id=79068 Patch by Hans Muller <hmuller@adobe.com> on 2012-03-12 Reviewed by Dirk Schulze. Source/WebCore: Added SVG support for the CSS 'transform-origin' property and for percentage values in the transform translate function. The changes conform to http://dev.w3.org/csswg/css3-transforms/. Tests: svg/transforms/percent-transform-values.xhtml svg/transforms/transform-origin-css-property.xhtml * css/svg.css: (*): (html|* > svg): Default transform-origin for SVG elements is 0 0. * platform/Length.h: (WebCore::Length::calcFloatValue): Added a calcFloatValue overload whose max parameter (for percent lengths) is a float. The original version will be obsolete when the sub-pixel layout support is completed. * rendering/style/RenderStyle.cpp: * rendering/style/RenderStyle.h: (WebCore): (WebCore::requireTransformOrigin): Transforms that only include translations don't depend on the transform-origin. (WebCore::RenderStyle::applyTransform): SVG elements interpret non-percentage/keyword transform-origin values relative to their viewport, unlike HTML which interprets all transform-origin values relative to the element's origin. The new FloatRect applyTransform() function handles SVG semantics. Similarly, SVG elements interpret percentage/keyword transform-origin values relative to the origin of their objectBoundingBox(), HTML uses the borderBox. All this per http://dev.w3.org/csswg/css3-transforms/. * svg/SVGStyledTransformableElement.cpp: (WebCore::SVGStyledTransformableElement::animatedLocalTransform): LayoutTests: Added tests for SVG CSS transform-origin property support and for CSS translations specified with percentages and applied to an SVG element. * svg/transforms/change-transform-origin-css-expected.xhtml: Added. * svg/transforms/change-transform-origin-css.xhtml: Added. * svg/transforms/change-transform-origin-presentation-attribute-expected.xhtml: Added. * svg/transforms/change-transform-origin-presentation-attribute.xhtml: Added. * svg/transforms/percent-transform-values-expected.txt: Added. * svg/transforms/percent-transform-values.xhtml: Added. * svg/transforms/transform-origin-css-property-expected.xhtml: Added. * svg/transforms/transform-origin-css-property.xhtml: Added. Canonical link: https://commits.webkit.org/98109@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@110532 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-03-13 02:45:38 +00:00
}
#transformOriginRect {
fill: green;
Support transform-box to switch sizing box in SVG 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. <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. 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
2017-05-22 19:19:24 +00:00
transform: rotate(90deg);
SVG should support transform-origin and relative values https://bugs.webkit.org/show_bug.cgi?id=79068 Patch by Hans Muller <hmuller@adobe.com> on 2012-03-12 Reviewed by Dirk Schulze. Source/WebCore: Added SVG support for the CSS 'transform-origin' property and for percentage values in the transform translate function. The changes conform to http://dev.w3.org/csswg/css3-transforms/. Tests: svg/transforms/percent-transform-values.xhtml svg/transforms/transform-origin-css-property.xhtml * css/svg.css: (*): (html|* > svg): Default transform-origin for SVG elements is 0 0. * platform/Length.h: (WebCore::Length::calcFloatValue): Added a calcFloatValue overload whose max parameter (for percent lengths) is a float. The original version will be obsolete when the sub-pixel layout support is completed. * rendering/style/RenderStyle.cpp: * rendering/style/RenderStyle.h: (WebCore): (WebCore::requireTransformOrigin): Transforms that only include translations don't depend on the transform-origin. (WebCore::RenderStyle::applyTransform): SVG elements interpret non-percentage/keyword transform-origin values relative to their viewport, unlike HTML which interprets all transform-origin values relative to the element's origin. The new FloatRect applyTransform() function handles SVG semantics. Similarly, SVG elements interpret percentage/keyword transform-origin values relative to the origin of their objectBoundingBox(), HTML uses the borderBox. All this per http://dev.w3.org/csswg/css3-transforms/. * svg/SVGStyledTransformableElement.cpp: (WebCore::SVGStyledTransformableElement::animatedLocalTransform): LayoutTests: Added tests for SVG CSS transform-origin property support and for CSS translations specified with percentages and applied to an SVG element. * svg/transforms/change-transform-origin-css-expected.xhtml: Added. * svg/transforms/change-transform-origin-css.xhtml: Added. * svg/transforms/change-transform-origin-presentation-attribute-expected.xhtml: Added. * svg/transforms/change-transform-origin-presentation-attribute.xhtml: Added. * svg/transforms/percent-transform-values-expected.txt: Added. * svg/transforms/percent-transform-values.xhtml: Added. * svg/transforms/transform-origin-css-property-expected.xhtml: Added. * svg/transforms/transform-origin-css-property.xhtml: Added. Canonical link: https://commits.webkit.org/98109@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@110532 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-03-13 02:45:38 +00:00
}
</style>
<!--
Test for bug 79068 - SVG should support transform-origin and relative values.
You should see 9 green 20x20 rectangles. Each green rectangle is actually one of a set of about 6, each one
with a different but equivalent value for the CSS transform-origin property.
-->
<body>
<svg id="svgRoot" xmlns="http://www.w3.org/2000/svg"></svg>
<script><![CDATA[
var svgNS = "http://www.w3.org/2000/svg";
function addTransformOriginRect(x, y, s)
{
var rect = document.createElementNS(svgNS, "rect");
var transformOrigin = (typeof(s) == "string") ? s : s[0] + "px " + s[1] + "px";
SVG should support transform-origin and relative values https://bugs.webkit.org/show_bug.cgi?id=79068 Patch by Hans Muller <hmuller@adobe.com> on 2012-03-12 Reviewed by Dirk Schulze. Source/WebCore: Added SVG support for the CSS 'transform-origin' property and for percentage values in the transform translate function. The changes conform to http://dev.w3.org/csswg/css3-transforms/. Tests: svg/transforms/percent-transform-values.xhtml svg/transforms/transform-origin-css-property.xhtml * css/svg.css: (*): (html|* > svg): Default transform-origin for SVG elements is 0 0. * platform/Length.h: (WebCore::Length::calcFloatValue): Added a calcFloatValue overload whose max parameter (for percent lengths) is a float. The original version will be obsolete when the sub-pixel layout support is completed. * rendering/style/RenderStyle.cpp: * rendering/style/RenderStyle.h: (WebCore): (WebCore::requireTransformOrigin): Transforms that only include translations don't depend on the transform-origin. (WebCore::RenderStyle::applyTransform): SVG elements interpret non-percentage/keyword transform-origin values relative to their viewport, unlike HTML which interprets all transform-origin values relative to the element's origin. The new FloatRect applyTransform() function handles SVG semantics. Similarly, SVG elements interpret percentage/keyword transform-origin values relative to the origin of their objectBoundingBox(), HTML uses the borderBox. All this per http://dev.w3.org/csswg/css3-transforms/. * svg/SVGStyledTransformableElement.cpp: (WebCore::SVGStyledTransformableElement::animatedLocalTransform): LayoutTests: Added tests for SVG CSS transform-origin property support and for CSS translations specified with percentages and applied to an SVG element. * svg/transforms/change-transform-origin-css-expected.xhtml: Added. * svg/transforms/change-transform-origin-css.xhtml: Added. * svg/transforms/change-transform-origin-presentation-attribute-expected.xhtml: Added. * svg/transforms/change-transform-origin-presentation-attribute.xhtml: Added. * svg/transforms/percent-transform-values-expected.txt: Added. * svg/transforms/percent-transform-values.xhtml: Added. * svg/transforms/transform-origin-css-property-expected.xhtml: Added. * svg/transforms/transform-origin-css-property.xhtml: Added. Canonical link: https://commits.webkit.org/98109@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@110532 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-03-13 02:45:38 +00:00
rect.setAttribute("id", "transformOriginRect");
rect.setAttribute("x", x);
rect.setAttribute("y", y);
rect.setAttribute("width", 30);
rect.setAttribute("height", 30);
rect.setAttribute("style", "transform-box: fill-box; transform-origin: " + transformOrigin + ";");
SVG should support transform-origin and relative values https://bugs.webkit.org/show_bug.cgi?id=79068 Patch by Hans Muller <hmuller@adobe.com> on 2012-03-12 Reviewed by Dirk Schulze. Source/WebCore: Added SVG support for the CSS 'transform-origin' property and for percentage values in the transform translate function. The changes conform to http://dev.w3.org/csswg/css3-transforms/. Tests: svg/transforms/percent-transform-values.xhtml svg/transforms/transform-origin-css-property.xhtml * css/svg.css: (*): (html|* > svg): Default transform-origin for SVG elements is 0 0. * platform/Length.h: (WebCore::Length::calcFloatValue): Added a calcFloatValue overload whose max parameter (for percent lengths) is a float. The original version will be obsolete when the sub-pixel layout support is completed. * rendering/style/RenderStyle.cpp: * rendering/style/RenderStyle.h: (WebCore): (WebCore::requireTransformOrigin): Transforms that only include translations don't depend on the transform-origin. (WebCore::RenderStyle::applyTransform): SVG elements interpret non-percentage/keyword transform-origin values relative to their viewport, unlike HTML which interprets all transform-origin values relative to the element's origin. The new FloatRect applyTransform() function handles SVG semantics. Similarly, SVG elements interpret percentage/keyword transform-origin values relative to the origin of their objectBoundingBox(), HTML uses the borderBox. All this per http://dev.w3.org/csswg/css3-transforms/. * svg/SVGStyledTransformableElement.cpp: (WebCore::SVGStyledTransformableElement::animatedLocalTransform): LayoutTests: Added tests for SVG CSS transform-origin property support and for CSS translations specified with percentages and applied to an SVG element. * svg/transforms/change-transform-origin-css-expected.xhtml: Added. * svg/transforms/change-transform-origin-css.xhtml: Added. * svg/transforms/change-transform-origin-presentation-attribute-expected.xhtml: Added. * svg/transforms/change-transform-origin-presentation-attribute.xhtml: Added. * svg/transforms/percent-transform-values-expected.txt: Added. * svg/transforms/percent-transform-values.xhtml: Added. * svg/transforms/transform-origin-css-property-expected.xhtml: Added. * svg/transforms/transform-origin-css-property.xhtml: Added. Canonical link: https://commits.webkit.org/98109@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@110532 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-03-13 02:45:38 +00:00
document.getElementById("svgRoot").appendChild(rect);
}
var equivalentTransformOrigins = [
["50% 50%", "center 50%", "50% center", "center", "center center", [15, 15]],
["0% 0%", "left 0%", "0% top", "left top", "top left", [0, 0]],
["0% 50%", "left 50%", "0% center", "left", "left center", "center left", [0, 15]],
["100% 0%", "right 0%", "100% top", "right top", "top right", [30, 0]],
["0% 50%", "left 50%", "0% center", "left center", "center left", [0, 15]],
["100% 50%", "right 50%", "100% center", "right center", "center right", [30, 15]],
["0% 100%", "left 100%", "0% bottom", "left bottom", "left bottom", [0, 30]],
["50% 100%", "center 100%", "50% bottom", "bottom", "center bottom", "bottom center", [15, 30]],
["100% 100%", "right 100%", "100% bottom", "right bottom", "bottom right", [30, 30]]
];
for (var i = 0; i < equivalentTransformOrigins.length; i++) {
var x = 60 + (i % 4) * 60;
var y = 60 + Math.floor(i / 4) * 60;
equivalentTransformOrigins[i].map( function(s) { addTransformOriginRect(x, y, s); } );
}
]]></script>
</body>
</html>