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

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

Issue 354333002: Add path option(path2d) for hit regions on canvas2d. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: nit and rebase Created 6 years, 5 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/bindings/core/v8/Dictionary.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
index 4d8569c799fa9e4ce795094724248f8c99e9b2a3..b81794eb824f37869fd383ddcbd76a7a15620dd7 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
@@ -2378,17 +2378,20 @@ void CanvasRenderingContext2D::addHitRegion(const Dictionary& options, Exception
return;
}
+ RefPtr<Path2D> path2d;
+ options.getWithUndefinedOrNullCheck("path", path2d);
+ Path hitRegionPath = path2d ? path2d->path() : m_path;
+
FloatRect clipBounds;
GraphicsContext* context = drawingContext();
- if (m_path.isEmpty() || !context || !state().m_invertibleCTM
+ if (hitRegionPath.isEmpty() || !context || !state().m_invertibleCTM
|| !context->getTransformedClipBounds(&clipBounds)) {
exceptionState.throwDOMException(NotSupportedError, "The specified path has no pixels.");
return;
}
- Path specifiedPath = m_path;
- specifiedPath.transform(state().m_transform);
+ hitRegionPath.transform(state().m_transform);
if (hasClip()) {
// FIXME: The hit regions should take clipping region into account.
@@ -2398,7 +2401,7 @@ void CanvasRenderingContext2D::addHitRegion(const Dictionary& options, Exception
return;
}
- passOptions.path = specifiedPath;
+ passOptions.path = hitRegionPath;
String fillRuleString;
options.getWithUndefinedOrNullCheck("fillRule", fillRuleString);
« no previous file with comments | « Source/bindings/core/v8/Dictionary.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698