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

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

Issue 2292013002: Notify LayoutImage that intrinsic dimensions changed when sizes changes (Closed)
Patch Set: Created 4 years, 3 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
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 m_form->associate(*this); 220 m_form->associate(*this);
221 } else { 221 } else {
222 m_form = nullptr; 222 m_form = nullptr;
223 } 223 }
224 } 224 }
225 225
226 void HTMLImageElement::setBestFitURLAndDPRFromImageCandidate(const ImageCandidat e& candidate) 226 void HTMLImageElement::setBestFitURLAndDPRFromImageCandidate(const ImageCandidat e& candidate)
227 { 227 {
228 m_bestFitImageURL = candidate.url(); 228 m_bestFitImageURL = candidate.url();
229 float candidateDensity = candidate.density(); 229 float candidateDensity = candidate.density();
230 float oldImageDevicePixelRatio = m_imageDevicePixelRatio;
230 if (candidateDensity >= 0) 231 if (candidateDensity >= 0)
231 m_imageDevicePixelRatio = 1.0 / candidateDensity; 232 m_imageDevicePixelRatio = 1.0 / candidateDensity;
232 233
233 bool intrinsicSizingViewportDependant = false; 234 bool intrinsicSizingViewportDependant = false;
234 if (candidate.getResourceWidth() > 0) { 235 if (candidate.getResourceWidth() > 0) {
235 intrinsicSizingViewportDependant = true; 236 intrinsicSizingViewportDependant = true;
236 UseCounter::count(document(), UseCounter::SrcsetWDescriptor); 237 UseCounter::count(document(), UseCounter::SrcsetWDescriptor);
237 } else if (!candidate.srcOrigin()) { 238 } else if (!candidate.srcOrigin()) {
238 UseCounter::count(document(), UseCounter::SrcsetXDescriptor); 239 UseCounter::count(document(), UseCounter::SrcsetXDescriptor);
239 } 240 }
240 if (layoutObject() && layoutObject()->isImage()) 241 if (layoutObject() && layoutObject()->isImage()) {
241 LayoutImageItem(toLayoutImage(layoutObject())).setImageDevicePixelRatio( m_imageDevicePixelRatio); 242 LayoutImageItem(toLayoutImage(layoutObject())).setImageDevicePixelRatio( m_imageDevicePixelRatio);
242 243
244 if (oldImageDevicePixelRatio != m_imageDevicePixelRatio)
245 toLayoutImage(layoutObject())->intrinsicSizeChanged();
246 }
247
243 if (intrinsicSizingViewportDependant) { 248 if (intrinsicSizingViewportDependant) {
244 if (!m_listener) 249 if (!m_listener)
245 m_listener = ViewportChangeListener::create(this); 250 m_listener = ViewportChangeListener::create(this);
246 251
247 document().mediaQueryMatcher().addViewportListener(m_listener); 252 document().mediaQueryMatcher().addViewportListener(m_listener);
248 } else if (m_listener) { 253 } else if (m_listener) {
249 document().mediaQueryMatcher().removeViewportListener(m_listener); 254 document().mediaQueryMatcher().removeViewportListener(m_listener);
250 } 255 }
251 } 256 }
252 257
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 { 832 {
828 ImageResource* image = cachedImage(); 833 ImageResource* image = cachedImage();
829 if (!image) 834 if (!image)
830 return IntSize(); 835 return IntSize();
831 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat ion(layoutObject()), 1.0f); 836 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat ion(layoutObject()), 1.0f);
832 DCHECK(lSize.fraction().isZero()); 837 DCHECK(lSize.fraction().isZero());
833 return IntSize(lSize.width().toInt(), lSize.height().toInt()); 838 return IntSize(lSize.width().toInt(), lSize.height().toInt());
834 } 839 }
835 840
836 } // namespace blink 841 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698