Title: [277689] branches/safari-612.1.12-branch
- Revision
- 277689
- Author
- alanc...@apple.com
- Date
- 2021-05-18 16:28:22 -0700 (Tue, 18 May 2021)
Log Message
Cherry-pick r277123. rdar://problem/78177928
Sampled Page Top Color: don't snapshot if the hit test location is a canvas
https://bugs.webkit.org/show_bug.cgi?id=225418
Reviewed by Tim Horton.
Source/WebCore:
Tests: SampledPageTopColor.HitTestHTMLCanvasWithoutRenderingContext
SampledPageTopColor.HitTestHTMLCanvasWithRenderingContext
* dom/Document.cpp:
(WebCore::isValidPageSampleLocation):
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm:
(TEST.SampledPageTopColor.HitTestHTMLCanvasWithoutRenderingContext): Added.
(TEST.SampledPageTopColor.HitTestHTMLCanvasWithRenderingContext): Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277123 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-612.1.12-branch/Source/WebCore/ChangeLog (277688 => 277689)
--- branches/safari-612.1.12-branch/Source/WebCore/ChangeLog 2021-05-18 23:15:23 UTC (rev 277688)
+++ branches/safari-612.1.12-branch/Source/WebCore/ChangeLog 2021-05-18 23:28:22 UTC (rev 277689)
@@ -1,5 +1,44 @@
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
+ https://bugs.webkit.org/show_bug.cgi?id=225418
+
+ Reviewed by Tim Horton.
+
+ Source/WebCore:
+
+ Tests: SampledPageTopColor.HitTestHTMLCanvasWithoutRenderingContext
+ SampledPageTopColor.HitTestHTMLCanvasWithRenderingContext
+
+ * dom/Document.cpp:
+ (WebCore::isValidPageSampleLocation):
+
+ Tools:
+
+ * TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm:
+ (TEST.SampledPageTopColor.HitTestHTMLCanvasWithoutRenderingContext): Added.
+ (TEST.SampledPageTopColor.HitTestHTMLCanvasWithRenderingContext): Added.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277123 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-05-06 Devin Rousso <drou...@apple.com>
+
+ Sampled Page Top Color: don't snapshot if the hit test location is a canvas
+ https://bugs.webkit.org/show_bug.cgi?id=225418
+
+ Reviewed by Tim Horton.
+
+ Tests: SampledPageTopColor.HitTestHTMLCanvasWithoutRenderingContext
+ SampledPageTopColor.HitTestHTMLCanvasWithRenderingContext
+
+ * dom/Document.cpp:
+ (WebCore::isValidPageSampleLocation):
+
+2021-05-18 Alan Coon <alanc...@apple.com>
+
Cherry-pick r277044. rdar://problem/78160469
Sampled Page Top Color: don't snapshot if the hit test location is an image or has an animation
Modified: branches/safari-612.1.12-branch/Source/WebCore/dom/Document.cpp (277688 => 277689)
--- branches/safari-612.1.12-branch/Source/WebCore/dom/Document.cpp 2021-05-18 23:15:23 UTC (rev 277688)
+++ branches/safari-612.1.12-branch/Source/WebCore/dom/Document.cpp 2021-05-18 23:28:22 UTC (rev 277689)
@@ -3908,6 +3908,11 @@
if (renderer->style().hasTransitions() || renderer->style().hasAnimations())
return false;
+ // Skip `<canvas>` but only if they've been drawn into. Guess this by seeing if there's already
+ // a `CanvasRenderingContext`, which is only created by _javascript_.
+ if (is<HTMLCanvasElement>(node) && downcast<HTMLCanvasElement>(node).renderingContext())
+ return false;
+
// Skip 3rd-party `<iframe>` as the content likely won't match the rest of the page.
if (is<HTMLIFrameElement>(node) && !areRegistrableDomainsEqual(downcast<HTMLIFrameElement>(node).location(), document.url()))
return false;
Modified: branches/safari-612.1.12-branch/Tools/ChangeLog (277688 => 277689)
--- branches/safari-612.1.12-branch/Tools/ChangeLog 2021-05-18 23:15:23 UTC (rev 277688)
+++ branches/safari-612.1.12-branch/Tools/ChangeLog 2021-05-18 23:28:22 UTC (rev 277689)
@@ -1,5 +1,42 @@
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
+ https://bugs.webkit.org/show_bug.cgi?id=225418
+
+ Reviewed by Tim Horton.
+
+ Source/WebCore:
+
+ Tests: SampledPageTopColor.HitTestHTMLCanvasWithoutRenderingContext
+ SampledPageTopColor.HitTestHTMLCanvasWithRenderingContext
+
+ * dom/Document.cpp:
+ (WebCore::isValidPageSampleLocation):
+
+ Tools:
+
+ * TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm:
+ (TEST.SampledPageTopColor.HitTestHTMLCanvasWithoutRenderingContext): Added.
+ (TEST.SampledPageTopColor.HitTestHTMLCanvasWithRenderingContext): Added.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277123 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-05-06 Devin Rousso <drou...@apple.com>
+
+ Sampled Page Top Color: don't snapshot if the hit test location is a canvas
+ https://bugs.webkit.org/show_bug.cgi?id=225418
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm:
+ (TEST.SampledPageTopColor.HitTestHTMLCanvasWithoutRenderingContext): Added.
+ (TEST.SampledPageTopColor.HitTestHTMLCanvasWithRenderingContext): Added.
+
+2021-05-18 Alan Coon <alanc...@apple.com>
+
Cherry-pick r277044. rdar://problem/78160469
Sampled Page Top Color: don't snapshot if the hit test location is an image or has an animation
Modified: branches/safari-612.1.12-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm (277688 => 277689)
--- branches/safari-612.1.12-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm 2021-05-18 23:15:23 UTC (rev 277688)
+++ branches/safari-612.1.12-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm 2021-05-18 23:28:22 UTC (rev 277689)
@@ -293,6 +293,24 @@
EXPECT_NULL([webView _sampledPageTopColor]);
}
+TEST(SampledPageTopColor, HitTestHTMLCanvasWithoutRenderingContext)
+{
+ auto webView = createWebViewWithSampledPageTopColorMaxDifference(5);
+ EXPECT_NULL([webView _sampledPageTopColor]);
+
+ waitForSampledPageTopColorToChangeForHTML(webView.get(), @"<body style='margin: 0'><canvas style='width: 100%; height: 100%; background-color: red'></canvas>Test");
+ EXPECT_EQ(WebCore::Color([webView _sampledPageTopColor].CGColor), WebCore::Color::red);
+}
+
+TEST(SampledPageTopColor, HitTestHTMLCanvasWithRenderingContext)
+{
+ auto webView = createWebViewWithSampledPageTopColorMaxDifference(5);
+ EXPECT_NULL([webView _sampledPageTopColor]);
+
+ [webView synchronouslyLoadHTMLStringAndWaitUntilAllImmediateChildFramesPaint:@"<body style='margin: 0'><canvas style='width: 100%; height: 100%; background-color: red'></canvas>Test<script>document.querySelector('canvas').getContext('2d')</script>"];
+ EXPECT_NULL([webView _sampledPageTopColor]);
+}
+
TEST(SampledPageTopColor, HitTestCSSBackgroundImage)
{
auto webView = createWebViewWithSampledPageTopColorMaxDifference(5);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes