diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/css/LengthFunctions.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/css/LengthFunctions.h')
-rw-r--r-- | Source/WebCore/css/LengthFunctions.h | 60 |
1 files changed, 48 insertions, 12 deletions
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<float>(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<int>(minimumValueForLength(length, maximumValue)); +} + +} // namespace WebCore |