summaryrefslogtreecommitdiffstats
path: root/WebCore/svg
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/svg')
-rw-r--r--WebCore/svg/SVGForeignObjectElement.cpp81
-rw-r--r--WebCore/svg/SVGLength.cpp16
-rw-r--r--WebCore/svg/SVGMaskElement.cpp128
-rw-r--r--WebCore/svg/SVGMaskElement.h15
-rw-r--r--WebCore/svg/SVGSVGElement.cpp13
-rw-r--r--WebCore/svg/SVGStyledElement.cpp18
-rw-r--r--WebCore/svg/SVGStyledElement.h2
-rw-r--r--WebCore/svg/SVGUnitTypes.h8
-rw-r--r--WebCore/svg/graphics/SVGImage.cpp2
-rw-r--r--WebCore/svg/graphics/SVGResource.h4
-rw-r--r--WebCore/svg/graphics/SVGResourceMasker.cpp99
-rw-r--r--WebCore/svg/graphics/SVGResourceMasker.h76
12 files changed, 51 insertions, 411 deletions
diff --git a/WebCore/svg/SVGForeignObjectElement.cpp b/WebCore/svg/SVGForeignObjectElement.cpp
index e9118ef..d28e2a4 100644
--- a/WebCore/svg/SVGForeignObjectElement.cpp
+++ b/WebCore/svg/SVGForeignObjectElement.cpp
@@ -72,82 +72,21 @@ void SVGForeignObjectElement::parseMappedAttribute(MappedAttribute* attr)
}
}
-// TODO: Move this function in some SVG*Element base class, as SVGSVGElement / SVGImageElement will need the same logic!
-
-// This function mimics addCSSProperty and StyledElement::attributeChanged.
-// In HTML code, you'd always call addCSSProperty from your derived parseMappedAttribute()
-// function - though in SVG code we need to move this logic into svgAttributeChanged, in
-// order to support SVG DOM changes (which don't use the parseMappedAttribute/attributeChanged).
-// If we'd ignore SVG DOM, we could use _exactly_ the same logic as HTML.
-static inline void addCSSPropertyAndNotifyAttributeMap(StyledElement* element, const QualifiedName& name, int cssProperty, const String& value)
-{
- ASSERT(element);
-
- if (!element)
- return;
-
- NamedMappedAttrMap* attrs = element->mappedAttributes();
- ASSERT(attrs);
-
- if (!attrs)
- return;
-
- Attribute* attr = attrs->getAttributeItem(name);
- if (!attr || !attr->isMappedAttribute())
- return;
-
- MappedAttribute* mappedAttr = static_cast<MappedAttribute*>(attr);
-
- // This logic is only meant to be used for entries that have to be parsed and are mapped to eNone. Assert that.
- MappedAttributeEntry entry;
- bool needToParse = element->mapToEntry(mappedAttr->name(), entry);
-
- ASSERT(needToParse);
- ASSERT(entry == eNone);
-
- if (!needToParse || entry != eNone)
- return;
-
- if (mappedAttr->decl()) {
- mappedAttr->setDecl(0);
- attrs->declRemoved();
- }
-
- element->setNeedsStyleRecalc();
- element->addCSSProperty(mappedAttr, cssProperty, value);
-
- if (CSSMappedAttributeDeclaration* decl = mappedAttr->decl()) {
- // Add the decl to the table in the appropriate spot.
- element->setMappedAttributeDecl(entry, mappedAttr, decl);
-
- decl->setMappedState(entry, mappedAttr->name(), mappedAttr->value());
- decl->setParent(0);
- decl->setNode(0);
-
- attrs->declAdded();
- }
-}
-
void SVGForeignObjectElement::svgAttributeChanged(const QualifiedName& attrName)
{
SVGStyledTransformableElement::svgAttributeChanged(attrName);
- if (attrName == SVGNames::widthAttr) {
- addCSSPropertyAndNotifyAttributeMap(this, attrName, CSSPropertyWidth, width().valueAsString());
- return;
- } else if (attrName == SVGNames::heightAttr) {
- addCSSPropertyAndNotifyAttributeMap(this, attrName, CSSPropertyHeight, height().valueAsString());
- return;
- }
-
if (!renderer())
return;
- if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr ||
- SVGTests::isKnownAttribute(attrName) ||
- SVGLangSpace::isKnownAttribute(attrName) ||
- SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
- SVGStyledTransformableElement::isKnownAttribute(attrName))
+ if (attrName == SVGNames::xAttr
+ || attrName == SVGNames::yAttr
+ || attrName == SVGNames::widthAttr
+ || attrName == SVGNames::heightAttr
+ || SVGTests::isKnownAttribute(attrName)
+ || SVGLangSpace::isKnownAttribute(attrName)
+ || SVGExternalResourcesRequired::isKnownAttribute(attrName)
+ || SVGStyledTransformableElement::isKnownAttribute(attrName))
renderer()->setNeedsLayout(true);
}
@@ -190,6 +129,6 @@ bool SVGForeignObjectElement::childShouldCreateRenderer(Node* child) const
return StyledElement::childShouldCreateRenderer(child);
}
-} // namespace WebCore
+}
-#endif // ENABLE(SVG) && ENABLE(SVG_FOREIGN_OBJECT)
+#endif
diff --git a/WebCore/svg/SVGLength.cpp b/WebCore/svg/SVGLength.cpp
index 2884507..e342acf 100644
--- a/WebCore/svg/SVGLength.cpp
+++ b/WebCore/svg/SVGLength.cpp
@@ -280,15 +280,16 @@ float SVGLength::PercentageOfViewport(float value, const SVGElement* context, SV
float width = 0.0f, height = 0.0f;
SVGElement* viewportElement = context->viewportElement();
+ // PercentageOfViewport() is used to resolve all relative-positioned values within a SVG document (fragment)
Document* doc = context->document();
if (doc->documentElement() == context) {
- // We have to ask the canvas for the full "canvas size"...
- RenderView* view = toRenderView(doc->renderer());
- if (view && view->frameView()) {
- width = view->frameView()->visibleWidth(); // TODO: recheck!
- height = view->frameView()->visibleHeight(); // TODO: recheck!
+ // Resolve value against outermost <svg> element
+ if (RenderView* view = toRenderView(doc->renderer())) {
+ width = view->viewWidth();
+ height = view->viewHeight();
}
} else if (viewportElement && viewportElement->isSVG()) {
+ // Resolve value against nearest viewport element (common case: inner <svg> elements)
const SVGSVGElement* svg = static_cast<const SVGSVGElement*>(viewportElement);
if (svg->hasAttribute(SVGNames::viewBoxAttr)) {
width = svg->viewBox().width();
@@ -298,6 +299,7 @@ float SVGLength::PercentageOfViewport(float value, const SVGElement* context, SV
height = svg->height().value(svg);
}
} else if (context->parent() && !context->parent()->isSVGElement()) {
+ // Resolve value against enclosing non-SVG RenderBox
if (RenderObject* renderer = context->renderer()) {
if (renderer->isBox()) {
RenderBox* box = toRenderBox(renderer);
@@ -319,6 +321,4 @@ float SVGLength::PercentageOfViewport(float value, const SVGElement* context, SV
}
-#endif // ENABLE(SVG)
-
-// vim:ts=4:noet
+#endif
diff --git a/WebCore/svg/SVGMaskElement.cpp b/WebCore/svg/SVGMaskElement.cpp
index 86d1062..67b0a98 100644
--- a/WebCore/svg/SVGMaskElement.cpp
+++ b/WebCore/svg/SVGMaskElement.cpp
@@ -3,6 +3,7 @@
2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
2005 Alexander Kellett <lypanov@kde.org>
2009 Dirk Schulze <krit@webkit.org>
+ Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -25,23 +26,13 @@
#if ENABLE(SVG)
#include "SVGMaskElement.h"
-#include "CanvasPixelArray.h"
#include "CSSStyleSelector.h"
-#include "GraphicsContext.h"
-#include "Image.h"
-#include "ImageBuffer.h"
-#include "ImageData.h"
#include "MappedAttribute.h"
-#include "RenderObject.h"
-#include "RenderSVGContainer.h"
+#include "RenderSVGResourceMasker.h"
#include "SVGLength.h"
#include "SVGNames.h"
#include "SVGRenderSupport.h"
#include "SVGUnitTypes.h"
-#include <math.h>
-#include <wtf/MathExtras.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/Vector.h>
using namespace std;
@@ -167,122 +158,9 @@ FloatRect SVGMaskElement::maskBoundingBox(const FloatRect& objectBoundingBox) co
return maskBBox;
}
-PassOwnPtr<ImageBuffer> SVGMaskElement::drawMaskerContent(const RenderObject* object, FloatRect& maskDestRect, bool& emptyMask) const
-{
- FloatRect objectBoundingBox = object->objectBoundingBox();
-
- // Mask rect clipped with clippingBoundingBox and filterBoundingBox as long as they are present.
- maskDestRect = object->repaintRectInLocalCoordinates();
- if (maskDestRect.isEmpty()) {
- emptyMask = true;
- return 0;
- }
-
- // Calculate the smallest rect for the mask ImageBuffer.
- FloatRect repaintRect;
- Vector<RenderObject*> rendererList;
- for (Node* node = firstChild(); node; node = node->nextSibling()) {
- if (!node->isSVGElement() || !static_cast<SVGElement*>(node)->isStyled() || !node->renderer())
- continue;
-
- rendererList.append(node->renderer());
- repaintRect.unite(node->renderer()->localToParentTransform().mapRect(node->renderer()->repaintRectInLocalCoordinates()));
- }
-
- AffineTransform contextTransform;
- // We need to scale repaintRect for objectBoundingBox to get the drawing area.
- if (maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
- contextTransform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.height());
- FloatPoint contextAdjustment = repaintRect.location();
- repaintRect = contextTransform.mapRect(repaintRect);
- repaintRect.move(objectBoundingBox.x(), objectBoundingBox.y());
- contextTransform.translate(-contextAdjustment.x(), -contextAdjustment.y());
- }
- repaintRect.intersect(maskDestRect);
- maskDestRect = repaintRect;
- IntRect maskImageRect = enclosingIntRect(maskDestRect);
-
- maskImageRect.setLocation(IntPoint());
-
- // Don't create ImageBuffers with image size of 0
- if (!maskImageRect.width() || !maskImageRect.height()) {
- emptyMask = true;
- return 0;
- }
-
- // FIXME: This changes color space to linearRGB, the default color space
- // for masking operations in SVG. We need a switch for the other color-space
- // attribute values sRGB, inherit and auto.
- OwnPtr<ImageBuffer> maskImage = ImageBuffer::create(maskImageRect.size(), LinearRGB);
- if (!maskImage)
- return 0;
-
- GraphicsContext* maskImageContext = maskImage->context();
- ASSERT(maskImageContext);
-
- maskImageContext->save();
-
- if (maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE)
- maskImageContext->translate(-maskDestRect.x(), -maskDestRect.y());
- maskImageContext->concatCTM(contextTransform);
-
- // draw the content into the ImageBuffer
- Vector<RenderObject*>::iterator end = rendererList.end();
- for (Vector<RenderObject*>::iterator it = rendererList.begin(); it != end; it++)
- renderSubtreeToImage(maskImage.get(), *it);
-
-
- maskImageContext->restore();
-
- // create the luminance mask
- RefPtr<ImageData> imageData(maskImage->getUnmultipliedImageData(maskImageRect));
- CanvasPixelArray* srcPixelArray(imageData->data());
-
- for (unsigned pixelOffset = 0; pixelOffset < srcPixelArray->length(); pixelOffset += 4) {
- unsigned char a = srcPixelArray->get(pixelOffset + 3);
- if (!a)
- continue;
- unsigned char r = srcPixelArray->get(pixelOffset);
- unsigned char g = srcPixelArray->get(pixelOffset + 1);
- unsigned char b = srcPixelArray->get(pixelOffset + 2);
-
- double luma = (r * 0.2125 + g * 0.7154 + b * 0.0721) * ((double)a / 255.0);
- srcPixelArray->set(pixelOffset + 3, luma);
- }
-
- maskImage->putUnmultipliedImageData(imageData.get(), maskImageRect, IntPoint());
-
- return maskImage.release();
-}
-
RenderObject* SVGMaskElement::createRenderer(RenderArena* arena, RenderStyle*)
{
- RenderSVGContainer* maskContainer = new (arena) RenderSVGContainer(this);
- maskContainer->setDrawsContents(false);
- return maskContainer;
-}
-
-SVGResource* SVGMaskElement::canvasResource(const RenderObject* object)
-{
- ASSERT(object);
-
- if (m_masker.contains(object))
- return m_masker.get(object).get();
-
- RefPtr<SVGResourceMasker> masker = SVGResourceMasker::create(this);
- SVGResourceMasker* maskerPtr = masker.get();
- m_masker.set(object, masker.release());
-
- return maskerPtr;
-}
-
-void SVGMaskElement::invalidateCanvasResources()
-{
- // Don't call through to the base class since the base class will just
- // invalidate one item in the HashMap.
- HashMap<const RenderObject*, RefPtr<SVGResourceMasker> >::const_iterator end = m_masker.end();
- for (HashMap<const RenderObject*, RefPtr<SVGResourceMasker> >::const_iterator it = m_masker.begin(); it != end; ++it)
- it->second->invalidate();
+ return new (arena) RenderSVGResourceMasker(this);
}
}
diff --git a/WebCore/svg/SVGMaskElement.h b/WebCore/svg/SVGMaskElement.h
index 005fa4f..7730e37 100644
--- a/WebCore/svg/SVGMaskElement.h
+++ b/WebCore/svg/SVGMaskElement.h
@@ -22,19 +22,15 @@
#if ENABLE(SVG)
#include "RenderObject.h"
-#include "SVGResourceMasker.h"
#include "SVGExternalResourcesRequired.h"
#include "SVGLangSpace.h"
#include "SVGStyledLocatableElement.h"
#include "SVGTests.h"
#include "SVGURIReference.h"
-#include <wtf/HashMap.h>
-#include <wtf/PassOwnPtr.h>
namespace WebCore {
class SVGLength;
- class SVGResourceMasker;
class SVGMaskElement : public SVGStyledLocatableElement,
public SVGURIReference,
@@ -53,9 +49,6 @@ namespace WebCore {
virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
- virtual SVGResource* canvasResource(const RenderObject*);
-
- PassOwnPtr<ImageBuffer> drawMaskerContent(const RenderObject*, FloatRect& maskRect, bool& emptyMask) const;
private:
DECLARE_ANIMATED_PROPERTY(SVGMaskElement, SVGNames::maskUnitsAttr, int, MaskUnits, maskUnits)
@@ -70,13 +63,9 @@ namespace WebCore {
// SVGExternalResourcesRequired
DECLARE_ANIMATED_PROPERTY(SVGMaskElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired)
-
- virtual void invalidateCanvasResources();
-
- HashMap<const RenderObject*, RefPtr<SVGResourceMasker> > m_masker;
};
-} // namespace WebCore
+}
-#endif // ENABLE(SVG)
+#endif
#endif
diff --git a/WebCore/svg/SVGSVGElement.cpp b/WebCore/svg/SVGSVGElement.cpp
index cfe1615..ff24c4f 100644
--- a/WebCore/svg/SVGSVGElement.cpp
+++ b/WebCore/svg/SVGSVGElement.cpp
@@ -187,16 +187,19 @@ SVGViewSpec* SVGSVGElement::currentView() const
float SVGSVGElement::currentScale() const
{
- if (document() && parentNode() == document())
- return document()->frame() ? document()->frame()->zoomFactor() : 1;
+ // Only the page zoom factor is relevant for SVG
+ if (Frame* frame = document()->frame())
+ return frame->pageZoomFactor();
return m_scale;
}
void SVGSVGElement::setCurrentScale(float scale)
{
- if (document() && parentNode() == document()) {
- if (document()->frame())
- document()->frame()->setZoomFactor(scale, true);
+ if (Frame* frame = document()->frame()) {
+ // Calling setCurrentScale() on the outermost <svg> element in a standalone SVG document
+ // is allowed to change the page zoom factor, influencing the document size, scrollbars etc.
+ if (parentNode() == document())
+ frame->setZoomFactor(scale, false);
return;
}
diff --git a/WebCore/svg/SVGStyledElement.cpp b/WebCore/svg/SVGStyledElement.cpp
index be1ba9c..ff94c7d 100644
--- a/WebCore/svg/SVGStyledElement.cpp
+++ b/WebCore/svg/SVGStyledElement.cpp
@@ -32,6 +32,8 @@
#include "MappedAttribute.h"
#include "PlatformString.h"
#include "RenderObject.h"
+#include "RenderSVGResource.h"
+#include "RenderSVGResourceMasker.h"
#include "SVGElement.h"
#include "SVGElementInstance.h"
#include "SVGElementRareData.h"
@@ -39,7 +41,6 @@
#include "SVGRenderStyle.h"
#include "SVGResourceClipper.h"
#include "SVGResourceFilter.h"
-#include "SVGResourceMasker.h"
#include "SVGSVGElement.h"
#include <wtf/Assertions.h>
@@ -234,9 +235,8 @@ void SVGStyledElement::invalidateResources()
filter->invalidate();
#endif
- SVGResourceMasker* masker = getMaskerById(document, svgStyle->maskElement(), object);
- if (masker)
- masker->invalidate();
+ if (RenderSVGResourceMasker* masker = getRenderSVGResourceById<RenderSVGResourceMasker>(document, svgStyle->maskElement()))
+ masker->invalidateClient(object);
SVGResourceClipper* clipper = getClipperById(document, svgStyle->clipPath(), object);
if (clipper)
@@ -260,7 +260,15 @@ void SVGStyledElement::invalidateResourcesInAncestorChain() const
void SVGStyledElement::invalidateCanvasResources()
{
- if (SVGResource* resource = canvasResource(renderer()))
+ RenderObject* object = renderer();
+ if (!object)
+ return;
+
+ if (object->isSVGResource())
+ object->toRenderSVGResource()->invalidateClients();
+
+ // The following lines will be removed soon, once all resources are handled by renderers.
+ if (SVGResource* resource = canvasResource(object))
resource->invalidate();
}
diff --git a/WebCore/svg/SVGStyledElement.h b/WebCore/svg/SVGStyledElement.h
index aec3e75..9645db4 100644
--- a/WebCore/svg/SVGStyledElement.h
+++ b/WebCore/svg/SVGStyledElement.h
@@ -71,7 +71,7 @@ namespace WebCore {
protected:
static int cssPropertyIdForSVGAttributeName(const QualifiedName&);
- virtual void invalidateCanvasResources();
+ void invalidateCanvasResources();
private:
DECLARE_ANIMATED_PROPERTY(SVGStyledElement, HTMLNames::classAttr, String, ClassName, className)
diff --git a/WebCore/svg/SVGUnitTypes.h b/WebCore/svg/SVGUnitTypes.h
index b639f29..86d49b4 100644
--- a/WebCore/svg/SVGUnitTypes.h
+++ b/WebCore/svg/SVGUnitTypes.h
@@ -38,9 +38,9 @@ private:
SVGUnitTypes() { }
};
-} // namespace WebCore
+static inline SVGUnitTypes::SVGUnitType toUnitType(int type) { return static_cast<SVGUnitTypes::SVGUnitType>(type); }
-#endif // ENABLE(SVG)
-#endif // SVGUnitTypes_h
+}
-// vim:ts=4:noet
+#endif
+#endif
diff --git a/WebCore/svg/graphics/SVGImage.cpp b/WebCore/svg/graphics/SVGImage.cpp
index 348df4f..febfce8 100644
--- a/WebCore/svg/graphics/SVGImage.cpp
+++ b/WebCore/svg/graphics/SVGImage.cpp
@@ -215,7 +215,7 @@ NativeImagePtr SVGImage::nativeImageForCurrentFrame()
m_frameCache = ImageBuffer::create(size());
if (!m_frameCache) // failed to allocate image
return 0;
- renderSubtreeToImage(m_frameCache.get(), m_page->mainFrame()->contentRenderer());
+ draw(m_frameCache->context(), rect(), rect(), DeviceColorSpace, CompositeSourceOver);
}
return m_frameCache->image()->nativeImageForCurrentFrame();
}
diff --git a/WebCore/svg/graphics/SVGResource.h b/WebCore/svg/graphics/SVGResource.h
index 8f303b5..b231b89 100644
--- a/WebCore/svg/graphics/SVGResource.h
+++ b/WebCore/svg/graphics/SVGResource.h
@@ -45,10 +45,9 @@ namespace WebCore {
enum SVGResourceType {
// Painting mode
ClipperResourceType = 0,
- MarkerResourceType,
ImageResourceType,
FilterResourceType,
- MaskerResourceType,
+ MarkerResourceType,
PaintServerResourceType,
// For resource tracking we need to know how many types of resource there are
@@ -78,7 +77,6 @@ namespace WebCore {
bool isFilter() const { return resourceType() == FilterResourceType; }
bool isClipper() const { return resourceType() == ClipperResourceType; }
bool isMarker() const { return resourceType() == MarkerResourceType; }
- bool isMasker() const { return resourceType() == MaskerResourceType; }
virtual TextStream& externalRepresentation(TextStream&) const;
diff --git a/WebCore/svg/graphics/SVGResourceMasker.cpp b/WebCore/svg/graphics/SVGResourceMasker.cpp
deleted file mode 100644
index 18bc71a..0000000
--- a/WebCore/svg/graphics/SVGResourceMasker.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- * 2009 Dirk Schulze <krit@webkit.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGResourceMasker.h"
-
-#include "CanvasPixelArray.h"
-#include "Image.h"
-#include "ImageBuffer.h"
-#include "ImageData.h"
-#include "GraphicsContext.h"
-#include "RenderObject.h"
-#include "SVGMaskElement.h"
-#include "SVGRenderSupport.h"
-#include "SVGRenderStyle.h"
-#include "TextStream.h"
-
-using namespace std;
-
-namespace WebCore {
-
-SVGResourceMasker::SVGResourceMasker(const SVGMaskElement* ownerElement)
- : SVGResource()
- , m_ownerElement(ownerElement)
- , m_emptyMask(false)
-{
-}
-
-SVGResourceMasker::~SVGResourceMasker()
-{
-}
-
-void SVGResourceMasker::invalidate()
-{
- SVGResource::invalidate();
- m_mask.clear();
- m_emptyMask = false;
-}
-
-FloatRect SVGResourceMasker::maskerBoundingBox(const FloatRect& objectBoundingBox) const
-{
- return m_ownerElement->maskBoundingBox(objectBoundingBox);
-}
-
-bool SVGResourceMasker::applyMask(GraphicsContext* context, const RenderObject* object)
-{
- if (!m_mask && !m_emptyMask)
- m_mask = m_ownerElement->drawMaskerContent(object, m_maskRect, m_emptyMask);
-
- if (!m_mask)
- return false;
-
- context->clipToImageBuffer(m_maskRect, m_mask.get());
- return true;
-}
-
-TextStream& SVGResourceMasker::externalRepresentation(TextStream& ts) const
-{
- ts << "[type=MASKER]";
- return ts;
-}
-
-SVGResourceMasker* getMaskerById(Document* document, const AtomicString& id, const RenderObject* object)
-{
- SVGResource* resource = getResourceById(document, id, object);
- if (resource && resource->isMasker())
- return static_cast<SVGResourceMasker*>(resource);
-
- return 0;
-}
-
-} // namespace WebCore
-
-#endif
diff --git a/WebCore/svg/graphics/SVGResourceMasker.h b/WebCore/svg/graphics/SVGResourceMasker.h
deleted file mode 100644
index 27364c2..0000000
--- a/WebCore/svg/graphics/SVGResourceMasker.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SVGResourceMasker_h
-#define SVGResourceMasker_h
-
-#if ENABLE(SVG)
-
-#include "GraphicsContext.h"
-#include "RenderObject.h"
-#include "SVGMaskElement.h"
-#include "SVGResource.h"
-
-#include <memory>
-
-#include <wtf/OwnPtr.h>
-#include <wtf/PassRefPtr.h>
-
-namespace WebCore {
-
- class FloatRect;
- class ImageBuffer;
- class SVGMaskElement;
-
- class SVGResourceMasker : public SVGResource {
- public:
- static PassRefPtr<SVGResourceMasker> create(const SVGMaskElement* ownerElement) { return adoptRef(new SVGResourceMasker(ownerElement)); }
- virtual ~SVGResourceMasker();
-
- virtual void invalidate();
-
- virtual SVGResourceType resourceType() const { return MaskerResourceType; }
- virtual TextStream& externalRepresentation(TextStream&) const;
-
- FloatRect maskerBoundingBox(const FloatRect&) const;
- bool applyMask(GraphicsContext*, const RenderObject*);
-
- private:
- SVGResourceMasker(const SVGMaskElement*);
-
- const SVGMaskElement* m_ownerElement;
-
- OwnPtr<ImageBuffer> m_mask;
- FloatRect m_maskRect;
- bool m_emptyMask;
- };
-
- SVGResourceMasker* getMaskerById(Document*, const AtomicString&, const RenderObject* object);
-
-} // namespace WebCore
-
-#endif
-
-#endif // SVGResourceMasker_h