+2007-08-10 Nikolas Zimmermann <zimmermann@kde.org>
+
+ Reviewed by Rob.
+
+ Update tests after the RenderSVGViewportContainer introduction.
+
+ * svg/W3C-SVG-1.1/coords-viewattr-01-b-expected.txt:
+ * svg/W3C-SVG-1.1/coords-viewattr-03-b-expected.txt:
+ * svg/W3C-SVG-1.1/filters-color-01-b-expected.txt:
+ * svg/W3C-SVG-1.1/filters-comptran-01-b-expected.txt:
+ * svg/W3C-SVG-1.1/filters-example-01-b-expected.txt:
+ * svg/W3C-SVG-1.1/interact-events-01-b-expected.txt:
+ * svg/W3C-SVG-1.1/masking-path-03-b-expected.txt:
+ * svg/W3C-SVG-1.1/painting-marker-01-f-expected.txt:
+ * svg/W3C-SVG-1.1/painting-marker-02-f-expected.txt:
+ * svg/W3C-SVG-1.1/painting-marker-03-f-expected.txt:
+ * svg/W3C-SVG-1.1/struct-group-02-b-expected.txt:
+ * svg/W3C-SVG-1.1/struct-image-02-b-expected.txt:
+ * svg/W3C-SVG-1.1/struct-symbol-01-b-expected.txt:
+ * svg/W3C-SVG-1.1/types-basicDOM-01-b-expected.txt:
+ * svg/carto.net/button-expected.txt:
+ * svg/carto.net/colourpicker-expected.txt:
+ * svg/carto.net/scrollbar-expected.txt:
+ * svg/carto.net/slider-expected.txt:
+ * svg/carto.net/textbox-expected.txt:
+ * svg/carto.net/window-expected.txt:
+ * svg/custom/circular-marker-reference-1-expected.txt:
+ * svg/custom/circular-marker-reference-2-expected.txt:
+ * svg/custom/circular-marker-reference-3-expected.txt:
+ * svg/custom/circular-marker-reference-4-expected.txt:
+ * svg/custom/container-opacity-clip-viewBox-expected.txt:
+ * svg/custom/deep-dynamic-updates-expected.txt:
+ * svg/custom/feComponentTransfer-Discrete-expected.txt:
+ * svg/custom/feComponentTransfer-Gamma-expected.txt:
+ * svg/custom/feComponentTransfer-Linear-expected.txt:
+ * svg/custom/feComponentTransfer-Table-expected.txt:
+ * svg/custom/image-clipped-hit-expected.txt:
+ * svg/custom/inner-percent-expected.txt:
+ * svg/custom/inner-svg-hit-test-expected.txt:
+ * svg/custom/invalid-css-expected.txt:
+ * svg/custom/js-late-marker-and-object-creation-expected.txt:
+ * svg/custom/js-late-marker-creation-expected.txt:
+ * svg/custom/marker-changes-expected.txt:
+ * svg/custom/marker-child-changes-expected.txt:
+ * svg/custom/marker-default-width-height-expected.txt:
+ * svg/custom/marker-overflow-clip-expected.txt:
+ * svg/custom/marker-viewBox-changes-expected.txt:
+ * svg/custom/non-circular-marker-reference-expected.txt:
+ * svg/custom/preserve-aspect-ratio-syntax-expected.txt:
+ * svg/custom/root-container-opacity-clip-viewBox-expected.txt:
+ * svg/custom/shapes-supporting-markers-expected.txt:
+ * svg/custom/struct-use-09-b-expected.txt:
+ * svg/custom/svg-overflow-types-expected.txt:
+ * svg/custom/text-ctm-expected.txt:
+ * svg/custom/use-clipped-hit-expected.txt:
+ * svg/custom/use-css-events-expected.txt:
+ * svg/custom/use-modify-target-symbol-expected.txt:
+ * svg/custom/use-on-disallowed-foreign-object-5-expected.txt:
+ * svg/custom/use-on-disallowed-foreign-object-6-expected.txt:
+ * svg/custom/use-on-g-containing-symbol-expected.txt:
+ * svg/custom/use-on-symbol-expected.txt:
+ * svg/custom/use-on-symbol-inside-pattern-expected.txt:
+ * svg/custom/use-symbol-overflow-expected.txt:
+ * svg/custom/viewbox-syntax-expected.txt:
+
2007-08-10 Nikolas Zimmermann <zimmermann@kde.org>
Reviewed by Oliver & Rob.
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderSVGRoot {svg} at (50,38.20) size 363x225.80
- RenderSVGContainer {svg} at (59.52,38.20) size 166x148 [opacity=0.90]
+ RenderSVGViewportContainer {svg} at (59.52,38.20) size 166x148 [opacity=0.90]
RenderSVGContainer {g} at (59.52,38.20) size 166x148 [transform={m=((1.00,0.00)(0.00,1.00)) t=(59.52,38.20)}]
- RenderSVGContainer {svg} at (59.52,38.20) size 166x148
+ RenderSVGViewportContainer {svg} at (59.52,38.20) size 166x148
RenderPath {rect} at (59.52,38.20) size 166x148 [fill={[type=SOLID] [color=#008000]}] [data="M-83.00,-84.00L83.00,-84.00L83.00,64.00L-83.00,64.00"]
RenderSVGContainer {g} at (50,216) size 363x48 [transform={m=((1.00,0.00)(0.00,1.00)) t=(50.00,230.00)}]
RenderSVGText {text} at (0,0) size 363x48 contains 3 chunk(s)
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderSVGRoot {svg} at (0,0) size 166x148 [opacity=0.90]
- RenderSVGContainer {svg} at (0,0) size 166x148
+ RenderSVGViewportContainer {svg} at (0,0) size 166x148
RenderPath {rect} at (0,0) size 166x148 [fill={[type=SOLID] [color=#008000]}] [data="M-83.00,-84.00L83.00,-84.00L83.00,64.00L-83.00,64.00"]
text run at (0,0) width 244: "You should only see this string ONCE"
RenderSVGContainer {use} at (0,0) size 0x0
RenderSVGContainer {g} at (25,25) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
- RenderSVGContainer {svg} at (25,25) size 0x0
+ RenderSVGViewportContainer {svg} at (25,25) size 0x0
RenderSVGContainer {use} at (0,0) size 0x0
RenderSVGContainer {g} at (10,10) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(10.00,10.00)}]
RenderSVGContainer {g} at (35,35) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
- RenderSVGContainer {svg} at (35,35) size 0x0
+ RenderSVGViewportContainer {svg} at (35,35) size 0x0
layer at (0,0) size 800x600
RenderSVGRoot {svg} at (0,0) size 0x0
RenderSVGHiddenContainer {defs} at (0,0) size 0x0
- RenderSVGContainer {svg} at (0,0) size 0x0
+ RenderSVGViewportContainer {svg} at (0,0) size 0x0
RenderForeignObject {foreignObject} at (0,0) size 580x380
RenderBlock {xhtml:div} at (0,0) size 580x18
RenderText {#text} at (0,0) size 244x18
text run at (0,0) width 244: "You should only see this string ONCE"
RenderSVGContainer {use} at (0,0) size 0x0
RenderSVGContainer {g} at (25,25) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
- RenderSVGContainer {svg} at (25,25) size 0x0
+ RenderSVGViewportContainer {svg} at (25,25) size 0x0
RenderSVGContainer {use} at (0,0) size 0x0
RenderSVGContainer {g} at (10,10) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(10.00,10.00)}]
RenderSVGContainer {g} at (35,35) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
- RenderSVGContainer {svg} at (35,35) size 0x0
+ RenderSVGViewportContainer {svg} at (35,35) size 0x0
RenderSVGContainer {use} at (45,45) size 130x30
RenderSVGContainer {g} at (45,45) size 130x30 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
RenderSVGContainer {g} at (45,45) size 130x30
- RenderSVGContainer {svg} at (45,45) size 130x30
+ RenderSVGViewportContainer {svg} at (45,45) size 130x30
RenderPath {rect} at (45,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,0.00L60.00,0.00L60.00,10.00L0.00,10.00"]
+2007-08-10 Nikolas Zimmermann <zimmermann@kde.org>
+
+ Reviewed by Rob.
+
+ Fixes: http://bugs.webkit.org/show_bug.cgi?id=14153
+
+ Final, long-awaited RenderSVGContainer split. Make RenderSVGContainer really a simple
+ container without special cases for inner <svg> elements or <marker>. Create a new
+ RenderSVGViewportContainer class handling these cases now.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * ksvg2/svg/SVGMarkerElement.cpp:
+ (WebCore::SVGMarkerElement::createRenderer):
+ * ksvg2/svg/SVGSVGElement.cpp:
+ (WebCore::SVGSVGElement::createRenderer):
+ * ksvg2/svg/SVGSVGElement.h:
+ * rendering/RenderSVGContainer.cpp:
+ (WebCore::RenderSVGContainer::layout):
+ (WebCore::RenderSVGContainer::applyContentTransforms):
+ (WebCore::RenderSVGContainer::applyAdditionalTransforms):
+ (WebCore::RenderSVGContainer::paint):
+ (WebCore::RenderSVGContainer::viewportTransform):
+ (WebCore::RenderSVGContainer::relativeBBox):
+ (WebCore::RenderSVGContainer::nodeAtPoint):
+ * rendering/RenderSVGContainer.h:
+ * rendering/RenderSVGRoot.cpp:
+ * rendering/RenderSVGViewportContainer.cpp: Added.
+ (WebCore::RenderSVGViewportContainer::RenderSVGViewportContainer):
+ (WebCore::RenderSVGViewportContainer::~RenderSVGViewportContainer):
+ (WebCore::RenderSVGViewportContainer::layout):
+ (WebCore::RenderSVGViewportContainer::paint):
+ (WebCore::RenderSVGViewportContainer::applyContentTransforms):
+ (WebCore::RenderSVGViewportContainer::applyAdditionalTransforms):
+ (WebCore::RenderSVGViewportContainer::viewport):
+ (WebCore::RenderSVGViewportContainer::calcViewport):
+ (WebCore::RenderSVGViewportContainer::viewportTransform):
+ (WebCore::RenderSVGViewportContainer::absoluteTransform):
+ (WebCore::RenderSVGViewportContainer::nodeAtPoint):
+ * rendering/RenderSVGViewportContainer.h: Added.
+ (WebCore::RenderSVGViewportContainer::isSVGContainer):
+ (WebCore::RenderSVGViewportContainer::renderName):
+
2007-08-10 Nikolas Zimmermann <zimmermann@kde.org>
Reviewed by Oliver & Rob.
B2CB92620B5BDA02009BAA78 /* DOMSVGElementInstance.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2CB925E0B5BDA02009BAA78 /* DOMSVGElementInstance.mm */; };
B2CB92630B5BDA02009BAA78 /* DOMSVGElementInstanceList.h in Headers */ = {isa = PBXBuildFile; fileRef = B2CB925F0B5BDA02009BAA78 /* DOMSVGElementInstanceList.h */; };
B2CB92640B5BDA02009BAA78 /* DOMSVGElementInstanceList.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2CB92600B5BDA02009BAA78 /* DOMSVGElementInstanceList.mm */; };
+ B2CCEC470C6CA9F1006A5424 /* RenderSVGViewportContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2CCEC450C6CA9F1006A5424 /* RenderSVGViewportContainer.cpp */; };
+ B2CCEC480C6CA9F1006A5424 /* RenderSVGViewportContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = B2CCEC460C6CA9F1006A5424 /* RenderSVGViewportContainer.h */; };
B2D3FC8A0C2212CB00CF3618 /* JSSVGTransformListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2D3FC890C2212CB00CF3618 /* JSSVGTransformListCustom.cpp */; };
B2D87C770B124E7300B0DE1E /* SVGPaintServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2D87C6B0B124E7300B0DE1E /* SVGPaintServer.cpp */; };
B2D87C780B124E7300B0DE1E /* SVGPaintServer.h in Headers */ = {isa = PBXBuildFile; fileRef = B2D87C6C0B124E7300B0DE1E /* SVGPaintServer.h */; };
B2CB925E0B5BDA02009BAA78 /* DOMSVGElementInstance.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMSVGElementInstance.mm; sourceTree = "<group>"; };
B2CB925F0B5BDA02009BAA78 /* DOMSVGElementInstanceList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMSVGElementInstanceList.h; sourceTree = "<group>"; };
B2CB92600B5BDA02009BAA78 /* DOMSVGElementInstanceList.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMSVGElementInstanceList.mm; sourceTree = "<group>"; };
+ B2CCEC450C6CA9F1006A5424 /* RenderSVGViewportContainer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGViewportContainer.cpp; sourceTree = "<group>"; };
+ B2CCEC460C6CA9F1006A5424 /* RenderSVGViewportContainer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderSVGViewportContainer.h; sourceTree = "<group>"; };
B2D3FC890C2212CB00CF3618 /* JSSVGTransformListCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGTransformListCustom.cpp; sourceTree = "<group>"; };
B2D87C6B0B124E7300B0DE1E /* SVGPaintServer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPaintServer.cpp; sourceTree = "<group>"; };
B2D87C6C0B124E7300B0DE1E /* SVGPaintServer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SVGPaintServer.h; sourceTree = "<group>"; };
B26554E90B80D74900A50EC3 /* RenderSVGTextPath.h */,
853CA9D40AEEC5E9002372DC /* RenderSVGTSpan.cpp */,
853CA9D50AEEC5E9002372DC /* RenderSVGTSpan.h */,
+ B2CCEC450C6CA9F1006A5424 /* RenderSVGViewportContainer.cpp */,
+ B2CCEC460C6CA9F1006A5424 /* RenderSVGViewportContainer.h */,
A8DF4AE20980C42C0052981B /* RenderTable.cpp */,
A8DF4AE10980C42C0052981B /* RenderTable.h */,
A8DF4AE00980C42C0052981B /* RenderTableCell.cpp */,
B223622E0C3AF0710008CA9B /* DOMSVGTextPathElement.h in Headers */,
B223622F0C3AF0710008CA9B /* DOMSVGTextPathElementInternal.h in Headers */,
AA4038910C4C0D8B00DB56DC /* SVGViewSpec.h in Headers */,
+ B2CCEC480C6CA9F1006A5424 /* RenderSVGViewportContainer.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
B22362280C3AF04A0008CA9B /* JSSVGTextPathElement.cpp in Sources */,
B2AE9B9D0C3AF27400F23F7F /* DOMSVGTextPathElement.mm in Sources */,
AA4038900C4C0D8B00DB56DC /* SVGViewSpec.cpp in Sources */,
+ B2CCEC470C6CA9F1006A5424 /* RenderSVGViewportContainer.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#include "SVGMarkerElement.h"
#include "PlatformString.h"
-#include "RenderSVGContainer.h"
+#include "RenderSVGViewportContainer.h"
#include "SVGAngle.h"
#include "SVGFitToViewBox.h"
#include "SVGLength.h"
RenderObject* SVGMarkerElement::createRenderer(RenderArena* arena, RenderStyle* style)
{
- RenderSVGContainer* markerContainer = new (arena) RenderSVGContainer(this);
+ RenderSVGViewportContainer* markerContainer = new (arena) RenderSVGViewportContainer(this);
markerContainer->setDrawsContents(false); // Marker contents will be explicitly drawn.
return markerContainer;
}
#include "FloatRect.h"
#include "Frame.h"
#include "HTMLNames.h"
-#include "RenderSVGContainer.h"
+#include "RenderSVGViewportContainer.h"
#include "RenderSVGRoot.h"
#include "SVGAngle.h"
#include "SVGLength.h"
if (!parentNode()->isSVGElement())
return new (arena) RenderSVGRoot(this);
else
- return new (arena) RenderSVGContainer(this);
+ return new (arena) RenderSVGViewportContainer(this);
}
void SVGSVGElement::insertedIntoDocument()
friend class RenderSVGContainer;
friend class RenderSVGRoot;
+ friend class RenderSVGViewportContainer;
+
virtual bool hasRelativeValues() const;
private:
#include "AXObjectCache.h"
#include "GraphicsContext.h"
#include "RenderView.h"
-#include "SVGFitToViewBox.h"
-#include "SVGLength.h"
-#include "SVGMarkerElement.h"
#include "SVGRenderSupport.h"
#include "SVGResourceFilter.h"
-#include "SVGSVGElement.h"
#include "SVGStyledElement.h"
#include "SVGURIReference.h"
{
ASSERT(needsLayout());
- calcViewport();
-
// Arbitrary affine transforms are incompatible with LayoutState.
view()->disableLayoutState();
void RenderSVGContainer::applyContentTransforms(PaintInfo& paintInfo)
{
- // Only the root <svg> element should need any translations using the HTML/CSS system
- // parentX, parentY are also non-zero for first-level kids of these
- // CSS-transformed <svg> root-elements (due to RenderBox::paint) for any other element
- // they should be 0. m_x, m_y should always be 0 for non-root svg containers
- if (!viewport().isEmpty()) {
- if (style()->overflowX() != OVISIBLE)
- paintInfo.context->clip(enclosingIntRect(viewport())); // FIXME: Eventually we'll want float-precision clipping
-
- paintInfo.context->concatCTM(AffineTransform().translate(viewport().x(), viewport().y()));
- }
-
if (!localTransform().isIdentity())
paintInfo.context->concatCTM(localTransform());
}
+void RenderSVGContainer::applyAdditionalTransforms(PaintInfo& paintInfo)
+{
+ // no-op
+}
+
void RenderSVGContainer::paint(PaintInfo& paintInfo, int parentX, int parentY)
{
if (paintInfo.context->paintingDisabled() || !drawsContents())
return;
- // A value of zero disables rendering of the element.
- if (!viewport().isEmpty() && (viewport().width() <= 0. || viewport().height() <= 0.))
- return;
-
if (!firstChild()) {
#if ENABLE(SVG_EXPERIMENTAL_FEATURES)
// Spec: groups w/o children still may render filter content.
applyContentTransforms(paintInfo);
SVGResourceFilter* filter = 0;
-
PaintInfo savedInfo(paintInfo);
FloatRect boundingBox = relativeBBox(true);
if (paintInfo.phase == PaintPhaseForeground)
prepareToRenderSVGContent(this, paintInfo, boundingBox, filter);
- paintInfo.context->concatCTM(viewportTransform());
+ applyAdditionalTransforms(paintInfo);
// default implementation. Just pass paint through to the children
PaintInfo childInfo(paintInfo);
paintOutline(paintInfo.context, m_absoluteBounds.x(), m_absoluteBounds.y(), m_absoluteBounds.width(), m_absoluteBounds.height(), style());
}
-FloatRect RenderSVGContainer::viewport() const
-{
- return m_viewport;
-}
-
-void RenderSVGContainer::calcViewport()
-{
- SVGElement* svgelem = static_cast<SVGElement*>(element());
- if (svgelem->hasTagName(SVGNames::svgTag)) {
- SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
-
- if (!selfNeedsLayout() && !svg->hasRelativeValues())
- return;
-
- float x = 0.0f;
- float y = 0.0f;
- if (parent()->isSVGContainer()) {
- x = svg->x().value();
- y = svg->y().value();
- }
- float w = svg->width().value();
- float h = svg->height().value();
- m_viewport = FloatRect(x, y, w, h);
- } else if (svgelem->hasTagName(SVGNames::markerTag)) {
- if (!selfNeedsLayout())
- return;
-
- SVGMarkerElement* svg = static_cast<SVGMarkerElement*>(element());
- float w = svg->markerWidth().value();
- float h = svg->markerHeight().value();
- m_viewport = FloatRect(0.0f, 0.0f, w, h);
- }
-}
-
AffineTransform RenderSVGContainer::viewportTransform() const
{
- if (element()->hasTagName(SVGNames::svgTag)) {
- SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
- return svg->viewBoxToViewTransform(viewport().width(), viewport().height());
- } else if (element()->hasTagName(SVGNames::markerTag)) {
- SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(element());
- return marker->viewBoxToViewTransform(viewport().width(), viewport().height());
- }
-
return AffineTransform();
}
rects.append(absoluteClippedOverflowRect());
}
-AffineTransform RenderSVGContainer::absoluteTransform() const
-{
- AffineTransform ctm = RenderObject::absoluteTransform();
- ctm.translate(viewport().x(), viewport().y());
- return viewportTransform() * ctm;
-}
-
-bool RenderSVGContainer::fillContains(const FloatPoint& p) const
-{
- RenderObject* current = firstChild();
- while (current != 0) {
- if (current->isRenderPath() && static_cast<RenderPath*>(current)->fillContains(p))
- return true;
-
- current = current->nextSibling();
- }
-
- return false;
-}
-
-bool RenderSVGContainer::strokeContains(const FloatPoint& p) const
-{
- RenderObject* current = firstChild();
- while (current != 0) {
- if (current->isRenderPath() && static_cast<RenderPath*>(current)->strokeContains(p))
- return true;
-
- current = current->nextSibling();
- }
-
- return false;
-}
-
FloatRect RenderSVGContainer::relativeBBox(bool includeStroke) const
{
FloatRect rect;
for (; current != 0; current = current->nextSibling()) {
FloatRect childBBox = current->relativeBBox(includeStroke);
FloatRect mappedBBox = current->localTransform().mapRect(childBBox);
+
// <svg> can have a viewBox contributing to the bbox
if (current->isSVGContainer())
mappedBBox = static_cast<RenderSVGContainer*>(current)->viewportTransform().mapRect(mappedBBox);
+
rect.unite(mappedBBox);
}
bool RenderSVGContainer::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction)
{
- if (!viewport().isEmpty()
- && style()->overflowX() == OHIDDEN
- && style()->overflowY() == OHIDDEN) {
- // Check if we need to do anything at all.
- IntRect overflowBox = overflowRect(false);
- overflowBox.move(_tx, _ty);
- AffineTransform ctm = RenderObject::absoluteTransform();
- ctm.translate(viewport().x(), viewport().y());
- double localX, localY;
- ctm.inverse().map(_x - _tx, _y - _ty, &localX, &localY);
- if (!overflowBox.contains((int)localX, (int)localY))
- return false;
- }
-
- int sx = 0;
- int sy = 0;
-
- // Respect parent translation offset for non-outermost <svg> elements.
- // Outermost <svg> element is handled by RenderSVGRoot.
- if (element()->hasTagName(SVGNames::svgTag)) {
- sx = _tx;
- sy = _ty;
- }
-
for (RenderObject* child = lastChild(); child; child = child->previousSibling()) {
- if (child->nodeAtPoint(request, result, _x - sx, _y - sy, _tx, _ty, hitTestAction)) {
+ if (child->nodeAtPoint(request, result, _x, _y, _tx, _ty, hitTestAction)) {
updateHitTestResult(result, IntPoint(_x - _tx, _y - _ty));
return true;
}
virtual bool isSVGContainer() const { return true; }
virtual const char* renderName() const { return "RenderSVGContainer"; }
-
+
virtual bool requiresLayer();
virtual short lineHeight(bool b, bool isRootLineBox = false) const;
virtual short baselinePosition(bool b, bool isRootLineBox = false) const;
-
+
virtual void layout();
virtual void paint(PaintInfo&, int parentX, int parentY);
-
+
virtual IntRect absoluteClippedOverflowRect();
virtual void absoluteRects(Vector<IntRect>& rects, int tx, int ty, bool topLevel = true);
virtual void addFocusRingRects(GraphicsContext*, int tx, int ty);
- virtual AffineTransform absoluteTransform() const;
-
- bool fillContains(const FloatPoint&) const;
- bool strokeContains(const FloatPoint&) const;
FloatRect relativeBBox(bool includeStroke = true) const;
-
+
virtual AffineTransform localTransform() const;
void setLocalTransform(const AffineTransform&);
-
- FloatRect viewport() const;
- AffineTransform viewportTransform() const;
-
+ virtual AffineTransform viewportTransform() const;
+
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
-
+
+protected:
+ virtual void applyContentTransforms(PaintInfo&);
+ virtual void applyAdditionalTransforms(PaintInfo&);
+
private:
- void calcViewport();
int calcReplacedWidth() const;
int calcReplacedHeight() const;
- void applyContentTransforms(PaintInfo&);
-
RenderObject* m_firstChild;
RenderObject* m_lastChild;
bool m_drawsContents : 1;
- AffineTransform m_matrix;
-
- FloatRect m_viewport;
IntRect m_absoluteBounds;
+
+ AffineTransform m_matrix;
};
} // namespace WebCore
return svg->viewBoxToViewTransform(width(), height()) * ctm;
}
-bool RenderSVGRoot::fillContains(const FloatPoint& p) const
-{
- RenderObject* current = firstChild();
- while (current != 0) {
- if (current->isRenderPath() && static_cast<RenderPath*>(current)->fillContains(p))
- return true;
-
- current = current->nextSibling();
- }
-
- return false;
-}
-
-bool RenderSVGRoot::strokeContains(const FloatPoint& p) const
-{
- RenderObject* current = firstChild();
- while (current != 0) {
- if (current->isRenderPath() && static_cast<RenderPath*>(current)->strokeContains(p))
- return true;
-
- current = current->nextSibling();
- }
-
- return false;
-}
-
FloatRect RenderSVGRoot::relativeBBox(bool includeStroke) const
{
FloatRect rect;
--- /dev/null
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2007 Rob Buis <buis@kde.org>
+ 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "RenderSVGViewportContainer.h"
+
+#include "GraphicsContext.h"
+#include "SVGMarkerElement.h"
+#include "SVGSVGElement.h"
+
+namespace WebCore {
+
+RenderSVGViewportContainer::RenderSVGViewportContainer(SVGStyledElement* node)
+ : RenderSVGContainer(node)
+{
+ setReplaced(true);
+}
+
+RenderSVGViewportContainer::~RenderSVGViewportContainer()
+{
+}
+
+void RenderSVGViewportContainer::layout()
+{
+ calcViewport();
+ RenderSVGContainer::layout();
+}
+
+void RenderSVGViewportContainer::paint(PaintInfo& paintInfo, int parentX, int parentY)
+{
+ // A value of zero disables rendering of the element.
+ if (!viewport().isEmpty() && (viewport().width() <= 0. || viewport().height() <= 0.))
+ return;
+
+ RenderSVGContainer::paint(paintInfo, parentX, parentY);
+}
+
+void RenderSVGViewportContainer::applyContentTransforms(PaintInfo& paintInfo)
+{
+ if (!viewport().isEmpty()) {
+ if (style()->overflowX() != OVISIBLE)
+ paintInfo.context->clip(enclosingIntRect(viewport())); // FIXME: Eventually we'll want float-precision clipping
+
+ paintInfo.context->concatCTM(AffineTransform().translate(viewport().x(), viewport().y()));
+ }
+
+ RenderSVGContainer::applyContentTransforms(paintInfo);
+}
+
+void RenderSVGViewportContainer::applyAdditionalTransforms(PaintInfo& paintInfo)
+{
+ paintInfo.context->concatCTM(viewportTransform());
+ RenderSVGContainer::applyAdditionalTransforms(paintInfo);
+}
+
+FloatRect RenderSVGViewportContainer::viewport() const
+{
+ return m_viewport;
+}
+
+void RenderSVGViewportContainer::calcViewport()
+{
+ SVGElement* svgelem = static_cast<SVGElement*>(element());
+ if (svgelem->hasTagName(SVGNames::svgTag)) {
+ SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
+
+ if (!selfNeedsLayout() && !svg->hasRelativeValues())
+ return;
+
+ double x = svg->x().value();
+ double y = svg->y().value();
+ double w = svg->width().value();
+ double h = svg->height().value();
+ m_viewport = FloatRect(x, y, w, h);
+ } else if (svgelem->hasTagName(SVGNames::markerTag)) {
+ if (!selfNeedsLayout())
+ return;
+
+ SVGMarkerElement* svg = static_cast<SVGMarkerElement*>(element());
+ double w = svg->markerWidth().value();
+ double h = svg->markerHeight().value();
+ m_viewport = FloatRect(0, 0, w, h);
+ }
+}
+
+AffineTransform RenderSVGViewportContainer::viewportTransform() const
+{
+ if (element()->hasTagName(SVGNames::svgTag)) {
+ SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
+ return svg->viewBoxToViewTransform(viewport().width(), viewport().height());
+ } else if (element()->hasTagName(SVGNames::markerTag)) {
+ SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(element());
+ return marker->viewBoxToViewTransform(viewport().width(), viewport().height());
+ }
+
+ return AffineTransform();
+}
+
+AffineTransform RenderSVGViewportContainer::absoluteTransform() const
+{
+ AffineTransform ctm = RenderObject::absoluteTransform();
+ ctm.translate(viewport().x(), viewport().y());
+ return viewportTransform() * ctm;
+}
+
+bool RenderSVGViewportContainer::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction)
+{
+ if (!viewport().isEmpty()
+ && style()->overflowX() == OHIDDEN
+ && style()->overflowY() == OHIDDEN) {
+ // Check if we need to do anything at all.
+ IntRect overflowBox = overflowRect(false);
+ overflowBox.move(_tx, _ty);
+ AffineTransform ctm = RenderObject::absoluteTransform();
+ ctm.translate(viewport().x(), viewport().y());
+ double localX, localY;
+ ctm.inverse().map(_x - _tx, _y - _ty, &localX, &localY);
+ if (!overflowBox.contains((int)localX, (int)localY))
+ return false;
+ }
+
+ int sx = 0;
+ int sy = 0;
+
+ // Respect parent translation offset for non-outermost <svg> elements.
+ // Outermost <svg> element is handled by RenderSVGRoot.
+ if (element()->hasTagName(SVGNames::svgTag)) {
+ sx = _tx;
+ sy = _ty;
+ }
+
+ for (RenderObject* child = lastChild(); child; child = child->previousSibling()) {
+ if (child->nodeAtPoint(request, result, _x - sx, _y - sy, _tx, _ty, hitTestAction)) {
+ updateHitTestResult(result, IntPoint(_x - _tx, _y - _ty));
+ return true;
+ }
+ }
+
+ // Spec: Only graphical elements can be targeted by the mouse, period.
+ // 16.4: "If there are no graphics elements whose relevant graphics content is under the pointer (i.e., there is no target element), the event is not dispatched."
+ return false;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
--- /dev/null
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef RenderSVGViewportContainer_h
+#define RenderSVGViewportContainer_h
+
+#if ENABLE(SVG)
+
+#include "RenderSVGContainer.h"
+
+namespace WebCore {
+
+class RenderSVGViewportContainer : public RenderSVGContainer {
+public:
+ RenderSVGViewportContainer(SVGStyledElement*);
+ ~RenderSVGViewportContainer();
+
+ virtual bool isSVGContainer() const { return true; }
+ virtual const char* renderName() const { return "RenderSVGViewportContainer"; }
+
+ virtual void layout();
+ virtual void paint(PaintInfo&, int parentX, int parentY);
+
+ virtual AffineTransform absoluteTransform() const;
+ virtual AffineTransform viewportTransform() const;
+
+ virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
+
+ FloatRect viewport() const;
+
+private:
+ void calcViewport();
+
+ virtual void applyContentTransforms(PaintInfo&);
+ virtual void applyAdditionalTransforms(PaintInfo&);
+
+ AffineTransform m_matrix;
+
+ FloatRect m_viewport;
+ IntRect m_absoluteBounds;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // RenderSVGViewportContainer_h
+
+// vim:ts=4:noet