Index: Source/core/rendering/RenderHTMLCanvas.cpp |
diff --git a/Source/core/rendering/RenderHTMLCanvas.cpp b/Source/core/rendering/RenderHTMLCanvas.cpp |
index ae259126b0a17d8a719035d46a76f678ac8f673c..661fbd6af648312c3426af2fd760e24fa5bea44f 100644 |
--- a/Source/core/rendering/RenderHTMLCanvas.cpp |
+++ b/Source/core/rendering/RenderHTMLCanvas.cpp |
@@ -26,11 +26,13 @@ |
#include "config.h" |
#include "core/rendering/RenderHTMLCanvas.h" |
-#include "core/html/HTMLCanvasElement.h" |
-#include "core/html/canvas/CanvasRenderingContext.h" |
#include "core/frame/FrameView.h" |
#include "core/frame/LocalFrame.h" |
+#include "core/html/HTMLCanvasElement.h" |
+#include "core/html/canvas/CanvasRenderingContext.h" |
+#include "core/html/canvas/CanvasRenderingContext2D.h" |
#include "core/page/Page.h" |
+#include "core/rendering/HitTestLocation.h" |
#include "core/rendering/PaintInfo.h" |
#include "core/rendering/RenderView.h" |
@@ -49,6 +51,29 @@ LayerType RenderHTMLCanvas::layerTypeRequired() const |
return NormalLayer; |
} |
+bool RenderHTMLCanvas::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction) |
+{ |
+ if (!RenderReplaced::nodeAtPoint(request, result, locationInContainer, accumulatedOffset, hitTestAction)) |
+ return false; |
+ |
+ if (!visibleToHitTestRequest(request) || hitTestAction != HitTestForeground) |
+ return true; |
+ |
+ HTMLCanvasElement* canvas = toHTMLCanvasElement(node()); |
+ // Thread/plumb through HTMLCanvasElement instead? |
+ if (!canvas->renderingContext() || !canvas->renderingContext()->is2d()) |
+ return true; |
+ |
+ // Check for intersections with hit regions. |
+ LayoutPoint adjustedLocation = accumulatedOffset + location(); |
+ LayoutPoint localPoint = locationInContainer.point() - toLayoutSize(adjustedLocation); |
+ if (CanvasHitRegion* hitRegion = toCanvasRenderingContext2D(canvas->renderingContext())->hitRegionAtPoint(localPoint)) { |
+ hitRegion = hitRegion; |
+ updateHitTestResult(result, localPoint); |
+ } |
+ return true; |
+} |
+ |
void RenderHTMLCanvas::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
{ |
GraphicsContext* context = paintInfo.context; |