Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(785)

Side by Side Diff: Source/core/html/HTMLImageElement.cpp

Issue 290203002: <picture>: Update the <img> element when a <source> changes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: review comments addressed Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/html/HTMLImageElement.h ('k') | Source/core/html/HTMLPictureElement.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 if (renderer() && renderer()->isImage()) 185 if (renderer() && renderer()->isImage())
186 toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePixelRa tio); 186 toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePixelRa tio);
187 } 187 }
188 188
189 void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value) 189 void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value)
190 { 190 {
191 if (name == altAttr) { 191 if (name == altAttr) {
192 if (renderer() && renderer()->isImage()) 192 if (renderer() && renderer()->isImage())
193 toRenderImage(renderer())->updateAltText(); 193 toRenderImage(renderer())->updateAltText();
194 } else if (name == srcAttr || name == srcsetAttr || name == sizesAttr) { 194 } else if (name == srcAttr || name == srcsetAttr || name == sizesAttr) {
195 unsigned effectiveSize = 0; 195 selectSourceURL(UpdateIgnorePreviousError);
196 if (RuntimeEnabledFeatures::pictureSizesEnabled())
197 effectiveSize = SizesAttributeParser::findEffectiveSize(fastGetAttri bute(sizesAttr), MediaValuesCached::create(document()));
198 ImageCandidate candidate = bestFitSourceForImageAttributes(document().de vicePixelRatio(), effectiveSize, fastGetAttribute(srcAttr), fastGetAttribute(src setAttr));
199 setBestFitURLAndDPRFromImageCandidate(candidate);
200 m_imageLoader.updateFromElementIgnoringPreviousError();
201 } else if (name == usemapAttr) { 196 } else if (name == usemapAttr) {
202 setIsLink(!value.isNull()); 197 setIsLink(!value.isNull());
203 } else if (name == compositeAttr) { 198 } else if (name == compositeAttr) {
204 // FIXME: images don't support blend modes in their compositing attribut e. 199 // FIXME: images don't support blend modes in their compositing attribut e.
205 blink::WebBlendMode blendOp = blink::WebBlendModeNormal; 200 blink::WebBlendMode blendOp = blink::WebBlendModeNormal;
206 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp) ) 201 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp) )
207 m_compositeOperator = CompositeSourceOver; 202 m_compositeOperator = CompositeSourceOver;
208 } else { 203 } else {
209 HTMLElement::parseAttribute(name, value); 204 HTMLElement::parseAttribute(name, value);
210 } 205 }
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 ImageResource* image = cachedImage(); 551 ImageResource* image = cachedImage();
557 if (!image) 552 if (!image)
558 return FloatSize(); 553 return FloatSize();
559 LayoutSize size; 554 LayoutSize size;
560 size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure abo ut this. 555 size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure abo ut this.
561 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i mage()->hasRelativeWidth()) 556 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i mage()->hasRelativeWidth())
562 size.scale(toRenderImage(renderer())->imageDevicePixelRatio()); 557 size.scale(toRenderImage(renderer())->imageDevicePixelRatio());
563 return size; 558 return size;
564 } 559 }
565 560
561 void HTMLImageElement::selectSourceURL(UpdateFromElementBehavior behavior)
562 {
563 bool foundURL = false;
564 if (RuntimeEnabledFeatures::pictureEnabled()) {
565 ImageCandidate candidate = findBestFitImageFromPictureParent();
566 if (!candidate.isEmpty()) {
567 setBestFitURLAndDPRFromImageCandidate(candidate);
568 foundURL = true;
569 }
570 }
571
572 if (!foundURL) {
573 unsigned effectiveSize = 0;
574 if (RuntimeEnabledFeatures::pictureSizesEnabled())
575 effectiveSize = SizesAttributeParser::findEffectiveSize(fastGetAttri bute(sizesAttr), MediaValuesCached::create(document()));
576 ImageCandidate candidate = bestFitSourceForImageAttributes(document().de vicePixelRatio(), effectiveSize, fastGetAttribute(srcAttr), fastGetAttribute(src setAttr));
577 setBestFitURLAndDPRFromImageCandidate(candidate);
578 }
579 if (behavior == UpdateIgnorePreviousError)
580 m_imageLoader.updateFromElementIgnoringPreviousError();
581 else
582 m_imageLoader.updateFromElement();
566 } 583 }
584 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLImageElement.h ('k') | Source/core/html/HTMLPictureElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698