Commit 0f4a4a03 authored by eseidel's avatar eseidel
Browse files

2006-08-11 Eric Seidel <eric@eseidel.com>

        Reviewed by andersca.

        The outermost <svg> element needs to clip itself
        http://bugzilla.opendarwin.org/show_bug.cgi?id=5358

        * css/cssstyleselector.cpp:
        (WebCore::CSSStyleSelector::adjustRenderStyle): adjust for SVG overflow rules
        * kcanvas/RenderSVGContainer.cpp:
        (WebCore::RenderSVGContainer::requiresLayer): only require layers for absolute/relative positioning of outermost SVG
        (WebCore::RenderSVGContainer::paint):
        * kcanvas/device/KRenderingDevice.h:
        * kcanvas/device/quartz/KRenderingDeviceQuartz.h: remove dead methods
        * kcanvas/device/quartz/KRenderingDeviceQuartz.mm: remove dead methods
        (WebCore::KRenderingDeviceContextQuartz::KRenderingDeviceContextQuartz):
        * ksvg2/svg/SVGPaint.cpp: spacing changes
        (WebCore::SVGPaint::SVGPaint): spacing cleanup
        * ksvg2/svg/SVGSVGElement.cpp:
        (WebCore::SVGSVGElement::parseMappedAttribute): spacing cleanup
        * platform/GraphicsContext.h: Added concatCTM
        * platform/cg/GraphicsContextCG.cpp:
        (WebCore::GraphicsContext::concatCTM): Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@15842 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 28d76d25
2006-08-11 Eric Seidel <eric@eseidel.com>
Reviewed by andersca.
Updated results, and new test for:
The outermost <svg> element needs to clip itself
http://bugzilla.opendarwin.org/show_bug.cgi?id=5358
* svg/W3C-SVG-1.1/coords-viewattr-01-b-expected.checksum:
* svg/W3C-SVG-1.1/coords-viewattr-01-b-expected.png:
* svg/W3C-SVG-1.1/masking-path-03-b-expected.checksum:
* svg/W3C-SVG-1.1/masking-path-03-b-expected.png:
* svg/custom/svg-overflow-types-expected.checksum: Added.
* svg/custom/svg-overflow-types-expected.png: Added.
* svg/custom/svg-overflow-types-expected.txt: Added.
* svg/custom/svg-overflow-types.svg: Added.
2006-08-11 Adele Peterson <adele@apple.com>
 
Reviewed by Brady.
9742a7f70e5cbd05e5e5355f9386931d
\ No newline at end of file
4449e6ebccb1b1b0d9ec1159af17f1f3
\ No newline at end of file
35926a21e4cfd298e0a02d9c56b14c42
\ No newline at end of file
8aa4ab10cb39b335f46c9b5bd998dfcc
\ No newline at end of file
76df8d127c7a82c815d0b0dc15cb2462
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
KCanvasContainer {svg} at (0,0) size 400x400
KCanvasItem {rect} at (0,0) size 200x200 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L200.00,0.00L200.00,200.00L0.00,200.00"]
KCanvasContainer {svg} at (0,0) size 200x200
KCanvasItem {rect} at (0,0) size 200x200 [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,0.00L200.00,0.00L200.00,200.00L0.00,200.00"]
KCanvasItem {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,100.00L0.00,100.00"]
RenderSVGText {text} at (0,0) size 785x18
RenderText {#text} at (0,0) size 108x18
text run at (0,0) width 108: "overflow: hidden"
KCanvasItem {rect} at (200,0) size 200x200 [fill={[type=SOLID] [color=#008000]}] [data="M200.00,0.00L400.00,0.00L400.00,200.00L200.00,200.00"]
KCanvasContainer {svg} at (0,0) size 200x200
KCanvasItem {rect} at (0,0) size 200x200 [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,0.00L200.00,0.00L200.00,200.00L0.00,200.00"]
KCanvasItem {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,100.00L0.00,100.00"]
RenderSVGText {text} at (0,0) size 785x18
RenderText {#text} at (0,0) size 99x18
text run at (0,0) width 99: "overflow: scroll"
KCanvasItem {rect} at (0,200) size 200x200 [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,200.00L200.00,200.00L200.00,400.00L0.00,400.00"]
KCanvasContainer {svg} at (0,0) size 200x200
KCanvasItem {rect} at (0,0) size 200x200 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L200.00,0.00L200.00,200.00L0.00,200.00"]
RenderSVGText {text} at (0,0) size 785x18
RenderText {#text} at (0,0) size 92x18
text run at (0,0) width 92: "overflow: auto"
KCanvasItem {rect} at (200,200) size 200x200 [fill={[type=SOLID] [color=#FF0000]}] [data="M200.00,200.00L400.00,200.00L400.00,400.00L200.00,400.00"]
KCanvasContainer {svg} at (0,0) size 200x200
KCanvasItem {rect} at (0,0) size 200x200 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L200.00,0.00L200.00,200.00L0.00,200.00"]
RenderSVGText {text} at (0,0) size 785x18
RenderText {#text} at (0,0) size 106x18
text run at (0,0) width 106: "overflow: visible"
<?xml version="1.0" ?>
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400">
<rect x='0' y='0' width='200' height='200' fill="green" />
<svg x='0' y='0' width="100" height="100" style="overflow: hidden">
<rect x='0' y='0' width='200' height='200' fill="red" />
<rect x='0' y='0' width='100' height='100' fill="green" />
</svg>
<text x='50' y='100'>overflow: hidden</text>
<rect x='200' y='0' width='200' height='200' fill="green" />
<svg x='200' y='0' width="100" height="100" style="overflow: scroll">
<rect x='0' y='0' width='200' height='200' fill="red" />
<rect x='0' y='0' width='100' height='100' fill="green" />
</svg>
<text x='250' y='100'>overflow: scroll</text>
<rect x='0' y='200' width='200' height='200' fill="red" />
<svg x='0' y='200' width="100" height="100" style="overflow: auto">
<rect x='0' y='0' width='200' height='200' fill="green" />
</svg>
<text x='50' y='300'>overflow: auto</text>
<rect x='200' y='200' width='200' height='200' fill="red" />
<svg x='200' y='200' width="100" height="100" style="overflow: visible">
<rect x='0' y='0' width='200' height='200' fill="green" />
</svg>
<text x='250' y='300'>overflow: visible</text>
</svg>
2006-08-11 Eric Seidel <eric@eseidel.com>
Reviewed by andersca.
The outermost <svg> element needs to clip itself
http://bugzilla.opendarwin.org/show_bug.cgi?id=5358
* css/cssstyleselector.cpp:
(WebCore::CSSStyleSelector::adjustRenderStyle): adjust for SVG overflow rules
* kcanvas/RenderSVGContainer.cpp:
(WebCore::RenderSVGContainer::requiresLayer): only require layers for absolute/relative positioning of outermost SVG
(WebCore::RenderSVGContainer::paint):
* kcanvas/device/KRenderingDevice.h:
* kcanvas/device/quartz/KRenderingDeviceQuartz.h: remove dead methods
* kcanvas/device/quartz/KRenderingDeviceQuartz.mm: remove dead methods
(WebCore::KRenderingDeviceContextQuartz::KRenderingDeviceContextQuartz):
* ksvg2/svg/SVGPaint.cpp: spacing changes
(WebCore::SVGPaint::SVGPaint): spacing cleanup
* ksvg2/svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::parseMappedAttribute): spacing cleanup
* platform/GraphicsContext.h: Added concatCTM
* platform/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::concatCTM): Added.
2006-08-11 Brady Eidson <beidson@apple.com>
 
Reviewed by Maciej
......
......@@ -1086,6 +1086,21 @@ void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, Element *e)
else
theme()->adjustStyle(this, style, e);
}
#ifdef SVG_SUPPORT
if (e->isSVGElement()) {
// Spec: http://www.w3.org/TR/SVG/masking.html#OverflowProperty
if (style->overflowY() == OSCROLL)
style->setOverflowY(OHIDDEN);
else if (style->overflowY() == OAUTO)
style->setOverflowY(OVISIBLE);
if (style->overflowX() == OSCROLL)
style->setOverflowX(OHIDDEN);
else if (style->overflowX() == OAUTO)
style->setOverflowX(OVISIBLE);
}
#endif
}
void CSSStyleSelector::updateFont()
......
......@@ -85,7 +85,8 @@ bool RenderSVGContainer::canHaveChildren() const
bool RenderSVGContainer::requiresLayer()
{
return false;
// Only allow an <svg> element to generate a layer when it's positioned in a non-SVG context
return (isPositioned() || isRelPositioned()) && (parent() && !parent()->element()->isSVGElement());
}
short RenderSVGContainer::lineHeight(bool b, bool isRootLineBox) const
......@@ -126,7 +127,7 @@ void RenderSVGContainer::layout()
RenderContainer::layout();
}
void RenderSVGContainer::paint(PaintInfo &paintInfo, int parentX, int parentY)
void RenderSVGContainer::paint(PaintInfo& paintInfo, int parentX, int parentY)
{
if (paintInfo.p->paintingDisabled())
return;
......@@ -165,8 +166,11 @@ void RenderSVGContainer::paint(PaintInfo &paintInfo, int parentX, int parentY)
parentX = parentY = 0;
}
if (!viewport().isEmpty())
if (!viewport().isEmpty()) {
if (style()->overflowX() != OVISIBLE)
paintInfo.p->addClip(enclosingIntRect(viewport())); // FIXME: Eventually we'll want float-precision clipping
deviceContext->concatCTM(AffineTransform().translate(viewport().x(), viewport().y()));
}
if (!localTransform().isIdentity())
deviceContext->concatCTM(localTransform());
......
......@@ -39,10 +39,7 @@ public:
virtual KCanvasMatrix concatCTM(const KCanvasMatrix &worldMatrix) = 0;
virtual KCanvasMatrix ctm() const = 0;
virtual IntRect mapFromVisual(const IntRect &rect) = 0;
virtual IntRect mapToVisual(const IntRect &rect) = 0;
virtual void clearPath() = 0;
virtual void addPath(const KCanvasPath*) = 0;
......
......@@ -49,9 +49,6 @@ public:
virtual KCanvasMatrix concatCTM(const KCanvasMatrix &worldMatrix);
virtual KCanvasMatrix ctm() const;
virtual IntRect mapFromVisual(const IntRect &rect);
virtual IntRect mapToVisual(const IntRect &rect);
virtual void clearPath();
virtual void addPath(const KCanvasPath*);
......
......@@ -44,7 +44,9 @@
namespace WebCore {
KRenderingDeviceContextQuartz::KRenderingDeviceContextQuartz(CGContextRef context) : m_cgContext(CGContextRetain(context)), m_nsGraphicsContext(0)
KRenderingDeviceContextQuartz::KRenderingDeviceContextQuartz(CGContextRef context)
: m_cgContext(CGContextRetain(context))
, m_nsGraphicsContext(0)
{
ASSERT(m_cgContext);
}
......@@ -70,16 +72,6 @@ KCanvasMatrix KRenderingDeviceContextQuartz::ctm() const
return KCanvasMatrix(contextCTM.a, contextCTM.b, contextCTM.c, contextCTM.d, contextCTM.tx, contextCTM.ty);
}
IntRect KRenderingDeviceContextQuartz::mapFromVisual(const IntRect &rect)
{
return IntRect();
}
IntRect KRenderingDeviceContextQuartz::mapToVisual(const IntRect &rect)
{
return IntRect();
}
void KRenderingDeviceContextQuartz::clearPath()
{
CGContextBeginPath(m_cgContext);
......
......@@ -25,25 +25,29 @@
#include "ksvg.h"
#include "SVGPaint.h"
using namespace WebCore;
namespace WebCore {
SVGPaint::SVGPaint() : SVGColor()
SVGPaint::SVGPaint()
: SVGColor()
{
m_paintType = SVG_PAINTTYPE_UNKNOWN;
}
SVGPaint::SVGPaint(StringImpl *uri) : SVGColor()
SVGPaint::SVGPaint(StringImpl *uri)
: SVGColor()
{
m_paintType = SVG_PAINTTYPE_URI;
setUri(uri);
}
SVGPaint::SVGPaint(unsigned short paintType) : SVGColor()
SVGPaint::SVGPaint(unsigned short paintType)
: SVGColor()
{
m_paintType = paintType;
}
SVGPaint::SVGPaint(unsigned short paintType, StringImpl *uri, StringImpl *rgbPaint, StringImpl *) : SVGColor(rgbPaint)
SVGPaint::SVGPaint(unsigned short paintType, StringImpl *uri, StringImpl *rgbPaint, StringImpl *)
: SVGColor(rgbPaint)
{
m_paintType = paintType;
setUri(uri);
......@@ -90,6 +94,8 @@ String SVGPaint::cssText() const
return SVGColor::cssText();
}
}
// vim:ts=4:noet
#endif // SVG_SUPPORT
......@@ -247,16 +247,19 @@ void SVGSVGElement::parseMappedAttribute(MappedAttribute *attr)
} else if (attr->name() == SVGNames::heightAttr) {
height()->baseVal()->setValueAsString(value.impl());
addCSSProperty(attr, CSS_PROP_HEIGHT, value);
} else
{
if(SVGTests::parseMappedAttribute(attr)) return;
if(SVGLangSpace::parseMappedAttribute(attr)) return;
if(SVGExternalResourcesRequired::parseMappedAttribute(attr)) return;
} else {
if (SVGTests::parseMappedAttribute(attr))
return;
if (SVGLangSpace::parseMappedAttribute(attr))
return;
if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
return;
if (SVGFitToViewBox::parseMappedAttribute(attr)) {
if (renderer())
static_cast<RenderSVGContainer*>(renderer())->setViewBox(FloatRect(viewBox()->baseVal()->x(), viewBox()->baseVal()->y(), viewBox()->baseVal()->width(), viewBox()->baseVal()->height()));
}
if(SVGZoomAndPan::parseMappedAttribute(attr)) return;
if (SVGZoomAndPan::parseMappedAttribute(attr))
return;
SVGStyledLocatableElement::parseMappedAttribute(attr);
}
......
......@@ -54,6 +54,7 @@ namespace WebCore {
const int cMisspellingLinePatternWidth = 4;
const int cMisspellingLinePatternGapWidth = 1;
class AffineTransform;
class DeprecatedString;
class Font;
class GraphicsContextPrivate;
......@@ -155,6 +156,8 @@ namespace WebCore {
void scale(const FloatSize&);
void rotate(float angleInRadians);
void translate(const FloatSize&);
void concatCTM(const AffineTransform&);
#ifdef SVG_SUPPORT
KRenderingDeviceContext* createRenderingDeviceContext();
......
......@@ -26,6 +26,7 @@
#include "config.h"
#include "GraphicsContext.h"
#include "AffineTransform.h"
#include "KRenderingDeviceQuartz.h"
#include "Path.h"
......@@ -634,6 +635,13 @@ void GraphicsContext::translate(const FloatSize& size)
CGContextTranslateCTM(platformContext(), size.width(), size.height());
}
void GraphicsContext::concatCTM(const AffineTransform& transform)
{
if (paintingDisabled())
return;
CGContextConcatCTM(platformContext(), transform);
}
FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect)
{
// It is not enough just to round to pixels in device space. The rotation part of the
......
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