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()); |