Commit 59e92ca2 authored by eseidel's avatar eseidel

2006-08-26 Eric Seidel <eric@eseidel.com>

        Reviewed by hyatt.

        pointer-events attribute does not work.
        http://bugzilla.opendarwin.org/show_bug.cgi?id=10415

        * kcanvas/RenderPath.cpp:
        (WebCore::RenderPath::pointerEventsHitRules): new function to contain pointer-events hit logic
        (WebCore::RenderPath::nodeAtPoint): respect pointer-events property
        * kcanvas/RenderPath.h:
        (WebCore::RenderPath::PointerEventsHitRules::PointerEventsHitRules):
        * ksvg2/css/SVGCSSParser.cpp:
        (WebCore::CSSParser::parseSVGValue):
        * ksvg2/svg/SVGPaint.cpp: Fix this to use a real enum value
        (WebCore::SVGPaint::SVGPaint):
        (WebCore::SVGPaint::paintType):
        (WebCore::SVGPaint::uri):
        (WebCore::SVGPaint::setUri):
        (WebCore::SVGPaint::setPaint):
        * ksvg2/svg/SVGPaint.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16053 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ceddffaa
2006-08-26 Eric Seidel <eric@eseidel.com>
Reviewed by hyatt.
Test case for: pointer-events does not work.
http://bugzilla.opendarwin.org/show_bug.cgi?id=10415
* svg/custom/pointer-events-path-expected.checksum: Added.
* svg/custom/pointer-events-path-expected.png: Added.
* svg/custom/pointer-events-path-expected.txt: Added.
* svg/custom/pointer-events-path.svg: Added.
2006-08-27 Rob Buis <buis@kde.org>
Reviewed by Eric.
7f45327d19a6b416dc13d65e96ac18aa
\ No newline at end of file
This diff is collapsed.
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" onload="fillTestContent()">
<style type="text/css">
rect {
stroke-width: 6px;
}
</style>
<script type="text/javascript">
<![CDATA[
if (window.layoutTestController)
layoutTestController.waitUntilDone();
var visibleValues = [ 'visible', 'hidden' ];
var fillValues = ['none', 'orange' ];
var strokeValues = ['none', 'blue' ];
var pointerEventsValues = ['visiblePainted', 'visibleFill', 'visibleStroke', 'visible', 'painted', 'fill', 'stroke', 'all', 'none'];
var leftEdge = 100;
var topEdge = 100;
var rectSpacing = 57;
var svgNS = "http://www.w3.org/2000/svg";
function clickHit(event, identifierString) {
// This is my cheap hack to see if we hit the stroke.
if ((event.clientX - parseInt(event.target.getAttribute('x'))) == 0) {
var strokeText = document.getElementById('stroke-text' + identifierString);
strokeText.textContent = 'HIT';
}
var fillText = document.getElementById('fill-text' + identifierString);
fillText.textContent = 'HIT';
}
function fillTestContent() {
var xOffset = leftEdge;
var yOffset = topEdge;
var testContent = document.getElementById("test-content");
for (var pi = 0; pi < pointerEventsValues.length; pi++) {
var eventLabel = document.createElementNS(svgNS, 'text');
eventLabel.setAttribute('x', 0);
eventLabel.setAttribute('y', yOffset + 30);
eventLabel.textContent = pointerEventsValues[pi];
testContent.appendChild(eventLabel);
for (var vi = 0; vi < visibleValues.length; vi++) {
for (var fi = 0; fi < fillValues.length; fi++) {
for (var si = 0; si < strokeValues.length; si++) {
var identString = "_" + pi + "_" + vi + "_" + fi + "_" + si;
var rect = document.createElementNS(svgNS, 'rect');
rect.setAttribute('x', xOffset);
rect.setAttribute('y', yOffset);
rect.setAttribute('width', 50);
rect.setAttribute('height', 50);
rect.setAttribute('visibility', visibleValues[vi]);
rect.setAttribute('fill', fillValues[fi]);
rect.setAttribute('stroke', strokeValues[si]);
rect.setAttribute('pointer-events', pointerEventsValues[pi]);
rect.setAttribute('onclick', 'clickHit(evt, "' + identString + '")');
testContent.appendChild(rect);
var fillText = document.createElementNS(svgNS, 'text');
fillText.setAttribute('x', xOffset + 5);
fillText.setAttribute('y', yOffset + 20);
fillText.textContent = "miss";
fillText.setAttribute('id', 'fill-text' + identString);
fillText.setAttribute('pointer-events', 'none');
testContent.appendChild(fillText);
var stokeText = document.createElementNS(svgNS, 'text');
stokeText.setAttribute('x', xOffset + 5);
stokeText.setAttribute('y', yOffset + 40);
stokeText.textContent = "miss";
stokeText.setAttribute('id', 'stroke-text' + identString);
stokeText.setAttribute('pointer-events', 'none');
testContent.appendChild(stokeText);
if (window.eventSender) {
// Stroke click
eventSender.mouseMoveTo(xOffset, yOffset);
eventSender.mouseDown();
eventSender.mouseUp();
// Fill click
eventSender.mouseMoveTo(xOffset + 25, yOffset + 25);
eventSender.mouseDown();
eventSender.mouseUp();
}
xOffset += rectSpacing;
}
}
}
xOffset = leftEdge;
yOffset += rectSpacing;
}
if (window.layoutTestController)
layoutTestController.notifyDone();
}
]]>
</script>
<text x="110" y="90">Visibility: visible</text>
<text x="340" y="90">Visibility: hidden</text>
<text x="10" y="18">Example:</text>
<text x="5" y="40">Hit Fill:</text>
<text x="5" y="60">Hit Stroke:</text>
<g id="test-content">
<rect x="80" y="20" width="50" height="50" fill="orange" />
<text x="85" y="40">HIT</text>
<text x="85" y="60">miss</text>
</g>
</svg>
2006-08-26 Eric Seidel <eric@eseidel.com>
Reviewed by hyatt.
pointer-events attribute does not work.
http://bugzilla.opendarwin.org/show_bug.cgi?id=10415
* kcanvas/RenderPath.cpp:
(WebCore::RenderPath::pointerEventsHitRules): new function to contain pointer-events hit logic
(WebCore::RenderPath::nodeAtPoint): respect pointer-events property
* kcanvas/RenderPath.h:
(WebCore::RenderPath::PointerEventsHitRules::PointerEventsHitRules):
* ksvg2/css/SVGCSSParser.cpp:
(WebCore::CSSParser::parseSVGValue):
* ksvg2/svg/SVGPaint.cpp: Fix this to use a real enum value
(WebCore::SVGPaint::SVGPaint):
(WebCore::SVGPaint::paintType):
(WebCore::SVGPaint::uri):
(WebCore::SVGPaint::setUri):
(WebCore::SVGPaint::setPaint):
* ksvg2/svg/SVGPaint.h:
2006-08-27 Rob Buis <buis@kde.org>
Reviewed by Eric.
......
......@@ -263,15 +263,73 @@ void RenderPath::absoluteRects(DeprecatedValueList<IntRect>& rects, int _tx, int
rects.append(getAbsoluteRepaintRect());
}
RenderPath::PointerEventsHitRules RenderPath::pointerEventsHitRules()
{
PointerEventsHitRules hitRules;
switch (style()->svgStyle()->pointerEvents())
{
case PE_VISIBLE_PAINTED:
hitRules.requireVisible = true;
hitRules.requireFill = true;
hitRules.requireStroke = true;
hitRules.canHitFill = true;
hitRules.canHitStroke = true;
break;
case PE_VISIBLE_FILL:
hitRules.requireVisible = true;
hitRules.canHitFill = true;
break;
case PE_VISIBLE_STROKE:
hitRules.requireVisible = true;
hitRules.canHitStroke = true;
break;
case PE_VISIBLE:
hitRules.requireVisible = true;
hitRules.canHitFill = true;
hitRules.canHitStroke = true;
break;
case PE_PAINTED:
hitRules.requireFill = true;
hitRules.requireStroke = true;
hitRules.canHitFill = true;
hitRules.canHitStroke = true;
break;
case PE_FILL:
hitRules.canHitFill = true;
break;
case PE_STROKE:
hitRules.canHitStroke = true;
break;
case PE_ALL:
hitRules.canHitFill = true;
hitRules.canHitStroke = true;
break;
case PE_NONE:
// nothing to do here, defaults are all false.
break;
}
return hitRules;
}
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.
if (hitTestAction != HitTestForeground)
return false;
if (strokeContains(FloatPoint(_x, _y)) || fillContains(FloatPoint(_x, _y))) {
setInnerNode(info);
return true;
PointerEventsHitRules hitRules = pointerEventsHitRules();
bool isVisible = (style()->visibility() == VISIBLE);
if (isVisible || !hitRules.requireVisible) {
bool hasFill = (style()->svgStyle()->fillPaint() && style()->svgStyle()->fillPaint()->paintType() != SVG_PAINTTYPE_NONE);
bool hasStroke = (style()->svgStyle()->strokePaint() && style()->svgStyle()->strokePaint()->paintType() != SVG_PAINTTYPE_NONE);
FloatPoint hitPoint(_x,_y);
if ((hitRules.canHitStroke && (hasStroke || !hitRules.requireStroke) && strokeContains(hitPoint))
|| (hitRules.canHitFill && (hasFill || !hitRules.requireFill) && fillContains(hitPoint))) {
setInnerNode(info);
return true;
}
}
return false;
}
......
......@@ -71,13 +71,32 @@ public:
virtual void absoluteRects(DeprecatedValueList<IntRect>& rects, int tx, int ty);
virtual bool nodeAtPoint(NodeInfo&, int x, int y, int tx, int ty, HitTestAction);
// FIXME: When the other SVG classes get pointer-events support this should be moved elsewhere
struct PointerEventsHitRules {
PointerEventsHitRules()
: requireVisible(false)
, requireFill(false)
, requireStroke(false)
, canHitStroke(false)
, canHitFill(false)
{}
bool requireVisible;
bool requireFill;
bool requireStroke;
bool canHitStroke;
bool canHitFill;
};
protected:
virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const KCanvasPath*) const = 0;
private:
FloatRect strokeBBox() const;
FloatPoint mapAbsolutePointToLocal(const FloatPoint& point) const;
FloatPoint mapAbsolutePointToLocal(const FloatPoint&) const;
PointerEventsHitRules pointerEventsHitRules();
class Private;
Private *d;
......
......@@ -188,8 +188,8 @@ bool CSSParser::parseSVGValue(int propId, bool important)
case SVGCSS_PROP_POINTER_EVENTS:
// visiblePainted | visibleFill | visibleStroke | visible |
// painted | fill | stroke || all | inherit
if (id == CSS_VAL_VISIBLE ||
// painted | fill | stroke | none | all | inherit
if (id == CSS_VAL_VISIBLE || id == CSS_VAL_NONE ||
(id >= SVGCSS_VAL_VISIBLEPAINTED && id <= SVGCSS_VAL_ALL))
valid_primitive = true;
break;
......
......@@ -29,27 +29,27 @@ namespace WebCore {
SVGPaint::SVGPaint()
: SVGColor()
, m_paintType(SVG_PAINTTYPE_UNKNOWN)
{
m_paintType = SVG_PAINTTYPE_UNKNOWN;
}
SVGPaint::SVGPaint(StringImpl *uri)
SVGPaint::SVGPaint(StringImpl* uri)
: SVGColor()
, m_paintType(SVG_PAINTTYPE_URI)
{
m_paintType = SVG_PAINTTYPE_URI;
setUri(uri);
}
SVGPaint::SVGPaint(unsigned short paintType)
SVGPaint::SVGPaint(SVGPaintType paintType)
: SVGColor()
, m_paintType(paintType)
{
m_paintType = paintType;
}
SVGPaint::SVGPaint(unsigned short paintType, StringImpl *uri, StringImpl *rgbPaint, StringImpl *)
SVGPaint::SVGPaint(SVGPaintType paintType, StringImpl* uri, StringImpl* rgbPaint, StringImpl*)
: SVGColor(rgbPaint)
, m_paintType(paintType)
{
m_paintType = paintType;
setUri(uri);
}
......@@ -57,22 +57,22 @@ SVGPaint::~SVGPaint()
{
}
unsigned short SVGPaint::paintType() const
SVGPaintType SVGPaint::paintType() const
{
return m_paintType;
}
StringImpl *SVGPaint::uri() const
StringImpl* SVGPaint::uri() const
{
return m_uri.impl();
}
void SVGPaint::setUri(StringImpl *uri)
void SVGPaint::setUri(StringImpl* uri)
{
m_uri = uri;
}
void SVGPaint::setPaint(unsigned short paintType, StringImpl *uri, StringImpl *rgbPaint, StringImpl *)
void SVGPaint::setPaint(SVGPaintType paintType, StringImpl* uri, StringImpl* rgbPaint, StringImpl*)
{
m_paintType = paintType;
......
......@@ -24,6 +24,7 @@
#define KSVG_SVGPaintImpl_H
#ifdef SVG_SUPPORT
#include "ksvg.h"
#include <SVGColor.h>
namespace WebCore {
......@@ -31,22 +32,22 @@ namespace WebCore {
class SVGPaint : public SVGColor {
public:
SVGPaint();
SVGPaint(StringImpl *uri);
SVGPaint(unsigned short paintType);
SVGPaint(unsigned short paintType, StringImpl *uri, StringImpl *rgbPaint = 0, StringImpl *iccPaint = 0);
SVGPaint(StringImpl* uri);
SVGPaint(SVGPaintType);
SVGPaint(SVGPaintType, StringImpl* uri, StringImpl* rgbPaint = 0, StringImpl* iccPaint = 0);
virtual ~SVGPaint();
// 'SVGPaint' functions
unsigned short paintType() const;
StringImpl *uri() const;
SVGPaintType paintType() const;
StringImpl* uri() const;
void setUri(StringImpl *uri);
void setPaint(unsigned short paintType, StringImpl *uri, StringImpl *rgbPaint, StringImpl *iccPaint);
void setUri(StringImpl*);
void setPaint(SVGPaintType, StringImpl* uri, StringImpl* rgbPaint, StringImpl* iccPaint);
virtual String cssText() const;
private:
unsigned short m_paintType;
SVGPaintType m_paintType;
String m_uri;
};
......
Markdown is supported
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