Chromium Code Reviews| Index: Source/core/html/HTMLImageElement.cpp |
| diff --git a/Source/core/html/HTMLImageElement.cpp b/Source/core/html/HTMLImageElement.cpp |
| index a2ee16b6e691f0e11ccd83c4abb17a58ae05c37c..a2d6ecb2a294d19d9998e530c5a6f6ee164367a4 100644 |
| --- a/Source/core/html/HTMLImageElement.cpp |
| +++ b/Source/core/html/HTMLImageElement.cpp |
| @@ -51,7 +51,6 @@ HTMLImageElement::HTMLImageElement(Document& document, HTMLFormElement* form) |
| , m_compositeOperator(CompositeSourceOver) |
| , m_imageDevicePixelRatio(1.0f) |
| , m_formWasSetByParser(false) |
| - , m_effectiveSize(0) |
| { |
| ScriptWrappable::init(this); |
| if (form && form->inDocument()) { |
| @@ -157,17 +156,18 @@ void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr |
| if (renderer() && renderer()->isImage()) |
| toRenderImage(renderer())->updateAltText(); |
| } else if (name == srcAttr || name == srcsetAttr) { |
| - int effectiveSize = -1; // FIXME - hook up the real value from `sizes` |
| + int effectiveSize = 0; |
| + if (RuntimeEnabledFeatures::pictureSizesEnabled()) |
| + effectiveSize = SizesAttributeParser::findEffectiveSize(fastGetAttribute(sizesAttr), MediaValuesCached::create(document())); |
|
eseidel
2014/04/19 04:18:46
This doesn't seem quite right. If you set src the
|
| ImageCandidate candidate = bestFitSourceForImageAttributes(document().devicePixelRatio(), effectiveSize, fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr)); |
| m_bestFitImageURL = candidate.toAtomicString(); |
| float candidateScaleFactor = candidate.scaleFactor(); |
| + // FIXME: Make this ">0" part match the spec, once it settles. |
| if (candidateScaleFactor > 0) |
| m_imageDevicePixelRatio = 1 / candidateScaleFactor; |
| if (renderer() && renderer()->isImage()) |
| toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePixelRatio); |
| m_imageLoader.updateFromElementIgnoringPreviousError(); |
| - } else if (RuntimeEnabledFeatures::pictureSizesEnabled() && name == sizesAttr) { |
| - m_effectiveSize = SizesAttributeParser::findEffectiveSize(value, MediaValuesCached::create(document())); |
| } else if (name == usemapAttr) { |
| setIsLink(!value.isNull()); |
| } else if (name == compositeAttr) { |
| @@ -313,6 +313,11 @@ int HTMLImageElement::naturalHeight() const |
| return m_imageLoader.image()->imageSizeForRenderer(renderer(), 1.0f).height(); |
| } |
| +AtomicString HTMLImageElement::currentSrc() const |
| +{ |
| + return m_bestFitImageURL; |
| +} |
| + |
| bool HTMLImageElement::isURLAttribute(const Attribute& attribute) const |
| { |
| return attribute.name() == srcAttr |