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

Unified Diff: Source/core/rendering/RenderHTMLCanvas.cpp

Issue 287163007: WIP: <canvas> hit regions (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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
« no previous file with comments | « Source/core/rendering/RenderHTMLCanvas.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « Source/core/rendering/RenderHTMLCanvas.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698