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 a7155d9eea21952d09be79e81fd6ccc9a465ae25..2c332677b0a1c3539e6f9cce0ca491418c9a0ef1 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,34 @@ void CanvasRenderingContext2D::styleDidChange(const ComputedStyle* oldStyle, con |
pruneLocalFontCache(0); |
} |
+Node* CanvasRenderingContext2D::getControlAndUpdateEvent(Event& event) |
+{ |
+ if (!event.isMouseEvent()) |
+ return nullptr; |
+ |
+ MouseEvent& e = toMouseEvent(event); |
philipj_slow
2016/02/01 04:05:20
https://www.chromium.org/blink/coding-style#TOC-Na
zino
2016/02/05 06:59:48
Done.
|
+ |
+ Document& document = canvas()->document(); |
+ document.updateLayoutTreeForNodeIfNeeded(canvas()); |
Justin Novosad
2016/02/01 16:51:43
Don't forget write a test that requires this updat
|
+ |
+ LayoutBox* box = canvas()->layoutBox(); |
+ FloatPoint localPos = box->absoluteToLocal(FloatPoint(e.absoluteLocation()), UseTransforms); |
+ if (box->hasBorderOrPadding()) |
+ localPos.move(-box->contentBoxOffset()); |
+ localPos.scale(canvas()->width() / box->contentWidth(), canvas()->height() / box->contentHeight()); |
Justin Novosad
2016/02/01 16:51:42
don't forget test cases that cover CSS zooming and
|
+ |
+ HitRegion* hitRegion = hitRegionAtPoint(localPos); |
+ if (hitRegion) { |
+ e.setRegion(hitRegion->id()); |
+ if (hitRegion->control()) { |
+ e.preventDefault(); |
+ e.setCancelBubble(true); |
+ return hitRegion->control(); |
+ } |
+ } |
+ return nullptr; |
+} |
+ |
String CanvasRenderingContext2D::textAlign() const |
{ |
return textAlignName(state().textAlign()); |