[PE] Fix hittesting under transform + fragmentation.

PLC::CollectFragments includes fragmentation offset if called in GeometryMapper
mode. However, when hit testing under transform, we apply fragmentation and transform,
then hit test each fragment without any fragmentation or transform offset.
Therefore, in this post-fragment/transform mode, don't apply fragmentation offset
again.

The callsites in PaintLayerPainter for the equivalent situation during paint already
correctly pass an empty LayoutPoint offset for layer bounds.

Bug: 823255
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I3135e51b72c5fd02a9d67b3dcbdc51e39ef3cde2
Reviewed-on: https://chromium-review.googlesource.com/978675
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545606}
diff --git a/third_party/WebKit/Source/core/paint/PaintLayer.cpp b/third_party/WebKit/Source/core/paint/PaintLayer.cpp
index d1c7909..925bcf9 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayer.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayer.cpp
@@ -2029,9 +2029,11 @@
   // fragment.
   PaintLayerFragments layer_fragments;
   if (applied_transform) {
+    DCHECK(root_layer == this);
+    LayoutPoint offset;
     AppendSingleFragmentIgnoringPagination(
         layer_fragments, root_layer, hit_test_rect,
-        kExcludeOverlayScrollbarSizeForHitTesting, clip_behavior);
+        kExcludeOverlayScrollbarSizeForHitTesting, clip_behavior, &offset);
   } else {
     CollectFragments(layer_fragments, root_layer, hit_test_rect,
                      kExcludeOverlayScrollbarSizeForHitTesting, clip_behavior);
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerTest.cpp b/third_party/WebKit/Source/core/paint/PaintLayerTest.cpp
index a5dcc51..c90cbf1e 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerTest.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerTest.cpp
@@ -1224,6 +1224,27 @@
   EXPECT_EQ(body, GetDocument().ElementFromPoint(60, 151));
 }
 
+TEST_P(PaintLayerTest, FragmentedHitTest) {
+  SetHtmlInnerHTML(R"HTML(
+    <style>
+    div {
+      break-inside: avoid-column;
+      width: 50px;
+      height: 50px;
+      position: relative;
+    }
+    </style>
+    <ul style="column-count: 4; position: relative">
+      <div></div>
+      <div id=target style=" position: relative; transform: translateY(0px);">
+      </div>
+    </ul>
+  )HTML");
+
+  auto* target = GetDocument().getElementById("target");
+  EXPECT_EQ(target, GetDocument().ElementFromPoint(280, 30));
+}
+
 TEST_P(PaintLayerTest, SquashingOffsets) {
   if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled())
     return;