From kde-commits Thu Apr 06 22:49:16 2006 From: Nikolas Zimmermann Date: Thu, 06 Apr 2006 22:49:16 +0000 To: kde-commits Subject: branches/work/khtml-svg/rendering Message-Id: <1144363756.607193.7085.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=114436376402755 SVN commit 527127 by wildfox: Revert my last commit and "hack around it for real". As we don't participate in layouting yet, all text is placed at x/y 0, so in a paint event which is ie. clipped to 0x0-504x128 we need to be able to paint ouside that area. I'm aware this is a hack, but it works for now, until the real solutions is discussed with the WebKit guys. CCMAIL: buis@kde.org M +32 -14 render_svg_text.cpp M +2 -1 render_svg_text.h --- branches/work/khtml-svg/rendering/render_svg_text.cpp #527126:527127 @@ -22,13 +22,14 @@ */ #include "rendering/kcanvas/KCanvasMatrix.h" - #include "rendering/kcanvas/device/KRenderingDevice.h" #include "svg/KSVGPainterFactory.h" #include "svg/SVGTextElementImpl.h" #include "svg/SVGAnimatedLengthListImpl.h" +#include "khtmlview.h" +#include "render_canvas.h" #include "render_svg_text.h" using namespace khtml; @@ -44,6 +45,16 @@ return QMatrix().translate(0, -offset); } +QMatrix RenderSVGText::translationForAttributes() +{ + KSVG::SVGTextElementImpl *text = static_cast(element()); + + float xOffset = text->x()->baseVal()->getFirst() ? text->x()->baseVal()->getFirst()->value() : 0; + float yOffset = text->y()->baseVal()->getFirst() ? text->y()->baseVal()->getFirst()->value() : 0; + + return QMatrix().translate(xOffset, yOffset); +} + void RenderSVGText::paint(PaintInfo &paintInfo, int parentX, int parentY) { KRenderingDevice *device = KRenderingDevice::self(); @@ -60,24 +71,27 @@ else paintInfo.p->save(); - // Get our rendering location... - KSVG::SVGTextElementImpl *text = static_cast(element()); - - float xOffset = text->x()->baseVal()->getFirst() ? text->x()->baseVal()->getFirst()->value() : 0; - float yOffset = text->y()->baseVal()->getFirst() ? text->y()->baseVal()->getFirst()->value() : 0; - - xOffset += parentX; - yOffset += parentY; - context->concatCTM(localTransform()); + context->concatCTM(QMatrix().translate(parentX, parentY)); + context->concatCTM(translationForAttributes()); context->concatCTM(translationTopToBaseline()); - + QRectF boundingBox(0, 0, width(), height()); const KSVG::SVGRenderStyle *svgStyle = style()->svgStyle(); if(KCanvasClipper *clipper = getClipperById(document(), svgStyle->clipPath().mid(1))) clipper->applyClip(boundingBox); + // Replace current paint info rect with a rect representing + // the currently visible canvas area. This is because we don't + // yet participate in layouting, so we need to allow painting + // to be happen _outside_ the area contained in 'paintInfo.r' + // It's quite hacky, we're aware of that - needs to changed :-) + QRect savedRect = paintInfo.r; + KHTMLView *view = canvas()->view(); + if(view) + paintInfo.r = QRect(0, 0, view->visibleWidth(), view->visibleHeight()); + KRenderingPaintServer *fillPaintServer = KSVG::KSVGPainterFactory::fillPaintServer(style(), this); if(fillPaintServer) { @@ -86,7 +100,7 @@ if(fillPaintServer->setup(context, this, APPLY_TO_FILL)) { - RenderBlock::paint(paintInfo, xOffset, yOffset); + RenderBlock::paint(paintInfo, 0, 0); fillPaintServer->teardown(context, this, APPLY_TO_FILL); } @@ -101,13 +115,16 @@ if(strokePaintServer->setup(context, this, APPLY_TO_STROKE)) { - RenderBlock::paint(paintInfo, xOffset, yOffset); + RenderBlock::paint(paintInfo, 0, 0); strokePaintServer->teardown(context, this, APPLY_TO_STROKE); } strokePaintServer->setPaintingText(false); } + // Restore paint info rect... + paintInfo.r = savedRect; + // restore drawing state if(shouldPopContext) { @@ -120,7 +137,8 @@ bool RenderSVGText::nodeAtPoint(NodeInfo &info, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction, bool inBox) { - QMatrix totalTransform = translationTopToBaseline(); + QMatrix totalTransform = translationForAttributes(); + totalTransform *= translationTopToBaseline(); totalTransform *= absoluteTransform(); double localX, localY; --- branches/work/khtml-svg/rendering/render_svg_text.h #527126:527127 @@ -44,11 +44,12 @@ virtual QMatrix localTransform() const { return m_transform; } virtual void setLocalTransform(const QMatrix &transform) { m_transform = transform; } - + virtual bool nodeAtPoint(NodeInfo &info, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction, bool inBox); private: QMatrix translationTopToBaseline(); + QMatrix translationForAttributes(); QMatrix m_transform; };