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

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: pointer validation check 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..776ff7d80f9aa48e1b9181734efb24e99cf098e4 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
@@ -999,6 +999,19 @@ 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)
+{
+ if (!domPath)
Justin Novosad 2014/02/25 16:45:08 Shouldn't this case throw a type mismatch DOM exce
+ return false;
+
+ return isPointInPathInternal(domPath->path(), x, y, windingRuleString);
+}
+
+bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, const float x, const float y, const String& windingRuleString)
+{
GraphicsContext* c = drawingContext();
if (!c)
return false;
@@ -1015,12 +1028,24 @@ 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)
+{
+ if (!domPath)
Justin Novosad 2014/02/25 16:45:08 DOM exception?
Rik 2014/02/25 17:37:54 Shouldn't that be called by blink's IDL preprocess
jcgregorio 2014/02/25 17:48:31 It should be caught by the code generated from the
+ return false;
+
+ 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 +1064,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