Commit d7140cc3 authored by krit@webkit.org's avatar krit@webkit.org
Browse files

2011-01-20 Dirk Schulze <krit@webkit.org>

        Reviewed by Rob Buis.

        SVG Pattern doesn't take preserveAspectRatio of references Pattern
        https://bugs.webkit.org/show_bug.cgi?id=52802

        SVGPattern didn't take preserveAspectRatio of a referenced SVGPattern into account. Store preserveAspectRatio
        in PatternAttributes as well, if the attribute was set on the referenced SVGPattern element.

        Test: svg/custom/pattern-referencing-preserve-aspect-ratio.svg

        * rendering/svg/RenderSVGResourcePattern.cpp:
        (WebCore::RenderSVGResourcePattern::buildTileImageTransform):
        * svg/PatternAttributes.h:
        (WebCore::PatternAttributes::PatternAttributes):
        (WebCore::PatternAttributes::preserveAspectRatio):
        (WebCore::PatternAttributes::setPreserveAspectRatio):
        (WebCore::PatternAttributes::hasPreserveAspectRatio):
        * svg/SVGPatternElement.cpp:
        (WebCore::SVGPatternElement::collectPatternAttributes):
2011-01-20  Dirk Schulze  <krit@webkit.org>

        Reviewed by Rob Buis.

        SVG Pattern doesn't take preserveAspectRatio of references Pattern
        https://bugs.webkit.org/show_bug.cgi?id=52802

        Added a test case to check that we take preserveAspectRatio of a referenced SVGPattern into account.

        * platform/mac/svg/custom/pattern-referencing-preserve-aspect-ratio-expected.checksum: Added.
        * platform/mac/svg/custom/pattern-referencing-preserve-aspect-ratio-expected.png: Added.
        * platform/mac/svg/custom/pattern-referencing-preserve-aspect-ratio-expected.txt: Added.
        * svg/custom/pattern-referencing-preserve-aspect-ratio.svg: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76274 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d557175d
2011-01-20 Dirk Schulze <krit@webkit.org>
Reviewed by Rob Buis.
SVG Pattern doesn't take preserveAspectRatio of references Pattern
https://bugs.webkit.org/show_bug.cgi?id=52802
Added a test case to check that we take preserveAspectRatio of a referenced SVGPattern into account.
* platform/mac/svg/custom/pattern-referencing-preserve-aspect-ratio-expected.checksum: Added.
* platform/mac/svg/custom/pattern-referencing-preserve-aspect-ratio-expected.png: Added.
* platform/mac/svg/custom/pattern-referencing-preserve-aspect-ratio-expected.txt: Added.
* svg/custom/pattern-referencing-preserve-aspect-ratio.svg: Added.
2011-01-20 Dan Bernstein <mitz@apple.com>
 
Reviewed by Adele Peterson.
......
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderSVGRoot {svg} at (80,0) size 60x80
RenderSVGHiddenContainer {defs} at (0,0) size 0x0
RenderSVGResourcePattern {pattern} [id="pattern1"] [patternUnits=userSpaceOnUse] [patternContentUnits=userSpaceOnUse]
RenderSVGPath {rect} at (0,0) size 30x40 [stroke={[type=SOLID] [color=#FF0000]}] [fill={[type=SOLID] [color=#000000]}] [x=0.50] [y=0.50] [width=29.00] [height=39.00]
RenderSVGContainer {g} at (5,10) size 20x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,5.00)}]
RenderSVGPath {circle} at (5,10) size 20x20 [fill={[type=SOLID] [color=#FFFF00]}] [cx=15.00] [cy=15.00] [r=10.00]
RenderSVGPath {circle} at (10,15) size 4x4 [fill={[type=SOLID] [color=#000000]}] [cx=12.00] [cy=12.00] [r=1.50]
RenderSVGPath {circle} at (15,15) size 4x4 [fill={[type=SOLID] [color=#000000]}] [cx=17.00] [cy=12.00] [r=1.50]
RenderSVGPath {path} at (9,23) size 12x5 [stroke={[type=SOLID] [color=#000000] [stroke width=2.00]}] [fill={[type=SOLID] [color=#000000]}] [data="M 10 19 C 12.9227 21.34 17.0773 21.34 20 19"]
RenderSVGResourcePattern {pattern} [id="pattern2"] [patternUnits=userSpaceOnUse] [patternContentUnits=userSpaceOnUse]
RenderSVGPath {rect} at (80,0) size 20x80 [fill={[type=PATTERN] [id="pattern1"]}] [x=80.00] [y=0.00] [width=20.00] [height=80.00]
RenderSVGPath {rect} at (100,0) size 40x80 [fill={[type=PATTERN] [id="pattern2"]}] [x=100.00] [y=0.00] [width=40.00] [height=80.00]
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<pattern id="pattern1" patternUnits="userSpaceOnUse" preserveAspectRatio="xMinYMid" x="-20" y="0" width="100" height="80" viewBox="0 0 20 40">
<rect x='.5' y='.5' width='29' height='39' fill='black' stroke='red'/>
<g transform='translate(0, 5)'>
<circle cx='15' cy='15' r='10' fill='yellow'/>
<circle cx='12' cy='12' r='1.5' fill='black'/>
<circle cx='17' cy='12' r='1.5' fill='black'/>
<path d='M 10 19 A 8 8 0 0 0 20 19' stroke='black' stroke-width='2'/>
</g>
</pattern>
<pattern id="pattern2" x="80" xlink:href="#pattern1" viewBox="0 0 20 40"/>
</defs>
<rect x="80" y="0" width="20" height="80" fill="url(#pattern1)"/>
<rect x="100" y="0" width="40" height="80" fill="url(#pattern2)"/>
</svg>
2011-01-20 Dirk Schulze <krit@webkit.org>
Reviewed by Rob Buis.
SVG Pattern doesn't take preserveAspectRatio of references Pattern
https://bugs.webkit.org/show_bug.cgi?id=52802
SVGPattern didn't take preserveAspectRatio of a referenced SVGPattern into account. Store preserveAspectRatio
in PatternAttributes as well, if the attribute was set on the referenced SVGPattern element.
Test: svg/custom/pattern-referencing-preserve-aspect-ratio.svg
* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::buildTileImageTransform):
* svg/PatternAttributes.h:
(WebCore::PatternAttributes::PatternAttributes):
(WebCore::PatternAttributes::preserveAspectRatio):
(WebCore::PatternAttributes::setPreserveAspectRatio):
(WebCore::PatternAttributes::hasPreserveAspectRatio):
* svg/SVGPatternElement.cpp:
(WebCore::SVGPatternElement::collectPatternAttributes):
2011-01-20 Dan Bernstein <mitz@apple.com>
 
Reviewed by Adele Peterson.
......@@ -228,7 +228,7 @@ bool RenderSVGResourcePattern::buildTileImageTransform(RenderObject* renderer,
if (patternBoundaries.width() <= 0 || patternBoundaries.height() <= 0)
return false;
AffineTransform viewBoxCTM = patternElement->viewBoxToViewTransform(attributes.viewBox(), patternElement->preserveAspectRatio(), patternBoundaries.width(), patternBoundaries.height());
AffineTransform viewBoxCTM = patternElement->viewBoxToViewTransform(attributes.viewBox(), attributes.preserveAspectRatio(), patternBoundaries.width(), patternBoundaries.height());
// Apply viewBox/objectBoundingBox transformations.
if (!viewBoxCTM.isIdentity())
......
......@@ -22,13 +22,12 @@
#if ENABLE(SVG)
#include "SVGLength.h"
#include "SVGPreserveAspectRatio.h"
namespace WebCore {
class SVGPatternElement;
// FIXME: We need to add PreserveAspectRatio as well.
// see https://bugs.webkit.org/show_bug.cgi?id=52802
struct PatternAttributes {
PatternAttributes()
: m_x()
......@@ -36,6 +35,7 @@ struct PatternAttributes {
, m_width()
, m_height()
, m_viewBox()
, m_preserveAspectRatio()
, m_boundingBoxMode(true)
, m_boundingBoxModeContent(false)
, m_patternContentElement(0)
......@@ -43,11 +43,12 @@ struct PatternAttributes {
, m_ySet(false)
, m_widthSet(false)
, m_heightSet(false)
, m_viewBoxSet(false)
, m_preserveAspectRatioSet(false)
, m_boundingBoxModeSet(false)
, m_boundingBoxModeContentSet(false)
, m_patternTransformSet(false)
, m_patternContentElementSet(false)
, m_viewBoxSet(false)
{
}
......@@ -56,6 +57,7 @@ struct PatternAttributes {
SVGLength width() const { return m_width; }
SVGLength height() const { return m_height; }
FloatRect viewBox() const { return m_viewBox; }
SVGPreserveAspectRatio preserveAspectRatio() const { return m_preserveAspectRatio; }
bool boundingBoxMode() const { return m_boundingBoxMode; }
bool boundingBoxModeContent() const { return m_boundingBoxModeContent; }
AffineTransform patternTransform() const { return m_patternTransform; }
......@@ -91,6 +93,12 @@ struct PatternAttributes {
m_viewBoxSet = true;
}
void setPreserveAspectRatio(const SVGPreserveAspectRatio& value)
{
m_preserveAspectRatio = value;
m_preserveAspectRatioSet = true;
}
void setBoundingBoxMode(bool value)
{
m_boundingBoxMode = value;
......@@ -120,6 +128,7 @@ struct PatternAttributes {
bool hasWidth() const { return m_widthSet; }
bool hasHeight() const { return m_heightSet; }
bool hasViewBox() const { return m_viewBoxSet; }
bool hasPreserveAspectRatio() const { return m_preserveAspectRatioSet; }
bool hasBoundingBoxMode() const { return m_boundingBoxModeSet; }
bool hasBoundingBoxModeContent() const { return m_boundingBoxModeContentSet; }
bool hasPatternTransform() const { return m_patternTransformSet; }
......@@ -132,6 +141,7 @@ private:
SVGLength m_width;
SVGLength m_height;
FloatRect m_viewBox;
SVGPreserveAspectRatio m_preserveAspectRatio;
bool m_boundingBoxMode;
bool m_boundingBoxModeContent;
AffineTransform m_patternTransform;
......@@ -142,11 +152,12 @@ private:
bool m_ySet : 1;
bool m_widthSet : 1;
bool m_heightSet : 1;
bool m_viewBoxSet : 1;
bool m_preserveAspectRatioSet : 1;
bool m_boundingBoxModeSet : 1;
bool m_boundingBoxModeContentSet : 1;
bool m_patternTransformSet : 1;
bool m_patternContentElementSet : 1;
bool m_viewBoxSet : 1;
};
} // namespace WebCore
......
......@@ -231,6 +231,9 @@ void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes)
if (!attributes.hasViewBox() && current->hasAttribute(SVGNames::viewBoxAttr))
attributes.setViewBox(current->viewBox());
if (!attributes.hasPreserveAspectRatio() && current->hasAttribute(SVGNames::preserveAspectRatioAttr))
attributes.setPreserveAspectRatio(current->preserveAspectRatio());
if (!attributes.hasBoundingBoxMode() && current->hasAttribute(SVGNames::patternUnitsAttr))
attributes.setBoundingBoxMode(current->patternUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment