| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 namespace WebCore { | 44 namespace WebCore { |
| 45 | 45 |
| 46 using namespace HTMLNames; | 46 using namespace HTMLNames; |
| 47 | 47 |
| 48 HTMLImageElement::HTMLImageElement(Document& document, HTMLFormElement* form) | 48 HTMLImageElement::HTMLImageElement(Document& document, HTMLFormElement* form) |
| 49 : HTMLElement(imgTag, document) | 49 : HTMLElement(imgTag, document) |
| 50 , m_imageLoader(this) | 50 , m_imageLoader(this) |
| 51 , m_compositeOperator(CompositeSourceOver) | 51 , m_compositeOperator(CompositeSourceOver) |
| 52 , m_imageDevicePixelRatio(1.0f) | 52 , m_imageDevicePixelRatio(1.0f) |
| 53 , m_formWasSetByParser(false) | 53 , m_formWasSetByParser(false) |
| 54 , m_effectiveSize(0) | |
| 55 { | 54 { |
| 56 ScriptWrappable::init(this); | 55 ScriptWrappable::init(this); |
| 57 if (form && form->inDocument()) { | 56 if (form && form->inDocument()) { |
| 58 m_form = form->createWeakPtr(); | 57 m_form = form->createWeakPtr(); |
| 59 m_formWasSetByParser = true; | 58 m_formWasSetByParser = true; |
| 60 m_form->associate(*this); | 59 m_form->associate(*this); |
| 61 m_form->didAssociateByParser(); | 60 m_form->didAssociateByParser(); |
| 62 } | 61 } |
| 63 } | 62 } |
| 64 | 63 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } else { | 148 } else { |
| 150 m_form = WeakPtr<HTMLFormElement>(); | 149 m_form = WeakPtr<HTMLFormElement>(); |
| 151 } | 150 } |
| 152 } | 151 } |
| 153 | 152 |
| 154 void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr
ing& value) | 153 void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr
ing& value) |
| 155 { | 154 { |
| 156 if (name == altAttr) { | 155 if (name == altAttr) { |
| 157 if (renderer() && renderer()->isImage()) | 156 if (renderer() && renderer()->isImage()) |
| 158 toRenderImage(renderer())->updateAltText(); | 157 toRenderImage(renderer())->updateAltText(); |
| 159 } else if (name == srcAttr || name == srcsetAttr) { | 158 } else if (name == srcAttr || name == srcsetAttr || name == sizesAttr) { |
| 160 int effectiveSize = -1; // FIXME - hook up the real value from `sizes` | 159 int effectiveSize = 0; |
| 160 if (RuntimeEnabledFeatures::pictureSizesEnabled()) |
| 161 effectiveSize = SizesAttributeParser::findEffectiveSize(fastGetAttri
bute(sizesAttr), MediaValuesCached::create(document())); |
| 161 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)); |
| 162 m_bestFitImageURL = candidate.toAtomicString(); | 163 m_bestFitImageURL = candidate.toAtomicString(); |
| 163 float candidateScaleFactor = candidate.scaleFactor(); | 164 float candidateScaleFactor = candidate.scaleFactor(); |
| 165 // FIXME: Make this ">0" part match the spec, once it settles. |
| 164 if (candidateScaleFactor > 0) | 166 if (candidateScaleFactor > 0) |
| 165 m_imageDevicePixelRatio = 1 / candidateScaleFactor; | 167 m_imageDevicePixelRatio = 1 / candidateScaleFactor; |
| 166 if (renderer() && renderer()->isImage()) | 168 if (renderer() && renderer()->isImage()) |
| 167 toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePix
elRatio); | 169 toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePix
elRatio); |
| 168 m_imageLoader.updateFromElementIgnoringPreviousError(); | 170 m_imageLoader.updateFromElementIgnoringPreviousError(); |
| 169 } else if (RuntimeEnabledFeatures::pictureSizesEnabled() && name == sizesAtt
r) { | |
| 170 m_effectiveSize = SizesAttributeParser::findEffectiveSize(value, MediaVa
luesCached::create(document())); | |
| 171 } else if (name == usemapAttr) { | 171 } else if (name == usemapAttr) { |
| 172 setIsLink(!value.isNull()); | 172 setIsLink(!value.isNull()); |
| 173 } else if (name == compositeAttr) { | 173 } else if (name == compositeAttr) { |
| 174 // FIXME: images don't support blend modes in their compositing attribut
e. | 174 // FIXME: images don't support blend modes in their compositing attribut
e. |
| 175 blink::WebBlendMode blendOp = blink::WebBlendModeNormal; | 175 blink::WebBlendMode blendOp = blink::WebBlendModeNormal; |
| 176 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp)
) | 176 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp)
) |
| 177 m_compositeOperator = CompositeSourceOver; | 177 m_compositeOperator = CompositeSourceOver; |
| 178 } else { | 178 } else { |
| 179 HTMLElement::parseAttribute(name, value); | 179 HTMLElement::parseAttribute(name, value); |
| 180 } | 180 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 } | 306 } |
| 307 | 307 |
| 308 int HTMLImageElement::naturalHeight() const | 308 int HTMLImageElement::naturalHeight() const |
| 309 { | 309 { |
| 310 if (!m_imageLoader.image()) | 310 if (!m_imageLoader.image()) |
| 311 return 0; | 311 return 0; |
| 312 | 312 |
| 313 return m_imageLoader.image()->imageSizeForRenderer(renderer(), 1.0f).height(
); | 313 return m_imageLoader.image()->imageSizeForRenderer(renderer(), 1.0f).height(
); |
| 314 } | 314 } |
| 315 | 315 |
| 316 const AtomicString& HTMLImageElement::currentSrc() const |
| 317 { |
| 318 return m_bestFitImageURL; |
| 319 } |
| 320 |
| 316 bool HTMLImageElement::isURLAttribute(const Attribute& attribute) const | 321 bool HTMLImageElement::isURLAttribute(const Attribute& attribute) const |
| 317 { | 322 { |
| 318 return attribute.name() == srcAttr | 323 return attribute.name() == srcAttr |
| 319 || attribute.name() == lowsrcAttr | 324 || attribute.name() == lowsrcAttr |
| 320 || attribute.name() == longdescAttr | 325 || attribute.name() == longdescAttr |
| 321 || (attribute.name() == usemapAttr && attribute.value().string()[0] != '
#') | 326 || (attribute.name() == usemapAttr && attribute.value().string()[0] != '
#') |
| 322 || HTMLElement::isURLAttribute(attribute); | 327 || HTMLElement::isURLAttribute(attribute); |
| 323 } | 328 } |
| 324 | 329 |
| 325 bool HTMLImageElement::hasLegalLinkAttribute(const QualifiedName& name) const | 330 bool HTMLImageElement::hasLegalLinkAttribute(const QualifiedName& name) const |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 if (!image) | 475 if (!image) |
| 471 return FloatSize(); | 476 return FloatSize(); |
| 472 LayoutSize size; | 477 LayoutSize size; |
| 473 size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure abo
ut this. | 478 size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure abo
ut this. |
| 474 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i
mage()->hasRelativeWidth()) | 479 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i
mage()->hasRelativeWidth()) |
| 475 size.scale(toRenderImage(renderer())->imageDevicePixelRatio()); | 480 size.scale(toRenderImage(renderer())->imageDevicePixelRatio()); |
| 476 return size; | 481 return size; |
| 477 } | 482 } |
| 478 | 483 |
| 479 } | 484 } |
| OLD | NEW |