WebKit Bugzilla
Attachment 360945 Details for
Bug 194073
: Hit testing functions optimizations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194073-20190201184422.patch (text/plain), 21.24 KB, created by
Benjamin Poulain
on 2019-02-01 18:44:22 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Benjamin Poulain
Created:
2019-02-01 18:44:22 PST
Size:
21.24 KB
patch
obsolete
>Subversion Revision: 240882 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 10fc8d044c9e18505d439be7cdba7b9667f12afd..2abccd2109d8ea435e480197efcca9c3bc12e6ad 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,30 @@ >+2019-01-31 Benjamin Poulain <benjamin@webkit.org> >+ >+ Hit testing functions optimizations >+ https://bugs.webkit.org/show_bug.cgi?id=194073 >+ <rdar://problem/47692312> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Previously, all use of clampTo() would convert the value to double >+ to do checks in double, then convert back to integer. >+ >+ This significantly impacts WebCore's LayoutUnit where most of those >+ checks would have been trivial if we do not switch to double to compute >+ everything. >+ >+ This patch changes clampTo() to work with: >+ -Same type as source and destination. >+ -Floating point input, integer destination. >+ -Both are signed integers of different sizes. >+ plus a version that clamp an unsigned integer into its signed range. >+ >+ All of those are used in WebCore. >+ >+ * wtf/MathExtras.h: >+ (clampTo): >+ (sizeof): >+ > 2019-01-31 Carlos Garcia Campos <cgarcia@igalia.com> > > Unreviewed. Fix WPE compile warnings due to deprecated glib API. >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 7b8dc4ce5086afbfd26acaaceff92a35d3e0fb66..3914564a8ca4ce6bb192d8e5c087b22403cd325e 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,44 @@ >+2019-01-31 Benjamin Poulain <benjamin@webkit.org> >+ >+ Hit testing functions optimizations >+ https://bugs.webkit.org/show_bug.cgi?id=194073 >+ <rdar://problem/47692312> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch implements some easy optimizations that speed up >+ hit testing without changing the algorithms. >+ >+ * page/FrameViewLayoutContext.h: >+ The code for: >+ view().frameView().layoutContext().isPaintOffsetCacheEnabled() >+ followed by: >+ view().frameView().layoutContext().layoutState() >+ was loading all the intermediate values twice and calling layoutState() >+ twice. >+ >+ By marking the function as pure, Clang can CSE the whole thing and >+ remove the duplicated code. >+ >+ * platform/graphics/LayoutRect.h: >+ (WebCore::LayoutRect::isInfinite const): >+ That one is pretty funny. >+ >+ Since LayoutRect::isInfinite() was implemented before operator==() is >+ declared, the compiler was falling back to the implicit convertion to FloatRect() >+ before doing any comparison. >+ >+ This explains a bunch of the convertions to float when using LayoutRect. >+ >+ * rendering/RenderBox.cpp: >+ (WebCore::RenderBox::mapLocalToContainer const): >+ Just reoder to make the register nice and clean for the optimization described above. >+ >+ * rendering/style/RenderStyle.h: >+ (WebCore::RenderStyle::setOpacity): >+ (WebCore::RenderStyle::setShapeImageThreshold): >+ Fix a couple of ambiguities with the new clampTo(). >+ > 2019-02-01 Chris Dumez <cdumez@apple.com> > > REGRESSION: Flaky ASSERTION FAILED: m_uncommittedState.state == State::Committed on http/tests/cookies/same-site/fetch-after-top-level-navigation-initiated-from-iframe-in-cross-origin-page.html >diff --git a/Source/WTF/wtf/MathExtras.h b/Source/WTF/wtf/MathExtras.h >index 5eef198790cb1ee86490d49ee1e7e69a5c92a32a..7b1631535538e0da83da49baad030054ebef4d92 100644 >--- a/Source/WTF/wtf/MathExtras.h >+++ b/Source/WTF/wtf/MathExtras.h >@@ -123,15 +123,94 @@ template<> constexpr float defaultMinimumForClamp() { return -std::numeric_limit > template<> constexpr double defaultMinimumForClamp() { return -std::numeric_limits<double>::max(); } > template<typename T> constexpr T defaultMaximumForClamp() { return std::numeric_limits<T>::max(); } > >-template<typename T> inline T clampTo(double value, T min = defaultMinimumForClamp<T>(), T max = defaultMaximumForClamp<T>()) >+// Same type in and out. >+template<typename TargetType, typename SourceType> >+typename std::enable_if<std::is_same<TargetType, SourceType>::value, TargetType>::type >+clampTo(SourceType value, TargetType min = defaultMinimumForClamp<TargetType>(), TargetType max = defaultMaximumForClamp<TargetType>()) > { >- if (value >= static_cast<double>(max)) >+ if (value >= max) > return max; >- if (value <= static_cast<double>(min)) >+ if (value <= min) > return min; >- return static_cast<T>(value); >+ return value; >+} >+ >+// Floating point source. >+template<typename TargetType, typename SourceType> >+typename std::enable_if<!std::is_same<TargetType, SourceType>::value >+ && std::is_floating_point<SourceType>::value, TargetType>::type >+clampTo(SourceType value, TargetType min = defaultMinimumForClamp<TargetType>(), TargetType max = defaultMaximumForClamp<TargetType>()) >+{ >+ if (value >= static_cast<SourceType>(max)) >+ return max; >+ if (value <= static_cast<SourceType>(min)) >+ return min; >+ return static_cast<TargetType>(value); >+} >+ >+// Source and Target have the same sign and Source is larger or equal to Target >+template<typename TargetType, typename SourceType> >+typename std::enable_if<!std::is_same<TargetType, SourceType>::value >+ && std::numeric_limits<SourceType>::is_integer >+ && std::numeric_limits<TargetType>::is_integer >+ && std::numeric_limits<TargetType>::is_signed == std::numeric_limits<SourceType>::is_signed >+ && sizeof(SourceType) >= sizeof(TargetType), TargetType>::type >+clampTo(SourceType value, TargetType min = defaultMinimumForClamp<TargetType>(), TargetType max = defaultMaximumForClamp<TargetType>()) >+{ >+ if (value >= static_cast<SourceType>(max)) >+ return max; >+ if (value <= static_cast<SourceType>(min)) >+ return min; >+ return static_cast<TargetType>(value); >+} >+ >+// Clamping a unsigned integer to the max signed value. >+template<typename TargetType, typename SourceType> >+typename std::enable_if<!std::is_same<TargetType, SourceType>::value >+ && std::numeric_limits<SourceType>::is_integer >+ && std::numeric_limits<TargetType>::is_integer >+ && std::numeric_limits<TargetType>::is_signed >+ && !std::numeric_limits<SourceType>::is_signed >+ && sizeof(SourceType) >= sizeof(TargetType), TargetType>::type >+clampTo(SourceType value) >+{ >+ TargetType max = std::numeric_limits<TargetType>::max(); >+ if (value >= static_cast<SourceType>(max)) >+ return max; >+ return static_cast<TargetType>(value); >+} >+ >+// Clamping a signed integer into a valid unsigned integer. >+template<typename TargetType, typename SourceType> >+typename std::enable_if<!std::is_same<TargetType, SourceType>::value >+ && std::numeric_limits<SourceType>::is_integer >+ && std::numeric_limits<TargetType>::is_integer >+ && !std::numeric_limits<TargetType>::is_signed >+ && std::numeric_limits<SourceType>::is_signed >+ && sizeof(SourceType) == sizeof(TargetType), TargetType>::type >+clampTo(SourceType value) >+{ >+ if (value < 0) >+ return 0; >+ return static_cast<TargetType>(value); >+} >+ >+template<typename TargetType, typename SourceType> >+typename std::enable_if<!std::is_same<TargetType, SourceType>::value >+ && std::numeric_limits<SourceType>::is_integer >+ && std::numeric_limits<TargetType>::is_integer >+ && !std::numeric_limits<TargetType>::is_signed >+ && std::numeric_limits<SourceType>::is_signed >+ && (sizeof(SourceType) > sizeof(TargetType)), TargetType>::type >+clampTo(SourceType value) >+{ >+ if (value < 0) >+ return 0; >+ TargetType max = std::numeric_limits<TargetType>::max(); >+ if (value >= static_cast<SourceType>(max)) >+ return max; >+ return static_cast<TargetType>(value); > } >-template<> inline long long int clampTo(double, long long int, long long int); // clampTo does not support long long ints. > > inline int clampToInteger(double value) > { >diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp >index b56b4eb96f8ec7ca12f35049382dcfbaced2699f..018d442489474923a2a81ed951d9cc5ad76fe1bf 100644 >--- a/Source/WebCore/page/FrameView.cpp >+++ b/Source/WebCore/page/FrameView.cpp >@@ -1566,8 +1566,8 @@ LayoutRect FrameView::computeUpdatedLayoutViewportRect(const LayoutRect& layoutV > // The max stable layout viewport origin really depends on the size of the layout viewport itself, so we need to adjust the location of the layout viewport one final time to make sure it does not end up out of bounds of the document. > // Without this adjustment (and with using the non-constrained unobscuredContentRect's size as the size of the layout viewport) the layout viewport can be pushed past the bounds of the document during rubber-banding, and cannot be pushed > // back in until the user scrolls back in the other direction. >- layoutViewportOrigin.setX(clampTo<float>(layoutViewportOrigin.x(), 0, documentRect.width() - layoutViewportRect.width())); >- layoutViewportOrigin.setY(clampTo<float>(layoutViewportOrigin.y(), 0, documentRect.height() - layoutViewportRect.height())); >+ layoutViewportOrigin.setX(clampTo<float>(layoutViewportOrigin.x().toFloat(), 0, documentRect.width() - layoutViewportRect.width())); >+ layoutViewportOrigin.setY(clampTo<float>(layoutViewportOrigin.y().toFloat(), 0, documentRect.height() - layoutViewportRect.height())); > } > layoutViewportRect.setLocation(layoutViewportOrigin); > >diff --git a/Source/WebCore/page/FrameViewLayoutContext.h b/Source/WebCore/page/FrameViewLayoutContext.h >index b07cf5a5d9b38ec152273ba84773d3b3d7b1f88a..0fffc36abdd1af1a978474cf072c67836c126b6a 100644 >--- a/Source/WebCore/page/FrameViewLayoutContext.h >+++ b/Source/WebCore/page/FrameViewLayoutContext.h >@@ -93,7 +93,7 @@ public: > > void flushAsynchronousTasks(); > >- RenderLayoutState* layoutState() const; >+ RenderLayoutState* layoutState() const PURE_FUNCTION; > // Returns true if layoutState should be used for its cached offset and clip. > bool isPaintOffsetCacheEnabled() const { return !m_paintOffsetCacheDisableCount && layoutState(); } > #ifndef NDEBUG >diff --git a/Source/WebCore/platform/graphics/LayoutRect.h b/Source/WebCore/platform/graphics/LayoutRect.h >index a2a22cb3e0dfa7e22dcc50342b464d5cb9e8a99f..609181ea6f1cdb339d9614387f65d4bace4077c9 100644 >--- a/Source/WebCore/platform/graphics/LayoutRect.h >+++ b/Source/WebCore/platform/graphics/LayoutRect.h >@@ -166,7 +166,7 @@ public: > void scale(float xScale, float yScale); > > LayoutRect transposedRect() const { return LayoutRect(m_location.transposedPoint(), m_size.transposedSize()); } >- bool isInfinite() const { return *this == LayoutRect::infiniteRect(); } >+ bool isInfinite() const; > > static LayoutRect infiniteRect() > { >@@ -207,6 +207,11 @@ inline bool operator!=(const LayoutRect& a, const LayoutRect& b) > return a.location() != b.location() || a.size() != b.size(); > } > >+inline bool LayoutRect::isInfinite() const >+{ >+ return *this == LayoutRect::infiniteRect(); >+} >+ > // Integral snapping functions. > inline IntRect snappedIntRect(const LayoutRect& rect) > { >diff --git a/Source/WebCore/rendering/RenderBox.cpp b/Source/WebCore/rendering/RenderBox.cpp >index d38720c9159f0be34ee6d2eac6aafe8a25ecbf53..7bd279b06dd0d46e8a2ff91dee68fca3b938cfc4 100644 >--- a/Source/WebCore/rendering/RenderBox.cpp >+++ b/Source/WebCore/rendering/RenderBox.cpp >@@ -1988,7 +1988,7 @@ void RenderBox::mapLocalToContainer(const RenderLayerModelObject* repaintContain > if (repaintContainer == this) > return; > >- if (view().frameView().layoutContext().isPaintOffsetCacheEnabled() && !repaintContainer) { >+ if (!repaintContainer && view().frameView().layoutContext().isPaintOffsetCacheEnabled()) { > auto* layoutState = view().frameView().layoutContext().layoutState(); > LayoutSize offset = layoutState->paintOffset() + locationOffset(); > if (style().hasInFlowPosition() && layer()) >diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h >index 324efe58cd09e9e44ac86209c8a3249816d02c43..69650df20f08e9de9325fdff067e477222b1348a 100644 >--- a/Source/WebCore/rendering/style/RenderStyle.h >+++ b/Source/WebCore/rendering/style/RenderStyle.h >@@ -1055,7 +1055,7 @@ public: > void setTextStrokeWidth(float w) { SET_VAR(m_rareInheritedData, textStrokeWidth, w); } > void setTextFillColor(const Color& c) { SET_VAR(m_rareInheritedData, textFillColor, c); } > void setCaretColor(const Color& c) { SET_VAR(m_rareInheritedData, caretColor, c); } >- void setOpacity(float f) { float v = clampTo<float>(f, 0, 1); SET_VAR(m_rareNonInheritedData, opacity, v); } >+ void setOpacity(float f) { float v = clampTo<float>(f, 0.f, 1.f); SET_VAR(m_rareNonInheritedData, opacity, v); } > void setAppearance(ControlPart a) { SET_VAR(m_rareNonInheritedData, appearance, a); } > // For valid values of box-align see http://www.w3.org/TR/2009/WD-css3-flexbox-20090723/#alignment > void setBoxAlign(BoxAlignment a) { SET_NESTED_VAR(m_rareNonInheritedData, deprecatedFlexibleBox, align, static_cast<unsigned>(a)); } >@@ -2196,7 +2196,7 @@ inline void RenderStyle::setShapeOutside(RefPtr<ShapeValue>&& value) > > inline void RenderStyle::setShapeImageThreshold(float shapeImageThreshold) > { >- float clampedShapeImageThreshold = clampTo<float>(shapeImageThreshold, 0, 1); >+ float clampedShapeImageThreshold = clampTo<float>(shapeImageThreshold, 0.f, 1.f); > SET_VAR(m_rareNonInheritedData, shapeImageThreshold, clampedShapeImageThreshold); > } > >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index ef3cf8f8c3eca571929c71dd9fc35d573a05d87e..0ad26eea28ce8c78a8efe7f7c9c5d24c08e1e201 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,18 @@ >+2019-02-01 Benjamin Poulain <benjamin@webkit.org> >+ >+ Hit testing functions optimizations >+ https://bugs.webkit.org/show_bug.cgi?id=194073 >+ <rdar://problem/47692312> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/Tests/WTF/MathExtras.cpp: >+ (TestWebKitAPI::testClampFloatingPointToInteger): >+ (TestWebKitAPI::TEST): >+ (TestWebKitAPI::testClampSameSignIntegers): >+ (TestWebKitAPI::testClampUnsignedToSigned): >+ (TestWebKitAPI::testClampSignedToUnsigned): >+ > 2019-02-01 Wenson Hsieh <wenson_hsieh@apple.com> > > [iOS] Consistent 1 sec hang when triggering modal alerts while handling synchronous touch events >diff --git a/Tools/TestWebKitAPI/Tests/WTF/MathExtras.cpp b/Tools/TestWebKitAPI/Tests/WTF/MathExtras.cpp >index 1789a0eb8b07730b9a3d12c05393f459ba9eae6d..6c616cab103ee2f38be6df903b4140bf27fb9ae2 100644 >--- a/Tools/TestWebKitAPI/Tests/WTF/MathExtras.cpp >+++ b/Tools/TestWebKitAPI/Tests/WTF/MathExtras.cpp >@@ -1,5 +1,6 @@ > /* > * Copyright (C) 2012 Intel Corporation >+ * Copyright (C) 2019 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -174,6 +175,108 @@ TEST(WTF, clampToUnsignedLongLong) > EXPECT_EQ(clampTo<unsigned>(-1), 0u); > } > >+template<typename FloatingPointType> >+static void testClampFloatingPointToInteger() >+{ >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(0)), 0); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(1)), 1); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(-1)), -1); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(std::numeric_limits<int32_t>::max())), std::numeric_limits<int32_t>::max()); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(std::numeric_limits<int32_t>::max()) + 1.f), std::numeric_limits<int32_t>::max()); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(std::numeric_limits<int32_t>::min())), std::numeric_limits<int32_t>::min()); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(std::numeric_limits<int32_t>::min()) - 1.f), std::numeric_limits<int32_t>::min()); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(std::numeric_limits<uint32_t>::max())), std::numeric_limits<int32_t>::max()); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(std::numeric_limits<uint32_t>::max()) + 1.f), std::numeric_limits<int32_t>::max()); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(std::numeric_limits<uint32_t>::min())), 0.f); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(std::numeric_limits<int64_t>::max())), std::numeric_limits<int32_t>::max()); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(std::numeric_limits<int64_t>::max()) + 1.f), std::numeric_limits<int32_t>::max()); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(std::numeric_limits<int64_t>::min())), std::numeric_limits<int32_t>::min()); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(std::numeric_limits<int64_t>::min()) - 1.f), std::numeric_limits<int32_t>::min()); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(std::numeric_limits<uint64_t>::max())), std::numeric_limits<int32_t>::max()); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(std::numeric_limits<uint64_t>::max()) + 1.f), std::numeric_limits<int32_t>::max()); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(std::numeric_limits<uint64_t>::min())), 0.f); >+ >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(std::numeric_limits<FloatingPointType>::infinity())), std::numeric_limits<int32_t>::max()); >+ EXPECT_EQ(clampTo<int32_t>(static_cast<FloatingPointType>(-std::numeric_limits<FloatingPointType>::infinity())), std::numeric_limits<int32_t>::min()); >+} >+ >+TEST(WTF, clampFloatToInt) >+{ >+ testClampFloatingPointToInteger<float>(); >+ testClampFloatingPointToInteger<double>(); >+} >+ >+template<typename TargetType, typename SourceType> >+static void testClampSameSignIntegers() >+{ >+ EXPECT_EQ(clampTo<TargetType>(static_cast<SourceType>(0)), static_cast<TargetType>(0)); >+ EXPECT_EQ(clampTo<TargetType>(static_cast<SourceType>(1)), static_cast<TargetType>(1)); >+ EXPECT_EQ(clampTo<TargetType>(static_cast<SourceType>(-1)), std::numeric_limits<TargetType>::is_signed ? static_cast<TargetType>(-1) : std::numeric_limits<TargetType>::max()); >+ >+ EXPECT_EQ(clampTo<TargetType>(static_cast<SourceType>(std::numeric_limits<TargetType>::min())), std::numeric_limits<TargetType>::min()); >+ EXPECT_EQ(clampTo<TargetType>(static_cast<SourceType>(std::numeric_limits<TargetType>::max())), std::numeric_limits<TargetType>::max()); >+ >+ EXPECT_EQ(clampTo<TargetType>(std::numeric_limits<SourceType>::min()), std::numeric_limits<TargetType>::min()); >+ EXPECT_EQ(clampTo<TargetType>(std::numeric_limits<SourceType>::max()), std::numeric_limits<TargetType>::max()); >+} >+ >+TEST(WTF, clampSameSignIntegers) >+{ >+ testClampSameSignIntegers<int32_t, int32_t>(); >+ testClampSameSignIntegers<uint32_t, uint32_t>(); >+ testClampSameSignIntegers<int32_t, int64_t>(); >+ testClampSameSignIntegers<uint32_t, uint64_t>(); >+ testClampSameSignIntegers<int16_t, int64_t>(); >+ testClampSameSignIntegers<uint16_t, uint64_t>(); >+} >+ >+template<typename TargetType, typename SourceType> >+static void testClampUnsignedToSigned() >+{ >+ EXPECT_EQ(clampTo<TargetType>(static_cast<SourceType>(0)), static_cast<TargetType>(0)); >+ EXPECT_EQ(clampTo<TargetType>(static_cast<SourceType>(1)), static_cast<TargetType>(1)); >+ >+ EXPECT_EQ(clampTo<TargetType>(static_cast<SourceType>(std::numeric_limits<TargetType>::max())), std::numeric_limits<TargetType>::max()); >+ EXPECT_EQ(clampTo<TargetType>(std::numeric_limits<SourceType>::max()), std::numeric_limits<TargetType>::max()); >+} >+ >+TEST(WTF, clampUnsignedToSigned) >+{ >+ testClampUnsignedToSigned<int32_t, uint32_t>(); >+ testClampUnsignedToSigned<int64_t, uint64_t>(); >+ testClampUnsignedToSigned<int32_t, uint64_t>(); >+ testClampUnsignedToSigned<int16_t, uint32_t>(); >+ testClampUnsignedToSigned<int16_t, uint64_t>(); >+} >+ >+template<typename TargetType, typename SourceType> >+static void testClampSignedToUnsigned() >+{ >+ EXPECT_EQ(clampTo<TargetType>(static_cast<SourceType>(0)), static_cast<TargetType>(0)); >+ EXPECT_EQ(clampTo<TargetType>(static_cast<SourceType>(1)), static_cast<TargetType>(1)); >+ EXPECT_EQ(clampTo<TargetType>(static_cast<SourceType>(-1)), static_cast<TargetType>(0)); >+ >+ if (sizeof(TargetType) < sizeof(SourceType)) { >+ EXPECT_EQ(clampTo<TargetType>(static_cast<SourceType>(std::numeric_limits<TargetType>::min())), static_cast<TargetType>(0)); >+ EXPECT_EQ(clampTo<TargetType>(static_cast<SourceType>(std::numeric_limits<TargetType>::max())), std::numeric_limits<TargetType>::max()); >+ } >+ >+ EXPECT_EQ(clampTo<TargetType>(std::numeric_limits<SourceType>::min()), static_cast<TargetType>(0)); >+ if (sizeof(TargetType) < sizeof(SourceType)) >+ EXPECT_EQ(clampTo<TargetType>(std::numeric_limits<SourceType>::max()), std::numeric_limits<TargetType>::max()); >+ else >+ EXPECT_EQ(clampTo<TargetType>(std::numeric_limits<SourceType>::max()), static_cast<TargetType>(std::numeric_limits<SourceType>::max())); >+} >+ >+TEST(WTF, clampSignedToUnsigned) >+{ >+ testClampSignedToUnsigned<uint32_t, int32_t>(); >+ testClampSignedToUnsigned<uint64_t, int64_t>(); >+ testClampSignedToUnsigned<uint32_t, int64_t>(); >+ testClampSignedToUnsigned<uint16_t, int32_t>(); >+ testClampSignedToUnsigned<uint16_t, int64_t>(); >+} >+ > TEST(WTF, roundUpToPowerOfTwo) > { > EXPECT_EQ(WTF::roundUpToPowerOfTwo(UINT32_MAX), 0U);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194073
:
360684
|
360823
|
360945
|
361155