Commit 4eb9f842 authored by eseidel's avatar eseidel
Browse files

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:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16604 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e1d38c67
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.
16310588467cfc20d551635abc59b784
\ No newline at end of file
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"]
<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
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.
......@@ -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;
}
......
......@@ -21,13 +21,13 @@
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
......@@ -29,17 +29,14 @@
#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();
CSSValueList* dashes = style->svgStyle()->strokeDashArray();
if (dashes) {
CSSPrimitiveValue *dash = 0;
CSSPrimitiveValue* dash = 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);
......
......@@ -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;
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment