WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-72294-20111114195428.patch (text/plain), 10.75 KB, created by
Dana Jansens
on 2011-11-14 16:54:30 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Dana Jansens
Created:
2011-11-14 16:54:30 PST
Size:
10.75 KB
patch
obsolete
>Subversion Revision: 100069 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 07a83e2c4573758e1461add6855ad37168edc170..8bac14f7ab2497d8de2d5e796c876e79ea4e6a41 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,16 @@ >+2011-11-14 Dana Jansens <danakj@chromium.org> >+ >+ Add occludes() test to Region >+ https://bugs.webkit.org/show_bug.cgi?id=72294 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Adds chromium unit test for the contains() method. >+ >+ * platform/graphics/Region.cpp: >+ (WebCore::Region::contains): Returns true if the query Rect is fully contained in areas belonging to the Region. >+ * platform/graphics/Region.h: >+ > 2011-11-11 Nat Duca <nduca@chromium.org> > > Since GraphicsContext3D::makeContextCurrent can fail, return bool. >diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog >index 3222f74f5172f49663df363ca2e07e1c366630f8..17131f995498920f053326f4777e9e3204b76ee0 100644 >--- a/Source/WebKit/chromium/ChangeLog >+++ b/Source/WebKit/chromium/ChangeLog >@@ -1,3 +1,15 @@ >+2011-11-14 Dana Jansens <danakj@chromium.org> >+ >+ Add occludes() test to Region >+ https://bugs.webkit.org/show_bug.cgi?id=72294 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebKit.gypi: >+ * tests/RegionContainsTest.cpp: Added. >+ (WebCore::query): >+ (WebCore::TEST): >+ > 2011-11-11 Nat Duca <nduca@chromium.org> > > Since GraphicsContext3D::makeContextCurrent can fail, return bool. >diff --git a/Source/WebCore/platform/graphics/Region.cpp b/Source/WebCore/platform/graphics/Region.cpp >index 5427c6c91d2160eb77e82787ab09aef421d66127..d22298955c785b2bf30a90d7a18e6f6dd7d87b01 100644 >--- a/Source/WebCore/platform/graphics/Region.cpp >+++ b/Source/WebCore/platform/graphics/Region.cpp >@@ -65,6 +65,77 @@ Vector<IntRect> Region::rects() const > return rects; > } > >+bool Region::contains(const IntRect& coverRect) const >+{ >+ bool occludes = true; >+ >+ bool yIntersects = false; >+ int yContiguousEnd = 0; >+ >+ for (Shape::SpanIterator span = m_shape.spans_begin(), end = m_shape.spans_end(); span != end && span + 1 != end; ++span) { >+ int y = span->y; >+ int maxY = (span + 1)->y; >+ >+ if (y >= coverRect.maxY()) >+ break; >+ if (maxY <= coverRect.y()) >+ continue; >+ if (!yIntersects) { >+ if (y > coverRect.y()) >+ occludes = false; >+ else { >+ yIntersects = true; >+ yContiguousEnd = maxY; >+ } >+ } else { >+ if (y > yContiguousEnd) >+ occludes = false; >+ else >+ yContiguousEnd = maxY; >+ } >+ if (!occludes) >+ break; >+ >+ bool xIntersects = false; >+ int xContiguousEnd = 0; >+ >+ for (Shape::SegmentIterator segment = m_shape.segments_begin(span), end = m_shape.segments_end(span); segment != end && segment + 1 != end; segment += 2) { >+ int x = *segment; >+ int maxX = *(segment + 1); >+ >+ if (x >= coverRect.maxX()) >+ break; >+ if (maxX <= coverRect.x()) >+ continue; >+ if (!xIntersects) { >+ if (x > coverRect.x()) >+ occludes = false; >+ else { >+ xIntersects = true; >+ xContiguousEnd = maxX; >+ } >+ } else { >+ if (x > xContiguousEnd) >+ occludes = false; >+ else >+ xContiguousEnd = maxX; >+ } >+ if (!occludes) >+ break; >+ } >+ >+ if (!xIntersects || xContiguousEnd < coverRect.maxX()) >+ occludes = false; >+ if (!occludes) >+ break; >+ } >+ >+ if (!yIntersects || yContiguousEnd < coverRect.maxY()) >+ occludes = false; >+ >+ return occludes; >+} >+ > Region::Shape::Shape() > { > } >diff --git a/Source/WebCore/platform/graphics/Region.h b/Source/WebCore/platform/graphics/Region.h >index b5359bbe39c025c3e2c5e55b39fa4a5757d7975f..a7aceb753e0428f43ac50ae72cca38ef4ec1993b 100644 >--- a/Source/WebCore/platform/graphics/Region.h >+++ b/Source/WebCore/platform/graphics/Region.h >@@ -40,6 +40,8 @@ public: > bool isEmpty() const { return m_bounds.isEmpty(); } > > Vector<IntRect> rects() const; >+ // Returns true if the rect is contained fully in the areas covered by the Region. >+ bool contains(const IntRect&) const; > > void unite(const Region&); > void intersect(const Region&); >diff --git a/Source/WebKit/chromium/WebKit.gypi b/Source/WebKit/chromium/WebKit.gypi >index 6093266b94a1c27f5d02751081f5ea80680b1209..ecffb66c6d9923bb6a1fcbb9fb8ce596459b6b93 100644 >--- a/Source/WebKit/chromium/WebKit.gypi >+++ b/Source/WebKit/chromium/WebKit.gypi >@@ -81,6 +81,7 @@ > 'tests/PODIntervalTreeTest.cpp', > 'tests/PODRedBlackTreeTest.cpp', > 'tests/RenderTableCellTest.cpp', >+ 'tests/RegionContainsTest.cpp', > 'tests/TilingDataTest.cpp', > 'tests/TreeSynchronizerTest.cpp', > 'tests/TreeTestHelpers.cpp', >diff --git a/Source/WebKit/chromium/tests/RegionContainsTest.cpp b/Source/WebKit/chromium/tests/RegionContainsTest.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..d3a3228c2c5fd8d9bc19a873fe93ab7b625cdffd >--- /dev/null >+++ b/Source/WebKit/chromium/tests/RegionContainsTest.cpp >@@ -0,0 +1,133 @@ >+/* >+ * Copyright (C) 2011 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: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. 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. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS 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 APPLE OR ITS 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. >+ */ >+ >+// Tests for the integer rect edges class. >+ >+#include "config.h" >+ >+#include "Region.h" >+ >+#include "IntRect.h" >+#include "Logging.h" >+#include <gtest/gtest.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+inline bool query(const Vector<IntRect>& rects, const IntRect& coverRect) >+{ >+ Region region; >+ for (size_t i = 0; i < rects.size(); ++i) >+ region.unite(rects[i]); >+ >+ return region.contains(coverRect); >+} >+ >+TEST(RegionContainsTest, TestNoIntersection) >+{ >+ Vector<IntRect> rects; >+ rects.append(IntRect(0, 0, 100, 100)); >+ rects.append(IntRect(100, 200, 100, 100)); >+ EXPECT_EQ(false, query(rects, IntRect(100, 0, 10, 10))); >+ EXPECT_EQ(false, query(rects, IntRect(0, 100, 10, 10))); >+ EXPECT_EQ(false, query(rects, IntRect(110, 110, 10, 10))); >+} >+ >+TEST(RegionContainsTest, TestNoCover) >+{ >+ Vector<IntRect> rects; >+ rects.append(IntRect(0, 0, 10, 10)); >+ rects.append(IntRect(0, 11, 10, 10)); >+ EXPECT_EQ(false, query(rects, IntRect(0, 0, 10, 20))); >+ rects.clear(); >+ rects.append(IntRect(0, 0, 10, 10)); >+ rects.append(IntRect(11, 0, 10, 10)); >+ EXPECT_EQ(false, query(rects, IntRect(0, 0, 20, 10))); >+ rects.clear(); >+ rects.append(IntRect(0, 0, 10, 10)); >+ rects.append(IntRect(1, 1, 10, 10)); >+ EXPECT_EQ(false, query(rects, IntRect(0, 0, 11, 11))); >+ rects.clear(); >+ rects.append(IntRect(0, 0, 10, 10)); >+ rects.append(IntRect(0, 1, 10, 10)); >+ EXPECT_EQ(false, query(rects, IntRect(0, 0, 11, 11))); >+ rects.clear(); >+ rects.append(IntRect(0, 0, 10, 10)); >+ rects.append(IntRect(1, 0, 10, 10)); >+ EXPECT_EQ(false, query(rects, IntRect(0, 0, 11, 11))); >+ rects.clear(); >+ rects.append(IntRect(0, 0, 10, 10)); >+ rects.append(IntRect(1, 1, 10, 10)); >+ EXPECT_EQ(false, query(rects, IntRect(1, 0, 10, 1))); >+ EXPECT_EQ(false, query(rects, IntRect(1, 0, 10, 2))); >+ EXPECT_EQ(true, query(rects, IntRect(1, 1, 10, 2))); >+ rects.clear(); >+ rects.append(IntRect(1, 1, 10, 10)); >+ EXPECT_EQ(false, query(rects, IntRect(0, 0, 12, 12))); >+ EXPECT_EQ(false, query(rects, IntRect(0, 0, 11, 11))); >+ EXPECT_EQ(false, query(rects, IntRect(1, 1, 11, 11))); >+} >+ >+TEST(RegionContainsTest, TestCover) >+{ >+ Vector<IntRect> rects; >+ rects.append(IntRect(0, 0, 10, 10)); >+ EXPECT_EQ(true, query(rects, IntRect(0, 0, 10, 10))); >+ EXPECT_EQ(true, query(rects, IntRect(1, 1, 8, 8))); >+ EXPECT_EQ(true, query(rects, IntRect(1, 1, 9, 9))); >+ EXPECT_EQ(true, query(rects, IntRect(0, 0, 9, 9))); >+ rects.clear(); >+ rects.append(IntRect(0, 0, 10, 10)); >+ rects.append(IntRect(0, 0, 10, 10)); >+ rects.append(IntRect(0, 0, 10, 10)); >+ rects.append(IntRect(0, 0, 10, 10)); >+ EXPECT_EQ(true, query(rects, IntRect(0, 0, 10, 10))); >+ EXPECT_EQ(true, query(rects, IntRect(1, 1, 8, 8))); >+ EXPECT_EQ(true, query(rects, IntRect(1, 1, 9, 9))); >+ EXPECT_EQ(true, query(rects, IntRect(0, 0, 9, 9))); >+ rects.clear(); >+ rects.append(IntRect(0, 0, 10, 10)); >+ rects.append(IntRect(5, 5, 10, 10)); >+ EXPECT_EQ(false, query(rects, IntRect(0, 0, 10, 15))); >+ EXPECT_EQ(true, query(rects, IntRect(0, 0, 10, 10))); >+ EXPECT_EQ(true, query(rects, IntRect(5, 5, 10, 10))); >+ EXPECT_EQ(false, query(rects, IntRect(0, 5, 15, 10))); >+ EXPECT_EQ(false, query(rects, IntRect(5, 0, 10, 15))); >+ EXPECT_EQ(true, query(rects, IntRect(0, 0, 10, 10))); >+ EXPECT_EQ(false, query(rects, IntRect(5, 5, 15, 10))); >+ EXPECT_EQ(true, query(rects, IntRect(5, 0, 5, 10))); >+ EXPECT_EQ(true, query(rects, IntRect(5, 0, 5, 15))); >+ rects.clear(); >+ rects.append(IntRect(0, 0, 10, 10)); >+ rects.append(IntRect(10, 0, 10, 10)); >+ EXPECT_EQ(true, query(rects, IntRect(0, 0, 10, 10))); >+ EXPECT_EQ(true, query(rects, IntRect(0, 0, 15, 10))); >+ EXPECT_EQ(true, query(rects, IntRect(0, 0, 20, 10))); >+ EXPECT_EQ(false, query(rects, IntRect(0, 0, 20, 11))); >+ EXPECT_EQ(false, query(rects, IntRect(0, 0, 21, 10))); >+ EXPECT_EQ(true, query(rects, IntRect(1, 1, 18, 8))); >+} >+ >+} // namespace WebCore
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 72294
:
114998
|
115009
|
115062
|
115172
|
115199
|
115212
|
115406
|
115410
|
115812
|
115818
|
124767
|
124822
|
125695
|
125714