From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WebCore/css/LengthFunctions.h | 60 ++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 12 deletions(-) (limited to 'Source/WebCore/css/LengthFunctions.h') diff --git a/Source/WebCore/css/LengthFunctions.h b/Source/WebCore/css/LengthFunctions.h index 9fcf2ef06..1c4e050da 100644 --- a/Source/WebCore/css/LengthFunctions.h +++ b/Source/WebCore/css/LengthFunctions.h @@ -1,6 +1,6 @@ /* Copyright (C) 1999 Lars Knoll (knoll@kde.org) - Copyright (C) 2006, 2008 Apple Inc. All rights reserved. + Copyright (C) 2006-2017 Apple Inc. All rights reserved. Copyright (C) 2011 Rik Cabanier (cabanier@adobe.com) Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. Copyright (C) 2012 Motorola Mobility, Inc. All rights reserved. @@ -21,22 +21,58 @@ Boston, MA 02110-1301, USA. */ -#ifndef LengthFunctions_h -#define LengthFunctions_h +#pragma once + +#include "LayoutUnit.h" +#include "Length.h" namespace WebCore { -class LayoutUnit; +class FloatSize; +class LayoutSize; class RenderView; + struct Length; +struct LengthSize; -int minimumIntValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false); -int intValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false); -LayoutUnit minimumValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false); -LayoutUnit valueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false); -float floatValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0); -float floatValueForLength(const Length&, float maximumValue, RenderView* = 0); +int minimumIntValueForLength(const Length&, LayoutUnit maximumValue); +int intValueForLength(const Length&, LayoutUnit maximumValue); +LayoutUnit minimumValueForLength(const Length&, LayoutUnit maximumValue); +WEBCORE_EXPORT LayoutUnit valueForLength(const Length&, LayoutUnit maximumValue); +LayoutSize sizeForLengthSize(const LengthSize&, const LayoutSize& maximumValue); +float floatValueForLength(const Length&, LayoutUnit maximumValue); +WEBCORE_EXPORT float floatValueForLength(const Length&, float maximumValue); +FloatSize floatSizeForLengthSize(const LengthSize&, const FloatSize&); -} // namespace WebCore +inline LayoutUnit minimumValueForLength(const Length& length, LayoutUnit maximumValue) +{ + switch (length.type()) { + case Fixed: + return length.value(); + case Percent: + // Don't remove the extra cast to float. It is needed for rounding on 32-bit Intel machines that use the FPU stack. + return LayoutUnit(static_cast(maximumValue * length.percent() / 100.0f)); + case Calculated: + return length.nonNanCalculatedValue(maximumValue); + case FillAvailable: + case Auto: + return 0; + case Relative: + case Intrinsic: + case MinIntrinsic: + case MinContent: + case MaxContent: + case FitContent: + case Undefined: + break; + } + ASSERT_NOT_REACHED(); + return 0; +} -#endif // LengthFunctions_h +inline int minimumIntValueForLength(const Length& length, LayoutUnit maximumValue) +{ + return static_cast(minimumValueForLength(length, maximumValue)); +} + +} // namespace WebCore -- cgit v1.2.1