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

Unified Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp

Issue 1654653002: Canvas2d: Implement rerouting event by hit region's control. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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: 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 f9db4cf808fc28ae868126c5ae87fe8477c24efc..cdc50f02cf23062285209d7194f85ed3876b1502 100644
--- a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
+++ b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
@@ -42,6 +42,7 @@
#include "core/dom/AXObjectCache.h"
#include "core/dom/StyleEngine.h"
#include "core/events/Event.h"
+#include "core/events/MouseEvent.h"
#include "core/frame/ImageBitmap.h"
#include "core/frame/Settings.h"
#include "core/html/HTMLVideoElement.h"
@@ -1818,6 +1819,20 @@ void CanvasRenderingContext2D::filterNeedsInvalidation()
state().clearResolvedFilter();
}
+std::pair<Element*, String> CanvasRenderingContext2D::getControlAndIdIfHitRegionExists(const LayoutPoint& location)
+{
+ 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)
+ return std::make_pair(hitRegion->control(), hitRegion->id());
+ return std::make_pair(nullptr, String());
+}
+
String CanvasRenderingContext2D::textAlign() const
{
return textAlignName(state().textAlign());

Powered by Google App Engine
This is Rietveld 408576698