Chromium Code Reviews| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 if (renderer() && renderer()->isImage()) | 165 if (renderer() && renderer()->isImage()) |
| 166 toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePixelRa tio); | 166 toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePixelRa tio); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value) | 169 void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value) |
| 170 { | 170 { |
| 171 if (name == altAttr) { | 171 if (name == altAttr) { |
| 172 if (renderer() && renderer()->isImage()) | 172 if (renderer() && renderer()->isImage()) |
| 173 toRenderImage(renderer())->updateAltText(); | 173 toRenderImage(renderer())->updateAltText(); |
| 174 } else if (name == srcAttr || name == srcsetAttr || name == sizesAttr) { | 174 } else if (name == srcAttr || name == srcsetAttr || name == sizesAttr) { |
| 175 unsigned effectiveSize = 0; | 175 selectSourceURL(true); |
| 176 if (RuntimeEnabledFeatures::pictureSizesEnabled()) | |
| 177 effectiveSize = SizesAttributeParser::findEffectiveSize(fastGetAttri bute(sizesAttr), MediaValuesCached::create(document())); | |
| 178 ImageCandidate candidate = bestFitSourceForImageAttributes(document().de vicePixelRatio(), effectiveSize, fastGetAttribute(srcAttr), fastGetAttribute(src setAttr)); | |
| 179 setBestFitURLAndDPRFromImageCandidate(candidate); | |
| 180 m_imageLoader.updateFromElementIgnoringPreviousError(); | |
| 181 } else if (name == usemapAttr) { | 176 } else if (name == usemapAttr) { |
| 182 setIsLink(!value.isNull()); | 177 setIsLink(!value.isNull()); |
| 183 } else if (name == compositeAttr) { | 178 } else if (name == compositeAttr) { |
| 184 // FIXME: images don't support blend modes in their compositing attribut e. | 179 // FIXME: images don't support blend modes in their compositing attribut e. |
| 185 blink::WebBlendMode blendOp = blink::WebBlendModeNormal; | 180 blink::WebBlendMode blendOp = blink::WebBlendModeNormal; |
| 186 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp) ) | 181 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp) ) |
| 187 m_compositeOperator = CompositeSourceOver; | 182 m_compositeOperator = CompositeSourceOver; |
| 188 } else { | 183 } else { |
| 189 HTMLElement::parseAttribute(name, value); | 184 HTMLElement::parseAttribute(name, value); |
| 190 } | 185 } |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 536 ImageResource* image = cachedImage(); | 531 ImageResource* image = cachedImage(); |
| 537 if (!image) | 532 if (!image) |
| 538 return FloatSize(); | 533 return FloatSize(); |
| 539 LayoutSize size; | 534 LayoutSize size; |
| 540 size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure abo ut this. | 535 size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure abo ut this. |
| 541 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i mage()->hasRelativeWidth()) | 536 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i mage()->hasRelativeWidth()) |
| 542 size.scale(toRenderImage(renderer())->imageDevicePixelRatio()); | 537 size.scale(toRenderImage(renderer())->imageDevicePixelRatio()); |
| 543 return size; | 538 return size; |
| 544 } | 539 } |
| 545 | 540 |
| 541 void HTMLImageElement::selectSourceURL(bool ignorePreviousError) | |
|
Yoav Weiss
2014/05/23 07:39:17
Maybe replace the bool with an enum?
cbiesinger
2014/05/23 19:30:37
Done.
| |
| 542 { | |
| 543 bool foundURL = false; | |
| 544 if (RuntimeEnabledFeatures::pictureEnabled()) { | |
| 545 ImageCandidate candidate = findBestFitImageFromPictureParent(); | |
| 546 if (!candidate.isEmpty()) { | |
| 547 setBestFitURLAndDPRFromImageCandidate(candidate); | |
| 548 foundURL = true; | |
| 549 } | |
| 550 } | |
| 551 | |
| 552 if (!foundURL) { | |
| 553 unsigned effectiveSize = 0; | |
| 554 if (RuntimeEnabledFeatures::pictureSizesEnabled()) | |
| 555 effectiveSize = SizesAttributeParser::findEffectiveSize(fastGetAttri bute(sizesAttr), MediaValuesCached::create(document())); | |
| 556 ImageCandidate candidate = bestFitSourceForImageAttributes(document().de vicePixelRatio(), effectiveSize, fastGetAttribute(srcAttr), fastGetAttribute(src setAttr)); | |
| 557 setBestFitURLAndDPRFromImageCandidate(candidate); | |
| 558 } | |
| 559 if (ignorePreviousError) | |
| 560 m_imageLoader.updateFromElementIgnoringPreviousError(); | |
| 561 else | |
| 562 m_imageLoader.updateFromElement(); | |
| 546 } | 563 } |
| 564 } | |
| OLD | NEW |