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

Unified Diff: third_party/WebKit/Source/modules/canvas2d/EventHitRegion.cpp

Issue 1575813002: css Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « third_party/WebKit/LayoutTests/fast/canvas/resources/test-helpers.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/canvas2d/EventHitRegion.cpp
diff --git a/third_party/WebKit/Source/modules/canvas2d/EventHitRegion.cpp b/third_party/WebKit/Source/modules/canvas2d/EventHitRegion.cpp
index fe7393ff5208476568d58103af3c2c92aed56df5..07651b8035c36cb88e46d8a5a119b317a64da9da 100644
--- a/third_party/WebKit/Source/modules/canvas2d/EventHitRegion.cpp
+++ b/third_party/WebKit/Source/modules/canvas2d/EventHitRegion.cpp
@@ -6,7 +6,8 @@
#include "core/dom/Document.h"
#include "core/html/HTMLCanvasElement.h"
-#include "core/layout/LayoutObject.h"
+#include "core/layout/LayoutBox.h"
+#include "core/page/Page.h"
#include "modules/canvas2d/CanvasRenderingContext2D.h"
#include "modules/canvas2d/HitRegion.h"
@@ -22,14 +23,11 @@ String EventHitRegion::regionIdFromAbsoluteLocation(HTMLCanvasElement& canvas, c
document.updateLayoutTreeForNodeIfNeeded(&canvas);
// Adjust offsetLocation to be relative to the canvas's position.
- LayoutObject* layoutObject = canvas.layoutObject();
- FloatPoint localPos = layoutObject->absoluteToLocal(FloatPoint(location), UseTransforms);
-
- LocalFrame* frame = document.frame();
- float zoomFactor = frame ? frame->pageZoomFactor() : 1;
- float scaleFactor = 1 / zoomFactor;
- if (scaleFactor != 1.0f)
- localPos.scale(scaleFactor, scaleFactor);
+ 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 = toCanvasRenderingContext2D(context)->hitRegionAtPoint(localPos);
if (!hitRegion || hitRegion->id().isEmpty())
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/canvas/resources/test-helpers.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698