2006-04-18 Rob Buis <buis@kde.org>
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Apr 2006 11:03:52 +0000 (11:03 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Apr 2006 11:03:52 +0000 (11:03 +0000)
        Reviewed by eseidel & darin.  Landed by eseidel.

        No automated tests possible (from javascript).

        Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=6664:
        Inspector does not highlight SVG elements properly

        Make sure RenderObject::absoluteBoundingBoxRect works for
        svg specific render objects by overriding absoluteRects.
        This fixes highlighting in the Inspector of svg shapes, paths,
        images and text.

        * kcanvas/RenderPath.cpp:
        (WebCore::RenderPath::absoluteRects):
        * kcanvas/RenderPath.h:
        * kcanvas/RenderSVGImage.cpp:
        (WebCore::RenderSVGImage::getAbsoluteRepaintRect):
        (WebCore::RenderSVGImage::absoluteRects):
        * kcanvas/RenderSVGImage.h:
        * kcanvas/RenderSVGText.cpp:
        (WebCore::RenderSVGText::absoluteRects):
        * kcanvas/RenderSVGText.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@13968 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/kcanvas/RenderPath.cpp
WebCore/kcanvas/RenderPath.h
WebCore/kcanvas/RenderSVGImage.cpp
WebCore/kcanvas/RenderSVGImage.h
WebCore/kcanvas/RenderSVGText.cpp
WebCore/kcanvas/RenderSVGText.h

index d9931f9d00230e0a65f3f67baa962f37a9bbd1a7..81a9ca31e06605ff64ef82f42e1d086530faba92 100644 (file)
@@ -1,3 +1,28 @@
+2006-04-18  Rob Buis  <buis@kde.org>
+
+        Reviewed by eseidel & darin.  Landed by eseidel.
+
+        No automated tests possible (from javascript).
+
+        Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=6664:
+        Inspector does not highlight SVG elements properly
+
+        Make sure RenderObject::absoluteBoundingBoxRect works for
+        svg specific render objects by overriding absoluteRects.
+        This fixes highlighting in the Inspector of svg shapes, paths,
+        images and text.
+
+        * kcanvas/RenderPath.cpp:
+        (WebCore::RenderPath::absoluteRects):
+        * kcanvas/RenderPath.h:
+        * kcanvas/RenderSVGImage.cpp:
+        (WebCore::RenderSVGImage::getAbsoluteRepaintRect):
+        (WebCore::RenderSVGImage::absoluteRects):
+        * kcanvas/RenderSVGImage.h:
+        * kcanvas/RenderSVGText.cpp:
+        (WebCore::RenderSVGText::absoluteRects):
+        * kcanvas/RenderSVGText.h:
+
 2006-04-17  Rob Buis  <buis@kde.org>
 
         Reviewed by eseidel.  Landed by eseidel.
index 1db69d1a4ec56b74d2446fc85d81f020f4eb3c76..bb07df5b3a6f64bb1da2b11d4ec618d3e40f6f7a 100644 (file)
@@ -242,6 +242,11 @@ void RenderPath::paint(PaintInfo &paintInfo, int parentX, int parentY)
         paintInfo.p->restore();
 }
 
+void RenderPath::absoluteRects(DeprecatedValueList<IntRect>& rects, int _tx, int _ty)
+{
+    rects.append(getAbsoluteRepaintRect());
+}
+
 bool RenderPath::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction)
 {
     // We only draw in the forground phase, so we only hit-test then.
index d54ec7d54d97adc919c889adfa8fcc7cecb1ffb0..2e14205e0a7895ac49f8f815e0aa808e395e584f 100644 (file)
@@ -68,7 +68,9 @@ public:
     virtual short lineHeight(bool b, bool isRootLineBox = false) const;
     virtual short baselinePosition(bool b, bool isRootLineBox = false) const;
     virtual void paint(PaintInfo&, int parentX, int parentY);
-    
+    virtual void absoluteRects(DeprecatedValueList<IntRect>& rects, int tx, int ty);
+
     virtual bool nodeAtPoint(NodeInfo&, int x, int y, int tx, int ty, HitTestAction);
 
 protected:
index aa859fdd881b148fe9089223720e67c10aa6ffa4..e40238ed316d50d32333b718eaff6087bdb046c8 100644 (file)
@@ -199,7 +199,10 @@ void RenderSVGImage::imageChanged(CachedImage* image)
 
 IntRect RenderSVGImage::getAbsoluteRepaintRect()
 {
-    FloatRect repaintRect = absoluteTransform().mapRect(relativeBBox(true));
+    SVGImageElement *image = static_cast<SVGImageElement *>(node());
+    float xOffset = image->x()->baseVal() ? image->x()->baseVal()->value() : 0;
+    float yOffset = image->y()->baseVal() ? image->y()->baseVal()->value() : 0;
+    FloatRect repaintRect = absoluteTransform().mapRect(FloatRect(xOffset, yOffset, width(), height()));
 
     // Filters can expand the bounding box
     KCanvasFilter *filter = getFilterById(document(), style()->svgStyle()->filter().mid(1));
@@ -209,6 +212,11 @@ IntRect RenderSVGImage::getAbsoluteRepaintRect()
     return enclosingIntRect(repaintRect);
 }
 
+void RenderSVGImage::absoluteRects(DeprecatedValueList<IntRect>& rects, int _tx, int _ty)
+{
+    rects.append(getAbsoluteRepaintRect());
+}
+
 void RenderSVGImage::translateForAttributes()
 {
     KRenderingDeviceContext *context = renderingDevice()->currentContext();
index 5f7499cbd8965553dd4b04fe16256b3eb27947a3..1ccf2e578485fe74c5e1d687340a4a8b9dc1c048 100644 (file)
@@ -42,6 +42,8 @@ namespace WebCore
         virtual FloatRect relativeBBox(bool includeStroke = true) const;
         virtual IntRect getAbsoluteRepaintRect();
         
+        virtual void absoluteRects(DeprecatedValueList<IntRect>& rects, int tx, int ty);
+
         virtual void imageChanged(CachedImage*);
         void adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, SVGPreserveAspectRatio *aspectRatio);
         virtual void paint(PaintInfo& paintInfo, int parentX, int parentY);
index 77b88f5099856f13d71a083a87965bbb700804ba..517a657c61f2f18c23acde68384f4ae1c3b10341 100644 (file)
@@ -133,6 +133,15 @@ bool RenderSVGText::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty
     return RenderBlock::nodeAtPoint(info, (int)localX, (int)localY, _tx, _ty, hitTestAction);
 }
 
+void RenderSVGText::absoluteRects(DeprecatedValueList<IntRect>& rects, int _tx, int _ty)
+{
+    QMatrix mat = translationForAttributes();
+    mat *= translationTopToBaseline();
+    mat *= absoluteTransform();
+
+    rects.append(enclosingIntRect(mat.mapRect(FloatRect(0, 0, width(), height()))));
+}
+
 }
 
 #endif // SVG_SUPPORT
index ab4e0171807a4f16df2623c67cbd27ff1e4fc001..7dc08ba1773006cf77aaeafeeb43a14a435cbfc1 100644 (file)
@@ -44,6 +44,8 @@ public:
     
     bool nodeAtPoint(NodeInfo&, int _x, int _y, int _tx, int _ty, WebCore::HitTestAction);
 
+    virtual void absoluteRects(DeprecatedValueList<IntRect>& rects, int tx, int ty);
+
  private:
     QMatrix translationTopToBaseline();
     QMatrix translationForAttributes();