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

Unified Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 179383002: Add versions of isPointIn*() that take a Path parameter. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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
Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
index 0c7b1131fd98c2dbb60f52e0861fd67454a15a78..0ff779f867e9c7f4df093cd18a17529939dd313c 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
@@ -999,6 +999,16 @@ void CanvasRenderingContext2D::clip(DOMPath* domPath, const String& windingRuleS
bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const String& windingRuleString)
{
+ return isPointInPathInternal(m_path, x, y, windingRuleString);
+}
+
+bool CanvasRenderingContext2D::isPointInPath(DOMPath* domPath, const float x, const float y, const String& windingRuleString)
+{
+ return isPointInPathInternal(domPath->path(), x, y, windingRuleString);
Rik 2014/02/25 07:46:45 should you check if the pointer is valid?
+}
+
+bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, const float x, const float y, const String& windingRuleString)
+{
GraphicsContext* c = drawingContext();
if (!c)
return false;
@@ -1015,12 +1025,21 @@ bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const
if (!parseWinding(windingRuleString, windRule))
return false;
- return m_path.contains(transformedPoint, windRule);
+ return path.contains(transformedPoint, windRule);
}
-
bool CanvasRenderingContext2D::isPointInStroke(const float x, const float y)
{
+ return isPointInStrokeInternal(m_path, x, y);
+}
+
+bool CanvasRenderingContext2D::isPointInStroke(DOMPath* domPath, const float x, const float y)
+{
+ return isPointInStrokeInternal(domPath->path(), x, y);
+}
+
+bool CanvasRenderingContext2D::isPointInStrokeInternal(const Path& path, const float x, const float y)
+{
GraphicsContext* c = drawingContext();
if (!c)
return false;
@@ -1039,7 +1058,7 @@ bool CanvasRenderingContext2D::isPointInStroke(const float x, const float y)
strokeData.setLineJoin(getLineJoin());
strokeData.setMiterLimit(miterLimit());
strokeData.setLineDash(getLineDash(), lineDashOffset());
- return m_path.strokeContains(transformedPoint, strokeData);
+ return path.strokeContains(transformedPoint, strokeData);
}
void CanvasRenderingContext2D::clearRect(float x, float y, float width, float height)

Powered by Google App Engine
This is Rietveld 408576698