Title: [259833] trunk
Revision
259833
Author
ddkil...@apple.com
Date
2020-04-09 15:08:48 -0700 (Thu, 09 Apr 2020)

Log Message

Add using WTF::isInBounds to CheckedArithmetic.h
<https://webkit.org/b/210299>

Reviewed by Darin Adler.

Source/WebCore:

* fileapi/Blob.cpp:
(WebCore::Blob::size const):
* page/PointerCaptureController.cpp:
(WebCore::PointerCaptureController::elementWasRemoved):
* platform/graphics/ImageSource.cpp:
(WebCore::ImageSource::cacheNativeImageAtIndex):
* platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm:
(WebCore::tryGetResourceAsBufferBinding):
- Remove WTF:: prefix from isInBounds().

Source/WebKit:

* Platform/IPC/ArgumentCoders.h:
* Shared/UserData.cpp:
(WebKit::UserData::decode):
- Remove WTF:: prefix from isInBounds().

Source/WTF:

* wtf/CheckedArithmetic.h:
- Add `using WTF::isInBounds` statement so this function may be
  used unprefixed outside the WTF project.

Tools:

* TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp:
(TestWebKitAPI::TEST):
- Remove WTF:: prefix from isInBounds().

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (259832 => 259833)


--- trunk/Source/WTF/ChangeLog	2020-04-09 21:55:53 UTC (rev 259832)
+++ trunk/Source/WTF/ChangeLog	2020-04-09 22:08:48 UTC (rev 259833)
@@ -1,5 +1,16 @@
 2020-04-09  David Kilzer  <ddkil...@apple.com>
 
+        Add using WTF::isInBounds to CheckedArithmetic.h
+        <https://webkit.org/b/210299>
+
+        Reviewed by Darin Adler.
+
+        * wtf/CheckedArithmetic.h:
+        - Add `using WTF::isInBounds` statement so this function may be
+          used unprefixed outside the WTF project.
+
+2020-04-09  David Kilzer  <ddkil...@apple.com>
+
         WTF::Persistence::Coder and WTF::Persistence::Decoder should use WARN_UNUSED_RETURN
         <https://webkit.org/b/210238>
         <rdar://problem/61491575>

Modified: trunk/Source/WTF/wtf/CheckedArithmetic.h (259832 => 259833)


--- trunk/Source/WTF/wtf/CheckedArithmetic.h	2020-04-09 21:55:53 UTC (rev 259832)
+++ trunk/Source/WTF/wtf/CheckedArithmetic.h	2020-04-09 22:08:48 UTC (rev 259833)
@@ -1006,5 +1006,6 @@
 using WTF::RecordOverflow;
 using WTF::checkedSum;
 using WTF::differenceOverflows;
+using WTF::isInBounds;
 using WTF::productOverflows;
 using WTF::sumOverflows;

Modified: trunk/Source/WebCore/ChangeLog (259832 => 259833)


--- trunk/Source/WebCore/ChangeLog	2020-04-09 21:55:53 UTC (rev 259832)
+++ trunk/Source/WebCore/ChangeLog	2020-04-09 22:08:48 UTC (rev 259833)
@@ -1,3 +1,20 @@
+2020-04-09  David Kilzer  <ddkil...@apple.com>
+
+        Add using WTF::isInBounds to CheckedArithmetic.h
+        <https://webkit.org/b/210299>
+
+        Reviewed by Darin Adler.
+
+        * fileapi/Blob.cpp:
+        (WebCore::Blob::size const):
+        * page/PointerCaptureController.cpp:
+        (WebCore::PointerCaptureController::elementWasRemoved):
+        * platform/graphics/ImageSource.cpp:
+        (WebCore::ImageSource::cacheNativeImageAtIndex):
+        * platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm:
+        (WebCore::tryGetResourceAsBufferBinding):
+        - Remove WTF:: prefix from isInBounds().
+
 2020-04-09  Andres Gonzalez  <andresg...@apple.com>
 
         Fix for crash in test accessibility/mac/aria-grid-with-strange-hierarchy.html in isolated tree mode.

Modified: trunk/Source/WebCore/fileapi/Blob.cpp (259832 => 259833)


--- trunk/Source/WebCore/fileapi/Blob.cpp	2020-04-09 21:55:53 UTC (rev 259832)
+++ trunk/Source/WebCore/fileapi/Blob.cpp	2020-04-09 22:08:48 UTC (rev 259833)
@@ -162,7 +162,7 @@
         // FIXME: _javascript_ cannot represent sizes as large as unsigned long long, we need to
         // come up with an exception to throw if file size is not representable.
         unsigned long long actualSize = ThreadableBlobRegistry::blobSize(m_internalURL);
-        m_size = WTF::isInBounds<long long>(actualSize) ? actualSize : 0;
+        m_size = isInBounds<long long>(actualSize) ? actualSize : 0;
     }
 
     return *m_size;

Modified: trunk/Source/WebCore/page/PointerCaptureController.cpp (259832 => 259833)


--- trunk/Source/WebCore/page/PointerCaptureController.cpp	2020-04-09 21:55:53 UTC (rev 259832)
+++ trunk/Source/WebCore/page/PointerCaptureController.cpp	2020-04-09 22:08:48 UTC (rev 259833)
@@ -144,7 +144,7 @@
             // When the pointer capture target override is no longer connected, the pending pointer capture target override and pointer capture target
             // override nodes SHOULD be cleared and also a PointerEvent named lostpointercapture corresponding to the captured pointer SHOULD be fired
             // at the document.
-            ASSERT(WTF::isInBounds<PointerID>(keyAndValue.key));
+            ASSERT(isInBounds<PointerID>(keyAndValue.key));
             auto pointerId = static_cast<PointerID>(keyAndValue.key);
             auto pointerType = capturingData.pointerType;
             releasePointerCapture(&element, pointerId);

Modified: trunk/Source/WebCore/platform/graphics/ImageSource.cpp (259832 => 259833)


--- trunk/Source/WebCore/platform/graphics/ImageSource.cpp	2020-04-09 21:55:53 UTC (rev 259832)
+++ trunk/Source/WebCore/platform/graphics/ImageSource.cpp	2020-04-09 22:08:48 UTC (rev 259833)
@@ -288,7 +288,7 @@
 
     // Do not cache the NativeImage if adding its frameByes to the MemoryCache will cause numerical overflow.
     size_t frameBytes = size().unclampedArea() * sizeof(uint32_t);
-    if (!WTF::isInBounds<unsigned>(frameBytes + decodedSize()))
+    if (!isInBounds<unsigned>(frameBytes + decodedSize()))
         return;
 
     // Move the new image to the cache.

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm (259832 => 259833)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm	2020-04-09 21:55:53 UTC (rev 259832)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm	2020-04-09 22:08:48 UTC (rev 259833)
@@ -55,12 +55,12 @@
         LOG(WebGPU, "%s: Invalid MTLBuffer in GPUBufferBinding!", functionName);
         return WTF::nullopt;
     }
-    if (!WTF::isInBounds<NSUInteger>(bufferBinding.size) || bufferBinding.size > bufferBinding.buffer->byteLength()) {
+    if (!isInBounds<NSUInteger>(bufferBinding.size) || bufferBinding.size > bufferBinding.buffer->byteLength()) {
         LOG(WebGPU, "%s: GPUBufferBinding size is too large!", functionName);
         return WTF::nullopt;
     }
     // MTLBuffer size (NSUInteger) is 32 bits on some platforms.
-    if (!WTF::isInBounds<NSUInteger>(bufferBinding.offset)) {
+    if (!isInBounds<NSUInteger>(bufferBinding.offset)) {
         LOG(WebGPU, "%s: Buffer offset is too large!", functionName);
         return WTF::nullopt;
     }

Modified: trunk/Source/WebKit/ChangeLog (259832 => 259833)


--- trunk/Source/WebKit/ChangeLog	2020-04-09 21:55:53 UTC (rev 259832)
+++ trunk/Source/WebKit/ChangeLog	2020-04-09 22:08:48 UTC (rev 259833)
@@ -1,3 +1,15 @@
+2020-04-09  David Kilzer  <ddkil...@apple.com>
+
+        Add using WTF::isInBounds to CheckedArithmetic.h
+        <https://webkit.org/b/210299>
+
+        Reviewed by Darin Adler.
+
+        * Platform/IPC/ArgumentCoders.h:
+        * Shared/UserData.cpp:
+        (WebKit::UserData::decode):
+        - Remove WTF:: prefix from isInBounds().
+
 2020-04-09  Keith Rollin  <krol...@apple.com>
 
         Set ENTITLEMENTS_REQUIRED=NO for some Xcode build targets

Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h (259832 => 259833)


--- trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h	2020-04-09 21:55:53 UTC (rev 259832)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h	2020-04-09 22:08:48 UTC (rev 259833)
@@ -372,7 +372,7 @@
             return false;
         }
 
-        if (!WTF::isInBounds<size_t>(decodedSize)) {
+        if (!isInBounds<size_t>(decodedSize)) {
             decoder.markInvalid();
             return false;
         }
@@ -407,7 +407,7 @@
             return WTF::nullopt;
         }
 
-        if (!WTF::isInBounds<size_t>(decodedSize)) {
+        if (!isInBounds<size_t>(decodedSize)) {
             decoder.markInvalid();
             return WTF::nullopt;
         }

Modified: trunk/Source/WebKit/Shared/UserData.cpp (259832 => 259833)


--- trunk/Source/WebKit/Shared/UserData.cpp	2020-04-09 21:55:53 UTC (rev 259832)
+++ trunk/Source/WebKit/Shared/UserData.cpp	2020-04-09 22:08:48 UTC (rev 259833)
@@ -345,7 +345,7 @@
         if (!decoder.decode(decodedSize))
             return false;
 
-        if (!WTF::isInBounds<size_t>(decodedSize))
+        if (!isInBounds<size_t>(decodedSize))
             return false;
 
         auto size = static_cast<size_t>(decodedSize);
@@ -386,7 +386,7 @@
         if (!decoder.decode(decodedSize))
             return false;
 
-        if (!WTF::isInBounds<size_t>(decodedSize))
+        if (!isInBounds<size_t>(decodedSize))
             return false;
 
         auto size = static_cast<size_t>(decodedSize);

Modified: trunk/Tools/ChangeLog (259832 => 259833)


--- trunk/Tools/ChangeLog	2020-04-09 21:55:53 UTC (rev 259832)
+++ trunk/Tools/ChangeLog	2020-04-09 22:08:48 UTC (rev 259833)
@@ -1,3 +1,14 @@
+2020-04-09  David Kilzer  <ddkil...@apple.com>
+
+        Add using WTF::isInBounds to CheckedArithmetic.h
+        <https://webkit.org/b/210299>
+
+        Reviewed by Darin Adler.
+
+        * TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp:
+        (TestWebKitAPI::TEST):
+        - Remove WTF:: prefix from isInBounds().
+
 2020-04-09  Keith Rollin  <krol...@apple.com>
 
         Set ENTITLEMENTS_REQUIRED=NO for some Xcode build targets

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp (259832 => 259833)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp	2020-04-09 21:55:53 UTC (rev 259832)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp	2020-04-09 22:08:48 UTC (rev 259833)
@@ -431,59 +431,59 @@
 TEST(CheckedArithmeticTest, IsInBounds)
 {
     // bigger precision, signed, signed
-    EXPECT_TRUE(WTF::isInBounds<int32_t>(std::numeric_limits<int16_t>::max()));
-    EXPECT_TRUE(WTF::isInBounds<int32_t>(std::numeric_limits<int16_t>::min()));
+    EXPECT_TRUE(isInBounds<int32_t>(std::numeric_limits<int16_t>::max()));
+    EXPECT_TRUE(isInBounds<int32_t>(std::numeric_limits<int16_t>::min()));
 
     // bigger precision, unsigned, signed
-    EXPECT_TRUE(WTF::isInBounds<uint32_t>(std::numeric_limits<int32_t>::max()));
-    EXPECT_FALSE(WTF::isInBounds<uint32_t>(std::numeric_limits<int16_t>::min()));
+    EXPECT_TRUE(isInBounds<uint32_t>(std::numeric_limits<int32_t>::max()));
+    EXPECT_FALSE(isInBounds<uint32_t>(std::numeric_limits<int16_t>::min()));
 
-    EXPECT_FALSE(WTF::isInBounds<uint32_t>((int32_t)-1));
-    EXPECT_FALSE(WTF::isInBounds<uint16_t>((int32_t)-1));
-    EXPECT_FALSE(WTF::isInBounds<unsigned long>((int)-1));
+    EXPECT_FALSE(isInBounds<uint32_t>((int32_t)-1));
+    EXPECT_FALSE(isInBounds<uint16_t>((int32_t)-1));
+    EXPECT_FALSE(isInBounds<unsigned long>((int)-1));
 
-    EXPECT_TRUE(WTF::isInBounds<uint32_t>((int32_t)1));
-    EXPECT_TRUE(WTF::isInBounds<uint32_t>((int16_t)1));
-    EXPECT_TRUE(WTF::isInBounds<unsigned>((int)1));
+    EXPECT_TRUE(isInBounds<uint32_t>((int32_t)1));
+    EXPECT_TRUE(isInBounds<uint32_t>((int16_t)1));
+    EXPECT_TRUE(isInBounds<unsigned>((int)1));
 
-    EXPECT_TRUE(WTF::isInBounds<uint32_t>((int32_t)0));
-    EXPECT_TRUE(WTF::isInBounds<uint16_t>((int32_t)0));
-    EXPECT_TRUE(WTF::isInBounds<uint32_t>((int16_t)0));
-    EXPECT_TRUE(WTF::isInBounds<unsigned>((int)0));
+    EXPECT_TRUE(isInBounds<uint32_t>((int32_t)0));
+    EXPECT_TRUE(isInBounds<uint16_t>((int32_t)0));
+    EXPECT_TRUE(isInBounds<uint32_t>((int16_t)0));
+    EXPECT_TRUE(isInBounds<unsigned>((int)0));
 
-    EXPECT_TRUE(WTF::isInBounds<uint32_t>(std::numeric_limits<int32_t>::max()));
-    EXPECT_TRUE(WTF::isInBounds<uint32_t>(std::numeric_limits<int16_t>::max()));
-    EXPECT_TRUE(WTF::isInBounds<unsigned>(std::numeric_limits<int>::max()));
+    EXPECT_TRUE(isInBounds<uint32_t>(std::numeric_limits<int32_t>::max()));
+    EXPECT_TRUE(isInBounds<uint32_t>(std::numeric_limits<int16_t>::max()));
+    EXPECT_TRUE(isInBounds<unsigned>(std::numeric_limits<int>::max()));
 
     // bigger precision, signed, unsigned
-    EXPECT_TRUE(WTF::isInBounds<int32_t>(std::numeric_limits<uint16_t>::max()));
-    EXPECT_FALSE(WTF::isInBounds<int32_t>(std::numeric_limits<uint32_t>::max()));
-    EXPECT_TRUE(WTF::isInBounds<int32_t>((uint32_t)0));
+    EXPECT_TRUE(isInBounds<int32_t>(std::numeric_limits<uint16_t>::max()));
+    EXPECT_FALSE(isInBounds<int32_t>(std::numeric_limits<uint32_t>::max()));
+    EXPECT_TRUE(isInBounds<int32_t>((uint32_t)0));
 
     // bigger precision, unsigned, unsigned
-    EXPECT_TRUE(WTF::isInBounds<uint32_t>(std::numeric_limits<uint16_t>::max()));
-    EXPECT_TRUE(WTF::isInBounds<uint32_t>(std::numeric_limits<uint16_t>::min()));
+    EXPECT_TRUE(isInBounds<uint32_t>(std::numeric_limits<uint16_t>::max()));
+    EXPECT_TRUE(isInBounds<uint32_t>(std::numeric_limits<uint16_t>::min()));
 
     // lower precision, signed signed
-    EXPECT_FALSE(WTF::isInBounds<int16_t>(std::numeric_limits<int32_t>::max()));
-    EXPECT_FALSE(WTF::isInBounds<int16_t>(std::numeric_limits<int32_t>::min()));
-    EXPECT_TRUE(WTF::isInBounds<int16_t>((int32_t)-1));
-    EXPECT_TRUE(WTF::isInBounds<int16_t>((int32_t)0));
-    EXPECT_TRUE(WTF::isInBounds<int16_t>((int32_t)1));
+    EXPECT_FALSE(isInBounds<int16_t>(std::numeric_limits<int32_t>::max()));
+    EXPECT_FALSE(isInBounds<int16_t>(std::numeric_limits<int32_t>::min()));
+    EXPECT_TRUE(isInBounds<int16_t>((int32_t)-1));
+    EXPECT_TRUE(isInBounds<int16_t>((int32_t)0));
+    EXPECT_TRUE(isInBounds<int16_t>((int32_t)1));
     // lower precision, unsigned, signed
-    EXPECT_FALSE(WTF::isInBounds<uint16_t>(std::numeric_limits<int32_t>::max()));
-    EXPECT_FALSE(WTF::isInBounds<uint16_t>(std::numeric_limits<int32_t>::min()));
-    EXPECT_FALSE(WTF::isInBounds<uint16_t>((int32_t)-1));
-    EXPECT_TRUE(WTF::isInBounds<uint16_t>((int32_t)0));
-    EXPECT_TRUE(WTF::isInBounds<uint16_t>((int32_t)1));
+    EXPECT_FALSE(isInBounds<uint16_t>(std::numeric_limits<int32_t>::max()));
+    EXPECT_FALSE(isInBounds<uint16_t>(std::numeric_limits<int32_t>::min()));
+    EXPECT_FALSE(isInBounds<uint16_t>((int32_t)-1));
+    EXPECT_TRUE(isInBounds<uint16_t>((int32_t)0));
+    EXPECT_TRUE(isInBounds<uint16_t>((int32_t)1));
     // lower precision, signed, unsigned
-    EXPECT_FALSE(WTF::isInBounds<int16_t>(std::numeric_limits<uint32_t>::max()));
-    EXPECT_TRUE(WTF::isInBounds<int16_t>((uint32_t)0));
-    EXPECT_TRUE(WTF::isInBounds<int16_t>((uint32_t)1));
+    EXPECT_FALSE(isInBounds<int16_t>(std::numeric_limits<uint32_t>::max()));
+    EXPECT_TRUE(isInBounds<int16_t>((uint32_t)0));
+    EXPECT_TRUE(isInBounds<int16_t>((uint32_t)1));
     // lower precision, unsigned, unsigned
-    EXPECT_FALSE(WTF::isInBounds<uint16_t>(std::numeric_limits<uint32_t>::max()));
-    EXPECT_TRUE(WTF::isInBounds<uint16_t>((uint32_t)0));
-    EXPECT_TRUE(WTF::isInBounds<uint16_t>((uint32_t)1));
+    EXPECT_FALSE(isInBounds<uint16_t>(std::numeric_limits<uint32_t>::max()));
+    EXPECT_TRUE(isInBounds<uint16_t>((uint32_t)0));
+    EXPECT_TRUE(isInBounds<uint16_t>((uint32_t)1));
 }
 
 } // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to