<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[277124] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/277124">277124</a></dd>
<dt>Author</dt> <dd>drousso@apple.com</dd>
<dt>Date</dt> <dd>2021-05-06 14:31:17 -0700 (Thu, 06 May 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingEllipsisBoxcpp">trunk/Source/WebCore/rendering/EllipsisBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingHitTestRequesth">trunk/Source/WebCore/rendering/HitTestRequest.h</a></li>
<li><a href="#trunkSourceWebCorerenderingInlineBoxh">trunk/Source/WebCore/rendering/InlineBox.h</a></li>
<li><a href="#trunkSourceWebCorerenderingInlineFlowBoxcpp">trunk/Source/WebCore/rendering/InlineFlowBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingInlineTextBoxcpp">trunk/Source/WebCore/rendering/InlineTextBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockcpp">trunk/Source/WebCore/rendering/RenderBlock.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxcpp">trunk/Source/WebCore/rendering/RenderBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderElementh">trunk/Source/WebCore/rendering/RenderElement.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderInlinecpp">trunk/Source/WebCore/rendering/RenderInline.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTablecpp">trunk/Source/WebCore/rendering/RenderTable.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderWidgetcpp">trunk/Source/WebCore/rendering/RenderWidget.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRootInlineBoxcpp">trunk/Source/WebCore/rendering/RootInlineBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgRenderSVGRootcpp">trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaSampledPageTopColormm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Source/WebCore/ChangeLog      2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -1,5 +1,50 @@
</span><span class="cx"> 2021-05-06  Devin Rousso  <drousso@apple.com>
</span><span class="cx"> 
</span><ins>+        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-06  Devin Rousso  <drousso@apple.com>
+
</ins><span class="cx">         Sampled Page Top Color: don't snapshot if the hit test location is a canvas
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=225418
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp    2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Source/WebCore/dom/Document.cpp       2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -3875,7 +3875,7 @@
</span><span class="cx"> {
</span><span class="cx">     // FIXME: <https://webkit.org/b/225167> (Sampled Page Top Color: hook into painting logic instead of taking snapshots)
</span><span class="cx"> 
</span><del>-    constexpr OptionSet<HitTestRequest::RequestType> hitTestRequestTypes { HitTestRequest::ReadOnly, HitTestRequest::DisallowUserAgentShadowContent, HitTestRequest::CollectMultipleElements, HitTestRequest::IncludeAllElementsUnderPoint };
</del><ins>+    constexpr OptionSet<HitTestRequest::RequestType> hitTestRequestTypes { HitTestRequest::ReadOnly, HitTestRequest::IgnoreCSSPointerEventsProperty, HitTestRequest::DisallowUserAgentShadowContent, HitTestRequest::CollectMultipleElements, HitTestRequest::IncludeAllElementsUnderPoint };
</ins><span class="cx">     HitTestResult hitTestResult(location);
</span><span class="cx">     document.hitTest(hitTestRequestTypes, hitTestResult);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingEllipsisBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/EllipsisBox.cpp (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/EllipsisBox.cpp   2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Source/WebCore/rendering/EllipsisBox.cpp      2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -161,7 +161,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     LayoutRect boundsRect { adjustedLocation, LayoutSize(LayoutUnit(logicalWidth()), m_height) };
</span><del>-    if (visibleToHitTesting() && boundsRect.intersects(HitTestLocation::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) {
</del><ins>+    if (visibleToHitTesting(request) && boundsRect.intersects(HitTestLocation::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) {
</ins><span class="cx">         blockFlow().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(adjustedLocation));
</span><span class="cx">         if (result.addNodeToListBasedTestResult(blockFlow().nodeForHitTest(), request, locationInContainer, boundsRect) == HitTestProgress::Stop)
</span><span class="cx">             return true;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingHitTestRequesth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/HitTestRequest.h (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/HitTestRequest.h  2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Source/WebCore/rendering/HitTestRequest.h     2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -34,19 +34,20 @@
</span><span class="cx">         Active = 1 << 2,
</span><span class="cx">         Move = 1 << 3,
</span><span class="cx">         Release = 1 << 4,
</span><del>-        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,
</del><ins>+        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,
</ins><span class="cx">         // Collect a list of nodes instead of just one. Used for elementsFromPoint and rect-based tests.
</span><del>-        CollectMultipleElements = 1 << 14,
</del><ins>+        CollectMultipleElements = 1 << 15,
</ins><span class="cx">         // When using list-based testing, continue hit testing even after a hit has been found.
</span><del>-        IncludeAllElementsUnderPoint = 1 << 15
</del><ins>+        IncludeAllElementsUnderPoint = 1 << 16,
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     HitTestRequest(OptionSet<RequestType> requestType = { ReadOnly, Active, DisallowUserAgentShadowContent })
</span><span class="lines">@@ -59,6 +60,7 @@
</span><span class="cx">     bool active() const { return m_requestType.contains(Active); }
</span><span class="cx">     bool move() const { return m_requestType.contains(Move); }
</span><span class="cx">     bool release() const { return m_requestType.contains(Release); }
</span><ins>+    bool ignoreCSSPointerEventsProperty() const { return m_requestType.contains(IgnoreCSSPointerEventsProperty); }
</ins><span class="cx">     bool ignoreClipping() const { return m_requestType.contains(IgnoreClipping); }
</span><span class="cx">     bool svgClipContent() const { return m_requestType.contains(SVGClipContent); }
</span><span class="cx">     bool touchEvent() const { return m_requestType.contains(TouchEvent); }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingInlineBoxh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/InlineBox.h (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/InlineBox.h       2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Source/WebCore/rendering/InlineBox.h  2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -20,6 +20,7 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><ins>+#include "HitTestRequest.h"
</ins><span class="cx"> #include "RenderBoxModelObject.h"
</span><span class="cx"> #include "RenderText.h"
</span><span class="cx"> #include "TextFlags.h"
</span><span class="lines">@@ -29,7 +30,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class HitTestRequest;
</del><span class="cx"> class HitTestResult;
</span><span class="cx"> class RootInlineBox;
</span><span class="cx"> 
</span><span class="lines">@@ -230,8 +230,17 @@
</span><span class="cx">     void invalidateParentChildList();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    bool visibleToHitTesting() const { return renderer().style().visibility() == Visibility::Visible && renderer().style().pointerEvents() != PointerEvents::None; }
</del><ins>+    bool visibleToHitTesting(Optional<HitTestRequest> hitTestRequest = WTF::nullopt) const
+    {
+        if (renderer().style().visibility() != Visibility::Visible)
+            return false;
</ins><span class="cx"> 
</span><ins>+        if ((!hitTestRequest || !hitTestRequest->ignoreCSSPointerEventsProperty()) && renderer().style().pointerEvents() == PointerEvents::None)
+            return false;
+
+        return true;
+    }
+
</ins><span class="cx">     const RenderStyle& lineStyle() const { return m_bitfields.firstLine() ? renderer().firstLineStyle() : renderer().style(); }
</span><span class="cx">     
</span><span class="cx">     VerticalAlign verticalAlign() const { return lineStyle().verticalAlign(); }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingInlineFlowBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/InlineFlowBox.cpp (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/InlineFlowBox.cpp 2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.cpp    2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -1134,7 +1134,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Now check ourselves. Pixel snap hit testing.
</span><del>-    if (!visibleToHitTesting())
</del><ins>+    if (!visibleToHitTesting(request))
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     // Do not hittest content beyond the ellipsis box.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingInlineTextBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/InlineTextBox.cpp 2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp    2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -362,7 +362,7 @@
</span><span class="cx"> bool InlineTextBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit /* lineTop */, LayoutUnit /*lineBottom*/,
</span><span class="cx">     HitTestAction /*hitTestAction*/)
</span><span class="cx"> {
</span><del>-    if (!visibleToHitTesting())
</del><ins>+    if (!visibleToHitTesting(request))
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     if (isLineBreak())
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlock.cpp   2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp      2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -2123,7 +2123,7 @@
</span><span class="cx">     // Now hit test our background
</span><span class="cx">     if (hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground) {
</span><span class="cx">         LayoutRect boundsRect(adjustedLocation, size());
</span><del>-        if (visibleToHitTesting() && locationInContainer.intersects(boundsRect)) {
</del><ins>+        if (visibleToHitTesting(request) && locationInContainer.intersects(boundsRect)) {
</ins><span class="cx">             updateHitTestResult(result, flipForWritingMode(locationInContainer.point() - localOffset));
</span><span class="cx">             if (result.addNodeToListBasedTestResult(nodeForHitTest(), request, locationInContainer, boundsRect) == HitTestProgress::Stop)
</span><span class="cx">                 return true;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBox.cpp     2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp        2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -1355,7 +1355,7 @@
</span><span class="cx">     // foreground phase (which is true for replaced elements like images).
</span><span class="cx">     LayoutRect boundsRect = borderBoxRectInFragment(nullptr);
</span><span class="cx">     boundsRect.moveBy(adjustedLocation);
</span><del>-    if (visibleToHitTesting() && action == HitTestForeground && locationInContainer.intersects(boundsRect)) {
</del><ins>+    if (visibleToHitTesting(request) && action == HitTestForeground && locationInContainer.intersects(boundsRect)) {
</ins><span class="cx">         updateHitTestResult(result, locationInContainer.point() - toLayoutSize(adjustedLocation));
</span><span class="cx">         if (result.addNodeToListBasedTestResult(nodeForHitTest(), request, locationInContainer, boundsRect) == HitTestProgress::Stop)
</span><span class="cx">             return true;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderElement.h (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderElement.h   2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Source/WebCore/rendering/RenderElement.h      2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -22,6 +22,7 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><ins>+#include "HitTestRequest.h"
</ins><span class="cx"> #include "LengthFunctions.h"
</span><span class="cx"> #include "RenderObject.h"
</span><span class="cx"> 
</span><span class="lines">@@ -144,8 +145,17 @@
</span><span class="cx">     bool isTransparent() const { return style().opacity() < 1.0f; }
</span><span class="cx">     float opacity() const { return style().opacity(); }
</span><span class="cx"> 
</span><del>-    bool visibleToHitTesting() const { return style().visibility() == Visibility::Visible && style().pointerEvents() != PointerEvents::None; }
</del><ins>+    bool visibleToHitTesting(Optional<HitTestRequest> hitTestRequest = WTF::nullopt) const
+    {
+        if (style().visibility() != Visibility::Visible)
+            return false;
</ins><span class="cx"> 
</span><ins>+        if ((!hitTestRequest || !hitTestRequest->ignoreCSSPointerEventsProperty()) && style().pointerEvents() == PointerEvents::None)
+            return false;
+
+        return true;
+    }
+
</ins><span class="cx">     bool hasBackground() const { return style().hasBackground(); }
</span><span class="cx">     bool hasMask() const { return style().hasMask(); }
</span><span class="cx">     bool hasClip() const { return isOutOfFlowPositioned() && style().hasClip(); }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderInlinecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderInline.cpp  2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp     2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -570,7 +570,7 @@
</span><span class="cx"> bool RenderInline::hitTestCulledInline(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(result.isRectBasedTest() && !alwaysCreateLineBoxes());
</span><del>-    if (!visibleToHitTesting())
</del><ins>+    if (!visibleToHitTesting(request))
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     HitTestLocation tmpLocation(locationInContainer, -toLayoutSize(accumulatedOffset));
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTablecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTable.cpp   2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp      2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -1572,7 +1572,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Check our bounds next.
</span><span class="cx">     LayoutRect boundsRect(adjustedLocation, size());
</span><del>-    if (visibleToHitTesting() && (action == HitTestBlockBackground || action == HitTestChildBlockBackground) && locationInContainer.intersects(boundsRect)) {
</del><ins>+    if (visibleToHitTesting(request) && (action == HitTestBlockBackground || action == HitTestChildBlockBackground) && locationInContainer.intersects(boundsRect)) {
</ins><span class="cx">         updateHitTestResult(result, flipForWritingMode(locationInContainer.point() - toLayoutSize(adjustedLocation)));
</span><span class="cx">         if (result.addNodeToListBasedTestResult(nodeForHitTest(), request, locationInContainer, boundsRect) == HitTestProgress::Stop)
</span><span class="cx">             return true;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderWidgetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderWidget.cpp (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderWidget.cpp  2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Source/WebCore/rendering/RenderWidget.cpp     2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -387,7 +387,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool RenderWidget::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action)
</span><span class="cx"> {
</span><del>-    auto shouldHitTestChildFrameContent = request.allowsChildFrameContent() || (request.allowsVisibleChildFrameContent() && visibleToHitTesting());
</del><ins>+    auto shouldHitTestChildFrameContent = request.allowsChildFrameContent() || (request.allowsVisibleChildFrameContent() && visibleToHitTesting(request));
</ins><span class="cx">     auto hasRenderView = is<FrameView>(widget()) && downcast<FrameView>(*widget()).renderView();
</span><span class="cx">     if (shouldHitTestChildFrameContent && hasRenderView) {
</span><span class="cx">         FrameView& childFrameView = downcast<FrameView>(*widget());
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRootInlineBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RootInlineBox.cpp (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RootInlineBox.cpp 2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Source/WebCore/rendering/RootInlineBox.cpp    2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -175,7 +175,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool RootInlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom, HitTestAction hitTestAction)
</span><span class="cx"> {
</span><del>-    if (hasEllipsisBox() && visibleToHitTesting()) {
</del><ins>+    if (hasEllipsisBox() && visibleToHitTesting(request)) {
</ins><span class="cx">         if (ellipsisBox()->nodeAtPoint(request, result, locationInContainer, accumulatedOffset, lineTop, lineBottom, hitTestAction)) {
</span><span class="cx">             renderer().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
</span><span class="cx">             return true;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgRenderSVGRootcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp     2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp        2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -447,7 +447,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // 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.
</span><del>-    if ((hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground) && visibleToHitTesting()) {
</del><ins>+    if ((hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground) && visibleToHitTesting(request)) {
</ins><span class="cx">         // Only return true here, if the last hit testing phase 'BlockBackground' is executed. If we'd return true in the 'Foreground' phase,
</span><span class="cx">         // hit testing would stop immediately. For SVG only trees this doesn't matter. Though when we have a <foreignObject> subtree we need
</span><span class="cx">         // 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 
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Tools/ChangeLog       2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -1,5 +1,15 @@
</span><span class="cx"> 2021-05-06  Devin Rousso  <drousso@apple.com>
</span><span class="cx"> 
</span><ins>+        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-06  Devin Rousso  <drousso@apple.com>
+
</ins><span class="cx">         Sampled Page Top Color: don't snapshot if the hit test location is a canvas
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=225418
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaSampledPageTopColormm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm (277123 => 277124)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm       2021-05-06 21:26:23 UTC (rev 277123)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm  2021-05-06 21:31:17 UTC (rev 277124)
</span><span class="lines">@@ -329,6 +329,15 @@
</span><span class="cx">     EXPECT_NULL([webView _sampledPageTopColor]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+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);
+}
+
</ins><span class="cx"> // FIXME: <https://webkit.org/b/225167> (Sampled Page Top Color: hook into painting logic instead of taking snapshots)
</span><span class="cx"> TEST(SampledPageTopColor, DISABLED_DisplayP3)
</span><span class="cx"> {
</span></span></pre>
</div>
</div>

</body>
</html>