Commit e4b1e1c5 authored by eseidel's avatar eseidel

Bug #: 4462

Submitted by: kimmo
Reviewed by: eseidel
	Changed use of QRect to QRectF in the points where SVG can have
	fractional numbers
        http://bugzilla.opendarwin.org/show_bug.cgi?id=4462

        Added test cases:
	* svg/custom/fractional-rects.svg: copy of rounded-rects.svg with
	fractional coordinates.

        * WebCore.xcodeproj/project.pbxproj:
        * kwq/KWQWMatrix.h:
        * kwq/KWQWMatrix.mm:
        (QWMatrix::mapRect): mapRect for QRectF
        * kwq/KWQRectF.h:
        * kwq/KWQRectF.mm:  Added. QRectF impl
        * kwq/KWQSizeF.h:
        * kwq/KWQSizeF.mm:  Added.QSizeF impl
        * kwq/KWQPointF.h:
        * kwq/KWQPointF.mm: Added. QPointF impl
        * kcanvas/KCanvasContainer.cpp:
        (KCanvasContainer::fillContains):
        (KCanvasContainer::strokeContains):
        (KCanvasContainer::relativeBBox):
        (KCanvasContainer::getAspectRatio): QRect -> QRectF
        * kcanvas/KCanvasContainer.h:
        * kcanvas/KCanvasFilters.cpp:
        (KCanvasFilterEffect::subRegion):
        (KCanvasFilterEffect::setSubRegion): QRect -> QRectF
        * kcanvas/KCanvasFilters.h:
        (KCanvasFilter::filterRect):
        (KCanvasFilter::setFilterRect):	QRect -> QRectF
        (KCanvasFEConvolveMatrix::kernelSize):
        (KCanvasFEConvolveMatrix::setKernelSize):
        (KCanvasFEConvolveMatrix::targetOffset):
        (KCanvasFEConvolveMatrix::setTargetOffset): QSize -> QSizeF
        * kcanvas/KCanvasItem.cpp:
        (RenderPath::fillContains):
        (RenderPath::strokeContains):
        (RenderPath::relativeBBox): QRect -> QRectF
        * kcanvas/KCanvasItem.h:
        * kcanvas/KCanvasResources.cpp:
        (KCanvasMarker::draw): QRect -> QRectF
        * kcanvas/KCanvasResources.h:
        * kcanvas/KCanvasTreeDebug.cpp:
        (hasFractions): helper function
        (operator<<): QSizeF operator, QRectF operator
        * kcanvas/KCanvasTreeDebug.h:
        * kcanvas/device/KRenderingPaintServerGradient.cpp:
        (KRenderingPaintServerLinearGradient::gradientStart):
        (KRenderingPaintServerLinearGradient::setGradientStart):
        (KRenderingPaintServerLinearGradient::gradientEnd):
        (KRenderingPaintServerLinearGradient::setGradientEnd):
        (KRenderingPaintServerRadialGradient::gradientCenter):
        (KRenderingPaintServerRadialGradient::setGradientCenter):
        (KRenderingPaintServerRadialGradient::gradientFocal):
        (KRenderingPaintServerRadialGradient::setGradientFocal): QPoint -> QPointF
        * kcanvas/device/KRenderingPaintServerGradient.h:
        * kcanvas/device/KRenderingPaintServerPattern.cpp:
        (KRenderingPaintServerPattern::Private::Private): x, y, width, height -> QRectF
        (KRenderingPaintServerPattern::setBbox): replaced get/set methods
        (KRenderingPaintServerPattern::bbox): replaced get/set methods
        (KRenderingPaintServerPattern::externalRepresentation):
        * kcanvas/device/KRenderingPaintServerPattern.h:
        * kcanvas/device/quartz/KCanvasFilterQuartz.h:
        * kcanvas/device/quartz/KCanvasFilterQuartz.mm:
        (KCanvasFilterQuartz::prepareFilter):
        (KCanvasFilterQuartz::applyFilter): QRect -> QRectF
        * kcanvas/device/quartz/KCanvasItemQuartz.h:
        (KCanvasItemQuartz::getAbsoluteRepaintRect): QRect -> QRectF
        * kcanvas/device/quartz/KCanvasItemQuartz.mm:
        (drawMarkerWithData):
        (KCanvasItemQuartz::drawMarkersIfNeeded):
        (KCanvasItemQuartz::paint): QRect -> QRectF
        (KCanvasItemQuartz::nodeAtPoint): QPoint -> QPointF
        (KCanvasItemQuartz::bboxForPath) :QRect -> QRectF
        (KCanvasItemQuartz::hitsPath):
        * kcanvas/device/quartz/KCanvasResourcesQuartz.h:
        (KCanvasContainerQuartz::getAbsoluteRepaintRect): QRect -> QRectF
        * kcanvas/device/quartz/KRenderingPaintServerQuartz.mm:
        (KRenderingPaintServerPatternQuartz::draw): QRect -> QRectF
        * khtml/rendering/render_object.h:
        (khtml::RenderObject::relativeBBox):QRect -> QRectF
        * ksvg2/svg/SVGFilterElementImpl.cpp:
        (SVGFilterElementImpl::canvasResource): QRect -> QRectF
        * ksvg2/svg/SVGFilterPrimitiveStandardAttributesImpl.cpp:
        (SVGFilterPrimitiveStandardAttributesImpl::setStandardAttributes):
        * ksvg2/svg/SVGLengthImpl.cpp:
        (SVGLengthImpl::value): QRect -> QRectF
        * ksvg2/svg/SVGLinearGradientElementImpl.cpp:
        (SVGLinearGradientElementImpl::buildGradient): QPoint -> QPointF, removed integer conversions
        * ksvg2/svg/SVGLocatableImpl.cpp:
        (SVGLocatableImpl::getBBox): Rect -> QRectF
        * ksvg2/svg/SVGPatternElementImpl.cpp:
        (SVGPatternElementImpl::drawPatternContentIntoTile): QRect -> QRectF
        * ksvg2/svg/SVGRadialGradientElementImpl.cpp:
        (SVGRadialGradientElementImpl::buildGradient): QPoint -> QPointF, removed integer conversions
        * ksvg2/svg/SVGSVGElementImpl.cpp:
        (SVGSVGElementImpl::checkIntersection): QRect -> QRectF, removed integer conversions
        (SVGSVGElementImpl::checkEnclosure): QRect -> QRectF, removed integer conversions


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@11870 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1011d862
2005-12-30 Kimmo Kinnunen <kimmo.kinnunen@nokia.com>
Reviewed by eseidel.
Changed use of QRect to QRectF in the points where SVG can have
fractional numbers
http://bugzilla.opendarwin.org/show_bug.cgi?id=4462
Added test cases:
* svg/custom/fractional-rects.svg: copy of rounded-rects.svg with
fractional coordinates.
* WebCore.xcodeproj/project.pbxproj:
* kwq/KWQWMatrix.h:
* kwq/KWQWMatrix.mm:
(QWMatrix::mapRect): mapRect for QRectF
* kwq/KWQRectF.h:
* kwq/KWQRectF.mm: Added. QRectF impl
* kwq/KWQSizeF.h:
* kwq/KWQSizeF.mm: Added.QSizeF impl
* kwq/KWQPointF.h:
* kwq/KWQPointF.mm: Added. QPointF impl
* kcanvas/KCanvasContainer.cpp:
(KCanvasContainer::fillContains):
(KCanvasContainer::strokeContains):
(KCanvasContainer::relativeBBox):
(KCanvasContainer::getAspectRatio): QRect -> QRectF
* kcanvas/KCanvasContainer.h:
* kcanvas/KCanvasFilters.cpp:
(KCanvasFilterEffect::subRegion):
(KCanvasFilterEffect::setSubRegion): QRect -> QRectF
* kcanvas/KCanvasFilters.h:
(KCanvasFilter::filterRect):
(KCanvasFilter::setFilterRect): QRect -> QRectF
(KCanvasFEConvolveMatrix::kernelSize):
(KCanvasFEConvolveMatrix::setKernelSize):
(KCanvasFEConvolveMatrix::targetOffset):
(KCanvasFEConvolveMatrix::setTargetOffset): QSize -> QSizeF
* kcanvas/KCanvasItem.cpp:
(RenderPath::fillContains):
(RenderPath::strokeContains):
(RenderPath::relativeBBox): QRect -> QRectF
* kcanvas/KCanvasItem.h:
* kcanvas/KCanvasResources.cpp:
(KCanvasMarker::draw): QRect -> QRectF
* kcanvas/KCanvasResources.h:
* kcanvas/KCanvasTreeDebug.cpp:
(hasFractions): helper function
(operator<<): QSizeF operator, QRectF operator
* kcanvas/KCanvasTreeDebug.h:
* kcanvas/device/KRenderingPaintServerGradient.cpp:
(KRenderingPaintServerLinearGradient::gradientStart):
(KRenderingPaintServerLinearGradient::setGradientStart):
(KRenderingPaintServerLinearGradient::gradientEnd):
(KRenderingPaintServerLinearGradient::setGradientEnd):
(KRenderingPaintServerRadialGradient::gradientCenter):
(KRenderingPaintServerRadialGradient::setGradientCenter):
(KRenderingPaintServerRadialGradient::gradientFocal):
(KRenderingPaintServerRadialGradient::setGradientFocal): QPoint -> QPointF
* kcanvas/device/KRenderingPaintServerGradient.h:
* kcanvas/device/KRenderingPaintServerPattern.cpp:
(KRenderingPaintServerPattern::Private::Private): x, y, width, height -> QRectF
(KRenderingPaintServerPattern::setBbox): replaced get/set methods
(KRenderingPaintServerPattern::bbox): replaced get/set methods
(KRenderingPaintServerPattern::externalRepresentation):
* kcanvas/device/KRenderingPaintServerPattern.h:
* kcanvas/device/quartz/KCanvasFilterQuartz.h:
* kcanvas/device/quartz/KCanvasFilterQuartz.mm:
(KCanvasFilterQuartz::prepareFilter):
(KCanvasFilterQuartz::applyFilter): QRect -> QRectF
* kcanvas/device/quartz/KCanvasItemQuartz.h:
(KCanvasItemQuartz::getAbsoluteRepaintRect): QRect -> QRectF
* kcanvas/device/quartz/KCanvasItemQuartz.mm:
(drawMarkerWithData):
(KCanvasItemQuartz::drawMarkersIfNeeded):
(KCanvasItemQuartz::paint): QRect -> QRectF
(KCanvasItemQuartz::nodeAtPoint): QPoint -> QPointF
(KCanvasItemQuartz::bboxForPath) :QRect -> QRectF
(KCanvasItemQuartz::hitsPath):
* kcanvas/device/quartz/KCanvasResourcesQuartz.h:
(KCanvasContainerQuartz::getAbsoluteRepaintRect): QRect -> QRectF
* kcanvas/device/quartz/KRenderingPaintServerQuartz.mm:
(KRenderingPaintServerPatternQuartz::draw): QRect -> QRectF
* khtml/rendering/render_object.h:
(khtml::RenderObject::relativeBBox):QRect -> QRectF
* ksvg2/svg/SVGFilterElementImpl.cpp:
(SVGFilterElementImpl::canvasResource): QRect -> QRectF
* ksvg2/svg/SVGFilterPrimitiveStandardAttributesImpl.cpp:
(SVGFilterPrimitiveStandardAttributesImpl::setStandardAttributes):
* ksvg2/svg/SVGLengthImpl.cpp:
(SVGLengthImpl::value): QRect -> QRectF
* ksvg2/svg/SVGLinearGradientElementImpl.cpp:
(SVGLinearGradientElementImpl::buildGradient): QPoint -> QPointF, removed integer conversions
* ksvg2/svg/SVGLocatableImpl.cpp:
(SVGLocatableImpl::getBBox): Rect -> QRectF
* ksvg2/svg/SVGPatternElementImpl.cpp:
(SVGPatternElementImpl::drawPatternContentIntoTile): QRect -> QRectF
* ksvg2/svg/SVGRadialGradientElementImpl.cpp:
(SVGRadialGradientElementImpl::buildGradient): QPoint -> QPointF, removed integer conversions
* ksvg2/svg/SVGSVGElementImpl.cpp:
(SVGSVGElementImpl::checkIntersection): QRect -> QRectF, removed integer conversions
(SVGSVGElementImpl::checkEnclosure): QRect -> QRectF, removed integer conversions
2006-01-03 Maciej Stachowiak <mjs@apple.com>
Reviewed by Vicki.
......
......@@ -9,6 +9,13 @@
/* Begin PBXBuildFile section */
1A69D381085627410009880D /* domparser.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A69D37F085627410009880D /* domparser.h */; };
1A69D382085627410009880D /* domparser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A69D380085627410009880D /* domparser.cpp */; };
4756536509652C5D00BD9F29 /* KWQPointF.h in Headers */ = {isa = PBXBuildFile; fileRef = 4756535F09652C5D00BD9F29 /* KWQPointF.h */; };
4756536609652C5D00BD9F29 /* KWQPointF.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4756536009652C5D00BD9F29 /* KWQPointF.mm */; };
4756536709652C5D00BD9F29 /* KWQRectF.h in Headers */ = {isa = PBXBuildFile; fileRef = 4756536109652C5D00BD9F29 /* KWQRectF.h */; };
4756536809652C5D00BD9F29 /* KWQRectF.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4756536209652C5D00BD9F29 /* KWQRectF.mm */; };
4756536909652C5D00BD9F29 /* KWQSizeF.h in Headers */ = {isa = PBXBuildFile; fileRef = 4756536309652C5D00BD9F29 /* KWQSizeF.h */; };
4756536A09652C5D00BD9F29 /* KWQSizeF.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4756536409652C5D00BD9F29 /* KWQSizeF.mm */; };
475658CB096A728100BD9F29 /* KCanvasHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 475658CA096A728100BD9F29 /* KCanvasHelper.h */; };
550A0BC9085F6039007353D6 /* dom_qname.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* dom_qname.cpp */; };
550A0BCA085F6039007353D6 /* dom_qname.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* dom_qname.h */; };
550A0BCD085F604D007353D6 /* htmlnames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BCB085F604D007353D6 /* htmlnames.cpp */; };
......@@ -1620,6 +1627,13 @@
1A69D380085627410009880D /* domparser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = domparser.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
2D90660B0665D937006B6F1A /* KWQClipboard.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KWQClipboard.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
2D90660C0665D937006B6F1A /* KWQClipboard.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KWQClipboard.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
4756535F09652C5D00BD9F29 /* KWQPointF.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = KWQPointF.h; sourceTree = "<group>"; };
4756536009652C5D00BD9F29 /* KWQPointF.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = KWQPointF.mm; sourceTree = "<group>"; };
4756536109652C5D00BD9F29 /* KWQRectF.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = KWQRectF.h; sourceTree = "<group>"; };
4756536209652C5D00BD9F29 /* KWQRectF.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = KWQRectF.mm; sourceTree = "<group>"; };
4756536309652C5D00BD9F29 /* KWQSizeF.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = KWQSizeF.h; sourceTree = "<group>"; };
4756536409652C5D00BD9F29 /* KWQSizeF.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = KWQSizeF.mm; sourceTree = "<group>"; };
475658CA096A728100BD9F29 /* KCanvasHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasHelper.h; sourceTree = "<group>"; };
4758C44308C5F217009BAF05 /* KCanvasPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KCanvasPath.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
51111AC007BD812C00B7162C /* DOMUtility.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMUtility.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
5150C2A10702629000AF642C /* WebDashboardRegion.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebDashboardRegion.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
......@@ -3355,6 +3369,7 @@
A8C0FB8A089701F800BA5114 /* KCanvasResources.cpp */,
A8C0FB8B089701F800BA5114 /* KCanvasResources.h */,
A8C0FB8C089701F800BA5114 /* KCanvasTypes.h */,
475658CA096A728100BD9F29 /* KCanvasHelper.h */,
A810E39308A4160F00333D98 /* KCanvasTreeDebug.h */,
A810E39408A4160F00333D98 /* KCanvasTreeDebug.cpp */,
);
......@@ -4172,6 +4187,12 @@
F58786BA02DE3B8601EA4122 /* KWQStringList.h */,
F587853202DE375901EA4122 /* KWQStringList.mm */,
F58786BB02DE3B8601EA4122 /* KWQStyle.h */,
4756535F09652C5D00BD9F29 /* KWQPointF.h */,
4756536009652C5D00BD9F29 /* KWQPointF.mm */,
4756536109652C5D00BD9F29 /* KWQRectF.h */,
4756536209652C5D00BD9F29 /* KWQRectF.mm */,
4756536309652C5D00BD9F29 /* KWQSizeF.h */,
4756536409652C5D00BD9F29 /* KWQSizeF.mm */,
F57B0EE002EBC78B018635CA /* KWQStyle.mm */,
F58786BC02DE3B8601EA4122 /* KWQStyleSheet.h */,
F58786BD02DE3B8601EA4122 /* KWQTextCodec.h */,
......@@ -4698,6 +4719,10 @@
A88AD5180952499F001DD196 /* RGBColorImpl.h in Headers */,
A88AD5190952499F001DD196 /* KDOMHeaders.h in Headers */,
A88AD51A0952499F001DD196 /* KDOMSettings.h in Headers */,
4756536509652C5D00BD9F29 /* KWQPointF.h in Headers */,
4756536709652C5D00BD9F29 /* KWQRectF.h in Headers */,
4756536909652C5D00BD9F29 /* KWQSizeF.h in Headers */,
475658CB096A728100BD9F29 /* KCanvasHelper.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -6536,6 +6561,9 @@
A88AD51D0952499F001DD196 /* XLinkNamesWrapper.cpp in Sources */,
A88AD51E0952499F001DD196 /* SVGNamesWrapper.cpp in Sources */,
A88AD5AA09525131001DD196 /* SVGCSSStyleSelector.cpp in Sources */,
4756536609652C5D00BD9F29 /* KWQPointF.mm in Sources */,
4756536809652C5D00BD9F29 /* KWQRectF.mm in Sources */,
4756536A09652C5D00BD9F29 /* KWQSizeF.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -68,7 +68,7 @@ void KCanvasContainer::setLocalTransform(const QMatrix &matrix)
d->matrix = matrix;
}
bool KCanvasContainer::fillContains(const QPoint &p) const
bool KCanvasContainer::fillContains(const QPointF &p) const
{
khtml::RenderObject *current = firstChild();
for(; current != 0; current = current->nextSibling())
......@@ -80,7 +80,7 @@ bool KCanvasContainer::fillContains(const QPoint &p) const
return false;
}
bool KCanvasContainer::strokeContains(const QPoint &p) const
bool KCanvasContainer::strokeContains(const QPointF &p) const
{
khtml::RenderObject *current = firstChild();
for(; current != 0; current = current->nextSibling())
......@@ -92,14 +92,14 @@ bool KCanvasContainer::strokeContains(const QPoint &p) const
return false;
}
QRect KCanvasContainer::relativeBBox(bool includeStroke) const
QRectF KCanvasContainer::relativeBBox(bool includeStroke) const
{
QRect rect(0,0,0,0);
QRectF rect;
khtml::RenderObject *current = firstChild();
for(; current != 0; current = current->nextSibling()) {
QRect childBBox = current->relativeBBox(includeStroke);
QRect mappedBBox = current->localTransform().mapRect(childBBox);
QRectF childBBox = current->relativeBBox(includeStroke);
QRectF mappedBBox = current->localTransform().mapRect(childBBox);
rect = rect.unite(mappedBBox);
}
......@@ -116,7 +116,7 @@ bool KCanvasContainer::slice() const
return d->slice;
}
KCanvasMatrix KCanvasContainer::getAspectRatio(const QRect logical, const QRect physical) const
KCanvasMatrix KCanvasContainer::getAspectRatio(const QRectF logical, const QRectF physical) const
{
KCanvasMatrix temp;
......
......@@ -59,18 +59,18 @@ public:
virtual bool isKCanvasContainer() const { return true; }
virtual const char *renderName() const { return "KCanvasContainer"; }
virtual bool fillContains(const QPoint &p) const;
virtual bool strokeContains(const QPoint &p) const;
virtual QRect relativeBBox(bool includeStroke = true) const;
virtual bool fillContains(const QPointF &p) const;
virtual bool strokeContains(const QPointF &p) const;
virtual QRectF relativeBBox(bool includeStroke = true) const;
virtual QMatrix localTransform() const;
virtual void setLocalTransform(const QMatrix &matrix);
virtual void setViewport(const QRect &viewport) = 0;
virtual QRect viewport() const = 0;
virtual void setViewport(const QRectF& viewport) = 0;
virtual QRectF viewport() const = 0;
virtual void setViewBox(const QRect &viewBox) = 0;
virtual QRect viewBox() const = 0;
virtual void setViewBox(const QRectF& viewBox) = 0;
virtual QRectF viewBox() const = 0;
virtual void setAlign(KCAlign align) = 0;
virtual KCAlign align() const = 0;
......@@ -79,7 +79,7 @@ public:
bool slice() const;
protected:
KCanvasMatrix getAspectRatio(const QRect logical, const QRect physical) const;
KCanvasMatrix getAspectRatio(const QRectF logical, const QRectF physical) const;
private:
class Private;
......
......@@ -71,12 +71,12 @@ QTextStream &operator<<(QTextStream &ts, const KCanvasFilterEffect &e)
return e.externalRepresentation(ts);
}
QRect KCanvasFilterEffect::subRegion() const
QRectF KCanvasFilterEffect::subRegion() const
{
return m_subregion;
}
void KCanvasFilterEffect::setSubRegion(const QRect &subregion)
void KCanvasFilterEffect::setSubRegion(const QRectF &subregion)
{
m_subregion = subregion;
}
......@@ -142,12 +142,6 @@ QTextStream &KCDistantLightSource::externalRepresentation(QTextStream &ts) const
return ts;
}
static QTextStream &operator<<(QTextStream &ts, QPointF p)
{
ts << "x=" << p.x() << " y=" << p.y();
return ts;
}
static QTextStream &operator<<(QTextStream &ts, KCBlendModeType t)
{
switch (t)
......@@ -266,12 +260,6 @@ static QTextStream &operator<<(QTextStream &ts, KCEdgeModeType t)
return ts;
}
static QTextStream &operator<<(QTextStream &ts, QSize s)
{
ts << "x=" << s.width() << " y=" << s.height();
return ts;
}
QTextStream &KCanvasFEConvolveMatrix::externalRepresentation(QTextStream &ts) const
{
ts << "[type=CONVOLVE-MATRIX] ";
......
......@@ -25,7 +25,7 @@
#define KCanvasFilters_H
#include "KCanvasResources.h"
#include <QSizeF>
// Enumerations
typedef enum
{
......@@ -75,41 +75,6 @@ private:
float m_z;
};
// FIXME: QPointF and QSizeF will be removed from this file when
// http://bugzilla.opendarwin.org/show_bug.cgi?id=4462 is resolved.
class QPointF {
public:
QPointF(float x, float y) : m_x(x), m_y(y) { }
// this constructor is needed for building on gcc 3.3
QPointF() { }
float x() const { return m_x; }
void setX(float x) { m_x = x; }
float y() const { return m_y; }
void setY(float y) { m_y = y; }
private:
float m_x;
float m_y;
};
class QSizeF {
public:
QSizeF(float w, float h) : m_width(w), m_height(h) { }
float width() const { return m_width; }
void setWidth(float width) { m_width = width; }
float height() const { return m_height; }
void setHeight(float height) { m_height = height; }
private:
float m_width;
float m_height;
};
class KCanvasFilterEffect;
class KRenderingDevice;
......@@ -127,18 +92,18 @@ public:
bool effectBoundingBoxMode() const { return m_effectBBoxMode; }
void setEffectBoundingBoxMode(bool bboxMode) { m_effectBBoxMode = bboxMode; }
QRect filterRect() const { return m_filterRect; }
void setFilterRect(const QRect &rect) { m_filterRect = rect; }
QRectF filterRect() const { return m_filterRect; }
void setFilterRect(const QRectF &rect) { m_filterRect = rect; }
void addFilterEffect(KCanvasFilterEffect *effect);
virtual void prepareFilter(KRenderingDevice *device, const QRect &bbox) = 0;
virtual void applyFilter(KRenderingDevice *device, const QRect &bbox) = 0;
virtual void prepareFilter(KRenderingDevice *device, const QRectF &bbox) = 0;
virtual void applyFilter(KRenderingDevice *device, const QRectF &bbox) = 0;
QTextStream &externalRepresentation(QTextStream &) const;
protected:
QRect m_filterRect;
QRectF m_filterRect;
Q3ValueList<KCanvasFilterEffect *> m_effects;
bool m_filterBBoxMode;
bool m_effectBBoxMode;
......@@ -165,8 +130,8 @@ public:
virtual KCFilterEffectType effectType() const { return FE_TURBULENCE; }
QRect subRegion() const;
void setSubRegion(const QRect &subregion);
QRectF subRegion() const;
void setSubRegion(const QRectF &subregion);
QString in() const;
void setIn(const QString &in);
......@@ -181,7 +146,7 @@ public:
virtual QTextStream &externalRepresentation(QTextStream &) const;
private:
QRect m_subregion;
QRectF m_subregion;
QString m_in;
QString m_result;
};
......@@ -327,8 +292,8 @@ class KCanvasFEConvolveMatrix : public KCanvasFilterEffect
public:
KCanvasFEConvolveMatrix() { };
QSize kernelSize() const { return m_kernelSize; }
void setKernelSize(QSize kernelSize) { m_kernelSize = kernelSize; }
QSizeF kernelSize() const { return m_kernelSize; }
void setKernelSize(QSizeF kernelSize) { m_kernelSize = kernelSize; }
Q3ValueList<float> kernel() const { return m_kernelMatrix; }
void setKernel(Q3ValueList<float> kernel) { m_kernelMatrix = kernel; }
......@@ -339,8 +304,8 @@ public:
float bias() const { return m_bias; }
void setBias(float bias) { m_bias = bias; }
QSize targetOffset() const { return m_targetOffset; }
void setTargetOffset(QSize targetOffset) { m_targetOffset = targetOffset; }
QSizeF targetOffset() const { return m_targetOffset; }
void setTargetOffset(QSizeF targetOffset) { m_targetOffset = targetOffset; }
KCEdgeModeType edgeMode() const { return m_edgeMode; }
void setEdgeMode(KCEdgeModeType edgeMode) { m_edgeMode = edgeMode; }
......@@ -354,11 +319,11 @@ public:
QTextStream &externalRepresentation(QTextStream &) const;
private:
QSize m_kernelSize;
QSizeF m_kernelSize;
Q3ValueList<float> m_kernelMatrix; // maybe should be a real matrix?
float m_divisor;
float m_bias;
QSize m_targetOffset;
QSizeF m_targetOffset;
KCEdgeModeType m_edgeMode;
QPointF m_kernelUnitLength;
bool m_preserveAlpha;
......
......@@ -53,7 +53,7 @@ public:
KSVG::KCanvasRenderingStyle *style;
RefPtr<KCanvasPath> path;
QRect fillBBox, strokeBbox;
QRectF fillBBox, strokeBbox;
QMatrix matrix;
};
......@@ -85,7 +85,7 @@ void RenderPath::setLocalTransform(const QMatrix &matrix)
d->matrix = matrix;
}
bool RenderPath::fillContains(const QPoint &p) const
bool RenderPath::fillContains(const QPointF &p) const
{
if(d->path && d->style)
return hitsPath(p, true);
......@@ -93,7 +93,7 @@ bool RenderPath::fillContains(const QPoint &p) const
return false;
}
bool RenderPath::strokeContains(const QPoint &p) const
bool RenderPath::strokeContains(const QPointF &p) const
{
if(d->path && d->style)
return hitsPath(p, false);
......@@ -101,9 +101,9 @@ bool RenderPath::strokeContains(const QPoint &p) const
return false;
}
QRect RenderPath::relativeBBox(bool includeStroke) const
QRectF RenderPath::relativeBBox(bool includeStroke) const
{
QRect result;
QRectF result;
if (!d->path)
return result;
......
......@@ -28,10 +28,12 @@
#include <qpoint.h>
#include <qrect.h>
#include <q3valuelist.h>
#include <QRectF>
#include <kcanvas/KCanvasTypes.h>
#include "khtml/rendering/render_object.h"
class QPointF;
namespace KSVG {
class SVGStyledElementImpl;
};
......@@ -48,11 +50,11 @@ public:
virtual ~RenderPath();
// Hit-detection seperated for the fill and the stroke
virtual bool fillContains(const QPoint &p) const;
virtual bool strokeContains(const QPoint &p) const;
virtual bool fillContains(const QPointF &p) const;
virtual bool strokeContains(const QPointF &p) const;
// Returns an unscaled bounding box (not even including localTransform()) for this vector path
virtual QRect relativeBBox(bool includeStroke = true) const;
virtual QRectF relativeBBox(bool includeStroke = true) const;
// Drawing
void setupForDraw() const;
......@@ -73,8 +75,8 @@ public:
protected:
// restricted set of args for passing to paint servers, etc.
const KCanvasCommonArgs commonArgs() const;
virtual bool hitsPath(const QPoint &hitPoint, bool fill) const = 0;
virtual QRect bboxForPath(bool includeStroke) const = 0;
virtual bool hitsPath(const QPointF &hitPoint, bool fill) const = 0;
virtual QRectF bboxForPath(bool includeStroke) const = 0;
private:
class Private;
......
......@@ -195,7 +195,7 @@ float KCanvasMarker::scaleY() const
return m_scaleY;
}
void KCanvasMarker::draw(const QRect &rect, double x, double y, double strokeWidth, double angle)
void KCanvasMarker::draw(const QRectF &rect, double x, double y, double strokeWidth, double angle)
{
if(m_marker)
{
......@@ -213,8 +213,9 @@ void KCanvasMarker::draw(const QRect &rect, double x, double y, double strokeWid
rotation.scale(strokeWidth, strokeWidth);
// FIXME: PaintInfo should be passed into this method instead.
// FIXME: bounding box fractions lost
QPainter p;
khtml::RenderObject::PaintInfo info(&p, rect, PaintActionForeground, 0);
khtml::RenderObject::PaintInfo info(&p, enclosingQRect(rect), PaintActionForeground, 0);
m_marker->setLocalTransform(rotation.multiply(translation).qmatrix());
static_cast<KCanvasContainer *>(m_marker)->setDrawsContents(true);
m_marker->paint(info, 0, 0);
......
......@@ -114,7 +114,7 @@ public:
float scaleY() const;
// Draw onto the canvas
void draw(const QRect &rect, double x, double y, double strokeWidth = 1., double angle = 0.0);
void draw(const QRectF &rect, double x, double y, double strokeWidth = 1., double angle = 0.0);
QTextStream& externalRepresentation(QTextStream &) const;
private:
......
......@@ -27,6 +27,7 @@
#include "config.h"
#include "KCanvasTreeDebug.h"
#include <math.h>
#include <kcanvas/KCanvas.h>
#include <kcanvas/KCanvasMatrix.h>
#include <kcanvas/RenderPath.h>
......@@ -56,6 +57,7 @@
#include "htmlnames.h"
#include <qtextstream.h>
#include <QSizeF>
using namespace KSVG;
......@@ -95,6 +97,70 @@ QTextStream &operator<<(QTextStream &ts, const QRect &r)
return ts << "at (" << r.x() << "," << r.y() << ") size " << r.width() << "x" << r.height();
}
bool hasFractions(double val)
{
double epsilon = 0.0001;
int ival = int(val);
double dval = double(ival);
return (fabs(val-dval) > epsilon);
}
QTextStream &operator<<(QTextStream &ts, const QRectF &r)
{
ts << "at (";
if (hasFractions(r.x()))
ts << r.x();
else
ts << int(r.x());
ts << ",";
if (hasFractions(r.y()))
ts << r.y();
else
ts << int(r.y());
ts << ") size ";
if (hasFractions(r.width()))
ts << r.width();
else
ts << int(r.width());
ts << "x";
if (hasFractions(r.height()))
ts << r.height();
else
ts << int(r.height());
return ts;
}
QTextStream &operator<<(QTextStream &ts, const QPointF &p)
{
ts << "(";
if (hasFractions(p.x()))
ts << p.x();
else
ts << int(p.x());
ts << ",";
if (hasFractions(p.y()))
ts << p.y();
else
ts << int(p.y());
return ts << ")";
}
QTextStream &operator<<(QTextStream &ts, const QSizeF &s)
{
ts << "width=";
if (hasFractions(s.width()))
ts << s.width();
else
ts << int(s.width());
ts << " height=";
if (hasFractions(s.height()))
ts << s.height();
else
ts << int(s.height());
return ts;
}
QTextStream &operator<<(QTextStream &ts, const QMatrix &m)
{
if (m.isIdentity())
......