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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutImage.cpp

Issue 1732563007: [NOT FOR COMMIT] Pass defaultObjectSize to get image size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com)
6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. 9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved.
10 * 10 *
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 // Per the spec, we let the server-sent header override srcset/other sources of dpr. 116 // Per the spec, we let the server-sent header override srcset/other sources of dpr.
117 // https://github.com/igrigorik/http-client-hints/blob/master/draft-grigorik -http-client-hints-01.txt#L255 117 // https://github.com/igrigorik/http-client-hints/blob/master/draft-grigorik -http-client-hints-01.txt#L255
118 if (m_imageResource->cachedImage() && m_imageResource->cachedImage()->hasDev icePixelRatioHeaderValue()) { 118 if (m_imageResource->cachedImage() && m_imageResource->cachedImage()->hasDev icePixelRatioHeaderValue()) {
119 UseCounter::count(&(view()->frameView()->frame()), UseCounter::ClientHin tsContentDPR); 119 UseCounter::count(&(view()->frameView()->frame()), UseCounter::ClientHin tsContentDPR);
120 m_imageDevicePixelRatio = 1 / m_imageResource->cachedImage()->devicePixe lRatioHeaderValue(); 120 m_imageDevicePixelRatio = 1 / m_imageResource->cachedImage()->devicePixe lRatioHeaderValue();
121 } 121 }
122 122
123 if (!m_didIncrementVisuallyNonEmptyPixelCount) { 123 if (!m_didIncrementVisuallyNonEmptyPixelCount) {
124 // At a zoom level of 1 the image is guaranteed to have an integer size. 124 // At a zoom level of 1 the image is guaranteed to have an integer size.
125 view()->frameView()->incrementVisuallyNonEmptyPixelCount(flooredIntSize( m_imageResource->imageSize(1.0f))); 125 view()->frameView()->incrementVisuallyNonEmptyPixelCount(flooredIntSize( m_imageResource->defaultConcreteObjectSize(1.0f)));
126 m_didIncrementVisuallyNonEmptyPixelCount = true; 126 m_didIncrementVisuallyNonEmptyPixelCount = true;
127 } 127 }
128 128
129 invalidatePaintAndMarkForLayoutIfNeeded(); 129 invalidatePaintAndMarkForLayoutIfNeeded();
130 } 130 }
131 131
132 void LayoutImage::updateIntrinsicSizeIfNeeded(const LayoutSize& newSize) 132 void LayoutImage::updateIntrinsicSizeIfNeeded(const LayoutSize& newSize)
133 { 133 {
134 if (m_imageResource->errorOccurred() || !m_imageResource->hasImage()) 134 if (m_imageResource->errorOccurred() || !m_imageResource->hasImage())
135 return; 135 return;
136 setIntrinsicSize(newSize); 136 setIntrinsicSize(newSize);
137 } 137 }
138 138
139 void LayoutImage::invalidatePaintAndMarkForLayoutIfNeeded() 139 void LayoutImage::invalidatePaintAndMarkForLayoutIfNeeded()
140 { 140 {
141 LayoutSize oldIntrinsicSize = intrinsicSize(); 141 LayoutSize oldIntrinsicSize = intrinsicSize();
142 LayoutSize newIntrinsicSize = m_imageResource->imageSize(style()->effectiveZ oom()); 142 LayoutSize newIntrinsicSize = m_imageResource->defaultConcreteObjectSize(sty le()->effectiveZoom());
143 updateIntrinsicSizeIfNeeded(newIntrinsicSize); 143 updateIntrinsicSizeIfNeeded(newIntrinsicSize);
144 144
145 // In the case of generated image content using :before/:after/content, we m ight not be 145 // In the case of generated image content using :before/:after/content, we m ight not be
146 // in the layout tree yet. In that case, we just need to update our intrinsi c size. 146 // in the layout tree yet. In that case, we just need to update our intrinsi c size.
147 // layout() will be called after we are inserted in the tree which will take care of 147 // layout() will be called after we are inserted in the tree which will take care of
148 // what we are doing here. 148 // what we are doing here.
149 if (!containingBlock()) 149 if (!containingBlock())
150 return; 150 return;
151 151
152 bool imageSourceHasChangedSize = oldIntrinsicSize != newIntrinsicSize; 152 bool imageSourceHasChangedSize = oldIntrinsicSize != newIntrinsicSize;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 return nullptr; 318 return nullptr;
319 319
320 ImageResource* cachedImage = m_imageResource->cachedImage(); 320 ImageResource* cachedImage = m_imageResource->cachedImage();
321 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) 321 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( ))
322 return toSVGImage(cachedImage->image())->embeddedContentBox(); 322 return toSVGImage(cachedImage->image())->embeddedContentBox();
323 323
324 return nullptr; 324 return nullptr;
325 } 325 }
326 326
327 } // namespace blink 327 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698