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

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: rebase again 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 9707f9a2e3cc298eee4f138b0cd6b3b0a9e842ff..78304a053ef5c482f216b78733414b21bf76aa66 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
@@ -1031,6 +1031,26 @@ 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, ExceptionState& exceptionState)
+{
+ return isPointInPath(domPath, x, y, "nonzero", exceptionState);
+}
+
+bool CanvasRenderingContext2D::isPointInPath(DOMPath* domPath, const float x, const float y, const String& windingRuleString, ExceptionState& exceptionState)
+{
+ if (!domPath) {
+ exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::argumentNullOrIncorrectType(1, "Path"));
+ 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;
@@ -1047,12 +1067,26 @@ 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, ExceptionState& exceptionState)
+{
+ if (!domPath) {
+ exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::argumentNullOrIncorrectType(1, "Path"));
+ 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;
@@ -1071,7 +1105,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)
« no previous file with comments | « Source/core/html/canvas/CanvasRenderingContext2D.h ('k') | Source/core/html/canvas/CanvasRenderingContext2D.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698