Title: [160749] trunk
Revision
160749
Author
jer.no...@apple.com
Date
2013-12-17 21:37:02 -0800 (Tue, 17 Dec 2013)

Log Message

Fix TimeRanges::intersectWith
https://bugs.webkit.org/show_bug.cgi?id=118802

Source/WebCore:

Test: TestWebKitAPI/Tests/WebCore/TimeRanges.cpp.

Reviewed by Eric Carlson.

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* html/TimeRanges.cpp:
(TimeRanges::invert):
(TimeRanges::intersectWith):

Merge
https://chromium.googlesource.com/chromium/blink/+/f557582b6c6283a8b165514f52d01cfd98130e85

Tools:

Reviewed by Eric Carlson.

Add unit tests for WebCore/TimeRanges.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebCore/TimeRanges.cpp: Added.
(TestWebKitAPI::ToString):
(TestWebKitAPI::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (160748 => 160749)


--- trunk/Source/WebCore/ChangeLog	2013-12-18 04:32:23 UTC (rev 160748)
+++ trunk/Source/WebCore/ChangeLog	2013-12-18 05:37:02 UTC (rev 160749)
@@ -1,3 +1,21 @@
+2013-12-17  Jer Noble  <jer.no...@apple.com>
+
+        Fix TimeRanges::intersectWith
+        https://bugs.webkit.org/show_bug.cgi?id=118802
+
+        Test: TestWebKitAPI/Tests/WebCore/TimeRanges.cpp.
+
+        Reviewed by Eric Carlson.
+
+        * WebCore.exp.in:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/TimeRanges.cpp:
+        (TimeRanges::invert):
+        (TimeRanges::intersectWith):
+
+        Merge
+        https://chromium.googlesource.com/chromium/blink/+/f557582b6c6283a8b165514f52d01cfd98130e85        
+
 2013-12-17  Eric Carlson  <eric.carl...@apple.com>
 
         ASSERT setting pseudoID with registered DOMSubtreeModified listener

Modified: trunk/Source/WebCore/WebCore.exp.in (160748 => 160749)


--- trunk/Source/WebCore/WebCore.exp.in	2013-12-18 04:32:23 UTC (rev 160748)
+++ trunk/Source/WebCore/WebCore.exp.in	2013-12-18 05:37:02 UTC (rev 160749)
@@ -1386,6 +1386,8 @@
 __ZN7WebCore9plainTextEPKNS_5RangeENS_20TextIteratorBehaviorEb
 __ZN7WebCore9toElementEN3JSC7JSValueE
 __ZN7WebCore9unionRectERKN3WTF6VectorINS_9FloatRectELm0ENS0_15CrashOnOverflowEEE
+__ZN7WebCore10TimeRanges13intersectWithEPKS0_
+__ZN7WebCore10TimeRangesC1Edd
 __ZNK3JSC8Bindings10RootObject12globalObjectEv
 __ZNK3WTF6String14createCFStringEv
 __ZNK7WebCore10Credential11hasPasswordEv
@@ -1418,6 +1420,9 @@
 __ZNK7WebCore10StorageMap6lengthEv
 __ZNK7WebCore10StorageMap7getItemERKN3WTF6StringE
 __ZNK7WebCore10StorageMap8containsERKN3WTF6StringE
+__ZNK7WebCore10TimeRanges3endEjRi
+__ZNK7WebCore10TimeRanges4copyEv
+__ZNK7WebCore10TimeRanges5startEjRi
 __ZNK7WebCore11FrameLoader10isCompleteEv
 __ZNK7WebCore11FrameLoader14cancelledErrorERKNS_15ResourceRequestE
 __ZNK7WebCore11FrameLoader14frameHasLoadedEv

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (160748 => 160749)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-12-18 04:32:23 UTC (rev 160748)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-12-18 05:37:02 UTC (rev 160749)
@@ -5786,7 +5786,7 @@
 		E44613AB0CD6331000FADA75 /* HTMLVideoElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E44613990CD6331000FADA75 /* HTMLVideoElement.h */; };
 		E44613AD0CD6331000FADA75 /* MediaError.h in Headers */ = {isa = PBXBuildFile; fileRef = E446139B0CD6331000FADA75 /* MediaError.h */; };
 		E44613AF0CD6331000FADA75 /* TimeRanges.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E446139D0CD6331000FADA75 /* TimeRanges.cpp */; };
-		E44613B00CD6331000FADA75 /* TimeRanges.h in Headers */ = {isa = PBXBuildFile; fileRef = E446139E0CD6331000FADA75 /* TimeRanges.h */; };
+		E44613B00CD6331000FADA75 /* TimeRanges.h in Headers */ = {isa = PBXBuildFile; fileRef = E446139E0CD6331000FADA75 /* TimeRanges.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E44613B60CD6344E00FADA75 /* VoidCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = E44613B40CD6344E00FADA75 /* VoidCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E44613E30CD6819F00FADA75 /* MediaPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B41E0C0CBF90BD00AF2ECE /* MediaPlayer.cpp */; };
 		E44613E40CD681A200FADA75 /* MediaPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = E4B41E0D0CBF90BD00AF2ECE /* MediaPlayer.h */; settings = {ATTRIBUTES = (Private, ); }; };

Modified: trunk/Source/WebCore/html/TimeRanges.cpp (160748 => 160749)


--- trunk/Source/WebCore/html/TimeRanges.cpp	2013-12-18 04:32:23 UTC (rev 160748)
+++ trunk/Source/WebCore/html/TimeRanges.cpp	2013-12-18 05:37:02 UTC (rev 160749)
@@ -58,13 +58,15 @@
     if (!m_ranges.size())
         inverted->add(negInf, posInf);
     else {
-        if (double start = m_ranges.first().m_start != negInf)
+        double start = m_ranges.first().m_start;
+        if (start != negInf)
             inverted->add(negInf, start);
 
         for (size_t index = 0; index + 1 < m_ranges.size(); ++index)
             inverted->add(m_ranges[index].m_end, m_ranges[index + 1].m_start);
 
-        if (double end = m_ranges.last().m_end != posInf)
+        double end = m_ranges.last().m_end;
+        if (end != posInf)
             inverted->add(end, posInf);
     }
 
@@ -74,12 +76,16 @@
 void TimeRanges::intersectWith(const TimeRanges* other)
 {
     ASSERT(other);
-    RefPtr<TimeRanges> inverted = copy();
+
+    if (other == this)
+        return;
+
     RefPtr<TimeRanges> invertedOther = other->copy();
-    inverted->unionWith(invertedOther.get());
-    inverted->invert();
+    invertedOther->invert();
 
-    m_ranges.swap(inverted->m_ranges);
+    invert();
+    unionWith(invertedOther.get());
+    invert();
 }
 
 void TimeRanges::unionWith(const TimeRanges* other)

Modified: trunk/Tools/ChangeLog (160748 => 160749)


--- trunk/Tools/ChangeLog	2013-12-18 04:32:23 UTC (rev 160748)
+++ trunk/Tools/ChangeLog	2013-12-18 05:37:02 UTC (rev 160749)
@@ -1,3 +1,17 @@
+2013-12-17  Jer Noble  <jer.no...@apple.com>
+
+        Fix TimeRanges::intersectWith
+        https://bugs.webkit.org/show_bug.cgi?id=118802
+
+        Reviewed by Eric Carlson.
+
+        Add unit tests for WebCore/TimeRanges.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebCore/TimeRanges.cpp: Added.
+        (TestWebKitAPI::ToString):
+        (TestWebKitAPI::TEST):
+
 2013-12-17  Alexey Proskuryakov  <a...@apple.com>
 
         Botwatcher's dashboard ceases to update itself after a while

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (160748 => 160749)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2013-12-18 04:32:23 UTC (rev 160748)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2013-12-18 05:37:02 UTC (rev 160749)
@@ -227,6 +227,7 @@
 		CD5393C81757BA9700C07123 /* MD5.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5393C71757BA9700C07123 /* MD5.cpp */; };
 		CD5393CA1757BAC400C07123 /* SHA1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5393C91757BAC400C07123 /* SHA1.cpp */; };
 		CD5497B415857F0C00B5BC30 /* MediaTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5497B315857F0C00B5BC30 /* MediaTime.cpp */; };
+		CDC2C71517970DDB00E627FB /* TimeRanges.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDC2C7141797089D00E627FB /* TimeRanges.cpp */; };
 		CE14F1A4181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CE14F1A2181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html */; };
 		CE32C7C818184C4900CD8C28 /* WillPerformClientRedirectToURLCrash.mm in Sources */ = {isa = PBXBuildFile; fileRef = CE32C7C718184C4900CD8C28 /* WillPerformClientRedirectToURLCrash.mm */; };
 		E1220DA0155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1220D9F155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm */; };
@@ -575,6 +576,7 @@
 		CD5393C71757BA9700C07123 /* MD5.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MD5.cpp; sourceTree = "<group>"; };
 		CD5393C91757BAC400C07123 /* SHA1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SHA1.cpp; sourceTree = "<group>"; };
 		CD5497B315857F0C00B5BC30 /* MediaTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaTime.cpp; sourceTree = "<group>"; };
+		CDC2C7141797089D00E627FB /* TimeRanges.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TimeRanges.cpp; sourceTree = "<group>"; };
 		CE14F1A2181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = WillPerformClientRedirectToURLCrash.html; sourceTree = "<group>"; };
 		CE32C7C718184C4900CD8C28 /* WillPerformClientRedirectToURLCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WillPerformClientRedirectToURLCrash.mm; sourceTree = "<group>"; };
 		E1220D9F155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCacheDisableWithinResourceLoadDelegate.mm; sourceTree = "<group>"; };
@@ -685,6 +687,7 @@
 		440A1D3614A01000008A66F2 /* WebCore */ = {
 			isa = PBXGroup;
 			children = (
+				CDC2C7141797089D00E627FB /* TimeRanges.cpp */,
 				440A1D3814A0103A008A66F2 /* URL.cpp */,
 				14464012167A8305000BD218 /* LayoutUnit.cpp */,
 			);
@@ -1251,6 +1254,7 @@
 				261516D615B0E60500A2C201 /* SetAndUpdateCacheModel.mm in Sources */,
 				52B8CF9615868CF000281053 /* SetDocumentURI.mm in Sources */,
 				7C8DDAAB1735DEEE00EA5AC0 /* CloseThenTerminate.cpp in Sources */,
+				CDC2C71517970DDB00E627FB /* TimeRanges.cpp in Sources */,
 				51FCF79A1534AC6D00104491 /* ShouldGoToBackForwardListItem.cpp in Sources */,
 				C540F776152E4DA000A40C8C /* SimplifyMarkup.mm in Sources */,
 				C02B77F2126612140026BF0F /* SpacebarScrolling.cpp in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebCore/TimeRanges.cpp (0 => 160749)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/TimeRanges.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/TimeRanges.cpp	2013-12-18 05:37:02 UTC (rev 160749)
@@ -0,0 +1,292 @@
+/*
+ * Copyright (c) 2013, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include <WebCore/TimeRanges.h>
+
+#include <WebCore/ExceptionCodePlaceholder.h>
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+static std::string ToString(const TimeRanges& ranges)
+{
+    std::stringstream ss;
+    ss << "{";
+    for (unsigned i = 0; i < ranges.length(); ++i)
+        ss << " [" << ranges.start(i, IGNORE_EXCEPTION) << "," << ranges.end(i, IGNORE_EXCEPTION) << ")";
+    ss << " }";
+
+    return ss.str();
+}
+
+#define ASSERT_RANGE(expected, range) EXPECT_EQ(expected, ToString(*range))
+
+TEST(TimeRanges, Empty)
+{
+    ASSERT_RANGE("{ }", TimeRanges::create());
+}
+
+TEST(TimeRanges, SingleRange)
+{
+    ASSERT_RANGE("{ [1,2) }", TimeRanges::create(1, 2));
+}
+
+TEST(TimeRanges, AddOrder)
+{
+    RefPtr<TimeRanges> rangeA = TimeRanges::create();
+    RefPtr<TimeRanges> rangeB = TimeRanges::create();
+
+    rangeA->add(0, 2);
+    rangeA->add(3, 4);
+    rangeA->add(5, 100);
+
+    std::string expected = "{ [0,2) [3,4) [5,100) }";
+    ASSERT_RANGE(expected, rangeA);
+
+    // Add the values in rangeA to rangeB in reverse order.
+    for (int i = rangeA->length() - 1; i >= 0; --i)
+        rangeB->add(rangeA->start(i, IGNORE_EXCEPTION), rangeA->end(i, IGNORE_EXCEPTION));
+
+    ASSERT_RANGE(expected, rangeB);
+}
+
+TEST(TimeRanges, OverlappingAdds)
+{
+    RefPtr<TimeRanges> ranges = TimeRanges::create();
+
+    ranges->add(0, 2);
+    ranges->add(10, 11);
+    ASSERT_RANGE("{ [0,2) [10,11) }", ranges);
+
+    ranges->add(0, 2);
+    ASSERT_RANGE("{ [0,2) [10,11) }", ranges);
+
+    ranges->add(2, 3);
+    ASSERT_RANGE("{ [0,3) [10,11) }", ranges);
+
+    ranges->add(2, 6);
+    ASSERT_RANGE("{ [0,6) [10,11) }", ranges);
+
+    ranges->add(9, 10);
+    ASSERT_RANGE("{ [0,6) [9,11) }", ranges);
+
+    ranges->add(8, 10);
+    ASSERT_RANGE("{ [0,6) [8,11) }", ranges);
+
+    ranges->add(-1, 7);
+    ASSERT_RANGE("{ [-1,7) [8,11) }", ranges);
+
+    ranges->add(6, 9);
+    ASSERT_RANGE("{ [-1,11) }", ranges);
+}
+
+TEST(TimeRanges, IntersectWith_Self)
+{
+    RefPtr<TimeRanges> ranges = TimeRanges::create(0, 2);
+
+    ASSERT_RANGE("{ [0,2) }", ranges);
+
+    ranges->intersectWith(ranges.get());
+
+    ASSERT_RANGE("{ [0,2) }", ranges);
+}
+
+TEST(TimeRanges, IntersectWith_IdenticalRange)
+{
+    RefPtr<TimeRanges> rangesA = TimeRanges::create(0, 2);
+    RefPtr<TimeRanges> rangesB = rangesA->copy();
+
+    ASSERT_RANGE("{ [0,2) }", rangesA);
+    ASSERT_RANGE("{ [0,2) }", rangesB);
+
+    rangesA->intersectWith(rangesB.get());
+
+    ASSERT_RANGE("{ [0,2) }", rangesA);
+    ASSERT_RANGE("{ [0,2) }", rangesB);
+}
+
+TEST(TimeRanges, IntersectWith_Empty)
+{
+    RefPtr<TimeRanges> rangesA = TimeRanges::create(0, 2);
+    RefPtr<TimeRanges> rangesB = TimeRanges::create();
+
+    ASSERT_RANGE("{ [0,2) }", rangesA);
+    ASSERT_RANGE("{ }", rangesB);
+
+    rangesA->intersectWith(rangesB.get());
+
+    ASSERT_RANGE("{ }", rangesA);
+    ASSERT_RANGE("{ }", rangesB);
+}
+
+TEST(TimeRanges, IntersectWith_DisjointRanges1)
+{
+    RefPtr<TimeRanges> rangesA = TimeRanges::create();
+    RefPtr<TimeRanges> rangesB = TimeRanges::create();
+
+    rangesA->add(0, 1);
+    rangesA->add(4, 5);
+
+    rangesB->add(2, 3);
+    rangesB->add(6, 7);
+
+    ASSERT_RANGE("{ [0,1) [4,5) }", rangesA);
+    ASSERT_RANGE("{ [2,3) [6,7) }", rangesB);
+
+    rangesA->intersectWith(rangesB.get());
+
+    ASSERT_RANGE("{ }", rangesA);
+    ASSERT_RANGE("{ [2,3) [6,7) }", rangesB);
+}
+
+TEST(TimeRanges, IntersectWith_DisjointRanges2)
+{
+    RefPtr<TimeRanges> rangesA = TimeRanges::create();
+    RefPtr<TimeRanges> rangesB = TimeRanges::create();
+
+    rangesA->add(0, 1);
+    rangesA->add(4, 5);
+
+    rangesB->add(1, 4);
+    rangesB->add(5, 7);
+
+    ASSERT_RANGE("{ [0,1) [4,5) }", rangesA);
+    ASSERT_RANGE("{ [1,4) [5,7) }", rangesB);
+
+    rangesA->intersectWith(rangesB.get());
+
+    ASSERT_RANGE("{ }", rangesA);
+    ASSERT_RANGE("{ [1,4) [5,7) }", rangesB);
+}
+
+TEST(TimeRanges, IntersectWith_CompleteOverlap1)
+{
+    RefPtr<TimeRanges> rangesA = TimeRanges::create();
+    RefPtr<TimeRanges> rangesB = TimeRanges::create();
+
+    rangesA->add(1, 3);
+    rangesA->add(4, 5);
+    rangesA->add(6, 9);
+
+    rangesB->add(0, 10);
+
+    ASSERT_RANGE("{ [1,3) [4,5) [6,9) }", rangesA);
+    ASSERT_RANGE("{ [0,10) }", rangesB);
+
+    rangesA->intersectWith(rangesB.get());
+
+    ASSERT_RANGE("{ [1,3) [4,5) [6,9) }", rangesA);
+    ASSERT_RANGE("{ [0,10) }", rangesB);
+}
+
+TEST(TimeRanges, IntersectWith_CompleteOverlap2)
+{
+    RefPtr<TimeRanges> rangesA = TimeRanges::create();
+    RefPtr<TimeRanges> rangesB = TimeRanges::create();
+
+    rangesA->add(1, 3);
+    rangesA->add(4, 5);
+    rangesA->add(6, 9);
+
+    rangesB->add(1, 9);
+
+    ASSERT_RANGE("{ [1,3) [4,5) [6,9) }", rangesA);
+    ASSERT_RANGE("{ [1,9) }", rangesB);
+
+    rangesA->intersectWith(rangesB.get());
+
+    ASSERT_RANGE("{ [1,3) [4,5) [6,9) }", rangesA);
+    ASSERT_RANGE("{ [1,9) }", rangesB);
+}
+
+TEST(TimeRanges, IntersectWith_Gaps1)
+{
+    RefPtr<TimeRanges> rangesA = TimeRanges::create();
+    RefPtr<TimeRanges> rangesB = TimeRanges::create();
+
+    rangesA->add(0, 2);
+    rangesA->add(4, 6);
+
+    rangesB->add(1, 5);
+
+    ASSERT_RANGE("{ [0,2) [4,6) }", rangesA);
+    ASSERT_RANGE("{ [1,5) }", rangesB);
+
+    rangesA->intersectWith(rangesB.get());
+
+    ASSERT_RANGE("{ [1,2) [4,5) }", rangesA);
+    ASSERT_RANGE("{ [1,5) }", rangesB);
+}
+
+TEST(TimeRanges, IntersectWith_Gaps2)
+{
+    RefPtr<TimeRanges> rangesA = TimeRanges::create();
+    RefPtr<TimeRanges> rangesB = TimeRanges::create();
+
+    rangesA->add(0, 2);
+    rangesA->add(4, 6);
+    rangesA->add(8, 10);
+
+    rangesB->add(1, 9);
+
+    ASSERT_RANGE("{ [0,2) [4,6) [8,10) }", rangesA);
+    ASSERT_RANGE("{ [1,9) }", rangesB);
+
+    rangesA->intersectWith(rangesB.get());
+
+    ASSERT_RANGE("{ [1,2) [4,6) [8,9) }", rangesA);
+    ASSERT_RANGE("{ [1,9) }", rangesB);
+}
+
+TEST(TimeRanges, IntersectWith_Gaps3)
+{
+    RefPtr<TimeRanges> rangesA = TimeRanges::create();
+    RefPtr<TimeRanges> rangesB = TimeRanges::create();
+
+    rangesA->add(0, 2);
+    rangesA->add(4, 7);
+    rangesA->add(8, 10);
+
+    rangesB->add(1, 5);
+    rangesB->add(6, 9);
+
+    ASSERT_RANGE("{ [0,2) [4,7) [8,10) }", rangesA);
+    ASSERT_RANGE("{ [1,5) [6,9) }", rangesB);
+
+    rangesA->intersectWith(rangesB.get());
+
+    ASSERT_RANGE("{ [1,2) [4,5) [6,7) [8,9) }", rangesA);
+    ASSERT_RANGE("{ [1,5) [6,9) }", rangesB);
+}
+
+}
+
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to