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

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

Issue 1685353004: Clean up Image::computeIntrinsicDimensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 ASSERT(solutionHeight <= size.height()); 722 ASSERT(solutionHeight <= size.height());
723 return LayoutSize(size.width(), solutionHeight); 723 return LayoutSize(size.width(), solutionHeight);
724 } 724 }
725 725
726 LayoutSize LayoutBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* i mage, const LayoutSize& positioningAreaSize, ScaleByEffectiveZoomOrNot shouldSca leOrNot) const 726 LayoutSize LayoutBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* i mage, const LayoutSize& positioningAreaSize, ScaleByEffectiveZoomOrNot shouldSca leOrNot) const
727 { 727 {
728 // A generated image without a fixed size, will always return the container size as intrinsic size. 728 // A generated image without a fixed size, will always return the container size as intrinsic size.
729 if (image->isGeneratedImage() && image->usesImageContainerSize()) 729 if (image->isGeneratedImage() && image->usesImageContainerSize())
730 return positioningAreaSize; 730 return positioningAreaSize;
731 731
732 Length intrinsicWidth(Fixed); 732 FloatSize intrinsicSize;
733 Length intrinsicHeight(Fixed);
734 FloatSize intrinsicRatio; 733 FloatSize intrinsicRatio;
735 image->computeIntrinsicDimensions(this, intrinsicWidth, intrinsicHeight, int rinsicRatio); 734 image->computeIntrinsicDimensions(this, intrinsicSize, intrinsicRatio);
736 735
737 ASSERT(intrinsicWidth.isFixed()); 736 LayoutSize resolvedSize(intrinsicSize.width(), intrinsicSize.height());
fs 2016/02/12 11:24:46 Nit: Use LayoutSize(const FloatSize&)?
davve 2016/02/12 11:58:29 Done.
738 ASSERT(intrinsicHeight.isFixed());
739
740 LayoutSize resolvedSize(intrinsicWidth.value(), intrinsicHeight.value());
741 LayoutSize minimumSize(resolvedSize.width() > LayoutUnit() ? LayoutUnit(1) : LayoutUnit(), 737 LayoutSize minimumSize(resolvedSize.width() > LayoutUnit() ? LayoutUnit(1) : LayoutUnit(),
742 resolvedSize.height() > LayoutUnit() ? LayoutUnit(1) : LayoutUnit()); 738 resolvedSize.height() > LayoutUnit() ? LayoutUnit(1) : LayoutUnit());
743 if (shouldScaleOrNot == ScaleByEffectiveZoom) 739 if (shouldScaleOrNot == ScaleByEffectiveZoom)
744 resolvedSize.scale(style()->effectiveZoom()); 740 resolvedSize.scale(style()->effectiveZoom());
745 resolvedSize.clampToMinimumSize(minimumSize); 741 resolvedSize.clampToMinimumSize(minimumSize);
746 742
747 if (!resolvedSize.isEmpty()) 743 if (!resolvedSize.isEmpty())
748 return resolvedSize; 744 return resolvedSize;
749 745
750 // If the image has one of either an intrinsic width or an intrinsic height: 746 // If the image has one of either an intrinsic width or an intrinsic height:
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 if (rootElementStyle->hasBackground()) 1054 if (rootElementStyle->hasBackground())
1059 return false; 1055 return false;
1060 1056
1061 if (node() != document().firstBodyElement()) 1057 if (node() != document().firstBodyElement())
1062 return false; 1058 return false;
1063 1059
1064 return true; 1060 return true;
1065 } 1061 }
1066 1062
1067 } // namespace blink 1063 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698