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

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

Issue 2394263004: Reformat comments in core/layout up until LayoutMultiColumnFlowThread (Closed)
Patch Set: Rebase w/HEAD Created 4 years, 2 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.
8 * All rights reserved.
8 * Copyright (C) 2010 Google Inc. All rights reserved. 9 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved.
10 * 11 *
11 * This library is free software; you can redistribute it and/or 12 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
15 * 16 *
16 * This library is distributed in the hope that it will be useful, 17 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 96
96 if (newImage != m_imageResource->imagePtr()) 97 if (newImage != m_imageResource->imagePtr())
97 return; 98 return;
98 99
99 if (isGeneratedContent() && isHTMLImageElement(node()) && 100 if (isGeneratedContent() && isHTMLImageElement(node()) &&
100 m_imageResource->errorOccurred()) { 101 m_imageResource->errorOccurred()) {
101 toHTMLImageElement(node())->ensureFallbackForGeneratedContent(); 102 toHTMLImageElement(node())->ensureFallbackForGeneratedContent();
102 return; 103 return;
103 } 104 }
104 105
105 // Per the spec, we let the server-sent header override srcset/other sources o f dpr. 106 // Per the spec, we let the server-sent header override srcset/other sources
107 // of dpr.
106 // https://github.com/igrigorik/http-client-hints/blob/master/draft-grigorik-h ttp-client-hints-01.txt#L255 108 // https://github.com/igrigorik/http-client-hints/blob/master/draft-grigorik-h ttp-client-hints-01.txt#L255
107 if (m_imageResource->cachedImage() && 109 if (m_imageResource->cachedImage() &&
108 m_imageResource->cachedImage()->hasDevicePixelRatioHeaderValue()) { 110 m_imageResource->cachedImage()->hasDevicePixelRatioHeaderValue()) {
109 UseCounter::count(&(view()->frameView()->frame()), 111 UseCounter::count(&(view()->frameView()->frame()),
110 UseCounter::ClientHintsContentDPR); 112 UseCounter::ClientHintsContentDPR);
111 m_imageDevicePixelRatio = 113 m_imageDevicePixelRatio =
112 1 / m_imageResource->cachedImage()->devicePixelRatioHeaderValue(); 114 1 / m_imageResource->cachedImage()->devicePixelRatioHeaderValue();
113 } 115 }
114 116
115 if (!m_didIncrementVisuallyNonEmptyPixelCount) { 117 if (!m_didIncrementVisuallyNonEmptyPixelCount) {
(...skipping 11 matching lines...) Expand all
127 return; 129 return;
128 setIntrinsicSize(newSize); 130 setIntrinsicSize(newSize);
129 } 131 }
130 132
131 void LayoutImage::invalidatePaintAndMarkForLayoutIfNeeded() { 133 void LayoutImage::invalidatePaintAndMarkForLayoutIfNeeded() {
132 LayoutSize oldIntrinsicSize = intrinsicSize(); 134 LayoutSize oldIntrinsicSize = intrinsicSize();
133 LayoutSize newIntrinsicSize = 135 LayoutSize newIntrinsicSize =
134 m_imageResource->imageSize(style()->effectiveZoom()); 136 m_imageResource->imageSize(style()->effectiveZoom());
135 updateIntrinsicSizeIfNeeded(newIntrinsicSize); 137 updateIntrinsicSizeIfNeeded(newIntrinsicSize);
136 138
137 // In the case of generated image content using :before/:after/content, we mig ht not be 139 // In the case of generated image content using :before/:after/content, we
138 // in the layout tree yet. In that case, we just need to update our intrinsic size. 140 // might not be in the layout tree yet. In that case, we just need to update
139 // layout() will be called after we are inserted in the tree which will take c are of 141 // our intrinsic size. layout() will be called after we are inserted in the
140 // what we are doing here. 142 // tree which will take care of what we are doing here.
141 if (!containingBlock()) 143 if (!containingBlock())
142 return; 144 return;
143 145
144 bool imageSourceHasChangedSize = oldIntrinsicSize != newIntrinsicSize; 146 bool imageSourceHasChangedSize = oldIntrinsicSize != newIntrinsicSize;
145 if (imageSourceHasChangedSize) 147 if (imageSourceHasChangedSize)
146 setPreferredLogicalWidthsDirty(); 148 setPreferredLogicalWidthsDirty();
147 149
148 // If the actual area occupied by the image has changed and it is not constrai ned by style then a layout is required. 150 // If the actual area occupied by the image has changed and it is not
151 // constrained by style then a layout is required.
149 bool imageSizeIsConstrained = style()->logicalWidth().isSpecified() && 152 bool imageSizeIsConstrained = style()->logicalWidth().isSpecified() &&
150 style()->logicalHeight().isSpecified(); 153 style()->logicalHeight().isSpecified();
151 154
152 // FIXME: We only need to recompute the containing block's preferred size if t he containing block's size 155 // FIXME: We only need to recompute the containing block's preferred size if
153 // depends on the image's size (i.e., the container uses shrink-to-fit sizing) . 156 // the containing block's size depends on the image's size (i.e., the
154 // There's no easy way to detect that shrink-to-fit is needed, always force a layout. 157 // container uses shrink-to-fit sizing). There's no easy way to detect that
158 // shrink-to-fit is needed, always force a layout.
155 bool containingBlockNeedsToRecomputePreferredSize = 159 bool containingBlockNeedsToRecomputePreferredSize =
156 style()->logicalWidth().isPercentOrCalc() || 160 style()->logicalWidth().isPercentOrCalc() ||
157 style()->logicalMaxWidth().isPercentOrCalc() || 161 style()->logicalMaxWidth().isPercentOrCalc() ||
158 style()->logicalMinWidth().isPercentOrCalc(); 162 style()->logicalMinWidth().isPercentOrCalc();
159 163
160 if (imageSourceHasChangedSize && 164 if (imageSourceHasChangedSize &&
161 (!imageSizeIsConstrained || 165 (!imageSizeIsConstrained ||
162 containingBlockNeedsToRecomputePreferredSize)) { 166 containingBlockNeedsToRecomputePreferredSize)) {
163 setNeedsLayoutAndFullPaintInvalidation( 167 setNeedsLayoutAndFullPaintInvalidation(
164 LayoutInvalidationReason::SizeChanged); 168 LayoutInvalidationReason::SizeChanged);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return false; 234 return false;
231 EFillBox backgroundClip = style()->backgroundClip(); 235 EFillBox backgroundClip = style()->backgroundClip();
232 // Background paints under borders. 236 // Background paints under borders.
233 if (backgroundClip == BorderFillBox && style()->hasBorder() && 237 if (backgroundClip == BorderFillBox && style()->hasBorder() &&
234 !style()->borderObscuresBackground()) 238 !style()->borderObscuresBackground())
235 return false; 239 return false;
236 // Background shows in padding area. 240 // Background shows in padding area.
237 if ((backgroundClip == BorderFillBox || backgroundClip == PaddingFillBox) && 241 if ((backgroundClip == BorderFillBox || backgroundClip == PaddingFillBox) &&
238 style()->hasPadding()) 242 style()->hasPadding())
239 return false; 243 return false;
240 // Object-position may leave parts of the content box empty, regardless of the value of object-fit. 244 // Object-position may leave parts of the content box empty, regardless of the
245 // value of object-fit.
241 if (style()->objectPosition() != ComputedStyle::initialObjectPosition()) 246 if (style()->objectPosition() != ComputedStyle::initialObjectPosition())
242 return false; 247 return false;
243 // Object-fit may leave parts of the content box empty. 248 // Object-fit may leave parts of the content box empty.
244 ObjectFit objectFit = style()->getObjectFit(); 249 ObjectFit objectFit = style()->getObjectFit();
245 if (objectFit != ObjectFitFill && objectFit != ObjectFitCover) 250 if (objectFit != ObjectFitFill && objectFit != ObjectFitCover)
246 return false; 251 return false;
247 // Check for image with alpha. 252 // Check for image with alpha.
248 TRACE_EVENT1( 253 TRACE_EVENT1(
249 TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", "data", 254 TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", "data",
250 InspectorPaintImageEvent::data(this, *m_imageResource->cachedImage())); 255 InspectorPaintImageEvent::data(this, *m_imageResource->cachedImage()));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 result.append(tempResult); 291 result.append(tempResult);
287 if (inside) 292 if (inside)
288 result = tempResult; 293 result = tempResult;
289 return inside; 294 return inside;
290 } 295 }
291 296
292 void LayoutImage::computeIntrinsicSizingInfo( 297 void LayoutImage::computeIntrinsicSizingInfo(
293 IntrinsicSizingInfo& intrinsicSizingInfo) const { 298 IntrinsicSizingInfo& intrinsicSizingInfo) const {
294 LayoutReplaced::computeIntrinsicSizingInfo(intrinsicSizingInfo); 299 LayoutReplaced::computeIntrinsicSizingInfo(intrinsicSizingInfo);
295 300
296 // Our intrinsicSize is empty if we're laying out generated images with relati ve width/height. Figure out the right intrinsic size to use. 301 // Our intrinsicSize is empty if we're laying out generated images with
302 // relative width/height. Figure out the right intrinsic size to use.
297 if (intrinsicSizingInfo.size.isEmpty() && 303 if (intrinsicSizingInfo.size.isEmpty() &&
298 m_imageResource->imageHasRelativeSize()) { 304 m_imageResource->imageHasRelativeSize()) {
299 LayoutObject* containingBlock = 305 LayoutObject* containingBlock =
300 isOutOfFlowPositioned() ? container() : this->containingBlock(); 306 isOutOfFlowPositioned() ? container() : this->containingBlock();
301 if (containingBlock->isBox()) { 307 if (containingBlock->isBox()) {
302 LayoutBox* box = toLayoutBox(containingBlock); 308 LayoutBox* box = toLayoutBox(containingBlock);
303 intrinsicSizingInfo.size.setWidth(box->availableLogicalWidth().toFloat()); 309 intrinsicSizingInfo.size.setWidth(box->availableLogicalWidth().toFloat());
304 intrinsicSizingInfo.size.setHeight( 310 intrinsicSizingInfo.size.setHeight(
305 box->availableLogicalHeight(IncludeMarginBorderPadding).toFloat()); 311 box->availableLogicalHeight(IncludeMarginBorderPadding).toFloat());
306 } 312 }
307 } 313 }
308 // Don't compute an intrinsic ratio to preserve historical WebKit behavior if we're painting alt text and/or a broken image. 314 // Don't compute an intrinsic ratio to preserve historical WebKit behavior if
309 // Video is excluded from this behavior because video elements have a default aspect ratio that a failed poster image load should not override. 315 // we're painting alt text and/or a broken image.
316 // Video is excluded from this behavior because video elements have a default
317 // aspect ratio that a failed poster image load should not override.
310 if (m_imageResource && m_imageResource->errorOccurred() && !isVideo()) { 318 if (m_imageResource && m_imageResource->errorOccurred() && !isVideo()) {
311 intrinsicSizingInfo.aspectRatio = FloatSize(1, 1); 319 intrinsicSizingInfo.aspectRatio = FloatSize(1, 1);
312 return; 320 return;
313 } 321 }
314 } 322 }
315 323
316 bool LayoutImage::needsPreferredWidthsRecalculation() const { 324 bool LayoutImage::needsPreferredWidthsRecalculation() const {
317 if (LayoutReplaced::needsPreferredWidthsRecalculation()) 325 if (LayoutReplaced::needsPreferredWidthsRecalculation())
318 return true; 326 return true;
319 return embeddedReplacedContent(); 327 return embeddedReplacedContent();
320 } 328 }
321 329
322 LayoutReplaced* LayoutImage::embeddedReplacedContent() const { 330 LayoutReplaced* LayoutImage::embeddedReplacedContent() const {
323 if (!m_imageResource) 331 if (!m_imageResource)
324 return nullptr; 332 return nullptr;
325 333
326 ImageResource* cachedImage = m_imageResource->cachedImage(); 334 ImageResource* cachedImage = m_imageResource->cachedImage();
327 if (cachedImage && cachedImage->getImage() && 335 if (cachedImage && cachedImage->getImage() &&
328 cachedImage->getImage()->isSVGImage()) 336 cachedImage->getImage()->isSVGImage())
329 return toSVGImage(cachedImage->getImage())->embeddedReplacedContent(); 337 return toSVGImage(cachedImage->getImage())->embeddedReplacedContent();
330 338
331 return nullptr; 339 return nullptr;
332 } 340 }
333 341
334 } // namespace blink 342 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutImage.h ('k') | third_party/WebKit/Source/core/layout/LayoutImageResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698