Index: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp |
diff --git a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp |
index ff96cb51b82b8ed1c31afd54261f3311c7d0e1ea..ead92561a4eb0d43e026d2b88f1fd62df3d908dc 100644 |
--- a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp |
+++ b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp |
@@ -41,6 +41,7 @@ |
#include "core/dom/AXObjectCache.h" |
#include "core/dom/StyleEngine.h" |
#include "core/events/Event.h" |
+#include "core/events/MouseEvent.h" |
#include "core/frame/Settings.h" |
#include "core/html/TextMetrics.h" |
#include "core/html/canvas/CanvasFontCache.h" |
@@ -578,6 +579,27 @@ bool CanvasRenderingContext2D::parseColorOrCurrentColor(Color& color, const Stri |
return ::blink::parseColorOrCurrentColor(color, colorString, canvas()); |
} |
+std::pair<Element*, String> CanvasRenderingContext2D::getControlAndIdIfHitRegionExists(const LayoutPoint& location) |
+{ |
+ if (hitRegionsCount() <= 0) |
+ return std::make_pair(nullptr, String()); |
+ |
+ LayoutBox* box = canvas()->layoutBox(); |
+ FloatPoint localPos = box->absoluteToLocal(FloatPoint(location), UseTransforms); |
+ if (box->hasBorderOrPadding()) |
+ localPos.move(-box->contentBoxOffset()); |
+ localPos.scale(canvas()->width() / box->contentWidth(), canvas()->height() / box->contentHeight()); |
+ |
+ HitRegion* hitRegion = hitRegionAtPoint(localPos); |
+ if (hitRegion) { |
+ Element* control = hitRegion->control(); |
+ if (control && canvas()->isSupportedInteractiveCanvasFallback(*control)) |
+ return std::make_pair(hitRegion->control(), hitRegion->id()); |
+ return std::make_pair(nullptr, hitRegion->id()); |
+ } |
+ return std::make_pair(nullptr, String()); |
+} |
+ |
String CanvasRenderingContext2D::textAlign() const |
{ |
return textAlignName(state().getTextAlign()); |