namespace WebCore {
// Animated property definitions
-DEFINE_ANIMATED_STRING(SVGImageElement, XLinkNames::hrefAttr, Href, href)
BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGImageElement)
- REGISTER_LOCAL_ANIMATED_PROPERTY(href)
REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
END_REGISTER_ANIMATED_PROPERTIES
inline SVGImageElement::SVGImageElement(Document& document)
: SVGGraphicsElement(SVGNames::imageTag, document)
+ , SVGURIReference(this)
, m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(LengthModeWidth)))
, m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(LengthModeHeight)))
, m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::create(LengthModeWidth)))
, m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::create(LengthModeHeight)))
, m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create()))
, m_imageLoader(this)
+ , m_needsLoaderURIUpdate(true)
{
ScriptWrappable::init(this);
{
SVGParsingError parseError = NoError;
- if (!isSupportedAttribute(name))
+ if (!isSupportedAttribute(name)) {
SVGGraphicsElement::parseAttribute(name, value);
- else if (name == SVGNames::xAttr)
+ } else if (name == SVGNames::xAttr) {
m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError);
- else if (name == SVGNames::yAttr)
+ } else if (name == SVGNames::yAttr) {
m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError);
- else if (name == SVGNames::widthAttr)
+ } else if (name == SVGNames::widthAttr) {
m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError);
- else if (name == SVGNames::heightAttr)
+ } else if (name == SVGNames::heightAttr) {
m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError);
- else if (name == SVGNames::preserveAspectRatioAttr) {
+ } else if (name == SVGNames::preserveAspectRatioAttr) {
m_preserveAspectRatio->setBaseValueAsString(value, parseError);
- } else if (SVGURIReference::parseAttribute(name, value)) {
- } else
+ } else if (SVGURIReference::parseAttribute(name, value, parseError)) {
+ } else {
ASSERT_NOT_REACHED();
+ }
reportAttributeParsingError(parseError, name, value);
}
updateRelativeLengthsInformation();
if (SVGURIReference::isKnownAttribute(attrName)) {
- m_imageLoader.updateFromElementIgnoringPreviousError();
+ if (inDocument())
+ m_imageLoader.updateFromElementIgnoringPreviousError();
+ else
+ m_needsLoaderURIUpdate = true;
return;
}
bool SVGImageElement::haveLoadedRequiredResources()
{
- return !m_imageLoader.hasPendingActivity();
+ return !m_needsLoaderURIUpdate && !m_imageLoader.hasPendingActivity();
}
void SVGImageElement::attach(const AttachContext& context)
SVGGraphicsElement::insertedInto(rootParent);
if (!rootParent->inDocument())
return InsertionDone;
- // Update image loader, as soon as we're living in the tree.
- // We can only resolve base URIs properly, after that!
- m_imageLoader.updateFromElement();
+
+ // We can only resolve base URIs properly after tree insertion - hence, URI mutations while
+ // detached are deferred until this point.
+ if (m_needsLoaderURIUpdate) {
+ m_imageLoader.updateFromElementIgnoringPreviousError();
+ m_needsLoaderURIUpdate = false;
+ }
+
return InsertionDone;
}
const AtomicString SVGImageElement::imageSourceURL() const
{
- return AtomicString(hrefCurrentValue());
+ return AtomicString(hrefString());
}
void SVGImageElement::didMoveToNewDocument(Document& oldDocument)