#include "core/svg/SVGUseElement.h"
-#include "bindings/v8/ExceptionStatePlaceholder.h"
+#include "bindings/core/v8/ExceptionStatePlaceholder.h"
#include "core/XLinkNames.h"
#include "core/dom/Document.h"
#include "core/dom/ElementTraversal.h"
#include "core/svg/SVGSVGElement.h"
#include "core/xml/parser/XMLDocumentParser.h"
-namespace WebCore {
+namespace blink {
inline SVGUseElement::SVGUseElement(Document& document)
: SVGGraphicsElement(SVGNames::useTag, document)
, m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired)
{
ASSERT(hasCustomStyleCallbacks());
- ScriptWrappable::init(this);
addToPropertyMap(m_x);
addToPropertyMap(m_y);
void SVGUseElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
- SVGParsingError parseError = NoError;
-
- if (!isSupportedAttribute(name)) {
- SVGGraphicsElement::parseAttribute(name, value);
- } else if (name == SVGNames::xAttr) {
- m_x->setBaseValueAsString(value, parseError);
- } else if (name == SVGNames::yAttr) {
- m_y->setBaseValueAsString(value, parseError);
- } else if (name == SVGNames::widthAttr) {
- m_width->setBaseValueAsString(value, parseError);
- } else if (name == SVGNames::heightAttr) {
- m_height->setBaseValueAsString(value, parseError);
- } else if (SVGURIReference::parseAttribute(name, value, parseError)) {
- } else {
- ASSERT_NOT_REACHED();
- }
-
- reportAttributeParsingError(parseError, name, value);
+ parseAttributeNew(name, value);
}
-#if ASSERT_ENABLED
+#if ENABLE(ASSERT)
static inline bool isWellFormedDocument(Document* document)
{
if (document->isXMLDocument())
void transferUseWidthAndHeightIfNeeded(const SVGUseElement& use, SVGElement* shadowElement, const SVGElement& originalElement)
{
+ DEFINE_STATIC_LOCAL(const AtomicString, hundredPercentString, ("100%", AtomicString::ConstructFromLiteral));
ASSERT(shadowElement);
if (isSVGSymbolElement(*shadowElement)) {
// Spec (<use> on <symbol>): This generated 'svg' will always have explicit values for attributes width and height.
// If attributes width and/or height are provided on the 'use' element, then these attributes
// will be transferred to the generated 'svg'. If attributes width and/or height are not specified,
// the generated 'svg' element will use values of 100% for these attributes.
- shadowElement->setAttribute(SVGNames::widthAttr, use.width()->isSpecified() ? AtomicString(use.width()->currentValue()->valueAsString()) : "100%");
- shadowElement->setAttribute(SVGNames::heightAttr, use.height()->isSpecified() ? AtomicString(use.height()->currentValue()->valueAsString()) : "100%");
+ shadowElement->setAttribute(SVGNames::widthAttr, use.width()->isSpecified() ? AtomicString(use.width()->currentValue()->valueAsString()) : hundredPercentString);
+ shadowElement->setAttribute(SVGNames::heightAttr, use.height()->isSpecified() ? AtomicString(use.height()->currentValue()->valueAsString()) : hundredPercentString);
} else if (isSVGSVGElement(*shadowElement)) {
// Spec (<use> on <svg>): If attributes width and/or height are provided on the 'use' element, then these
// values will override the corresponding attributes on the 'svg' in the generated tree.
if (isExternalReference) {
KURL url = document().completeURL(hrefString());
if (url.hasFragmentIdentifier()) {
- FetchRequest request(ResourceRequest(url.string()), localName());
+ FetchRequest request(ResourceRequest(url), localName());
setDocumentResource(document().fetcher()->fetchSVGDocument(request));
}
} else {
m_needsShadowTreeRecreation = false;
document().unscheduleUseShadowTreeUpdate(*this);
- document().accessSVGExtensions().removeAllTargetReferencesForElement(this);
+ removeAllOutgoingReferences();
}
void SVGUseElement::buildPendingResource()
return new RenderSVGTransformableContainer(this);
}
-static bool isDirectReference(const Node& node)
+static bool isDirectReference(const SVGElement& element)
{
- return isSVGPathElement(node)
- || isSVGRectElement(node)
- || isSVGCircleElement(node)
- || isSVGEllipseElement(node)
- || isSVGPolygonElement(node)
- || isSVGPolylineElement(node)
- || isSVGTextElement(node);
+ return isSVGPathElement(element)
+ || isSVGRectElement(element)
+ || isSVGCircleElement(element)
+ || isSVGEllipseElement(element)
+ || isSVGPolygonElement(element)
+ || isSVGPolylineElement(element)
+ || isSVGTextElement(element);
}
void SVGUseElement::toClipPath(Path& path)
ASSERT(path.isEmpty());
Node* n = userAgentShadowRoot()->firstChild();
- if (!n)
+ if (!n || !n->isSVGElement())
return;
+ SVGElement& element = toSVGElement(*n);
- if (n->isSVGElement() && toSVGElement(n)->isSVGGraphicsElement()) {
- if (!isDirectReference(*n)) {
+ if (element.isSVGGraphicsElement()) {
+ if (!isDirectReference(element)) {
// Spec: Indirect references are an error (14.3.5)
document().accessSVGExtensions().reportError("Not allowed to use indirect reference in <clip-path>");
} else {
- toSVGGraphicsElement(n)->toClipPath(path);
+ toSVGGraphicsElement(element).toClipPath(path);
// FIXME: Avoid manual resolution of x/y here. Its potentially harmful.
SVGLengthContext lengthContext(this);
path.translate(FloatSize(m_x->currentValue()->value(lengthContext), m_y->currentValue()->value(lengthContext)));
RenderObject* SVGUseElement::rendererClipChild() const
{
if (Node* n = userAgentShadowRoot()->firstChild()) {
- if (n->isSVGElement() && isDirectReference(*n))
- return toSVGElement(n)->renderer();
+ if (n->isSVGElement() && isDirectReference(toSVGElement(*n)))
+ return n->renderer();
}
return 0;
if (isSVGUseElement(*target)) {
// We only need to track first degree <use> dependencies. Indirect references are handled
// as the invalidation bubbles up the dependency chain.
- if (!foundUse) {
- document().accessSVGExtensions().addElementReferencingTarget(this, target);
+ if (!foundUse && !isStructurallyExternal()) {
+ addReferenceTo(target);
foundUse = true;
}
} else if (isDisallowedElement(target)) {