| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv
ed. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv
ed. |
| 5 * Copyright (C) 2010 Google Inc. All rights reserved. | 5 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 { | 154 { |
| 155 if (name == altAttr) { | 155 if (name == altAttr) { |
| 156 if (renderer() && renderer()->isImage()) | 156 if (renderer() && renderer()->isImage()) |
| 157 toRenderImage(renderer())->updateAltText(); | 157 toRenderImage(renderer())->updateAltText(); |
| 158 } else if (name == srcAttr || name == srcsetAttr || name == sizesAttr) { | 158 } else if (name == srcAttr || name == srcsetAttr || name == sizesAttr) { |
| 159 int effectiveSize = 0; | 159 int effectiveSize = 0; |
| 160 if (RuntimeEnabledFeatures::pictureSizesEnabled()) | 160 if (RuntimeEnabledFeatures::pictureSizesEnabled()) |
| 161 effectiveSize = SizesAttributeParser::findEffectiveSize(fastGetAttri
bute(sizesAttr), MediaValuesCached::create(document())); | 161 effectiveSize = SizesAttributeParser::findEffectiveSize(fastGetAttri
bute(sizesAttr), MediaValuesCached::create(document())); |
| 162 ImageCandidate candidate = bestFitSourceForImageAttributes(document().de
vicePixelRatio(), effectiveSize, fastGetAttribute(srcAttr), fastGetAttribute(src
setAttr)); | 162 ImageCandidate candidate = bestFitSourceForImageAttributes(document().de
vicePixelRatio(), effectiveSize, fastGetAttribute(srcAttr), fastGetAttribute(src
setAttr)); |
| 163 m_bestFitImageURL = candidate.toAtomicString(); | 163 m_bestFitImageURL = candidate.toAtomicString(); |
| 164 m_currentSrc = AtomicString(document().completeURL(imageSourceURL()).str
ing()); |
| 164 float candidateScaleFactor = candidate.scaleFactor(); | 165 float candidateScaleFactor = candidate.scaleFactor(); |
| 165 // FIXME: Make this ">0" part match the spec, once it settles. | 166 // FIXME: Make this ">0" part match the spec, once it settles. |
| 166 if (candidateScaleFactor > 0) | 167 if (candidateScaleFactor > 0) |
| 167 m_imageDevicePixelRatio = 1 / candidateScaleFactor; | 168 m_imageDevicePixelRatio = 1 / candidateScaleFactor; |
| 168 if (renderer() && renderer()->isImage()) | 169 if (renderer() && renderer()->isImage()) |
| 169 toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePix
elRatio); | 170 toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePix
elRatio); |
| 170 m_imageLoader.updateFromElementIgnoringPreviousError(); | 171 m_imageLoader.updateFromElementIgnoringPreviousError(); |
| 171 } else if (name == usemapAttr) { | 172 } else if (name == usemapAttr) { |
| 172 setIsLink(!value.isNull()); | 173 setIsLink(!value.isNull()); |
| 173 } else if (name == compositeAttr) { | 174 } else if (name == compositeAttr) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 int HTMLImageElement::naturalHeight() const | 309 int HTMLImageElement::naturalHeight() const |
| 309 { | 310 { |
| 310 if (!m_imageLoader.image()) | 311 if (!m_imageLoader.image()) |
| 311 return 0; | 312 return 0; |
| 312 | 313 |
| 313 return m_imageLoader.image()->imageSizeForRenderer(renderer(), 1.0f).height(
); | 314 return m_imageLoader.image()->imageSizeForRenderer(renderer(), 1.0f).height(
); |
| 314 } | 315 } |
| 315 | 316 |
| 316 const AtomicString& HTMLImageElement::currentSrc() const | 317 const AtomicString& HTMLImageElement::currentSrc() const |
| 317 { | 318 { |
| 318 return m_bestFitImageURL; | 319 return m_currentSrc; |
| 319 } | 320 } |
| 320 | 321 |
| 321 bool HTMLImageElement::isURLAttribute(const Attribute& attribute) const | 322 bool HTMLImageElement::isURLAttribute(const Attribute& attribute) const |
| 322 { | 323 { |
| 323 return attribute.name() == srcAttr | 324 return attribute.name() == srcAttr |
| 324 || attribute.name() == lowsrcAttr | 325 || attribute.name() == lowsrcAttr |
| 325 || attribute.name() == longdescAttr | 326 || attribute.name() == longdescAttr |
| 326 || (attribute.name() == usemapAttr && attribute.value().string()[0] != '
#') | 327 || (attribute.name() == usemapAttr && attribute.value().string()[0] != '
#') |
| 327 || HTMLElement::isURLAttribute(attribute); | 328 || HTMLElement::isURLAttribute(attribute); |
| 328 } | 329 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 if (!image) | 476 if (!image) |
| 476 return FloatSize(); | 477 return FloatSize(); |
| 477 LayoutSize size; | 478 LayoutSize size; |
| 478 size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure abo
ut this. | 479 size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure abo
ut this. |
| 479 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i
mage()->hasRelativeWidth()) | 480 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i
mage()->hasRelativeWidth()) |
| 480 size.scale(toRenderImage(renderer())->imageDevicePixelRatio()); | 481 size.scale(toRenderImage(renderer())->imageDevicePixelRatio()); |
| 481 return size; | 482 return size; |
| 482 } | 483 } |
| 483 | 484 |
| 484 } | 485 } |
| OLD | NEW |