void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { if (name == altAttr) { if (renderer() && renderer()->isRenderImage()) toRenderImage(renderer())->updateAltText(); } else if (name == srcAttr || name == srcsetAttr) { ImageWithScale candidate = bestFitSourceForImageAttributes(document().deviceScaleFactor(), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr)); m_bestFitImageURL = candidate.imageURL(fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr)); float candidateScaleFactor = candidate.scaleFactor(); if (candidateScaleFactor > 0) m_imageDevicePixelRatio = 1 / candidateScaleFactor; if (renderer() && renderer()->isImage()) toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePixelRatio); m_imageLoader.updateFromElementIgnoringPreviousError(); } else if (name == usemapAttr) { setIsLink(!value.isNull() && !shouldProhibitLinks(this)); if (inDocument() && !m_lowercasedUsemap.isNull()) document().removeImageElementByLowercasedUsemap(*m_lowercasedUsemap.impl(), *this); // The HTMLImageElement's useMap() value includes the '#' symbol at the beginning, which has to be stripped off. // FIXME: We should check that the first character is '#'. // FIXME: HTML5 specification says we should strip any leading string before '#'. // FIXME: HTML5 specification says we should ignore usemap attributes without #. if (value.length() > 1) m_lowercasedUsemap = value.string().substring(1).lower(); else m_lowercasedUsemap = nullAtom; if (inDocument() && !m_lowercasedUsemap.isNull()) document().addImageElementByLowercasedUsemap(*m_lowercasedUsemap.impl(), *this); } else if (name == onbeforeloadAttr) setAttributeEventListener(eventNames().beforeloadEvent, name, value); else if (name == compositeAttr) { // FIXME: images don't support blend modes in their compositing attribute. BlendMode blendOp = BlendModeNormal; if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp)) m_compositeOperator = CompositeSourceOver; } else { if (name == nameAttr) { bool willHaveName = !value.isNull(); if (hasName() != willHaveName && inDocument() && document().isHTMLDocument()) { HTMLDocument* document = toHTMLDocument(&this->document()); const AtomicString& id = getIdAttribute(); if (!id.isEmpty() && id != getNameAttribute()) { if (willHaveName) document->addDocumentNamedItem(*id.impl(), *this); else document->removeDocumentNamedItem(*id.impl(), *this); } } } HTMLElement::parseAttribute(name, value); } }