[webkit-changes] cvs commit: WebCore/kwq KWQWMatrix.mm
Eric
eseidel at opensource.apple.com
Wed Nov 23 07:14:11 PST 2005
eseidel 05/11/23 07:14:11
Modified: . ChangeLog
kcanvas KCanvasContainer.cpp KCanvasContainer.h
KCanvasFilters.h KCanvasItem.cpp KCanvasItem.h
KCanvasPath.cpp KCanvasPath.h KCanvasResources.cpp
KCanvasResources.h KCanvasTreeDebug.cpp
kcanvas/device/quartz KCanvasFilterQuartz.h
KCanvasFilterQuartz.mm KCanvasItemQuartz.h
KCanvasItemQuartz.mm KCanvasResourcesQuartz.h
KCanvasResourcesQuartz.mm
KRenderingPaintServerQuartz.mm
khtml/rendering render_object.cpp render_object.h
khtml/xml dom_docimpl.cpp
ksvg2/svg SVGElementImpl.cpp SVGImageElementImpl.cpp
SVGImageElementImpl.h SVGLengthImpl.cpp
SVGLocatableImpl.cpp SVGMarkerElementImpl.cpp
SVGPatternElementImpl.cpp SVGSVGElementImpl.cpp
kwq KWQWMatrix.mm
Log:
Bug #: 4780
Submitted by: eseidel
Reviewed by: mjs
No additional test cases needed, this fixes 15+ existing tests.
This latest set of changes fixes <image> loading (mostly)
(There still seems to be an image loading race condition.)
This also fixes viewBox support (for many tests)
Fixes a Safari crasher when using patterns
Fixes bbox() handling throughout code (for spec conformance)
* kcanvas/KCanvasContainer.cpp:
(KCanvasContainer::Private::Private): renamed drawContents
(KCanvasContainer::drawsContents): renamed drawContents
(KCanvasContainer::setDrawsContents): renamed drawContents
(KCanvasContainer::relativeBBox): renamed bbox(), fixed
* kcanvas/KCanvasContainer.h:
* kcanvas/KCanvasFilters.h:
* kcanvas/KCanvasItem.cpp:
(RenderPath::relativeBBox): renamed bbox()
* kcanvas/KCanvasItem.h:
* kcanvas/KCanvasPath.cpp:
(operator<<): removed deprecated "viewportClip" support
* kcanvas/KCanvasPath.h:
(KCClipDataList::addPath): removed "viewportClip" support
* kcanvas/KCanvasResources.cpp:
(KCanvasClipper::KCanvasClipper): removed "viewportClip" support
(KCanvasClipper::addClipData): removed "viewportClip" support
(KCanvasClipper::externalRepresentation): removed "viewportClip"
* kcanvas/KCanvasResources.h:
* kcanvas/KCanvasTreeDebug.cpp:
(operator<<): removed "viewportClip" support
* kcanvas/device/quartz/KCanvasFilterQuartz.h:
* kcanvas/device/quartz/KCanvasFilterQuartz.mm:
(KCanvasFilterQuartz::prepareFilter): combined, simplified
(KCanvasFilterQuartz::applyFilter): combined, simplified
(KCanvasFilterQuartz::filterBBoxForItemBBox): simplified
* kcanvas/device/quartz/KCanvasItemQuartz.h:
(KCanvasItemQuartz::getAbsoluteRepaintRect): added
* kcanvas/device/quartz/KCanvasItemQuartz.mm:
(KCanvasItemQuartz::paint): updated for bbox() changes
(getSharedContext): simplified
(KCanvasItemQuartz::bboxForPath): name change
(KCanvasItemQuartz::hitsPath): fixed for absoluteTransform()
* kcanvas/device/quartz/KCanvasResourcesQuartz.h:
(KCanvasContainerQuartz::getAbsoluteRepaintRect): added
* kcanvas/device/quartz/KCanvasResourcesQuartz.mm:
(KCanvasContainerQuartz::layout): call RenderContainer::layout()
(KCanvasContainerQuartz::paint): drawsContents() && viewbox()
(KCanvasContainerQuartz::absoluteTransform): added
(KCanvasClipperQuartz::applyClip): simplified
* kcanvas/device/quartz/KRenderingPaintServerQuartz.mm:
(KRenderingPaintServerImageQuartz::draw): added stretch/scale
* khtml/rendering/render_object.cpp: added absoluteTransform()
(RenderObject::absoluteTransform):
* khtml/rendering/render_object.h: added absoluteTransform()
(khtml::RenderObject::relativeBBox): rename
(khtml::RenderObject::localTransform): better default behavior
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::createElementNS): simpler code
* ksvg2/svg/SVGElementImpl.cpp:
(SVGElementImpl::viewportElement): use isElementNode()
* ksvg2/svg/SVGImageElementImpl.cpp: removed finalizeStyle()
(SVGImageElementImpl::attach):
(SVGImageElementImpl::notifyFinished):
* ksvg2/svg/SVGImageElementImpl.h:
* ksvg2/svg/SVGLengthImpl.cpp:
(SVGLengthImpl::value): bbox() rename
* ksvg2/svg/SVGLocatableImpl.cpp:
(SVGLocatableImpl::getBBox): fixed bbox() behavior
* ksvg2/svg/SVGMarkerElementImpl.cpp:
(SVGMarkerElementImpl::createRenderer): drawsContents rename
* ksvg2/svg/SVGPatternElementImpl.cpp:
(SVGPatternElementImpl::drawPatternContentIntoTile): fixed crash
(SVGPatternElementImpl::createRenderer): drawsContents rename
* ksvg2/svg/SVGSVGElementImpl.cpp:
(SVGSVGElementImpl::x): simplified code
(SVGSVGElementImpl::y): simplified code
(SVGSVGElementImpl::width): simplified code
(SVGSVGElementImpl::height): simplified code
(SVGSVGElementImpl::parseMappedAttribute): add width/height to DOM
* kwq/KWQWMatrix.mm:
(QWMatrix::mapRect): simplified code
Revision Changes Path
1.398 +85 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.397
retrieving revision 1.398
diff -u -r1.397 -r1.398
--- ChangeLog 23 Nov 2005 09:46:49 -0000 1.397
+++ ChangeLog 23 Nov 2005 15:14:04 -0000 1.398
@@ -1,3 +1,88 @@
+ 2005-11-23 Eric Seidel <eseidel at apple.com>
+
+ Reviewed by mjs.
+
+ No additional test cases needed, this fixes 15+ existing tests.
+
+ This latest set of changes fixes <image> loading (mostly)
+ (There still seems to be an image loading race condition.)
+ This also fixes viewBox support (for many tests)
+ Fixes a Safari crasher when using patterns
+ Fixes bbox() handling throughout code (for spec conformance)
+
+ * kcanvas/KCanvasContainer.cpp:
+ (KCanvasContainer::Private::Private): renamed drawContents
+ (KCanvasContainer::drawsContents): renamed drawContents
+ (KCanvasContainer::setDrawsContents): renamed drawContents
+ (KCanvasContainer::relativeBBox): renamed bbox(), fixed
+ * kcanvas/KCanvasContainer.h:
+ * kcanvas/KCanvasFilters.h:
+ * kcanvas/KCanvasItem.cpp:
+ (RenderPath::relativeBBox): renamed bbox()
+ * kcanvas/KCanvasItem.h:
+ * kcanvas/KCanvasPath.cpp:
+ (operator<<): removed deprecated "viewportClip" support
+ * kcanvas/KCanvasPath.h:
+ (KCClipDataList::addPath): removed "viewportClip" support
+ * kcanvas/KCanvasResources.cpp:
+ (KCanvasClipper::KCanvasClipper): removed "viewportClip" support
+ (KCanvasClipper::addClipData): removed "viewportClip" support
+ (KCanvasClipper::externalRepresentation): removed "viewportClip"
+ * kcanvas/KCanvasResources.h:
+ * kcanvas/KCanvasTreeDebug.cpp:
+ (operator<<): removed "viewportClip" support
+ * kcanvas/device/quartz/KCanvasFilterQuartz.h:
+ * kcanvas/device/quartz/KCanvasFilterQuartz.mm:
+ (KCanvasFilterQuartz::prepareFilter): combined, simplified
+ (KCanvasFilterQuartz::applyFilter): combined, simplified
+ (KCanvasFilterQuartz::filterBBoxForItemBBox): simplified
+ * kcanvas/device/quartz/KCanvasItemQuartz.h:
+ (KCanvasItemQuartz::getAbsoluteRepaintRect): added
+ * kcanvas/device/quartz/KCanvasItemQuartz.mm:
+ (KCanvasItemQuartz::paint): updated for bbox() changes
+ (getSharedContext): simplified
+ (KCanvasItemQuartz::bboxForPath): name change
+ (KCanvasItemQuartz::hitsPath): fixed for absoluteTransform()
+ * kcanvas/device/quartz/KCanvasResourcesQuartz.h:
+ (KCanvasContainerQuartz::getAbsoluteRepaintRect): added
+ * kcanvas/device/quartz/KCanvasResourcesQuartz.mm:
+ (KCanvasContainerQuartz::layout): call RenderContainer::layout()
+ (KCanvasContainerQuartz::paint): drawsContents() && viewbox()
+ (KCanvasContainerQuartz::absoluteTransform): added
+ (KCanvasClipperQuartz::applyClip): simplified
+ * kcanvas/device/quartz/KRenderingPaintServerQuartz.mm:
+ (KRenderingPaintServerImageQuartz::draw): added stretch/scale
+ * khtml/rendering/render_object.cpp: added absoluteTransform()
+ (RenderObject::absoluteTransform):
+ * khtml/rendering/render_object.h: added absoluteTransform()
+ (khtml::RenderObject::relativeBBox): rename
+ (khtml::RenderObject::localTransform): better default behavior
+ * khtml/xml/dom_docimpl.cpp:
+ (DocumentImpl::createElementNS): simpler code
+ * ksvg2/svg/SVGElementImpl.cpp:
+ (SVGElementImpl::viewportElement): use isElementNode()
+ * ksvg2/svg/SVGImageElementImpl.cpp: removed finalizeStyle()
+ (SVGImageElementImpl::attach):
+ (SVGImageElementImpl::notifyFinished):
+ * ksvg2/svg/SVGImageElementImpl.h:
+ * ksvg2/svg/SVGLengthImpl.cpp:
+ (SVGLengthImpl::value): bbox() rename
+ * ksvg2/svg/SVGLocatableImpl.cpp:
+ (SVGLocatableImpl::getBBox): fixed bbox() behavior
+ * ksvg2/svg/SVGMarkerElementImpl.cpp:
+ (SVGMarkerElementImpl::createRenderer): drawsContents rename
+ * ksvg2/svg/SVGPatternElementImpl.cpp:
+ (SVGPatternElementImpl::drawPatternContentIntoTile): fixed crash
+ (SVGPatternElementImpl::createRenderer): drawsContents rename
+ * ksvg2/svg/SVGSVGElementImpl.cpp:
+ (SVGSVGElementImpl::x): simplified code
+ (SVGSVGElementImpl::y): simplified code
+ (SVGSVGElementImpl::width): simplified code
+ (SVGSVGElementImpl::height): simplified code
+ (SVGSVGElementImpl::parseMappedAttribute): add width/height to DOM
+ * kwq/KWQWMatrix.mm:
+ (QWMatrix::mapRect): simplified code
+
2005-11-23 Anders Carlsson <andersca at mac.com>
Reviewed by Eric.
1.10 +15 -7 SVGSupport/kcanvas/KCanvasContainer.cpp
Index: KCanvasContainer.cpp
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/KCanvasContainer.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- KCanvasContainer.cpp 21 Nov 2005 08:29:11 -0000 1.9
+++ KCanvasContainer.cpp 23 Nov 2005 15:14:05 -0000 1.10
@@ -29,10 +29,10 @@
class KCanvasContainer::Private
{
public:
- Private() : drawContents(true), slice(false) { }
+ Private() : drawsContents(true), slice(false) { }
~Private() { }
- bool drawContents : 1;
+ bool drawsContents : 1;
bool slice : 1;
QMatrix matrix;
};
@@ -47,9 +47,14 @@
delete d;
}
-void KCanvasContainer::setDrawContents(bool drawContents)
+bool KCanvasContainer::drawsContents() const
{
- d->drawContents = drawContents;
+ return d->drawsContents;
+}
+
+void KCanvasContainer::setDrawsContents(bool drawsContents)
+{
+ d->drawsContents = drawsContents;
}
QMatrix KCanvasContainer::localTransform() const
@@ -86,13 +91,16 @@
return false;
}
-QRect KCanvasContainer::bbox(bool includeStroke) const
+QRect KCanvasContainer::relativeBBox(bool includeStroke) const
{
QRect rect(0,0,0,0);
khtml::RenderObject *current = firstChild();
- for(; current != 0; current = current->nextSibling())
- rect = rect.unite(current->bbox(includeStroke));
+ for(; current != 0; current = current->nextSibling()) {
+ QRect childBBox = current->relativeBBox(includeStroke);
+ QRect mappedBBox = current->localTransform().mapRect(childBBox);
+ rect = rect.unite(mappedBBox);
+ }
return rect;
}
1.7 +3 -2 SVGSupport/kcanvas/KCanvasContainer.h
Index: KCanvasContainer.h
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/KCanvasContainer.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- KCanvasContainer.h 21 Nov 2005 08:29:11 -0000 1.6
+++ KCanvasContainer.h 23 Nov 2005 15:14:05 -0000 1.7
@@ -53,14 +53,15 @@
// Some containers do not want it's children
// to be drawn, because they may be 'referenced'
// Example: <marker> children in SVG
- void setDrawContents(bool drawContents);
+ void setDrawsContents(bool drawsContents);
+ bool drawsContents() const;
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 bbox(bool includeStroke = true) const;
+ virtual QRect relativeBBox(bool includeStroke = true) const;
virtual QMatrix localTransform() const;
virtual void setLocalTransform(const QMatrix &matrix);
1.11 +1 -1 SVGSupport/kcanvas/KCanvasFilters.h
Index: KCanvasFilters.h
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/KCanvasFilters.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- KCanvasFilters.h 22 Nov 2005 23:04:27 -0000 1.10
+++ KCanvasFilters.h 23 Nov 2005 15:14:05 -0000 1.11
@@ -76,7 +76,7 @@
void addFilterEffect(KCanvasFilterEffect *effect);
virtual void prepareFilter(KRenderingDevice *device, const QRect &bbox) = 0;
- virtual void applyFilter(KRenderingDevice *device, KCanvasMatrix objectMatrix, const QRect &bbox) = 0;
+ virtual void applyFilter(KRenderingDevice *device, const QRect &bbox) = 0;
QTextStream &externalRepresentation(QTextStream &) const;
1.8 +3 -13 SVGSupport/kcanvas/KCanvasItem.cpp
Index: KCanvasItem.cpp
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/KCanvasItem.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- KCanvasItem.cpp 21 Nov 2005 08:29:11 -0000 1.7
+++ KCanvasItem.cpp 23 Nov 2005 15:14:05 -0000 1.8
@@ -103,7 +103,7 @@
return false;
}
-QRect RenderPath::bbox(bool includeStroke) const
+QRect RenderPath::relativeBBox(bool includeStroke) const
{
QRect result;
@@ -112,27 +112,17 @@
if (includeStroke) {
if(!d->strokeBbox.isValid())
- d->strokeBbox = bboxPath(true);
+ d->strokeBbox = bboxForPath(true);
result = d->strokeBbox;
} else {
if(!d->fillBBox.isValid())
- d->fillBBox = bboxPath(false);
+ d->fillBBox = bboxForPath(false);
result = d->fillBBox;
}
return result;
}
-bool RenderPath::hitsPath(const QPoint &hitPoint, bool fill) const
-{
- return false;
-}
-
-QRect RenderPath::bboxPath(bool includeStroke, bool includeTransforms) const
-{
- return QRect();
-}
-
void RenderPath::setupForDraw() const
{
if(d->path && d->style && canvas() && canvas()->renderingDevice())
1.6 +4 -4 SVGSupport/kcanvas/KCanvasItem.h
Index: KCanvasItem.h
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/KCanvasItem.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- KCanvasItem.h 21 Nov 2005 08:29:11 -0000 1.5
+++ KCanvasItem.h 23 Nov 2005 15:14:05 -0000 1.6
@@ -51,8 +51,8 @@
virtual bool fillContains(const QPoint &p) const;
virtual bool strokeContains(const QPoint &p) const;
- // Returns an unscaled bounding box for this vector path
- virtual QRect bbox(bool includeStroke = true) const;
+ // Returns an unscaled bounding box (not even including localTransform()) for this vector path
+ virtual QRect relativeBBox(bool includeStroke = true) const;
// Drawing
void setupForDraw() const;
@@ -73,8 +73,8 @@
protected:
// restricted set of args for passing to paint servers, etc.
const KCanvasCommonArgs commonArgs() const;
- virtual bool hitsPath(const QPoint &hitPoint, bool fill) const;
- virtual QRect bboxPath(bool includeStroke, bool includeTransforms = true) const;
+ virtual bool hitsPath(const QPoint &hitPoint, bool fill) const = 0;
+ virtual QRect bboxForPath(bool includeStroke) const = 0;
private:
class Private;
1.3 +1 -3 SVGSupport/kcanvas/KCanvasPath.cpp
Index: KCanvasPath.cpp
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/KCanvasPath.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- KCanvasPath.cpp 5 Oct 2005 05:36:45 -0000 1.2
+++ KCanvasPath.cpp 23 Nov 2005 15:14:05 -0000 1.3
@@ -85,9 +85,7 @@
{
ts << "[winding=" << d.rule << "]";
if (d.bbox)
- ts << " [bounding box mode=" << d.bbox << "]";
- if (d.viewportClipped)
- ts << " [viewport clipped=" << d.viewportClipped << "]";
+ ts << " [bounding box mode=" << d.bbox << "]";
ts << " [path=" << d.path << "]";
return ts;
}
1.6 +1 -3 SVGSupport/kcanvas/KCanvasPath.h
Index: KCanvasPath.h
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/KCanvasPath.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- KCanvasPath.h 2 Sep 2005 10:02:56 -0000 1.5
+++ KCanvasPath.h 23 Nov 2005 15:14:05 -0000 1.6
@@ -96,7 +96,6 @@
{
KCWindRule rule : 1;
bool bbox : 1;
- bool viewportClipped : 1;
KCPathDataList path;
};
@@ -107,13 +106,12 @@
public:
KCClipDataList() { }
- inline void addPath(const KCPathDataList &pathData, KCWindRule rule, bool bbox, bool viewportClipped = false)
+ inline void addPath(const KCPathDataList &pathData, KCWindRule rule, bool bbox)
{
KCClipData data;
data.rule = rule;
data.bbox = bbox;
data.path = pathData;
- data.viewportClipped = viewportClipped;
append(data);
}
};
1.10 +1 -14 SVGSupport/kcanvas/KCanvasResources.cpp
Index: KCanvasResources.cpp
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/KCanvasResources.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- KCanvasResources.cpp 22 Nov 2005 10:03:25 -0000 1.9
+++ KCanvasResources.cpp 23 Nov 2005 15:14:05 -0000 1.10
@@ -91,23 +91,12 @@
// KCanvasClipper
KCanvasClipper::KCanvasClipper() : KCanvasResource()
{
- m_viewportMode = false;
}
KCanvasClipper::~KCanvasClipper()
{
}
-bool KCanvasClipper::viewportClipper() const
-{
- return m_viewportMode;
-}
-
-void KCanvasClipper::setViewportClipper(bool viewport)
-{
- m_viewportMode = viewport;
-}
-
void KCanvasClipper::resetClipData()
{
m_clipData.clear();
@@ -115,7 +104,7 @@
void KCanvasClipper::addClipData(const KCPathDataList &path, KCWindRule rule, bool bbox)
{
- m_clipData.addPath(path, rule, bbox, viewportClipper());
+ m_clipData.addPath(path, rule, bbox);
}
KCClipDataList KCanvasClipper::clipData() const
@@ -126,8 +115,6 @@
QTextStream& KCanvasClipper::externalRepresentation(QTextStream &ts) const
{
ts << "[type=CLIPPER]";
- if (viewportClipper())
- ts << " [viewport clipped=" << viewportClipper() << "]";
ts << " [clip data=" << clipData() << "]";
return ts;
}
1.9 +0 -5 SVGSupport/kcanvas/KCanvasResources.h
Index: KCanvasResources.h
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/KCanvasResources.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- KCanvasResources.h 22 Nov 2005 00:09:10 -0000 1.8
+++ KCanvasResources.h 23 Nov 2005 15:14:05 -0000 1.9
@@ -78,10 +78,6 @@
virtual bool isClipper() const { return true; }
- // Differentiate between viewport clipping and normal clipping data...
- bool viewportClipper() const;
- void setViewportClipper(bool viewport);
-
void resetClipData();
void addClipData(const KCPathDataList &path, KCWindRule rule, bool bbox);
@@ -89,7 +85,6 @@
QTextStream& externalRepresentation(QTextStream &) const;
protected:
- bool m_viewportMode : 1;
KCClipDataList m_clipData;
};
1.9 +2 -2 SVGSupport/kcanvas/KCanvasTreeDebug.cpp
Index: KCanvasTreeDebug.cpp
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/KCanvasTreeDebug.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- KCanvasTreeDebug.cpp 21 Nov 2005 08:29:11 -0000 1.8
+++ KCanvasTreeDebug.cpp 23 Nov 2005 15:14:06 -0000 1.9
@@ -247,7 +247,7 @@
static QTextStream &operator<<(QTextStream &ts, const RenderPath &o)
{
- ts << " " << o.bbox();
+ ts << " " << o.relativeBBox();
writeStyle(ts, o);
@@ -258,7 +258,7 @@
static QTextStream &operator<<(QTextStream &ts, const KCanvasContainer &o)
{
- ts << " " << o.bbox();
+ ts << " " << o.relativeBBox();
writeStyle(ts, o);
1.7 +2 -2 SVGSupport/kcanvas/device/quartz/KCanvasFilterQuartz.h
Index: KCanvasFilterQuartz.h
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/device/quartz/KCanvasFilterQuartz.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- KCanvasFilterQuartz.h 22 Nov 2005 23:04:27 -0000 1.6
+++ KCanvasFilterQuartz.h 23 Nov 2005 15:14:07 -0000 1.7
@@ -42,7 +42,7 @@
virtual ~KCanvasFilterQuartz();
virtual void prepareFilter(KRenderingDevice *device, const QRect &bbox);
- virtual void applyFilter(KRenderingDevice *device, KCanvasMatrix objectMatrix, const QRect &bbox);
+ virtual void applyFilter(KRenderingDevice *device, const QRect &bbox);
CIImage *imageForName(const QString &name) const;
void setImageForName(CIImage *image, const QString &name);
@@ -53,7 +53,7 @@
private:
NSArray *getCIFilterStack(CIImage *inputImage);
- CGRect filterBBoxForItemBBox(CGRect itemBBox, CGAffineTransform currentCTM) const;
+ CGRect filterBBoxForItemBBox(CGRect itemBBox) const;
CIContext *m_filterCIContext;
CGLayerRef m_filterCGLayer;
1.14 +9 -16 SVGSupport/kcanvas/device/quartz/KCanvasFilterQuartz.mm
Index: KCanvasFilterQuartz.mm
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/device/quartz/KCanvasFilterQuartz.mm,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- KCanvasFilterQuartz.mm 22 Nov 2005 23:04:27 -0000 1.13
+++ KCanvasFilterQuartz.mm 23 Nov 2005 15:14:07 -0000 1.14
@@ -60,7 +60,7 @@
void KCanvasFilterQuartz::prepareFilter(KRenderingDevice *device, const QRect &bbox)
{
- if (! bbox.isValid() || !KRenderingDeviceQuartz::filtersEnabled())
+ if (!bbox.isValid() || !KRenderingDeviceQuartz::filtersEnabled())
return;
if (m_effects.isEmpty()) {
@@ -88,9 +88,9 @@
CGContextConcatCTM(filterCGContext, CGAffineTransformMakeTranslation(float(-1 * bbox.x()), float(-1 * bbox.y())));
}
-void KCanvasFilterQuartz::applyFilter(KRenderingDevice *device, KCanvasMatrix objectMatrix, const QRect &bbox)
+void KCanvasFilterQuartz::applyFilter(KRenderingDevice *device, const QRect &bbox)
{
- if (! bbox.isValid() || !KRenderingDeviceQuartz::filtersEnabled() || m_effects.isEmpty())
+ if (!bbox.isValid() || !KRenderingDeviceQuartz::filtersEnabled() || m_effects.isEmpty())
return;
// restore the previous context.
@@ -108,7 +108,7 @@
// actually draw the result to the original context
- CGRect filterRect = filterBBoxForItemBBox(CGRect(bbox), CGAffineTransform(objectMatrix.qmatrix()));
+ CGRect filterRect = filterBBoxForItemBBox(CGRect(bbox));
CGRect translated = filterRect;
CGPoint bboxOrigin = CGRect(bbox).origin;
CGRect sourceRect = CGRectIntersection(translated,[outputImage extent]);
@@ -125,22 +125,15 @@
[m_filterCIContext release];
}
-CGRect KCanvasFilterQuartz::filterBBoxForItemBBox(CGRect itemBBox, CGAffineTransform currentCTM) const
+CGRect KCanvasFilterQuartz::filterBBoxForItemBBox(CGRect itemBBox) const
{
// FIXME: hack for now
CGRect filterBBox = CGRect(filterRect());
if(filterBoundingBoxMode())
- {
- //NSLog(@"relative bbox: %@", NSStringFromRect(*(NSRect *)&filterBBox));
- filterBBox =
- CGRectMake((filterBBox.origin.x/100.f * itemBBox.size.width),
- (filterBBox.origin.y/100.f * itemBBox.size.height),
- (filterBBox.size.width/100.f * itemBBox.size.width),
- (filterBBox.size.height/100.f * itemBBox.size.height));
- //NSLog(@"scaled bbox: %@", NSStringFromRect(*(NSRect *)&filterBBox));
- } else {
- //filterBBox = CGRectApplyAffineTransform(filterBBox, currentCTM);
- }
+ filterBBox = CGRectMake((filterBBox.origin.x/100.f * itemBBox.size.width),
+ (filterBBox.origin.y/100.f * itemBBox.size.height),
+ (filterBBox.size.width/100.f * itemBBox.size.width),
+ (filterBBox.size.height/100.f * itemBBox.size.height));
return filterBBox;
}
1.4 +3 -1 SVGSupport/kcanvas/device/quartz/KCanvasItemQuartz.h
Index: KCanvasItemQuartz.h
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/device/quartz/KCanvasItemQuartz.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- KCanvasItemQuartz.h 21 Nov 2005 08:29:15 -0000 1.3
+++ KCanvasItemQuartz.h 23 Nov 2005 15:14:07 -0000 1.4
@@ -31,9 +31,11 @@
KCanvasItemQuartz(khtml::RenderStyle *style, KSVG::SVGStyledElementImpl *node);
virtual ~KCanvasItemQuartz() { }
- virtual QRect bboxPath(bool includeStroke, bool applyTransforms = true) const;
+ virtual QRect bboxForPath(bool includeStroke) const;
virtual bool hitsPath(const QPoint &p, bool fill /* false means stroke */) const;
+ virtual QRect getAbsoluteRepaintRect() { return absoluteTransform().mapRect(relativeBBox(true)); }
+
virtual bool requiresLayer() { return false; }
virtual void layout() { setNeedsLayout(false); }
virtual void paint(PaintInfo &paintInfo, int parentX, int parentY);
1.9 +64 -81 SVGSupport/kcanvas/device/quartz/KCanvasItemQuartz.mm
Index: KCanvasItemQuartz.mm
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/device/quartz/KCanvasItemQuartz.mm,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- KCanvasItemQuartz.mm 22 Nov 2005 23:04:27 -0000 1.8
+++ KCanvasItemQuartz.mm 23 Nov 2005 15:14:07 -0000 1.9
@@ -88,18 +88,15 @@
// setup to apply filters
KCanvasFilter *filter = getFilterById(document(), style()->svgStyle()->filter().mid(1));
- QRect bboxForFilter;
if (filter) {
- // FIXME:: This should be fixed now that it has moved into RenderPath::draw()
- bboxForFilter = bboxPath(true, false); // FIXME: HACK! 30% of my time spent here!
- filter->prepareFilter(quartzDevice, bboxForFilter);
+ filter->prepareFilter(quartzDevice, relativeBBox(true));
context = quartzDevice->currentCGContext();
}
QString clipname = style()->svgStyle()->clipPath().mid(1);
KCanvasClipperQuartz *clipper = static_cast<KCanvasClipperQuartz *>(getClipperById(document(), clipname));
if (clipper)
- clipper->applyClip(context, bbox(true));
+ clipper->applyClip(context, CGRect(relativeBBox(true)));
CGContextBeginPath(context);
@@ -119,7 +116,7 @@
// actually apply the filter
if (filter) {
- filter->applyFilter(quartzDevice, localTransform(), bboxForFilter);
+ filter->applyFilter(quartzDevice, relativeBBox(true));
context = quartzDevice->currentCGContext();
}
@@ -145,90 +142,76 @@
return false;
}
-CGContextRef getSharedContext() {
- static CGContextRef sharedContext = NULL;
- if (!sharedContext) {
- CFMutableDataRef empty = CFDataCreateMutable(NULL, 0);
- CGDataConsumerRef consumer = CGDataConsumerCreateWithCFData(empty);
- sharedContext = CGPDFContextCreate(consumer, NULL, NULL);
+CGContextRef getSharedContext()
+{
+ static CGContextRef sharedContext = NULL;
+ if (!sharedContext) {
+ CFMutableDataRef empty = CFDataCreateMutable(NULL, 0);
+ CGDataConsumerRef consumer = CGDataConsumerCreateWithCFData(empty);
+ sharedContext = CGPDFContextCreate(consumer, NULL, NULL);
CGDataConsumerRelease(consumer);
CFRelease(empty);
- // CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
- // CGContextRef context = CGGLContextCreate(NULL, CGSizeMake(canvas->canvasWidth(), canvas->canvasHeight()), colorspace);
- // CGColorSpaceRelease(colorspace);
- float black[4] = {0,0,0,1};
- CGContextSetFillColor(sharedContext,black);
- CGContextSetStrokeColor(sharedContext,black);
- }
- return sharedContext;
+ float black[4] = {0,0,0,1};
+ CGContextSetFillColor(sharedContext,black);
+ CGContextSetStrokeColor(sharedContext,black);
+ }
+ return sharedContext;
}
-QRect KCanvasItemQuartz::bboxPath(bool includeStroke, bool applyTransforms) const
+QRect KCanvasItemQuartz::bboxForPath(bool includeStroke) const
{
- KCanvasQuartzPathData *pathData = static_cast<KCanvasQuartzPathData *>(path());
- CGMutablePathRef cgPath = pathData->path;
- ASSERT(cgPath != 0);
- CGRect bbox;
-
- // the bbox might grow if the path is stroked.
- // and CGPathGetBoundingBox doesn't support that, so we'll have
- // to make an alternative call...
- if(includeStroke && canvasStyle()->isStroked()) {
- CGContextRef sharedContext = getSharedContext();
-
- CGContextSaveGState(sharedContext);
- CGContextBeginPath(sharedContext);
- CGContextAddPath(sharedContext, cgPath);
- applyStrokeStyleToContext(sharedContext, canvasStyle());
- CGContextReplacePathWithStrokedPath(sharedContext);
-
- bbox = CGContextGetPathBoundingBox(sharedContext);
-
- CGContextRestoreGState(sharedContext);
- } else {
- // the easy (and efficient) case:
- bbox = CGPathGetBoundingBox(cgPath);
- }
-
- // apply any local transforms
- if (applyTransforms) {
- CGAffineTransform transform = CGAffineTransform(localTransform());
- CGRect tranformedBBox = CGRectApplyAffineTransform(bbox, transform);
- return QRect(tranformedBBox);
- }
- return QRect(bbox);
+ KCanvasQuartzPathData *pathData = static_cast<KCanvasQuartzPathData *>(path());
+ CGMutablePathRef cgPath = pathData->path;
+ ASSERT(cgPath != 0);
+ CGRect bbox;
+
+ // the bbox might grow if the path is stroked.
+ // and CGPathGetBoundingBox doesn't support that, so we'll have
+ // to make an alternative call...
+ if(includeStroke && canvasStyle()->isStroked()) {
+ CGContextRef sharedContext = getSharedContext();
+
+ CGContextSaveGState(sharedContext);
+ CGContextBeginPath(sharedContext);
+ CGContextAddPath(sharedContext, cgPath);
+ applyStrokeStyleToContext(sharedContext, canvasStyle());
+ CGContextReplacePathWithStrokedPath(sharedContext);
+
+ bbox = CGContextGetPathBoundingBox(sharedContext);
+
+ CGContextRestoreGState(sharedContext);
+ } else
+ // the easy (and efficient) case:
+ bbox = CGPathGetBoundingBox(cgPath);
+
+ return QRect(bbox);
}
bool KCanvasItemQuartz::hitsPath(const QPoint &hitPoint, bool fill) const
{
- CGMutablePathRef cgPath = static_cast<KCanvasQuartzPathData *>(path())->path;
- ASSERT(cgPath != 0);
-
- bool hitSuccess = false;
- CGContextRef sharedContext = getSharedContext();
- CGContextSaveGState(sharedContext);
-
- CGContextBeginPath(sharedContext);
- CGContextAddPath(sharedContext, cgPath);
-
- CGAffineTransform transform = CGAffineTransform(localTransform());
- /* we transform the hit point locally, instead of translating the shape to the hit point. */
- CGPoint localHitPoint = CGPointApplyAffineTransform(CGPoint(hitPoint), CGAffineTransformInvert(transform));
-
- if (fill && canvasStyle()->fillPainter()->paintServer()) {
- CGPathDrawingMode drawMode = (canvasStyle()->fillPainter()->fillRule() == RULE_EVENODD) ? kCGPathEOFill : kCGPathFill;
- hitSuccess = CGContextPathContainsPoint(sharedContext, localHitPoint, drawMode);
-// if (!hitSuccess)
-// NSLog(@"Point: %@ fails to hit path: %@ with bbox: %@",
-// NSStringFromPoint(NSPoint(hitPoint)), CFStringFromCGPath(cgPath),
-// NSStringFromRect(*(NSRect *)&CGContextGetPathBoundingBox(sharedContext)));
- } else if (!fill && canvasStyle()->strokePainter()->paintServer()) {
- hitSuccess = CGContextPathContainsPoint(sharedContext, localHitPoint, kCGPathStroke);
- }
-
- CGContextRestoreGState(sharedContext);
-
- return hitSuccess;
+ CGMutablePathRef cgPath = static_cast<KCanvasQuartzPathData *>(path())->path;
+ ASSERT(cgPath != 0);
+
+ bool hitSuccess = false;
+ CGContextRef sharedContext = getSharedContext();
+ CGContextSaveGState(sharedContext);
+
+ CGContextBeginPath(sharedContext);
+ CGContextAddPath(sharedContext, cgPath);
+
+ CGAffineTransform transform = CGAffineTransform(absoluteTransform());
+ /* we transform the hit point locally, instead of translating the shape to the hit point. */
+ CGPoint localHitPoint = CGPointApplyAffineTransform(CGPoint(hitPoint), CGAffineTransformInvert(transform));
+
+ if (fill && canvasStyle()->fillPainter()->paintServer()) {
+ CGPathDrawingMode drawMode = (canvasStyle()->fillPainter()->fillRule() == RULE_EVENODD) ? kCGPathEOFill : kCGPathFill;
+ hitSuccess = CGContextPathContainsPoint(sharedContext, localHitPoint, drawMode);
+ } else if (!fill && canvasStyle()->strokePainter()->paintServer())
+ hitSuccess = CGContextPathContainsPoint(sharedContext, localHitPoint, kCGPathStroke);
+
+ CGContextRestoreGState(sharedContext);
+
+ return hitSuccess;
}
1.6 +4 -1 SVGSupport/kcanvas/device/quartz/KCanvasResourcesQuartz.h
Index: KCanvasResourcesQuartz.h
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/device/quartz/KCanvasResourcesQuartz.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- KCanvasResourcesQuartz.h 22 Nov 2005 12:03:15 -0000 1.5
+++ KCanvasResourcesQuartz.h 23 Nov 2005 15:14:07 -0000 1.6
@@ -42,6 +42,9 @@
virtual void layout();
virtual void paint(PaintInfo &paintInfo, int parentX, int parentY);
+ virtual QRect getAbsoluteRepaintRect() { return absoluteTransform().mapRect(relativeBBox(true)); }
+ virtual QMatrix absoluteTransform() const;
+
virtual void setViewport(const QRect &viewport);
virtual QRect viewport() const;
@@ -61,7 +64,7 @@
public:
KCanvasClipperQuartz() {};
- void applyClip(CGContextRef, const QRect &) const;
+ void applyClip(CGContextRef context, CGRect relativeBBox) const;
};
class KCanvasImageQuartz : public KCanvasImage {
1.8 +71 -66 SVGSupport/kcanvas/device/quartz/KCanvasResourcesQuartz.mm
Index: KCanvasResourcesQuartz.mm
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/device/quartz/KCanvasResourcesQuartz.mm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- KCanvasResourcesQuartz.mm 22 Nov 2005 23:04:27 -0000 1.7
+++ KCanvasResourcesQuartz.mm 23 Nov 2005 15:14:07 -0000 1.8
@@ -82,8 +82,8 @@
if (checkForRepaint)
repaintAfterLayoutIfNeeded(oldBounds, oldBounds);
-
- setNeedsLayout(false);
+
+ RenderContainer::layout();
}
void KCanvasContainerQuartz::paint(PaintInfo &paintInfo, int parentX, int parentY)
@@ -93,6 +93,9 @@
int absoluteX = parentX + m_x;
int absoluteY = parentY + m_y;
+
+ ASSERT(absoluteX == 0 && absoluteY == 0);
+ // We ignore the khtml absolute transforms (for now)
if (shouldPaintBackgroundOrBorder() && paintInfo.phase != PaintActionOutline)
paintBoxDecorations(paintInfo, absoluteX, absoluteY);
@@ -100,7 +103,7 @@
if (paintInfo.phase == PaintActionOutline && style()->outlineWidth() && style()->visibility() == khtml::VISIBLE)
paintOutline(paintInfo.p, absoluteX, absoluteY, width(), height(), style());
- if (paintInfo.phase != PaintActionForeground || !firstChild())
+ if (paintInfo.phase != PaintActionForeground || !firstChild() || !drawsContents())
return;
KRenderingDeviceQuartz *quartzDevice = static_cast<KRenderingDeviceQuartz *>(canvas()->renderingDevice());
@@ -112,15 +115,12 @@
if(!localTransform().isIdentity())
CGContextConcatCTM(context, CGAffineTransform(localTransform()));
- if(!viewBox().isNull())
- CGContextConcatCTM(context, CGAffineTransform(getAspectRatio(viewBox(), viewport()).qmatrix()));
-
QRect dirtyRect = paintInfo.r;
QString clipname = style()->svgStyle()->clipPath().mid(1);
KCanvasClipperQuartz *clipper = static_cast<KCanvasClipperQuartz *>(getClipperById(document(), clipname));
if (clipper)
- clipper->applyClip(context, bbox());
+ clipper->applyClip(context, CGRect(relativeBBox(true)));
float opacity = style()->opacity();
if (opacity < 1.0f)
@@ -128,12 +128,15 @@
KCanvasFilter *filter = getFilterById(document(), style()->svgStyle()->filter().mid(1));
if (filter)
- filter->prepareFilter(quartzDevice, bbox());
+ filter->prepareFilter(quartzDevice, relativeBBox(true));
+
+ if (!viewBox().isNull())
+ CGContextConcatCTM(paintInfo.p->currentContext(), CGAffineTransform(getAspectRatio(viewBox(), QRect(viewport().x(), viewport().y(), width(), height())).qmatrix()));
- RenderContainer::paint(paintInfo, parentX, parentY);
+ RenderContainer::paint(paintInfo, absoluteX, absoluteY);
if (filter)
- filter->applyFilter(quartzDevice, localTransform(), bbox()); // FIXME, I'm not sure if this should be "localTransform"
+ filter->applyFilter(quartzDevice, relativeBBox(true));
if (opacity < 1.0f)
paintInfo.p->endTransparencyLayer();
@@ -173,63 +176,65 @@
return m_align;
}
-void KCanvasClipperQuartz::applyClip(CGContextRef context, const QRect &bbox) const
+QMatrix KCanvasContainerQuartz::absoluteTransform() const
{
- // FIXME: until the path representation is fixed in
- // KCanvas, we have to convert a KCPathDataList to a CGPath
-
- BOOL heterogenousClipRules = NO;
- KCWindRule clipRule = RULE_NONZERO;
- if (m_clipData.count()) clipRule = m_clipData[0].rule;
-
- CGContextBeginPath(context);
-
- CGAffineTransform bboxTransform = CGAffineTransformMakeMapBetweenRects(CGRectMake(0,0,1,1),CGRect(bbox)); // could be done lazily.
-
- for( unsigned int x = 0; x < m_clipData.count(); x++) {
- KCClipData data = m_clipData[x];
- if (data.rule != clipRule) heterogenousClipRules = YES;
-
- CGPathRef clipPath = CGPathFromKCPathDataList(data.path);
-
- if (CGPathIsEmpty(clipPath)) // FIXME: occasionally we get empty clip paths...
- NSLog(@"WARNING: Asked to clip an empty path, ignoring.");
-
- if (data.bbox) {
- CGPathRef transformedPath = CGPathApplyTransform(clipPath, bboxTransform);
- CGPathRelease(clipPath);
- clipPath = transformedPath;
- }
-
- if (data.viewportClipped) {
- NSLog(@"Viewport clip?");
- }
-
- //NSLog(@"Applying clip path: %@ bbox: %@ (%@)", CFStringFromCGPath(clipPath), data.bbox ? @"YES" : @"NO", NSStringFromRect(NSRect(bbox)));
-
- CGContextAddPath(context, clipPath);
-
- CGPathRelease(clipPath);
- }
-
- if (m_clipData.count()) {
- // FIXME!
- // We don't currently allow for heterogenous clip rules.
- // we would have to detect such, draw to a mask, and then clip
- // to that mask
- if (heterogenousClipRules)
- NSLog(@"WARNING: Quartz does not yet support heterogenous clip rules, clipping will be incorrect.");
-
- if (CGContextIsPathEmpty(context)) {
- NSLog(@"ERROR: Final clip path empty, ignoring.");
- } else {
- if (m_clipData[0].rule == RULE_EVENODD) {
- CGContextEOClip(context);
- } else {
- CGContextClip(context);
- }
- }
- }
+ QMatrix transform = KCanvasContainer::absoluteTransform();
+ //transform *= getAspectRatio(viewBox(), bbox(true)).qmatrix();
+ return transform;
+}
+
+void KCanvasClipperQuartz::applyClip(CGContextRef context, CGRect relativeBBox) const
+{
+ // FIXME: until the path representation is fixed in
+ // KCanvas, we have to convert a KCPathDataList to a CGPath
+
+ if (m_clipData.count() < 1) {
+ NSLog(@"WARNING: Applying empty clipper, ignoring.");
+ return;
+ }
+
+ BOOL heterogenousClipRules = NO;
+ KCWindRule clipRule = m_clipData[0].rule;
+
+ CGContextBeginPath(context);
+
+ CGAffineTransform bboxTransform = CGAffineTransformMakeMapBetweenRects(CGRectMake(0,0,1,1), relativeBBox); // could be done lazily.
+
+ for (unsigned int x = 0; x < m_clipData.count(); x++) {
+ KCClipData data = m_clipData[x];
+ if (data.rule != clipRule)
+ heterogenousClipRules = YES;
+
+ CGPathRef clipPath = CGPathFromKCPathDataList(data.path);
+
+ if (CGPathIsEmpty(clipPath)) // FIXME: occasionally we get empty clip paths...
+ NSLog(@"WARNING: Asked to clip an empty path, ignoring.");
+
+ if (data.bbox) {
+ CGPathRef transformedPath = CGPathApplyTransform(clipPath, bboxTransform);
+ CGPathRelease(clipPath);
+ clipPath = transformedPath;
+ }
+ CGContextAddPath(context, clipPath);
+ CGPathRelease(clipPath);
+ }
+
+ if (m_clipData.count()) {
+ // FIXME!
+ // We don't currently allow for heterogenous clip rules.
+ // we would have to detect such, draw to a mask, and then clip
+ // to that mask
+ if (heterogenousClipRules)
+ NSLog(@"WARNING: Quartz does not yet support heterogenous clip rules, clipping will be incorrect.");
+
+ if (!CGContextIsPathEmpty(context)) {
+ if (m_clipData[0].rule == RULE_EVENODD)
+ CGContextEOClip(context);
+ else
+ CGContextClip(context);
+ } else
+ NSLog(@"ERROR: Final clip path empty, ignoring.");
+ }
}
1.10 +3 -2 SVGSupport/kcanvas/device/quartz/KRenderingPaintServerQuartz.mm
Index: KRenderingPaintServerQuartz.mm
===================================================================
RCS file: /cvs/root/SVGSupport/kcanvas/device/quartz/KRenderingPaintServerQuartz.mm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- KRenderingPaintServerQuartz.mm 22 Nov 2005 12:03:15 -0000 1.9
+++ KRenderingPaintServerQuartz.mm 23 Nov 2005 15:14:07 -0000 1.10
@@ -152,7 +152,8 @@
// FIXME: total hack
KRenderingDeviceContextQuartz *quartzContext = static_cast<KRenderingDeviceContextQuartz *>(renderingContext);
CGContextRef context = quartzContext->cgContext();
- CGRect objectBBox = CGContextGetPathBoundingBox(context);
+ QRect bbox = QRect(CGContextGetPathBoundingBox(context));
QPainter p;
- p.drawPixmap(QPoint(objectBBox.origin), image(), image().rect());
+ QRect imageRect = image().rect();
+ p.drawScaledAndTiledPixmap(bbox.x(), bbox.y(), bbox.width(), bbox.height(), image(), imageRect.x(), imageRect.y(), imageRect.width(), imageRect.height());
}
1.227 +12 -0 WebCore/khtml/rendering/render_object.cpp
Index: render_object.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_object.cpp,v
retrieving revision 1.226
retrieving revision 1.227
diff -u -r1.226 -r1.227
--- render_object.cpp 21 Nov 2005 01:20:26 -0000 1.226
+++ render_object.cpp 23 Nov 2005 15:14:08 -0000 1.227
@@ -2564,3 +2564,15 @@
{
return inlineBoxWrapper();
}
+
+#if SVG_SUPPORT
+QMatrix RenderObject::absoluteTransform() const
+{
+ if (parent()) {
+ QMatrix transform = parent()->absoluteTransform();
+ transform *= localTransform();
+ return transform;
+ } else
+ return localTransform();
+}
+#endif
1.169 +3 -2 WebCore/khtml/rendering/render_object.h
Index: render_object.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_object.h,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -r1.168 -r1.169
--- render_object.h 22 Nov 2005 12:25:13 -0000 1.168
+++ render_object.h 23 Nov 2005 15:14:08 -0000 1.169
@@ -281,10 +281,11 @@
#if SVG_SUPPORT
virtual bool isKCanvasContainer() const { return false; }
virtual bool isRenderPath() const { return false; }
- virtual QRect bbox(bool includeStroke = true) const { return QRect(); }
+ virtual QRect relativeBBox(bool includeStroke = true) const { return QRect(); }
// We may eventually want to make these non-virtual
- virtual QMatrix localTransform() const { return QMatrix(); }
+ virtual QMatrix localTransform() const { return QMatrix(1,0,0,1,xPos(),xPos()); }
virtual void setLocalTransform(const QMatrix&) { }
+ virtual QMatrix absoluteTransform() const;
#endif
virtual bool isEditable() const;
1.277 +1 -7 WebCore/khtml/xml/dom_docimpl.cpp
Index: dom_docimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_docimpl.cpp,v
retrieving revision 1.276
retrieving revision 1.277
diff -u -r1.276 -r1.277
--- dom_docimpl.cpp 23 Nov 2005 09:46:56 -0000 1.276
+++ dom_docimpl.cpp 23 Nov 2005 15:14:08 -0000 1.277
@@ -790,14 +790,8 @@
}
}
#ifdef SVG_SUPPORT
- else if (_namespaceURI == KSVG::SVGNames::svgNamespaceURI) {
+ else if (_namespaceURI == KSVG::SVGNames::svgNamespaceURI)
e = KSVG::SVGElementFactory::createSVGElement(qName, this, false);
- if (e && !prefix.isNull()) {
- e->setPrefix(qName.prefix(), exceptioncode);
- if (exceptioncode)
- return 0;
- }
- }
#endif
if (!e)
1.10 +2 -3 SVGSupport/ksvg2/svg/SVGElementImpl.cpp
Index: SVGElementImpl.cpp
===================================================================
RCS file: /cvs/root/SVGSupport/ksvg2/svg/SVGElementImpl.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SVGElementImpl.cpp 22 Nov 2005 00:09:02 -0000 1.9
+++ SVGElementImpl.cpp 23 Nov 2005 15:14:09 -0000 1.10
@@ -71,9 +71,8 @@
SVGElementImpl *SVGElementImpl::viewportElement() const
{
NodeImpl *n = parentNode();
- while(n)
- {
- if(n->nodeType() == KDOM::ELEMENT_NODE &&
+ while (n) {
+ if (n->isElementNode() &&
(n->hasTagName(SVGNames::svgTag) || n->hasTagName(SVGNames::imageTag) || n->hasTagName(SVGNames::symbolTag)))
return static_cast<SVGElementImpl *>(n);
1.10 +36 -40 SVGSupport/ksvg2/svg/SVGImageElementImpl.cpp
Index: SVGImageElementImpl.cpp
===================================================================
RCS file: /cvs/root/SVGSupport/ksvg2/svg/SVGImageElementImpl.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SVGImageElementImpl.cpp 22 Nov 2005 12:03:17 -0000 1.9
+++ SVGImageElementImpl.cpp 23 Nov 2005 15:14:09 -0000 1.10
@@ -57,9 +57,10 @@
#ifndef APPLE_CHANGES
#include <kdom/parser/KDOMParserFactory.h>
#endif
-//#include <kdom/DOMConfiguration.h>
#include <kdom/core/DOMConfigurationImpl.h>
+#include <kxmlcore/Assertions.h>
+
using namespace KSVG;
SVGImageElementImpl::SVGImageElementImpl(const KDOM::QualifiedName& tagName, KDOM::DocumentImpl *doc)
@@ -165,9 +166,33 @@
return canvas()->renderingDevice()->createItem(arena, style, this, path);
}
+void SVGImageElementImpl::attach()
+{
+ SVGStyledTransformableElementImpl::attach();
+ // if (!m_cachedDocument)
+ {
+ m_cachedImage = ownerDocument()->docLoader()->requestImage(href()->baseVal());
+
+ if(m_cachedImage)
+ m_cachedImage->ref(this);
+ }
+}
void SVGImageElementImpl::notifyFinished(KDOM::CachedObject *finishedObj)
{
+ if (!renderer() || !renderer()->isRenderPath())
+ return; // FIXME: I'm not sure why this would ever happen, but it does.
+
+ RenderPath *imagePath = static_cast<RenderPath *>(renderer());
+ KCanvasRenderingStyle *canvasStyle = imagePath->canvasStyle();
+
+ // Set up image paint server
+ canvasStyle->disableFillPainter();
+ canvasStyle->disableStrokePainter();
+
+ KRenderingPaintServer *fillPaintServer = canvas()->renderingDevice()->createPaintServer(PS_IMAGE);
+ canvasStyle->fillPainter()->setPaintServer(fillPaintServer);
+
#ifndef APPLE_COMPILE_HACK
if(finishedObj == m_cachedDocument)
{
@@ -204,50 +229,21 @@
#endif
if(finishedObj == m_cachedImage)
{
- if(renderer() && renderer()->isRenderPath() && renderer()->style())
- {
- RenderPath *item = static_cast<RenderPath *>(renderer());
- KRenderingFillPainter *fillPainter = item->canvasStyle()->fillPainter();
- if(!fillPainter)
- return;
-
- KRenderingPaintServer *fillPaintServer = fillPainter->paintServer();
- if (fillPaintServer->type() != PS_IMAGE)
- return;
- KRenderingPaintServerImage *fillPaintServerImage = static_cast<KRenderingPaintServerImage *>(fillPaintServer);
- fillPaintServerImage->setImage(m_cachedImage->pixmap());
+ KRenderingFillPainter *fillPainter = canvasStyle->fillPainter();
+ ASSERT(fillPainter);
- item->setNeedsLayout(true);
- }
+ KRenderingPaintServer *fillPaintServer = fillPainter->paintServer();
+ ASSERT(fillPaintServer->type() == PS_IMAGE);
+
+ KRenderingPaintServerImage *fillPaintServerImage = static_cast<KRenderingPaintServerImage *>(fillPaintServer);
+ fillPaintServerImage->setImage(m_cachedImage->pixmap());
m_cachedImage->deref(this);
m_cachedImage = 0;
+
+ imagePath->setNeedsLayout(true);
+ imagePath->repaint();
}
}
-void SVGImageElementImpl::finalizeStyle(KCanvasRenderingStyle *style, bool /* needFillStrokeUpdate */)
-{
- SVGElementImpl *parentElement = svg_dynamic_cast(parentNode());
- if (!parentElement || !parentElement->isStyled())
- return;
- SVGStyledElementImpl *parent = static_cast<SVGStyledElementImpl *>(parentElement);
- if(!parent->allowAttachChildren(this))
- return;
-
- // Set up image paint server
- style->disableFillPainter();
- style->disableStrokePainter();
-
- KRenderingPaintServer *fillPaintServer = canvas()->renderingDevice()->createPaintServer(PS_IMAGE);
- style->fillPainter()->setPaintServer(fillPaintServer);
-
-// if(!m_cachedDocument) // bitmap
-// {
- m_cachedImage = ownerDocument()->docLoader()->requestImage(href()->baseVal());
-
- if(m_cachedImage)
- m_cachedImage->ref(this);
-// }
-}
-
// vim:ts=4:noet
1.6 +2 -3 SVGSupport/ksvg2/svg/SVGImageElementImpl.h
Index: SVGImageElementImpl.h
===================================================================
RCS file: /cvs/root/SVGSupport/ksvg2/svg/SVGImageElementImpl.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SVGImageElementImpl.h 21 Nov 2005 08:29:40 -0000 1.5
+++ SVGImageElementImpl.h 23 Nov 2005 15:14:09 -0000 1.6
@@ -60,14 +60,13 @@
virtual void parseMappedAttribute(KDOM::MappedAttributeImpl *attr);
+ virtual void attach();
+
virtual bool rendererIsNeeded(khtml::RenderStyle *) { return true; }
virtual khtml::RenderObject *createRenderer(RenderArena *arena, khtml::RenderStyle *style);
virtual void notifyFinished(KDOM::CachedObject *finishedObj);
- protected:
- virtual void finalizeStyle(KCanvasRenderingStyle *style, bool needFillStrokeUpdate = true);
-
private:
mutable SVGAnimatedLengthImpl *m_x;
mutable SVGAnimatedLengthImpl *m_y;
1.8 +1 -1 SVGSupport/ksvg2/svg/SVGLengthImpl.cpp
Index: SVGLengthImpl.cpp
===================================================================
RCS file: /cvs/root/SVGSupport/ksvg2/svg/SVGLengthImpl.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SVGLengthImpl.cpp 21 Nov 2005 08:29:40 -0000 1.7
+++ SVGLengthImpl.cpp 23 Nov 2005 15:14:09 -0000 1.8
@@ -97,7 +97,7 @@
khtml::RenderObject *item = (m_context ? m_context->renderer() : 0);
if(item)
{
- QRect bbox = item->bbox();
+ QRect bbox = item->relativeBBox();
float result = 0;
if(m_mode == LM_WIDTH)
1.8 +3 -1 SVGSupport/ksvg2/svg/SVGLocatableImpl.cpp
Index: SVGLocatableImpl.cpp
===================================================================
RCS file: /cvs/root/SVGSupport/ksvg2/svg/SVGLocatableImpl.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SVGLocatableImpl.cpp 21 Nov 2005 08:29:41 -0000 1.7
+++ SVGLocatableImpl.cpp 23 Nov 2005 15:14:09 -0000 1.8
@@ -77,13 +77,15 @@
return farthest;
}
+// Spec:
+// http://www.w3.org/TR/2005/WD-SVGMobile12-20050413/svgudom.html#svg::SVGLocatable
SVGRectImpl *SVGLocatableImpl::getBBox(const SVGStyledElementImpl *e)
{
SVGRectImpl *rect = 0;
if(e && e->renderer())
{
- QRect bboxRect = e->renderer()->bbox(false);
+ QRect bboxRect = e->renderer()->relativeBBox(false);
rect = new SVGRectImpl(0);
rect->setX(bboxRect.x());
rect->setY(bboxRect.y());
1.8 +1 -1 SVGSupport/ksvg2/svg/SVGMarkerElementImpl.cpp
Index: SVGMarkerElementImpl.cpp
===================================================================
RCS file: /cvs/root/SVGSupport/ksvg2/svg/SVGMarkerElementImpl.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SVGMarkerElementImpl.cpp 21 Nov 2005 08:29:41 -0000 1.7
+++ SVGMarkerElementImpl.cpp 23 Nov 2005 15:14:09 -0000 1.8
@@ -185,7 +185,7 @@
khtml::RenderObject *SVGMarkerElementImpl::createRenderer(RenderArena *arena, khtml::RenderStyle *style)
{
KCanvasContainer *markerContainer = canvas()->renderingDevice()->createContainer(arena, style, this);
- markerContainer->setDrawContents(false); // Marker contents will be explicitly drawn.
+ markerContainer->setDrawsContents(false); // Marker contents will be explicitly drawn.
return markerContainer;
}
1.11 +2 -2 SVGSupport/ksvg2/svg/SVGPatternElementImpl.cpp
Index: SVGPatternElementImpl.cpp
===================================================================
RCS file: /cvs/root/SVGSupport/ksvg2/svg/SVGPatternElementImpl.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- SVGPatternElementImpl.cpp 22 Nov 2005 00:09:05 -0000 1.10
+++ SVGPatternElementImpl.cpp 23 Nov 2005 15:14:09 -0000 1.11
@@ -255,7 +255,7 @@
{
SVGElementImpl *elem = svg_dynamic_cast(n);
if (!elem || !elem->isStyled())
- return;
+ continue;
SVGStyledElementImpl *e = static_cast<SVGStyledElementImpl *>(elem);
khtml::RenderObject *item = e->renderer();
if(!item)
@@ -373,7 +373,7 @@
khtml::RenderObject *SVGPatternElementImpl::createRenderer(RenderArena *arena, khtml::RenderStyle *style)
{
KCanvasContainer *patternContainer = canvas()->renderingDevice()->createContainer(arena, style, this);
- patternContainer->setDrawContents(false);
+ patternContainer->setDrawsContents(false);
return patternContainer;
}
1.11 +22 -15 SVGSupport/ksvg2/svg/SVGSVGElementImpl.cpp
Index: SVGSVGElementImpl.cpp
===================================================================
RCS file: /cvs/root/SVGSupport/ksvg2/svg/SVGSVGElementImpl.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- SVGSVGElementImpl.cpp 21 Nov 2005 08:29:41 -0000 1.10
+++ SVGSVGElementImpl.cpp 23 Nov 2005 15:14:09 -0000 1.11
@@ -54,6 +54,8 @@
#include "SVGPreserveAspectRatioImpl.h"
#include "SVGAnimatedPreserveAspectRatioImpl.h"
+#include "cssproperties.h"
+
#include <q3paintdevicemetrics.h>
#include <qtextstream.h>
@@ -84,12 +86,14 @@
SVGAnimatedLengthImpl *SVGSVGElementImpl::x() const
{
- return lazy_create<SVGAnimatedLengthImpl>(m_x, static_cast<const SVGStyledElementImpl *>(0), LM_WIDTH, ownerDocument()->documentElement() == static_cast<const KDOM::ElementImpl *>(this) ? this : viewportElement());
+ const SVGElementImpl *viewport = ownerDocument()->documentElement() == this ? this : viewportElement();
+ return lazy_create<SVGAnimatedLengthImpl>(m_x, (SVGStyledElementImpl *)0, LM_WIDTH, viewport);
}
SVGAnimatedLengthImpl *SVGSVGElementImpl::y() const
{
- return lazy_create<SVGAnimatedLengthImpl>(m_y, static_cast<const SVGStyledElementImpl *>(0), LM_HEIGHT, ownerDocument()->documentElement() == static_cast<const KDOM::ElementImpl *>(this) ? this : viewportElement());
+ const SVGElementImpl *viewport = ownerDocument()->documentElement() == this ? this : viewportElement();
+ return lazy_create<SVGAnimatedLengthImpl>(m_y, (SVGStyledElementImpl *)0, LM_HEIGHT, viewport);
}
SVGAnimatedLengthImpl *SVGSVGElementImpl::width() const
@@ -97,7 +101,8 @@
if(!m_width)
{
KDOM::DOMString temp("100%");
- lazy_create<SVGAnimatedLengthImpl>(m_width, static_cast<const SVGStyledElementImpl *>(0), LM_WIDTH, ownerDocument()->documentElement() == static_cast<const KDOM::ElementImpl *>(this) ? this : viewportElement());
+ const SVGElementImpl *viewport = ownerDocument()->documentElement() == this ? this : viewportElement();
+ lazy_create<SVGAnimatedLengthImpl>(m_width, (SVGStyledElementImpl *)0, LM_WIDTH, viewport);
m_width->baseVal()->setValueAsString(temp.impl());
}
@@ -109,7 +114,8 @@
if(!m_height)
{
KDOM::DOMString temp("100%");
- lazy_create<SVGAnimatedLengthImpl>(m_height, static_cast<const SVGStyledElementImpl *>(0), LM_HEIGHT, ownerDocument()->documentElement() == static_cast<const KDOM::ElementImpl *>(this) ? this : viewportElement());
+ const SVGElementImpl *viewport = ownerDocument()->documentElement() == this ? this : viewportElement();
+ lazy_create<SVGAnimatedLengthImpl>(m_height, (SVGStyledElementImpl *)0, LM_HEIGHT, viewport);
m_height->baseVal()->setValueAsString(temp.impl());
}
@@ -236,17 +242,18 @@
void SVGSVGElementImpl::parseMappedAttribute(KDOM::MappedAttributeImpl *attr)
{
-// const KDOM::AtomicString& value = attr->value();
-// Try letting these fall through to CSS
-// if (attr->name() == SVGNames::xAttr)
-// x()->baseVal()->setValueAsString(value.impl());
-// else if (attr->name() == SVGNames::yAttr)
-// y()->baseVal()->setValueAsString(value.impl());
-// else if (attr->name() == SVGNames::widthAttr)
-// width()->baseVal()->setValueAsString(value.impl());
-// else if (attr->name() == SVGNames::heightAttr)
-// height()->baseVal()->setValueAsString(value.impl());
-// else
+ const KDOM::AtomicString& value = attr->value();
+ if (attr->name() == SVGNames::xAttr) {
+ x()->baseVal()->setValueAsString(value.impl());
+ } else if (attr->name() == SVGNames::yAttr) {
+ y()->baseVal()->setValueAsString(value.impl());
+ } else if (attr->name() == SVGNames::widthAttr) {
+ width()->baseVal()->setValueAsString(value.impl());
+ addCSSProperty(attr, CSS_PROP_WIDTH, value);
+ } else if (attr->name() == SVGNames::heightAttr) {
+ height()->baseVal()->setValueAsString(value.impl());
+ addCSSProperty(attr, CSS_PROP_HEIGHT, value);
+ } else
{
if(SVGTestsImpl::parseMappedAttribute(attr)) return;
if(SVGLangSpaceImpl::parseMappedAttribute(attr)) return;
1.10 +1 -2 WebCore/kwq/KWQWMatrix.mm
Index: KWQWMatrix.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQWMatrix.mm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- KWQWMatrix.mm 21 Nov 2005 04:02:02 -0000 1.9
+++ KWQWMatrix.mm 23 Nov 2005 15:14:11 -0000 1.10
@@ -57,8 +57,7 @@
QRect QWMatrix::mapRect(const QRect &rect) const
{
- CGRect result = CGRectApplyAffineTransform(CGRectMake(rect.left(), rect.bottom(), rect.width(), rect.height()),m_transform);
- return QRect((int)result.origin.x, (int)result.origin.y + (int)result.size.height, (int)result.size.width, (int)result.size.height);
+ return QRect(CGRectApplyAffineTransform(CGRect(rect), m_transform));
}
bool QWMatrix::isIdentity() const
More information about the webkit-changes
mailing list