Title: [277690] branches/safari-612.1.12-branch
Revision
277690
Author
alanc...@apple.com
Date
2021-05-18 16:28:28 -0700 (Tue, 18 May 2021)

Log Message

Cherry-pick r277124. rdar://problem/78177934

    Sampled Page Top Color: make hit tests consider elements with `pointer-events: none`
    https://bugs.webkit.org/show_bug.cgi?id=225419

    Reviewed by Tim Horton.

    Source/WebCore:

    Test: SampledPageTopColor.HitTestCSSPointerEventsNone

    * rendering/HitTestRequest.h:
    (WebCore::HitTestRequest::ignoreCSSPointerEventsProperty const): Added.
    * rendering/InlineBox.h:
    (WebCore::InlineBox::visibleToHitTesting const):
    * rendering/RenderElement.h:
    (WebCore::RenderElement::visibleToHitTesting const):
    Add `RequestType::IgnoreCSSPointerEventsProperty` that's used inside `visibleToHitTesting`
    to control whether `style().pointerEvents() == PointerEvents::None` is checked.

    * dom/Document.cpp:
    (WebCore::isValidPageSampleLocation):
    Include the new `RequestType::IgnoreCSSPointerEventsProperty` since we're not hit testing
    for interaction, rather we're hit testing in an attempt to see what will be painted.

    * rendering/EllipsisBox.cpp:
    (WebCore::EllipsisBox::nodeAtPoint):
    * rendering/InlineFlowBox.cpp:
    (WebCore::InlineFlowBox::nodeAtPoint):
    * rendering/InlineTextBox.cpp:
    (WebCore::InlineTextBox::nodeAtPoint):
    * rendering/RenderBlock.cpp:
    (WebCore::RenderBlock::nodeAtPoint):
    * rendering/RenderBox.cpp:
    (WebCore::RenderBox::nodeAtPoint):
    * rendering/RenderInline.cpp:
    (WebCore::RenderInline::hitTestCulledInline):
    * rendering/RenderTable.cpp:
    (WebCore::RenderTable::nodeAtPoint):
    * rendering/RenderWidget.cpp:
    (WebCore::RenderWidget::nodeAtPoint):
    * rendering/RootInlineBox.cpp:
    (WebCore::RootInlineBox::nodeAtPoint):
    * rendering/svg/RenderSVGRoot.cpp:
    (WebCore::RenderSVGRoot::nodeAtPoint):
    Pass the `HitTestRequest` to `visibleToHitTesting`.

    Tools:

    * TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm:
    (TEST.SampledPageTopColor.HitTestCSSPointerEventsNone): Added.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277124 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-612.1.12-branch/Source/WebCore/ChangeLog (277689 => 277690)


--- branches/safari-612.1.12-branch/Source/WebCore/ChangeLog	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Source/WebCore/ChangeLog	2021-05-18 23:28:28 UTC (rev 277690)
@@ -1,5 +1,107 @@
 2021-05-18  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r277124. rdar://problem/78177934
+
+    Sampled Page Top Color: make hit tests consider elements with `pointer-events: none`
+    https://bugs.webkit.org/show_bug.cgi?id=225419
+    
+    Reviewed by Tim Horton.
+    
+    Source/WebCore:
+    
+    Test: SampledPageTopColor.HitTestCSSPointerEventsNone
+    
+    * rendering/HitTestRequest.h:
+    (WebCore::HitTestRequest::ignoreCSSPointerEventsProperty const): Added.
+    * rendering/InlineBox.h:
+    (WebCore::InlineBox::visibleToHitTesting const):
+    * rendering/RenderElement.h:
+    (WebCore::RenderElement::visibleToHitTesting const):
+    Add `RequestType::IgnoreCSSPointerEventsProperty` that's used inside `visibleToHitTesting`
+    to control whether `style().pointerEvents() == PointerEvents::None` is checked.
+    
+    * dom/Document.cpp:
+    (WebCore::isValidPageSampleLocation):
+    Include the new `RequestType::IgnoreCSSPointerEventsProperty` since we're not hit testing
+    for interaction, rather we're hit testing in an attempt to see what will be painted.
+    
+    * rendering/EllipsisBox.cpp:
+    (WebCore::EllipsisBox::nodeAtPoint):
+    * rendering/InlineFlowBox.cpp:
+    (WebCore::InlineFlowBox::nodeAtPoint):
+    * rendering/InlineTextBox.cpp:
+    (WebCore::InlineTextBox::nodeAtPoint):
+    * rendering/RenderBlock.cpp:
+    (WebCore::RenderBlock::nodeAtPoint):
+    * rendering/RenderBox.cpp:
+    (WebCore::RenderBox::nodeAtPoint):
+    * rendering/RenderInline.cpp:
+    (WebCore::RenderInline::hitTestCulledInline):
+    * rendering/RenderTable.cpp:
+    (WebCore::RenderTable::nodeAtPoint):
+    * rendering/RenderWidget.cpp:
+    (WebCore::RenderWidget::nodeAtPoint):
+    * rendering/RootInlineBox.cpp:
+    (WebCore::RootInlineBox::nodeAtPoint):
+    * rendering/svg/RenderSVGRoot.cpp:
+    (WebCore::RenderSVGRoot::nodeAtPoint):
+    Pass the `HitTestRequest` to `visibleToHitTesting`.
+    
+    Tools:
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm:
+    (TEST.SampledPageTopColor.HitTestCSSPointerEventsNone): Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277124 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-05-06  Devin Rousso  <drou...@apple.com>
+
+            Sampled Page Top Color: make hit tests consider elements with `pointer-events: none`
+            https://bugs.webkit.org/show_bug.cgi?id=225419
+
+            Reviewed by Tim Horton.
+
+            Test: SampledPageTopColor.HitTestCSSPointerEventsNone
+
+            * rendering/HitTestRequest.h:
+            (WebCore::HitTestRequest::ignoreCSSPointerEventsProperty const): Added.
+            * rendering/InlineBox.h:
+            (WebCore::InlineBox::visibleToHitTesting const):
+            * rendering/RenderElement.h:
+            (WebCore::RenderElement::visibleToHitTesting const):
+            Add `RequestType::IgnoreCSSPointerEventsProperty` that's used inside `visibleToHitTesting`
+            to control whether `style().pointerEvents() == PointerEvents::None` is checked.
+
+            * dom/Document.cpp:
+            (WebCore::isValidPageSampleLocation):
+            Include the new `RequestType::IgnoreCSSPointerEventsProperty` since we're not hit testing
+            for interaction, rather we're hit testing in an attempt to see what will be painted.
+
+            * rendering/EllipsisBox.cpp:
+            (WebCore::EllipsisBox::nodeAtPoint):
+            * rendering/InlineFlowBox.cpp:
+            (WebCore::InlineFlowBox::nodeAtPoint):
+            * rendering/InlineTextBox.cpp:
+            (WebCore::InlineTextBox::nodeAtPoint):
+            * rendering/RenderBlock.cpp:
+            (WebCore::RenderBlock::nodeAtPoint):
+            * rendering/RenderBox.cpp:
+            (WebCore::RenderBox::nodeAtPoint):
+            * rendering/RenderInline.cpp:
+            (WebCore::RenderInline::hitTestCulledInline):
+            * rendering/RenderTable.cpp:
+            (WebCore::RenderTable::nodeAtPoint):
+            * rendering/RenderWidget.cpp:
+            (WebCore::RenderWidget::nodeAtPoint):
+            * rendering/RootInlineBox.cpp:
+            (WebCore::RootInlineBox::nodeAtPoint):
+            * rendering/svg/RenderSVGRoot.cpp:
+            (WebCore::RenderSVGRoot::nodeAtPoint):
+            Pass the `HitTestRequest` to `visibleToHitTesting`.
+
+2021-05-18  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r277123. rdar://problem/78177928
 
     Sampled Page Top Color: don't snapshot if the hit test location is a canvas

Modified: branches/safari-612.1.12-branch/Source/WebCore/dom/Document.cpp (277689 => 277690)


--- branches/safari-612.1.12-branch/Source/WebCore/dom/Document.cpp	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Source/WebCore/dom/Document.cpp	2021-05-18 23:28:28 UTC (rev 277690)
@@ -3889,7 +3889,7 @@
 {
     // FIXME: <https://webkit.org/b/225167> (Sampled Page Top Color: hook into painting logic instead of taking snapshots)
 
-    constexpr OptionSet<HitTestRequest::RequestType> hitTestRequestTypes { HitTestRequest::ReadOnly, HitTestRequest::DisallowUserAgentShadowContent, HitTestRequest::CollectMultipleElements, HitTestRequest::IncludeAllElementsUnderPoint };
+    constexpr OptionSet<HitTestRequest::RequestType> hitTestRequestTypes { HitTestRequest::ReadOnly, HitTestRequest::IgnoreCSSPointerEventsProperty, HitTestRequest::DisallowUserAgentShadowContent, HitTestRequest::CollectMultipleElements, HitTestRequest::IncludeAllElementsUnderPoint };
     HitTestResult hitTestResult(location);
     document.hitTest(hitTestRequestTypes, hitTestResult);
 

Modified: branches/safari-612.1.12-branch/Source/WebCore/rendering/EllipsisBox.cpp (277689 => 277690)


--- branches/safari-612.1.12-branch/Source/WebCore/rendering/EllipsisBox.cpp	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Source/WebCore/rendering/EllipsisBox.cpp	2021-05-18 23:28:28 UTC (rev 277690)
@@ -161,7 +161,7 @@
     }
 
     LayoutRect boundsRect { adjustedLocation, LayoutSize(LayoutUnit(logicalWidth()), m_height) };
-    if (visibleToHitTesting() && boundsRect.intersects(HitTestLocation::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) {
+    if (visibleToHitTesting(request) && boundsRect.intersects(HitTestLocation::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) {
         blockFlow().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(adjustedLocation));
         if (result.addNodeToListBasedTestResult(blockFlow().nodeForHitTest(), request, locationInContainer, boundsRect) == HitTestProgress::Stop)
             return true;

Modified: branches/safari-612.1.12-branch/Source/WebCore/rendering/HitTestRequest.h (277689 => 277690)


--- branches/safari-612.1.12-branch/Source/WebCore/rendering/HitTestRequest.h	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Source/WebCore/rendering/HitTestRequest.h	2021-05-18 23:28:28 UTC (rev 277690)
@@ -34,19 +34,20 @@
         Active = 1 << 2,
         Move = 1 << 3,
         Release = 1 << 4,
-        IgnoreClipping = 1 << 5,
-        SVGClipContent = 1 << 6,
-        TouchEvent = 1 << 7,
-        DisallowUserAgentShadowContent = 1 << 8,
-        AllowFrameScrollbars = 1 << 9,
-        AllowChildFrameContent = 1 << 10,
-        AllowVisibleChildFrameContentOnly = 1 << 11,
-        ChildFrameHitTest = 1 << 12,
-        AccessibilityHitTest = 1 << 13,
+        IgnoreCSSPointerEventsProperty = 1 << 5,
+        IgnoreClipping = 1 << 6,
+        SVGClipContent = 1 << 7,
+        TouchEvent = 1 << 8,
+        DisallowUserAgentShadowContent = 1 << 9,
+        AllowFrameScrollbars = 1 << 10,
+        AllowChildFrameContent = 1 << 11,
+        AllowVisibleChildFrameContentOnly = 1 << 12,
+        ChildFrameHitTest = 1 << 13,
+        AccessibilityHitTest = 1 << 14,
         // Collect a list of nodes instead of just one. Used for elementsFromPoint and rect-based tests.
-        CollectMultipleElements = 1 << 14,
+        CollectMultipleElements = 1 << 15,
         // When using list-based testing, continue hit testing even after a hit has been found.
-        IncludeAllElementsUnderPoint = 1 << 15
+        IncludeAllElementsUnderPoint = 1 << 16,
     };
 
     HitTestRequest(OptionSet<RequestType> requestType = { ReadOnly, Active, DisallowUserAgentShadowContent })
@@ -59,6 +60,7 @@
     bool active() const { return m_requestType.contains(Active); }
     bool move() const { return m_requestType.contains(Move); }
     bool release() const { return m_requestType.contains(Release); }
+    bool ignoreCSSPointerEventsProperty() const { return m_requestType.contains(IgnoreCSSPointerEventsProperty); }
     bool ignoreClipping() const { return m_requestType.contains(IgnoreClipping); }
     bool svgClipContent() const { return m_requestType.contains(SVGClipContent); }
     bool touchEvent() const { return m_requestType.contains(TouchEvent); }

Modified: branches/safari-612.1.12-branch/Source/WebCore/rendering/InlineBox.h (277689 => 277690)


--- branches/safari-612.1.12-branch/Source/WebCore/rendering/InlineBox.h	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Source/WebCore/rendering/InlineBox.h	2021-05-18 23:28:28 UTC (rev 277690)
@@ -20,6 +20,7 @@
 
 #pragma once
 
+#include "HitTestRequest.h"
 #include "RenderBoxModelObject.h"
 #include "RenderText.h"
 #include "TextFlags.h"
@@ -29,7 +30,6 @@
 
 namespace WebCore {
 
-class HitTestRequest;
 class HitTestResult;
 class RootInlineBox;
 
@@ -230,8 +230,17 @@
     void invalidateParentChildList();
 #endif
 
-    bool visibleToHitTesting() const { return renderer().style().visibility() == Visibility::Visible && renderer().style().pointerEvents() != PointerEvents::None; }
+    bool visibleToHitTesting(Optional<HitTestRequest> hitTestRequest = WTF::nullopt) const
+    {
+        if (renderer().style().visibility() != Visibility::Visible)
+            return false;
 
+        if ((!hitTestRequest || !hitTestRequest->ignoreCSSPointerEventsProperty()) && renderer().style().pointerEvents() == PointerEvents::None)
+            return false;
+
+        return true;
+    }
+
     const RenderStyle& lineStyle() const { return m_bitfields.firstLine() ? renderer().firstLineStyle() : renderer().style(); }
     
     VerticalAlign verticalAlign() const { return lineStyle().verticalAlign(); }

Modified: branches/safari-612.1.12-branch/Source/WebCore/rendering/InlineFlowBox.cpp (277689 => 277690)


--- branches/safari-612.1.12-branch/Source/WebCore/rendering/InlineFlowBox.cpp	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Source/WebCore/rendering/InlineFlowBox.cpp	2021-05-18 23:28:28 UTC (rev 277690)
@@ -1134,7 +1134,7 @@
     }
 
     // Now check ourselves. Pixel snap hit testing.
-    if (!visibleToHitTesting())
+    if (!visibleToHitTesting(request))
         return false;
 
     // Do not hittest content beyond the ellipsis box.

Modified: branches/safari-612.1.12-branch/Source/WebCore/rendering/InlineTextBox.cpp (277689 => 277690)


--- branches/safari-612.1.12-branch/Source/WebCore/rendering/InlineTextBox.cpp	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Source/WebCore/rendering/InlineTextBox.cpp	2021-05-18 23:28:28 UTC (rev 277690)
@@ -362,7 +362,7 @@
 bool InlineTextBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit /* lineTop */, LayoutUnit /*lineBottom*/,
     HitTestAction /*hitTestAction*/)
 {
-    if (!visibleToHitTesting())
+    if (!visibleToHitTesting(request))
         return false;
 
     if (isLineBreak())

Modified: branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderBlock.cpp (277689 => 277690)


--- branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderBlock.cpp	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderBlock.cpp	2021-05-18 23:28:28 UTC (rev 277690)
@@ -2123,7 +2123,7 @@
     // Now hit test our background
     if (hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground) {
         LayoutRect boundsRect(adjustedLocation, size());
-        if (visibleToHitTesting() && locationInContainer.intersects(boundsRect)) {
+        if (visibleToHitTesting(request) && locationInContainer.intersects(boundsRect)) {
             updateHitTestResult(result, flipForWritingMode(locationInContainer.point() - localOffset));
             if (result.addNodeToListBasedTestResult(nodeForHitTest(), request, locationInContainer, boundsRect) == HitTestProgress::Stop)
                 return true;

Modified: branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderBox.cpp (277689 => 277690)


--- branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderBox.cpp	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderBox.cpp	2021-05-18 23:28:28 UTC (rev 277690)
@@ -1357,7 +1357,7 @@
     // foreground phase (which is true for replaced elements like images).
     LayoutRect boundsRect = borderBoxRectInFragment(nullptr);
     boundsRect.moveBy(adjustedLocation);
-    if (visibleToHitTesting() && action == HitTestForeground && locationInContainer.intersects(boundsRect)) {
+    if (visibleToHitTesting(request) && action == HitTestForeground && locationInContainer.intersects(boundsRect)) {
         updateHitTestResult(result, locationInContainer.point() - toLayoutSize(adjustedLocation));
         if (result.addNodeToListBasedTestResult(nodeForHitTest(), request, locationInContainer, boundsRect) == HitTestProgress::Stop)
             return true;

Modified: branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderElement.h (277689 => 277690)


--- branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderElement.h	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderElement.h	2021-05-18 23:28:28 UTC (rev 277690)
@@ -22,6 +22,7 @@
 
 #pragma once
 
+#include "HitTestRequest.h"
 #include "LengthFunctions.h"
 #include "RenderObject.h"
 
@@ -144,8 +145,17 @@
     bool isTransparent() const { return style().opacity() < 1.0f; }
     float opacity() const { return style().opacity(); }
 
-    bool visibleToHitTesting() const { return style().visibility() == Visibility::Visible && style().pointerEvents() != PointerEvents::None; }
+    bool visibleToHitTesting(Optional<HitTestRequest> hitTestRequest = WTF::nullopt) const
+    {
+        if (style().visibility() != Visibility::Visible)
+            return false;
 
+        if ((!hitTestRequest || !hitTestRequest->ignoreCSSPointerEventsProperty()) && style().pointerEvents() == PointerEvents::None)
+            return false;
+
+        return true;
+    }
+
     bool hasBackground() const { return style().hasBackground(); }
     bool hasMask() const { return style().hasMask(); }
     bool hasClip() const { return isOutOfFlowPositioned() && style().hasClip(); }

Modified: branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderInline.cpp (277689 => 277690)


--- branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderInline.cpp	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderInline.cpp	2021-05-18 23:28:28 UTC (rev 277690)
@@ -570,7 +570,7 @@
 bool RenderInline::hitTestCulledInline(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset)
 {
     ASSERT(result.isRectBasedTest() && !alwaysCreateLineBoxes());
-    if (!visibleToHitTesting())
+    if (!visibleToHitTesting(request))
         return false;
 
     HitTestLocation tmpLocation(locationInContainer, -toLayoutSize(accumulatedOffset));

Modified: branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderTable.cpp (277689 => 277690)


--- branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderTable.cpp	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderTable.cpp	2021-05-18 23:28:28 UTC (rev 277690)
@@ -1572,7 +1572,7 @@
 
     // Check our bounds next.
     LayoutRect boundsRect(adjustedLocation, size());
-    if (visibleToHitTesting() && (action == HitTestBlockBackground || action == HitTestChildBlockBackground) && locationInContainer.intersects(boundsRect)) {
+    if (visibleToHitTesting(request) && (action == HitTestBlockBackground || action == HitTestChildBlockBackground) && locationInContainer.intersects(boundsRect)) {
         updateHitTestResult(result, flipForWritingMode(locationInContainer.point() - toLayoutSize(adjustedLocation)));
         if (result.addNodeToListBasedTestResult(nodeForHitTest(), request, locationInContainer, boundsRect) == HitTestProgress::Stop)
             return true;

Modified: branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderWidget.cpp (277689 => 277690)


--- branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderWidget.cpp	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderWidget.cpp	2021-05-18 23:28:28 UTC (rev 277690)
@@ -387,7 +387,7 @@
 
 bool RenderWidget::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action)
 {
-    auto shouldHitTestChildFrameContent = request.allowsChildFrameContent() || (request.allowsVisibleChildFrameContent() && visibleToHitTesting());
+    auto shouldHitTestChildFrameContent = request.allowsChildFrameContent() || (request.allowsVisibleChildFrameContent() && visibleToHitTesting(request));
     auto hasRenderView = is<FrameView>(widget()) && downcast<FrameView>(*widget()).renderView();
     if (shouldHitTestChildFrameContent && hasRenderView) {
         FrameView& childFrameView = downcast<FrameView>(*widget());

Modified: branches/safari-612.1.12-branch/Source/WebCore/rendering/RootInlineBox.cpp (277689 => 277690)


--- branches/safari-612.1.12-branch/Source/WebCore/rendering/RootInlineBox.cpp	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Source/WebCore/rendering/RootInlineBox.cpp	2021-05-18 23:28:28 UTC (rev 277690)
@@ -175,7 +175,7 @@
 
 bool RootInlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom, HitTestAction hitTestAction)
 {
-    if (hasEllipsisBox() && visibleToHitTesting()) {
+    if (hasEllipsisBox() && visibleToHitTesting(request)) {
         if (ellipsisBox()->nodeAtPoint(request, result, locationInContainer, accumulatedOffset, lineTop, lineBottom, hitTestAction)) {
             renderer().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
             return true;

Modified: branches/safari-612.1.12-branch/Source/WebCore/rendering/svg/RenderSVGRoot.cpp (277689 => 277690)


--- branches/safari-612.1.12-branch/Source/WebCore/rendering/svg/RenderSVGRoot.cpp	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Source/WebCore/rendering/svg/RenderSVGRoot.cpp	2021-05-18 23:28:28 UTC (rev 277690)
@@ -447,7 +447,7 @@
     }
 
     // If we didn't early exit above, we've just hit the container <svg> element. Unlike SVG 1.1, 2nd Edition allows container elements to be hit.
-    if ((hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground) && visibleToHitTesting()) {
+    if ((hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground) && visibleToHitTesting(request)) {
         // Only return true here, if the last hit testing phase 'BlockBackground' is executed. If we'd return true in the 'Foreground' phase,
         // hit testing would stop immediately. For SVG only trees this doesn't matter. Though when we have a <foreignObject> subtree we need
         // to be able to detect hits on the background of a <div> element. If we'd return true here in the 'Foreground' phase, we are not able 

Modified: branches/safari-612.1.12-branch/Tools/ChangeLog (277689 => 277690)


--- branches/safari-612.1.12-branch/Tools/ChangeLog	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Tools/ChangeLog	2021-05-18 23:28:28 UTC (rev 277690)
@@ -1,5 +1,72 @@
 2021-05-18  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r277124. rdar://problem/78177934
+
+    Sampled Page Top Color: make hit tests consider elements with `pointer-events: none`
+    https://bugs.webkit.org/show_bug.cgi?id=225419
+    
+    Reviewed by Tim Horton.
+    
+    Source/WebCore:
+    
+    Test: SampledPageTopColor.HitTestCSSPointerEventsNone
+    
+    * rendering/HitTestRequest.h:
+    (WebCore::HitTestRequest::ignoreCSSPointerEventsProperty const): Added.
+    * rendering/InlineBox.h:
+    (WebCore::InlineBox::visibleToHitTesting const):
+    * rendering/RenderElement.h:
+    (WebCore::RenderElement::visibleToHitTesting const):
+    Add `RequestType::IgnoreCSSPointerEventsProperty` that's used inside `visibleToHitTesting`
+    to control whether `style().pointerEvents() == PointerEvents::None` is checked.
+    
+    * dom/Document.cpp:
+    (WebCore::isValidPageSampleLocation):
+    Include the new `RequestType::IgnoreCSSPointerEventsProperty` since we're not hit testing
+    for interaction, rather we're hit testing in an attempt to see what will be painted.
+    
+    * rendering/EllipsisBox.cpp:
+    (WebCore::EllipsisBox::nodeAtPoint):
+    * rendering/InlineFlowBox.cpp:
+    (WebCore::InlineFlowBox::nodeAtPoint):
+    * rendering/InlineTextBox.cpp:
+    (WebCore::InlineTextBox::nodeAtPoint):
+    * rendering/RenderBlock.cpp:
+    (WebCore::RenderBlock::nodeAtPoint):
+    * rendering/RenderBox.cpp:
+    (WebCore::RenderBox::nodeAtPoint):
+    * rendering/RenderInline.cpp:
+    (WebCore::RenderInline::hitTestCulledInline):
+    * rendering/RenderTable.cpp:
+    (WebCore::RenderTable::nodeAtPoint):
+    * rendering/RenderWidget.cpp:
+    (WebCore::RenderWidget::nodeAtPoint):
+    * rendering/RootInlineBox.cpp:
+    (WebCore::RootInlineBox::nodeAtPoint):
+    * rendering/svg/RenderSVGRoot.cpp:
+    (WebCore::RenderSVGRoot::nodeAtPoint):
+    Pass the `HitTestRequest` to `visibleToHitTesting`.
+    
+    Tools:
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm:
+    (TEST.SampledPageTopColor.HitTestCSSPointerEventsNone): Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277124 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-05-06  Devin Rousso  <drou...@apple.com>
+
+            Sampled Page Top Color: make hit tests consider elements with `pointer-events: none`
+            https://bugs.webkit.org/show_bug.cgi?id=225419
+
+            Reviewed by Tim Horton.
+
+            * TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm:
+            (TEST.SampledPageTopColor.HitTestCSSPointerEventsNone): Added.
+
+2021-05-18  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r277123. rdar://problem/78177928
 
     Sampled Page Top Color: don't snapshot if the hit test location is a canvas

Modified: branches/safari-612.1.12-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm (277689 => 277690)


--- branches/safari-612.1.12-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm	2021-05-18 23:28:22 UTC (rev 277689)
+++ branches/safari-612.1.12-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm	2021-05-18 23:28:28 UTC (rev 277690)
@@ -329,6 +329,15 @@
     EXPECT_NULL([webView _sampledPageTopColor]);
 }
 
+TEST(SampledPageTopColor, HitTestCSSPointerEventsNone)
+{
+    auto webView = createWebViewWithSampledPageTopColorMaxDifference(5);
+    EXPECT_NULL([webView _sampledPageTopColor]);
+
+    [webView synchronouslyLoadHTMLStringAndWaitUntilAllImmediateChildFramesPaint:@"<body style='margin: 0'><div style='width: 100%; height: 100%; background-color: red; pointer-events: none'></div>Test"];
+    EXPECT_EQ(WebCore::Color([webView _sampledPageTopColor].CGColor), WebCore::Color::red);
+}
+
 // FIXME: <https://webkit.org/b/225167> (Sampled Page Top Color: hook into painting logic instead of taking snapshots)
 TEST(SampledPageTopColor, DISABLED_DisplayP3)
 {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to