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

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: Pass existing tests. 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 b1b23b4b52d119924a99f3b68259dbfbe0fa2664..932aef6110ae307977220a66c906461f2c2b3b5b 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"
@@ -1796,6 +1797,23 @@ void CanvasRenderingContext2D::styleDidChange(const ComputedStyle* oldStyle, con
pruneLocalFontCache(0);
}
+std::pair<Element*, String> CanvasRenderingContext2D::getControlAndIDIfHitRegionExists(const LayoutPoint& location)
+{
+ Document& document = canvas()->document();
+ document.updateLayoutTreeForNodeIfNeeded(canvas());
Justin Novosad 2016/02/05 15:22:53 Updating layout... Is this the right thing to do?
Rick Byers 2016/02/05 16:01:20 I agree we absolutely don't want to force any extr
zino 2016/02/12 15:26:19 Probably done.
Justin Novosad 2016/02/12 15:41:59 I think this is correct (layout "IfNeeded"). But I
+
+ 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