+2012-02-06 Dana Jansens <danakj@chromium.org>
+
+ Add contains() test to Region
+ https://bugs.webkit.org/show_bug.cgi?id=72294
+
+ Reviewed by Anders Carlsson.
+
+ * platform/graphics/Region.cpp:
+ (WebCore::Region::contains):
+ (WebCore):
+ * platform/graphics/Region.h:
+ (Region):
+ (Shape):
+ (WebCore::operator==):
+ (WebCore):
+
2012-02-06 Kentaro Hara <haraken@chromium.org>
Rename [DontCheckEnums], [ReturnsNew], [DoNotCheckDomainSecurityOnGet],
return rects;
}
+bool Region::contains(const Region& region) const
+{
+ return WebCore::intersect(region, *this) == region;
+}
+
Region::Shape::Shape()
{
}
SegmentIterator s1 = segments1;
SegmentIterator s2 = segments2;
- Vector<int> segments;
+ Vector<int, 32> segments;
// Now iterate over the segments in each span and construct a new vector of segments.
while (s1 != segments1End && s2 != segments2End) {
void translate(const IntSize&);
+ // Returns true if the query region is a subset of this region.
+ bool contains(const Region&) const;
+
#ifndef NDEBUG
void dump() const;
#endif
bool canCoalesce(SegmentIterator begin, SegmentIterator end);
- // FIXME: These vectors should have inline sizes. Figure out a good optimal value.
- Vector<int> m_segments;
- Vector<Span> m_spans;
+ Vector<int, 32> m_segments;
+ Vector<Span, 16> m_spans;
+
+ friend bool operator==(const Shape&, const Shape&);
};
IntRect m_bounds;
Shape m_shape;
+
+ friend bool operator==(const Region&, const Region&);
+ friend bool operator==(const Shape&, const Shape&);
+ friend bool operator==(const Span&, const Span&);
};
static inline Region intersect(const Region& a, const Region& b)
return result;
}
+inline bool operator==(const Region& a, const Region& b)
+{
+ return a.m_bounds == b.m_bounds && a.m_shape == b.m_shape;
+}
+
+inline bool operator==(const Region::Shape& a, const Region::Shape& b)
+{
+ return a.m_spans == b.m_spans && a.m_segments == b.m_segments;
+}
+
+inline bool operator==(const Region::Span& a, const Region::Span& b)
+{
+ return a.y == b.y && a.segmentIndex == b.segmentIndex;
+}
+
} // namespace WebCore
#endif // Region_h