2006-09-27 Eric Seidel <eric@eseidel.com>
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Sep 2006 23:48:09 +0000 (23:48 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Sep 2006 23:48:09 +0000 (23:48 +0000)
        Reviewed by mitz.

        paths with no fill specified default to black but do not recieve paint-related mouse events
        http://bugzilla.opendarwin.org/show_bug.cgi?id=11069
        The default fill was being applied at the wrong place in the rendering chain, causing this problem.

        Test: svg/custom/hover-default-fill.svg

        * kcanvas/RenderPath.cpp:
        (WebCore::RenderPath::nodeAtPoint): use isFilled and isStroked
        * ksvg2/css/SVGRenderStyle.h: use defaultFill() and defaultStroke()
        * ksvg2/misc/KCanvasRenderingStyle.cpp:
        (WebCore::KSVGPainterFactory::isFilled): remove null check
        (WebCore::KSVGPainterFactory::fillPaintServer): remove null check
        (WebCore::KSVGPainterFactory::isStroked): remove null check
        (WebCore::KSVGPainterFactory::strokePaintServer): remove null check
        * ksvg2/svg/SVGPaint.cpp:
        (WebCore::SVGPaint::defaultFill): added.
        (WebCore::SVGPaint::defaultStroke): added.
        * ksvg2/svg/SVGPaint.h:

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

LayoutTests/ChangeLog
LayoutTests/svg/custom/hover-default-fill-expected.checksum [new file with mode: 0644]
LayoutTests/svg/custom/hover-default-fill-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/hover-default-fill-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/hover-default-fill.svg [new file with mode: 0644]
WebCore/ChangeLog
WebCore/kcanvas/RenderPath.cpp
WebCore/ksvg2/css/SVGRenderStyle.h
WebCore/ksvg2/misc/KCanvasRenderingStyle.cpp
WebCore/ksvg2/svg/SVGPaint.cpp
WebCore/ksvg2/svg/SVGPaint.h

index 545b8fc1bb43c221cff4ca10e2d65e2fd0328163..49dc4f94c9017fffe5e4126fddc38e147af094aa 100644 (file)
@@ -1,3 +1,15 @@
+2006-09-27  Eric Seidel  <eric@eseidel.com>
+
+        Reviewed by mitz.
+        
+        paths with no fill specified default to black but do not recieve paint-related mouse events
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=11069
+
+        * svg/custom/hover-default-fill-expected.checksum: Added.
+        * svg/custom/hover-default-fill-expected.png: Added.
+        * svg/custom/hover-default-fill-expected.txt: Added.
+        * svg/custom/hover-default-fill.svg: Added.
+
 2006-09-27  Rob Buis  <buis@kde.org>
 
         Reviewed by eseidel.
diff --git a/LayoutTests/svg/custom/hover-default-fill-expected.checksum b/LayoutTests/svg/custom/hover-default-fill-expected.checksum
new file mode 100644 (file)
index 0000000..3a4f1f7
--- /dev/null
@@ -0,0 +1 @@
+16310588467cfc20d551635abc59b784
\ No newline at end of file
diff --git a/LayoutTests/svg/custom/hover-default-fill-expected.png b/LayoutTests/svg/custom/hover-default-fill-expected.png
new file mode 100644 (file)
index 0000000..3db2634
Binary files /dev/null and b/LayoutTests/svg/custom/hover-default-fill-expected.png differ
diff --git a/LayoutTests/svg/custom/hover-default-fill-expected.txt b/LayoutTests/svg/custom/hover-default-fill-expected.txt
new file mode 100644 (file)
index 0000000..9f8cf9a
--- /dev/null
@@ -0,0 +1,5 @@
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:(null) affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+    KCanvasContainer {svg} at (0,0) size 100x100
+      KCanvasItem {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,100.00L0.00,100.00"]
diff --git a/LayoutTests/svg/custom/hover-default-fill.svg b/LayoutTests/svg/custom/hover-default-fill.svg
new file mode 100644 (file)
index 0000000..ba2cc83
--- /dev/null
@@ -0,0 +1,14 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="100px" height="100px">
+<style type="text/css">
+  rect:hover {fill:green;}
+</style>
+<rect width="100" height="100"/>
+<script type="text/javascript">
+<![CDATA[
+  if (window.eventSender) {
+    eventSender.mouseMoveTo(50, 50);
+    eventSender.mouseDown();
+  }
+]]>
+</script>
+</svg>
\ No newline at end of file
index cee112c3c007021d7dfdc9b2f44c25770b42bfb1..4ebb71e6bfe93e894beeb18c4246ed8c04a50c47 100644 (file)
@@ -1,3 +1,26 @@
+2006-09-27  Eric Seidel  <eric@eseidel.com>
+
+        Reviewed by mitz.
+
+        paths with no fill specified default to black but do not recieve paint-related mouse events
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=11069
+        The default fill was being applied at the wrong place in the rendering chain, causing this problem.
+
+        Test: svg/custom/hover-default-fill.svg
+
+        * kcanvas/RenderPath.cpp:
+        (WebCore::RenderPath::nodeAtPoint): use isFilled and isStroked
+        * ksvg2/css/SVGRenderStyle.h: use defaultFill() and defaultStroke()
+        * ksvg2/misc/KCanvasRenderingStyle.cpp:
+        (WebCore::KSVGPainterFactory::isFilled): remove null check
+        (WebCore::KSVGPainterFactory::fillPaintServer): remove null check
+        (WebCore::KSVGPainterFactory::isStroked): remove null check
+        (WebCore::KSVGPainterFactory::strokePaintServer): remove null check
+        * ksvg2/svg/SVGPaint.cpp:
+        (WebCore::SVGPaint::defaultFill): added.
+        (WebCore::SVGPaint::defaultStroke): added.
+        * ksvg2/svg/SVGPaint.h:
+
 2006-09-27  Rob Buis  <buis@kde.org>
 
         Reviewed by eseidel.
index 031d533a370bf3d44c3122f3c38beb03a078b7a7..2d680f13b02b2dea3f97dc9d5e1bc5dfccf76a55 100644 (file)
@@ -294,11 +294,9 @@ bool RenderPath::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, H
     
     bool isVisible = (style()->visibility() == VISIBLE);
     if (isVisible || !hitRules.requireVisible) {
-        bool hasFill = (style()->svgStyle()->fillPaint() && style()->svgStyle()->fillPaint()->paintType() != SVGPaint::SVG_PAINTTYPE_NONE);
-        bool hasStroke = (style()->svgStyle()->strokePaint() && style()->svgStyle()->strokePaint()->paintType() != SVGPaint::SVG_PAINTTYPE_NONE);
         FloatPoint hitPoint(_x,_y);
-        if ((hitRules.canHitStroke && (hasStroke || !hitRules.requireStroke) && strokeContains(hitPoint, hitRules.requireStroke))
-            || (hitRules.canHitFill && (hasFill || !hitRules.requireFill) && fillContains(hitPoint, hitRules.requireFill))) {
+        if ((hitRules.canHitStroke && (KSVGPainterFactory::isStroked(style()) || !hitRules.requireStroke) && strokeContains(hitPoint, hitRules.requireStroke))
+            || (hitRules.canHitFill && (KSVGPainterFactory::isFilled(style()) || !hitRules.requireFill) && fillContains(hitPoint, hitRules.requireFill))) {
             setInnerNode(info);
             return true;
         }
index 89ecf3071f05c287205898d98d3d9dfe6fefaadb..1bc9f11dcc9499b23c4bf918c3460b161c0c78f4 100644 (file)
     Boston, MA 02111-1307, USA.
 */
 
-#ifndef KSVG_SVGRenderStyle_H
-#define KSVG_SVGRenderStyle_H
+#ifndef SVGRenderStyle_H
+#define SVGRenderStyle_H
 #ifdef SVG_SUPPORT
 
 #include "DataRef.h"
-#include <ksvg2/svg/SVGPaint.h>
-#include <ksvg2/css/SVGRenderStyleDefs.h>
+#include "SVGPaint.h"
+#include "SVGRenderStyleDefs.h"
 #include <wtf/Platform.h>
 
 #if PLATFORM(WIN_OS)
@@ -63,14 +63,14 @@ namespace WebCore {
     public:
         SVGRenderStyle();
         SVGRenderStyle(bool); // Used to create the default style.
-        SVGRenderStyle(const SVGRenderStyle &other);
+        SVGRenderStyle(const SVGRenderStyle&);
         ~SVGRenderStyle();
 
-        bool inheritedNotEqual(const SVGRenderStyle *other) const;
+        bool inheritedNotEqual(const SVGRenderStyle*) const;
 
-        void inheritFrom(const SVGRenderStyle *inheritParent);
+        void inheritFrom(const SVGRenderStyle*);
         
-        bool operator==(const SVGRenderStyle& o) const;
+        bool operator==(const SVGRenderStyle&) const;
         bool operator!=(const SVGRenderStyle& o) const { return !(*this == o); }
 
         // SVG CSS Properties
@@ -93,15 +93,15 @@ namespace WebCore {
 
         // SVG CSS Properties (using DataRef's)
         RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(float, fill, opacity, FillOpacity, fillOpacity, 1.0)
-        RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(SVGPaint *, fill, paint, FillPaint, fillPaint, 0)
+        RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(SVGPaint*, fill, paint, FillPaint, fillPaint, SVGPaint::defaultFill())
 
         RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(float, stroke, opacity, StrokeOpacity, strokeOpacity, 1.0)
-        RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(SVGPaint *, stroke, paint, StrokePaint, strokePaint, 0)
-        RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(CSSValueList *, stroke, dashArray, StrokeDashArray, strokeDashArray, 0)
+        RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(SVGPaint*, stroke, paint, StrokePaint, strokePaint, SVGPaint::defaultStroke())
+        RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(CSSValueList*, stroke, dashArray, StrokeDashArray, strokeDashArray, 0)
         RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(unsigned int, stroke, miterLimit, StrokeMiterLimit, strokeMiterLimit, 4)
         
-        RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(CSSValue *, stroke, width, StrokeWidth, strokeWidth, 0)
-        RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(CSSValue *, stroke, dashOffset, StrokeDashOffset, strokeDashOffset, 0);
+        RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(CSSValue*, stroke, width, StrokeWidth, strokeWidth, 0)
+        RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(CSSValue*, stroke, dashOffset, StrokeDashOffset, strokeDashOffset, 0);
     
         RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(float, stops, opacity, StopOpacity, stopOpacity, 1.0)
         RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(Color, stops, color, StopColor, stopColor, Color(0, 0, 0))    
@@ -175,7 +175,7 @@ namespace WebCore {
         static SVGRenderStyle *s_defaultStyle;
 
     private:
-        SVGRenderStyle(const SVGRenderStyle *) { }
+        SVGRenderStyle(const SVGRenderStyle*) { }
 
         void setBitDefaults()
         {
@@ -201,6 +201,6 @@ namespace WebCore {
 } // namespace WebCore
 
 #endif // SVG_SUPPORT
-#endif // KSVG_SVGRenderStyle_H
+#endif // SVGRenderStyle_H
 
 // vim:ts=4:noet
index e6580279e6e080e607b3cfe3b5dc4631cefa06f4..0a0f8e5305283c215ed3a491e4ca7dccc29e07b1 100644 (file)
 #include "KCanvasRenderingStyle.h"
 #include "KRenderingDevice.h"
 #include "KRenderingFillPainter.h"
-#include "KRenderingPaintServer.h"
 #include "KRenderingPaintServerGradient.h"
 #include "KRenderingPaintServerSolid.h"
 #include "KRenderingStrokePainter.h"
-#include "PlatformString.h"
 #include "RenderObject.h"
 #include "SVGLength.h"
 #include "SVGRenderStyle.h"
 #include "SVGStyledElement.h"
 #include "ksvg.h"
-#include "RenderStyle.h"
 
 namespace WebCore {
 
@@ -47,14 +44,13 @@ static KRenderingPaintServerSolid* sharedSolidPaintServer()
 {
     static KRenderingPaintServerSolid* _sharedSolidPaintServer = 0;
     if (!_sharedSolidPaintServer)
-        _sharedSolidPaintServer = static_cast<KRenderingPaintServerSolid *>(renderingDevice()->createPaintServer(PS_SOLID));
+        _sharedSolidPaintServer = static_cast<KRenderingPaintServerSolid*>(renderingDevice()->createPaintServer(PS_SOLID));
     return _sharedSolidPaintServer;
 }
 
 bool KSVGPainterFactory::isFilled(const RenderStyle* style)
 {
-    SVGPaint* fill = style->svgStyle()->fillPaint();
-    if (fill && fill->paintType() == SVGPaint::SVG_PAINTTYPE_NONE)
+    if (style->svgStyle()->fillPaint()->paintType() == SVGPaint::SVG_PAINTTYPE_NONE)
         return false;
     return true;
 }
@@ -67,11 +63,16 @@ KRenderingPaintServer* KSVGPainterFactory::fillPaintServer(const RenderStyle* st
     SVGPaint* fill = style->svgStyle()->fillPaint();
 
     KRenderingPaintServer* fillPaintServer = 0;
-    if (fill && fill->paintType() == SVGPaint::SVG_PAINTTYPE_URI) {
+    if (fill->paintType() == SVGPaint::SVG_PAINTTYPE_URI) {
         fillPaintServer = getPaintServerById(item->document(), AtomicString(fill->uri().substring(1)));
-        if (item && fillPaintServer && item->isRenderPath())
+        if (fillPaintServer && item->isRenderPath())
             fillPaintServer->addClient(static_cast<const RenderPath*>(item));
-    } else if (fill) {
+        if (!fillPaintServer) {
+            // default value (black), see bug 11017
+            fillPaintServer = sharedSolidPaintServer();
+            static_cast<KRenderingPaintServerSolid*>(fillPaintServer)->setColor(Color::black);
+        }
+    } else {
         fillPaintServer = sharedSolidPaintServer();
         KRenderingPaintServerSolid* fillPaintServerSolid = static_cast<KRenderingPaintServerSolid*>(fillPaintServer);
         if (fill->paintType() == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR)
@@ -79,21 +80,13 @@ KRenderingPaintServer* KSVGPainterFactory::fillPaintServer(const RenderStyle* st
         else
             fillPaintServerSolid->setColor(fill->color());
     }
-    
-    if (!fillPaintServer) {
-        // default value (black), see bug 11017
-        fillPaintServer = sharedSolidPaintServer();
-        static_cast<KRenderingPaintServerSolid *>(fillPaintServer)->setColor(Color::black);
-    }
-
     return fillPaintServer;
 }
 
 
 bool KSVGPainterFactory::isStroked(const RenderStyle* style)
 {
-    SVGPaint* stroke = style->svgStyle()->strokePaint();
-    if (!stroke || stroke->paintType() == SVGPaint::SVG_PAINTTYPE_NONE)
+    if (style->svgStyle()->strokePaint()->paintType() == SVGPaint::SVG_PAINTTYPE_NONE)
         return false;
     return true;
 }
@@ -106,13 +99,13 @@ KRenderingPaintServer* KSVGPainterFactory::strokePaintServer(const RenderStyle*
     SVGPaint* stroke = style->svgStyle()->strokePaint();
 
     KRenderingPaintServer* strokePaintServer = 0;
-    if (stroke && stroke->paintType() == SVGPaint::SVG_PAINTTYPE_URI) {
+    if (stroke->paintType() == SVGPaint::SVG_PAINTTYPE_URI) {
         strokePaintServer = getPaintServerById(item->document(), AtomicString(stroke->uri().substring(1)));
-        if(item && strokePaintServer && item->isRenderPath())
+        if (item && strokePaintServer && item->isRenderPath())
             strokePaintServer->addClient(static_cast<const RenderPath*>(item));
     } else {
         strokePaintServer = sharedSolidPaintServer();
-        KRenderingPaintServerSolid *strokePaintServerSolid = static_cast<KRenderingPaintServerSolid *>(strokePaintServer);
+        KRenderingPaintServerSolid* strokePaintServerSolid = static_cast<KRenderingPaintServerSolid*>(strokePaintServer);
         if (stroke->paintType() == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR)
             strokePaintServerSolid->setColor(style->color());
         else
@@ -124,24 +117,22 @@ KRenderingPaintServer* KSVGPainterFactory::strokePaintServer(const RenderStyle*
 
 double KSVGPainterFactory::cssPrimitiveToLength(const RenderObject* item, CSSValue *value, double defaultValue)
 {
-    CSSPrimitiveValue *primitive = static_cast<CSSPrimitiveValue *>(value);
+    CSSPrimitiveValue* primitive = static_cast<CSSPrimitiveValue*>(value);
 
     unsigned short cssType = (primitive ? primitive->primitiveType() : (unsigned short) CSSPrimitiveValue::CSS_UNKNOWN);
-    if(!(cssType > CSSPrimitiveValue::CSS_UNKNOWN && cssType <= CSSPrimitiveValue::CSS_PC))
+    if (!(cssType > CSSPrimitiveValue::CSS_UNKNOWN && cssType <= CSSPrimitiveValue::CSS_PC))
         return defaultValue;
 
-    if(cssType == CSSPrimitiveValue::CSS_PERCENTAGE)
-    {
-        SVGElement *element = static_cast<SVGElement *>(item->element());
-        SVGElement *viewportElement = (element ? element->viewportElement() : 0);
-        if(viewportElement)
-        {
+    if (cssType == CSSPrimitiveValue::CSS_PERCENTAGE) {
+        SVGElement* element = static_cast<SVGElement*>(item->element());
+        SVGElement* viewportElement = (element ? element->viewportElement() : 0);
+        if (viewportElement) {
             double result = primitive->getFloatValue() / 100.0;
             return SVGHelper::PercentageOfViewport(result, viewportElement, LM_OTHER);
         }
     }
 
-    return primitive->computeLengthFloat(const_cast<RenderStyle *>(item->style()));
+    return primitive->computeLengthFloat(const_cast<RenderStyle*>(item->style()));
 }
 
 KRenderingStrokePainter KSVGPainterFactory::strokePainter(const RenderStyle* style, const RenderObject* item)
@@ -151,15 +142,15 @@ KRenderingStrokePainter KSVGPainterFactory::strokePainter(const RenderStyle* sty
     strokePainter.setOpacity(style->svgStyle()->strokeOpacity());
     strokePainter.setStrokeWidth(KSVGPainterFactory::cssPrimitiveToLength(item, style->svgStyle()->strokeWidth(), 1.0));
 
-    CSSValueList *dashes = style->svgStyle()->strokeDashArray();
+    CSSValueListdashes = style->svgStyle()->strokeDashArray();
     if (dashes) {
-        CSSPrimitiveValue *dash = 0;
+        CSSPrimitiveValuedash = 0;
         KCDashArray array;
         unsigned long len = dashes->length();
         for (unsigned long i = 0; i < len; i++) {
-            dash = static_cast<CSSPrimitiveValue *>(dashes->item(i));
+            dash = static_cast<CSSPrimitiveValue*>(dashes->item(i));
             if (dash)
-                array.append((float) dash->computeLengthFloat(const_cast<RenderStyle *>(style)));
+                array.append((float) dash->computeLengthFloat(const_cast<RenderStyle*>(style)));
         }
 
         strokePainter.setDashArray(array);
index b7641878ffb21b64a364ce2be3b19f88ce3582d1..682644f8a0d5b06f4cc2565aad6ac260a7447d51 100644 (file)
@@ -57,6 +57,18 @@ SVGPaint::~SVGPaint()
 {
 }
 
+SVGPaint* SVGPaint::defaultFill()
+{
+    static SVGPaint* _defaultFill = new SVGPaint(SVG_PAINTTYPE_RGBCOLOR, String(), "black");
+    return _defaultFill;
+}
+
+SVGPaint* SVGPaint::defaultStroke()
+{
+    static SVGPaint* _defaultStroke = new SVGPaint(SVG_PAINTTYPE_NONE);
+    return _defaultStroke;
+}
+
 String SVGPaint::uri() const
 {
     return m_uri;
index 54eaf797b1403d16a6073f5b1c0e7e4127733ee5..5ae10e32f805be35b020e001366cc3d8377f664d 100644 (file)
@@ -58,6 +58,9 @@ namespace WebCore {
         void setPaint(SVGPaintType, const String& uri, const String& rgbPaint, const String& iccPaint, ExceptionCode&);
 
         virtual String cssText() const;
+        
+        static SVGPaint* defaultFill();
+        static SVGPaint* defaultStroke();
 
     private:
         SVGPaintType m_paintType;