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

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

        Reviewed by Andreas Kling.

        SVG Pattern doesn't take the viewBox of a referenced Pattern
        https://bugs.webkit.org/show_bug.cgi?id=52804
        
        SVGPattern element didn't use the viewBox of another SVGPattern element, referenced
        by xlink:href. Modified PatternAttributes, to take the value of the viewBox of the
        SVGPattern element as well, if the attribute was set.
        This gets checked by a W3C SVG test case.        

        Test: svg/W3C-SVG-1.1-SE/pservers-pattern-04-f.svg

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

        Reviewed by Andreas Kling.

        SVG Pattern doesn't take the viewBox of a referenced Pattern
        https://bugs.webkit.org/show_bug.cgi?id=52804
        
        Added a test case of the W3C SVG test suite to check, if we take
        the viewBox of a referenced SVGPattern.

        * svg/W3C-SVG-1.1-SE/pservers-pattern-04-f.svg: Added.
        * platform/mac/svg/W3C-SVG-1.1-SE/pservers-pattern-04-f-expected.checksum
        * platform/mac/svg/W3C-SVG-1.1-SE/pservers-pattern-04-f-expected.png
        * platform/mac/svg/W3C-SVG-1.1-SE/pservers-pattern-04-f-expected.txt


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76236 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1b1b979f
2011-01-20 Dirk Schulze <krit@webkit.org>
Reviewed by Andreas Kling.
SVG Pattern doesn't take the viewBox of a referenced Pattern
https://bugs.webkit.org/show_bug.cgi?id=52804
Added a test case of the W3C SVG test suite to check, if we take
the viewBox of a referenced SVGPattern.
* svg/W3C-SVG-1.1-SE/pservers-pattern-04-f.svg: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-pattern-04-f-expected.checksum
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-pattern-04-f-expected.png
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-pattern-04-f-expected.txt
2011-01-19 Stephen White <senorblanco@chromium.org>
 
Reviewed by James Robinson.
......
cab9f490ff83da5ab791dccdeadd3f17
\ No newline at end of file
layer at (0,0) size 480x360
RenderView at (0,0) size 480x360
layer at (0,0) size 480x360
RenderSVGRoot {svg} at (0,0) size 480x360
RenderSVGHiddenContainer {defs} at (0,0) size 0x0
RenderSVGContainer {g} at (1,1) size 200x200
RenderSVGHiddenContainer {defs} at (0,0) size 0x0
RenderSVGResourcePattern {pattern} [id="pattern1"] [patternUnits=userSpaceOnUse] [patternContentUnits=userSpaceOnUse]
RenderSVGPath {circle} at (3,3) size 4x4 [fill={[type=SOLID] [color=#FF0000]}] [cx=5.00] [cy=5.00] [r=1.90]
RenderSVGResourcePattern {pattern} [id="pattern2"] [patternUnits=userSpaceOnUse] [patternContentUnits=userSpaceOnUse]
RenderSVGPath {circle} at (3,0) size 4x4 [fill={[type=SOLID] [color=#00FF00]}] [cx=5.00] [cy=2.00] [r=2.00]
RenderSVGPath {rect} at (1,1) size 200x200 [fill={[type=PATTERN] [id="pattern1"]}] [x=1.00] [y=1.00] [width=200.00] [height=200.00]
RenderSVGPath {rect} at (1,1) size 200x200 [fill={[type=PATTERN] [id="pattern2"]}] [x=1.00] [y=1.00] [width=200.00] [height=200.00]
RenderSVGContainer {g} at (10,310) size 231x37
RenderSVGText {text} at (10,310) size 231x37 contains 1 chunk(s)
RenderSVGInlineText {#text} at (0,0) size 231x37
chunk 1 text run 1 at (10.00,340.00) startOffset 0 endOffset 16 width 231.00: "$Revision: 1.3 $"
RenderSVGPath {rect} at (0,0) size 480x360 [stroke={[type=SOLID] [color=#000000]}] [x=1.00] [y=1.00] [width=478.00] [height=358.00]
<svg id="svg-root" width="100%" height="100%" viewBox="0 0 480 360" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!--======================================================================-->
<!--= Copyright 2008 World Wide Web Consortium, (Massachusetts =-->
<!--= Institute of Technology, European Research Consortium for =-->
<!--= Informatics and Mathematics (ERCIM), Keio University). =-->
<!--= All Rights Reserved. =-->
<!--= See http://www.w3.org/Consortium/Legal/. =-->
<!--======================================================================-->
<d:SVGTestCase xmlns:d="http://www.w3.org/2000/02/svg/testsuite/description/" template-version="1.4" reviewer="ED" author="Microsoft" status="accepted" version="$Revision: 1.3 $" testname="$RCSfile: pservers-pattern-04-f.svg,v $">
<d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/pservers.html#Patterns">
<p>
Inherited attributes from a referenced 'pattern' are not applied if they are already defined on the referencing 'pattern' element.
</p>
<p>
Define a pattern 'pattern1' with circles that have red fill. Inherit 'pattern1' into 'pattern2' and add circles at different 'y'
attribute and with 'fill' set to 'lime' on 'pattern2'. Reference 'pattern1' from a square using 'fill' attribute. Reference 'pattern2'
from a different square using 'fill' attribute. Position the second square directly over the first square. Verify that there is green visible.
</p>
</d:testDescription>
<d:operatorScript xmlns="http://www.w3.org/1999/xhtml">
<p>
Run the test. No interaction required.
</p>
</d:operatorScript>
<d:passCriteria xmlns="http://www.w3.org/1999/xhtml">
<p>
The test is passed if there are four green circles visible on the page, and no red.
</p>
</d:passCriteria>
</d:SVGTestCase>
<title id="test-title">$RCSfile: pservers-pattern-04-f.svg,v $</title>
<defs>
<font-face font-family="SVGFreeSansASCII" unicode-range="U+0-7F">
<font-face-src>
<font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/>
</font-face-src>
</font-face>
</defs>
<g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
<defs>
<pattern id="pattern1" patternUnits="userSpaceOnUse" x="0" y="0" width="100" height="100" viewBox="0 0 10 10">
<circle cx="5" cy="5" r="1.9" fill="red"/>
</pattern>
<pattern id="pattern2" xlink:href="#pattern1" y="30">
<circle cx="5" cy="2" r="2" fill="lime"/>
</pattern>
</defs>
<rect fill="url(#pattern1)" stroke="none" x="1" y="1" width="200" height="200"/>
<rect fill="url(#pattern2)" stroke="none" x="1" y="1" width="200" height="200"/>
</g>
<g font-family="SVGFreeSansASCII,sans-serif" font-size="32">
<text id="revision" x="10" y="340" stroke="none" fill="black">$Revision: 1.3 $</text>
</g>
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
<!-- comment out this watermark once the test is approved -->
<!--
<g id="draft-watermark">
<rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/>
<text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240"
text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text>
</g>
-->
</svg>
\ No newline at end of file
2011-01-20 Dirk Schulze <krit@webkit.org>
Reviewed by Andreas Kling.
SVG Pattern doesn't take the viewBox of a referenced Pattern
https://bugs.webkit.org/show_bug.cgi?id=52804
SVGPattern element didn't use the viewBox of another SVGPattern element, referenced
by xlink:href. Modified PatternAttributes, to take the value of the viewBox of the
SVGPattern element as well, if the attribute was set.
This gets checked by a W3C SVG test case.
Test: svg/W3C-SVG-1.1-SE/pservers-pattern-04-f.svg
* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::buildTileImageTransform):
* svg/PatternAttributes.h:
(WebCore::PatternAttributes::PatternAttributes):
(WebCore::PatternAttributes::viewBox):
(WebCore::PatternAttributes::setViewBox):
(WebCore::PatternAttributes::hasViewBox):
* svg/SVGPatternElement.cpp:
(WebCore::SVGPatternElement::collectPatternAttributes):
2011-01-19 Stephen White <senorblanco@chromium.org>
 
[Re-land of r76159 with a compile fix for the Chromium linux shlib
......@@ -228,7 +228,7 @@ bool RenderSVGResourcePattern::buildTileImageTransform(RenderObject* renderer,
if (patternBoundaries.width() <= 0 || patternBoundaries.height() <= 0)
return false;
AffineTransform viewBoxCTM = patternElement->viewBoxToViewTransform(patternElement->viewBox(), patternElement->preserveAspectRatio(), patternBoundaries.width(), patternBoundaries.height());
AffineTransform viewBoxCTM = patternElement->viewBoxToViewTransform(attributes.viewBox(), patternElement->preserveAspectRatio(), patternBoundaries.width(), patternBoundaries.height());
// Apply viewBox/objectBoundingBox transformations.
if (!viewBoxCTM.isIdentity())
......
......@@ -27,12 +27,15 @@ 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()
, m_y()
, m_width()
, m_height()
, m_viewBox()
, m_boundingBoxMode(true)
, m_boundingBoxModeContent(false)
, m_patternContentElement(0)
......@@ -44,6 +47,7 @@ struct PatternAttributes {
, m_boundingBoxModeContentSet(false)
, m_patternTransformSet(false)
, m_patternContentElementSet(false)
, m_viewBoxSet(false)
{
}
......@@ -51,6 +55,7 @@ struct PatternAttributes {
SVGLength y() const { return m_y; }
SVGLength width() const { return m_width; }
SVGLength height() const { return m_height; }
FloatRect viewBox() const { return m_viewBox; }
bool boundingBoxMode() const { return m_boundingBoxMode; }
bool boundingBoxModeContent() const { return m_boundingBoxModeContent; }
AffineTransform patternTransform() const { return m_patternTransform; }
......@@ -80,6 +85,12 @@ struct PatternAttributes {
m_heightSet = true;
}
void setViewBox(const FloatRect& value)
{
m_viewBox = value;
m_viewBoxSet = true;
}
void setBoundingBoxMode(bool value)
{
m_boundingBoxMode = value;
......@@ -108,6 +119,7 @@ struct PatternAttributes {
bool hasY() const { return m_ySet; }
bool hasWidth() const { return m_widthSet; }
bool hasHeight() const { return m_heightSet; }
bool hasViewBox() const { return m_viewBoxSet; }
bool hasBoundingBoxMode() const { return m_boundingBoxModeSet; }
bool hasBoundingBoxModeContent() const { return m_boundingBoxModeContentSet; }
bool hasPatternTransform() const { return m_patternTransformSet; }
......@@ -119,6 +131,7 @@ private:
SVGLength m_y;
SVGLength m_width;
SVGLength m_height;
FloatRect m_viewBox;
bool m_boundingBoxMode;
bool m_boundingBoxModeContent;
AffineTransform m_patternTransform;
......@@ -133,6 +146,7 @@ private:
bool m_boundingBoxModeContentSet : 1;
bool m_patternTransformSet : 1;
bool m_patternContentElementSet : 1;
bool m_viewBoxSet : 1;
};
} // namespace WebCore
......
......@@ -228,6 +228,9 @@ void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes)
if (!attributes.hasHeight() && current->hasAttribute(SVGNames::heightAttr))
attributes.setHeight(current->height());
if (!attributes.hasViewBox() && current->hasAttribute(SVGNames::viewBoxAttr))
attributes.setViewBox(current->viewBox());
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