- Revision
- 276026
- Author
- wenson_hs...@apple.com
- Date
- 2021-04-15 09:50:02 -0700 (Thu, 15 Apr 2021)
Log Message
[iOS] Image extraction fails in Google search results
https://bugs.webkit.org/show_bug.cgi?id=224527
<rdar://problem/76500331>
Reviewed by Andy Estes.
Source/WebCore:
Override the `-webkit-user-select` CSS property in Google search results pages, and make a slight adjustment to
the user agent stylesheet.
Test: fast/images/image-extraction/image-overlay-in-image-with-zero-font-size.html
* html/HTMLElement.cpp:
(WebCore::HTMLElement::updateWithImageExtractionResult):
* html/shadow/imageOverlay.css:
(div#image-overlay):
Additionally force a default value for the font size and font family of the image overlay text, so that a
cascading font size of 0 won't end up breaking logic for computing image overlay CSS transforms. See layout test
for more details.
* page/Quirks.cpp:
(WebCore::Quirks::needsToForceUserSelectWhenInstallingImageOverlay const):
* page/Quirks.h:
LayoutTests:
Add a new layout test to exercise the user agent stylesheet change.
* fast/images/image-extraction/image-overlay-in-image-with-zero-font-size-expected-mismatch.html: Added.
* fast/images/image-extraction/image-overlay-in-image-with-zero-font-size.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (276025 => 276026)
--- trunk/LayoutTests/ChangeLog 2021-04-15 16:33:24 UTC (rev 276025)
+++ trunk/LayoutTests/ChangeLog 2021-04-15 16:50:02 UTC (rev 276026)
@@ -1,3 +1,16 @@
+2021-04-14 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [iOS] Image extraction fails in Google search results
+ https://bugs.webkit.org/show_bug.cgi?id=224527
+ <rdar://problem/76500331>
+
+ Reviewed by Andy Estes.
+
+ Add a new layout test to exercise the user agent stylesheet change.
+
+ * fast/images/image-extraction/image-overlay-in-image-with-zero-font-size-expected-mismatch.html: Added.
+ * fast/images/image-extraction/image-overlay-in-image-with-zero-font-size.html: Added.
+
2021-04-15 Chris Gambrell <cgambr...@apple.com>
[LayoutTests] Convert http/tests/media convert PHP to Python
Added: trunk/LayoutTests/fast/images/image-extraction/image-overlay-in-image-with-zero-font-size-expected-mismatch.html (0 => 276026)
--- trunk/LayoutTests/fast/images/image-extraction/image-overlay-in-image-with-zero-font-size-expected-mismatch.html (rev 0)
+++ trunk/LayoutTests/fast/images/image-extraction/image-overlay-in-image-with-zero-font-size-expected-mismatch.html 2021-04-15 16:50:02 UTC (rev 276026)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+img {
+ font-size: 0;
+}
+</style>
+</head>
+<body>
+<img src=""
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/fast/images/image-extraction/image-overlay-in-image-with-zero-font-size.html (0 => 276026)
--- trunk/LayoutTests/fast/images/image-extraction/image-overlay-in-image-with-zero-font-size.html (rev 0)
+++ trunk/LayoutTests/fast/images/image-extraction/image-overlay-in-image-with-zero-font-size.html 2021-04-15 16:50:02 UTC (rev 276026)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+img {
+ font-size: 0;
+}
+</style>
+</head>
+<body>
+<img src=""
+<script>
+addEventListener("load", () => {
+ let image = document.querySelector("img");
+ internals.installImageOverlay(image, [{
+ text : "Hello",
+ topLeft : new DOMPointReadOnly(0.5, 0.5),
+ topRight : new DOMPointReadOnly(1, 0.5),
+ bottomRight : new DOMPointReadOnly(1, 1),
+ bottomLeft : new DOMPointReadOnly(0.5, 1),
+ }]);
+ internals.shadowRoot(image).getElementById("image-overlay").style.color = "black";
+});
+</script>
+</body>
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (276025 => 276026)
--- trunk/Source/WebCore/ChangeLog 2021-04-15 16:33:24 UTC (rev 276025)
+++ trunk/Source/WebCore/ChangeLog 2021-04-15 16:50:02 UTC (rev 276026)
@@ -1,3 +1,29 @@
+2021-04-14 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [iOS] Image extraction fails in Google search results
+ https://bugs.webkit.org/show_bug.cgi?id=224527
+ <rdar://problem/76500331>
+
+ Reviewed by Andy Estes.
+
+ Override the `-webkit-user-select` CSS property in Google search results pages, and make a slight adjustment to
+ the user agent stylesheet.
+
+ Test: fast/images/image-extraction/image-overlay-in-image-with-zero-font-size.html
+
+ * html/HTMLElement.cpp:
+ (WebCore::HTMLElement::updateWithImageExtractionResult):
+ * html/shadow/imageOverlay.css:
+ (div#image-overlay):
+
+ Additionally force a default value for the font size and font family of the image overlay text, so that a
+ cascading font size of 0 won't end up breaking logic for computing image overlay CSS transforms. See layout test
+ for more details.
+
+ * page/Quirks.cpp:
+ (WebCore::Quirks::needsToForceUserSelectWhenInstallingImageOverlay const):
+ * page/Quirks.h:
+
2021-04-15 Antti Koivisto <an...@apple.com>
Remove unused RunIterator::setAtEnd
Modified: trunk/Source/WebCore/html/HTMLElement.cpp (276025 => 276026)
--- trunk/Source/WebCore/html/HTMLElement.cpp 2021-04-15 16:33:24 UTC (rev 276025)
+++ trunk/Source/WebCore/html/HTMLElement.cpp 2021-04-15 16:50:02 UTC (rev 276026)
@@ -1328,6 +1328,9 @@
container->setInlineStyleProperty(CSSPropertyWebkitUserSelect, CSSValueText);
shadowRoot->appendChild(container);
+ if (document().quirks().needsToForceUserSelectWhenInstallingImageOverlay())
+ setInlineStyleProperty(CSSPropertyWebkitUserSelect, CSSValueText);
+
static MainThreadNeverDestroyed<const AtomString> imageOverlayTextClass("image-overlay-text", AtomString::ConstructFromLiteral);
IntSize containerSize { offsetWidth(), offsetHeight() };
Modified: trunk/Source/WebCore/html/shadow/imageOverlay.css (276025 => 276026)
--- trunk/Source/WebCore/html/shadow/imageOverlay.css 2021-04-15 16:33:24 UTC (rev 276025)
+++ trunk/Source/WebCore/html/shadow/imageOverlay.css 2021-04-15 16:50:02 UTC (rev 276026)
@@ -30,6 +30,8 @@
text-align: center;
white-space: nowrap;
line-height: 100%;
+ font-family: system-ui;
+ font-size: 16px;
}
div.image-overlay-text {
Modified: trunk/Source/WebCore/page/Quirks.cpp (276025 => 276026)
--- trunk/Source/WebCore/page/Quirks.cpp 2021-04-15 16:33:24 UTC (rev 276025)
+++ trunk/Source/WebCore/page/Quirks.cpp 2021-04-15 16:50:02 UTC (rev 276026)
@@ -1463,4 +1463,20 @@
}
#endif
+#if ENABLE(IMAGE_EXTRACTION)
+
+bool Quirks::needsToForceUserSelectWhenInstallingImageOverlay() const
+{
+ if (!needsQuirks())
+ return false;
+
+ auto& url = ""
+ if (topPrivatelyControlledDomain(url.host().toString()).startsWith("google.") && url.path() == "/search")
+ return true;
+
+ return false;
}
+
+#endif // ENABLE(IMAGE_EXTRACTION)
+
+}
Modified: trunk/Source/WebCore/page/Quirks.h (276025 => 276026)
--- trunk/Source/WebCore/page/Quirks.h 2021-04-15 16:33:24 UTC (rev 276025)
+++ trunk/Source/WebCore/page/Quirks.h 2021-04-15 16:50:02 UTC (rev 276026)
@@ -152,6 +152,10 @@
static bool shouldOmitHTMLDocumentSupportedPropertyNames();
+#if ENABLE(IMAGE_EXTRACTION)
+ bool needsToForceUserSelectWhenInstallingImageOverlay() const;
+#endif
+
private:
bool needsQuirks() const;