Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1148)

Unified Diff: Source/core/rendering/shapes/ShapeInterval.h

Issue 264453009: [CSS Shapes] shape-outside polygon can fail when line-top intersects a vertex (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove -webkit-font-smoothing Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/shapes/PolygonShape.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/shapes/ShapeInterval.h
diff --git a/Source/core/rendering/shapes/ShapeInterval.h b/Source/core/rendering/shapes/ShapeInterval.h
index c032daf0af21b141f5e456516b42eb4664d0793e..47c20178f0f943dcf8c5f60aaa3b086da48e9849 100644
--- a/Source/core/rendering/shapes/ShapeInterval.h
+++ b/Source/core/rendering/shapes/ShapeInterval.h
@@ -38,29 +38,27 @@ template <typename T>
class ShapeInterval {
WTF_MAKE_FAST_ALLOCATED;
public:
- ShapeInterval(T x1 = 0, T x2 = 0)
- : m_x1(x1)
- , m_x2(x2)
+ ShapeInterval()
+ : m_x1(-1)
+ , m_x2(-2)
{
- ASSERT(x2 >= x1);
+ // The initial values of m_x1,x2 don't matter (unless you're looking
+ // at them in the debugger) so long as isUndefined() is true.
+ ASSERT(isUndefined());
}
- T x1() const { return m_x1; }
- T x2() const { return m_x2; }
- T width() const { return m_x2 - m_x1; }
- bool isEmpty() const { return !m_x1 && !m_x2; }
-
- void setX1(T x1)
+ ShapeInterval(T x1, T x2)
+ : m_x1(x1)
+ , m_x2(x2)
{
- ASSERT(m_x2 >= x1);
- m_x1 = x1;
+ ASSERT(x2 >= x1);
}
- void setX2(T x2)
- {
- ASSERT(x2 >= m_x1);
- m_x2 = x2;
- }
+ bool isUndefined() const { return m_x2 < m_x1; }
+ T x1() const { return isUndefined() ? 0 : m_x1; }
+ T x2() const { return isUndefined() ? 0 : m_x2; }
+ T width() const { return isUndefined() ? 0 : m_x2 - m_x1; }
+ bool isEmpty() const { return isUndefined() ? true : m_x1 == m_x2; }
void set(T x1, T x2)
{
@@ -71,11 +69,15 @@ public:
bool overlaps(const ShapeInterval<T>& interval) const
{
+ if (isUndefined() || interval.isUndefined())
+ return false;
return x2() >= interval.x1() && x1() <= interval.x2();
}
bool contains(const ShapeInterval<T>& interval) const
{
+ if (isUndefined() || interval.isUndefined())
+ return false;
return x1() <= interval.x1() && x2() >= interval.x2();
}
@@ -84,9 +86,9 @@ public:
void unite(const ShapeInterval<T>& interval)
{
- if (interval.isEmpty())
+ if (interval.isUndefined())
return;
- if (isEmpty())
+ if (isUndefined())
set(interval.x1(), interval.x2());
else
set(std::min<T>(x1(), interval.x1()), std::max<T>(x2(), interval.x2()));
« no previous file with comments | « Source/core/rendering/shapes/PolygonShape.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698