Title: [274395] trunk
Revision
274395
Author
[email protected]
Date
2021-03-13 19:32:31 -0800 (Sat, 13 Mar 2021)

Log Message

Add support for accessibility image overlays in layout tests
https://bugs.webkit.org/show_bug.cgi?id=223146

Reviewed by Tim Horton.

Source/WebCore:

Introduce an internal testing hook to install image overlay content, for layout and API tests.

Test: fast/images/image-extraction/basic-image-overlay.html

* dom/DOMPointReadOnly.h:
* dom/DOMPointReadOnly.idl:

Additionally add WebCore export macros to `DOMPointReadOnly`, so that Internals code can this class.

* testing/Internals.cpp:
(WebCore::Internals::installImageOverlay):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

Add a very basic test to ensure that image overlay content can be installed.

* TestExpectations:
* fast/images/image-extraction/basic-image-overlay-expected-mismatch.html: Added.
* fast/images/image-extraction/basic-image-overlay.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (274394 => 274395)


--- trunk/LayoutTests/ChangeLog	2021-03-14 03:22:18 UTC (rev 274394)
+++ trunk/LayoutTests/ChangeLog	2021-03-14 03:32:31 UTC (rev 274395)
@@ -1,3 +1,16 @@
+2021-03-13  Wenson Hsieh  <[email protected]>
+
+        Add support for accessibility image overlays in layout tests
+        https://bugs.webkit.org/show_bug.cgi?id=223146
+
+        Reviewed by Tim Horton.
+
+        Add a very basic test to ensure that image overlay content can be installed.
+
+        * TestExpectations:
+        * fast/images/image-extraction/basic-image-overlay-expected-mismatch.html: Added.
+        * fast/images/image-extraction/basic-image-overlay.html: Added.
+
 2021-03-13  Commit Queue  <[email protected]>
 
         Unreviewed, reverting r274379.

Modified: trunk/LayoutTests/TestExpectations (274394 => 274395)


--- trunk/LayoutTests/TestExpectations	2021-03-14 03:22:18 UTC (rev 274394)
+++ trunk/LayoutTests/TestExpectations	2021-03-14 03:32:31 UTC (rev 274395)
@@ -38,6 +38,7 @@
 fast/forms/select/mac-wk2 [ Skip ]
 fast/forms/textarea/ios [ Skip ]
 fast/forms/watchos [ Skip ]
+fast/images/image-extraction [ Skip ]
 fast/sandbox/ios [ Skip ]
 fast/sandbox/mac [ Skip ]
 fast/viewport/watchos [ Skip ]

Added: trunk/LayoutTests/fast/images/image-extraction/basic-image-overlay-expected-mismatch.html (0 => 274395)


--- trunk/LayoutTests/fast/images/image-extraction/basic-image-overlay-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/image-extraction/basic-image-overlay-expected-mismatch.html	2021-03-14 03:32:31 UTC (rev 274395)
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+<img src=""
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/images/image-extraction/basic-image-overlay.html (0 => 274395)


--- trunk/LayoutTests/fast/images/image-extraction/basic-image-overlay.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/image-extraction/basic-image-overlay.html	2021-03-14 03:32:31 UTC (rev 274395)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<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 (274394 => 274395)


--- trunk/Source/WebCore/ChangeLog	2021-03-14 03:22:18 UTC (rev 274394)
+++ trunk/Source/WebCore/ChangeLog	2021-03-14 03:32:31 UTC (rev 274395)
@@ -1,3 +1,24 @@
+2021-03-13  Wenson Hsieh  <[email protected]>
+
+        Add support for accessibility image overlays in layout tests
+        https://bugs.webkit.org/show_bug.cgi?id=223146
+
+        Reviewed by Tim Horton.
+
+        Introduce an internal testing hook to install image overlay content, for layout and API tests.
+
+        Test: fast/images/image-extraction/basic-image-overlay.html
+
+        * dom/DOMPointReadOnly.h:
+        * dom/DOMPointReadOnly.idl:
+
+        Additionally add WebCore export macros to `DOMPointReadOnly`, so that Internals code can this class.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::installImageOverlay):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2021-03-13  Commit Queue  <[email protected]>
 
         Unreviewed, reverting r274379.

Modified: trunk/Source/WebCore/dom/DOMPointReadOnly.h (274394 => 274395)


--- trunk/Source/WebCore/dom/DOMPointReadOnly.h	2021-03-14 03:22:18 UTC (rev 274394)
+++ trunk/Source/WebCore/dom/DOMPointReadOnly.h	2021-03-14 03:32:31 UTC (rev 274395)
@@ -33,6 +33,7 @@
 #include "DOMPointInit.h"
 #include "ExceptionOr.h"
 #include "ScriptWrappable.h"
+#include <wtf/IsoMalloc.h>
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
@@ -41,7 +42,7 @@
 class DOMPoint;
 
 class DOMPointReadOnly : public ScriptWrappable, public RefCounted<DOMPointReadOnly> {
-    WTF_MAKE_ISO_ALLOCATED(DOMPointReadOnly);
+    WTF_MAKE_ISO_ALLOCATED_EXPORT(DOMPointReadOnly, WEBCORE_EXPORT);
 public:
     static Ref<DOMPointReadOnly> create(double x, double y, double z, double w) { return adoptRef(*new DOMPointReadOnly(x, y, z, w)); }
     static Ref<DOMPointReadOnly> create(const DOMPointInit& init) { return create(init.x, init.y, init.z, init.w); }

Modified: trunk/Source/WebCore/dom/DOMPointReadOnly.idl (274394 => 274395)


--- trunk/Source/WebCore/dom/DOMPointReadOnly.idl	2021-03-14 03:22:18 UTC (rev 274394)
+++ trunk/Source/WebCore/dom/DOMPointReadOnly.idl	2021-03-14 03:32:31 UTC (rev 274395)
@@ -30,6 +30,7 @@
 
 // The DOMPointInit constructor exists in https://www.w3.org/TR/geometry-1/ but is removed in https://drafts.fxtf.org/geometry/
 [
+    ExportMacro=WEBCORE_EXPORT,
     Exposed=(Window,Worker),
     ImplementationLacksVTable
 ] interface DOMPointReadOnly {

Modified: trunk/Source/WebCore/testing/Internals.cpp (274394 => 274395)


--- trunk/Source/WebCore/testing/Internals.cpp	2021-03-14 03:22:18 UTC (rev 274394)
+++ trunk/Source/WebCore/testing/Internals.cpp	2021-03-14 03:32:31 UTC (rev 274395)
@@ -55,6 +55,7 @@
 #include "ComposedTreeIterator.h"
 #include "CookieJar.h"
 #include "Cursor.h"
+#include "DOMPointReadOnly.h"
 #include "DOMRect.h"
 #include "DOMRectList.h"
 #include "DOMStringList.h"
@@ -78,6 +79,7 @@
 #include "ExtensionStyleSheets.h"
 #include "FetchResponse.h"
 #include "File.h"
+#include "FloatQuad.h"
 #include "FontCache.h"
 #include "FormController.h"
 #include "Frame.h"
@@ -334,6 +336,10 @@
 #include <wtf/spi/darwin/SandboxSPI.h>
 #endif
 
+#if ENABLE(IMAGE_EXTRACTION)
+#include "ImageExtractionResult.h"
+#endif
+
 using JSC::CallData;
 using JSC::CodeBlock;
 using JSC::FunctionExecutable;
@@ -5513,6 +5519,29 @@
 }
 #endif
 
+Internals::ImageOverlayText::~ImageOverlayText() = default;
+
+void Internals::installImageOverlay(Element& element, Vector<ImageOverlayText>&& allTextInfo)
+{
+    if (!is<HTMLElement>(element))
+        return;
+
+#if ENABLE(IMAGE_EXTRACTION)
+    downcast<HTMLElement>(element).updateWithImageExtractionResult(ImageExtractionResult {
+        allTextInfo.map([] (auto& textInfo) -> ImageExtractionTextData {
+            return { textInfo.text, {
+                FloatPoint(textInfo.topLeft->x(), textInfo.topLeft->y()),
+                FloatPoint(textInfo.topRight->x(), textInfo.topRight->y()),
+                FloatPoint(textInfo.bottomRight->x(), textInfo.bottomRight->y()),
+                FloatPoint(textInfo.bottomLeft->x(), textInfo.bottomLeft->y()),
+            }};
+        })
+    });
+#else
+    UNUSED_PARAM(allTextInfo);
+#endif
+}
+
 bool Internals::isSystemPreviewLink(Element& element) const
 {
 #if USE(SYSTEM_PREVIEW)

Modified: trunk/Source/WebCore/testing/Internals.h (274394 => 274395)


--- trunk/Source/WebCore/testing/Internals.h	2021-03-14 03:22:18 UTC (rev 274394)
+++ trunk/Source/WebCore/testing/Internals.h	2021-03-14 03:32:31 UTC (rev 274395)
@@ -52,6 +52,7 @@
 class AudioContext;
 class AudioTrack;
 class CacheStorageConnection;
+class DOMPointReadOnly;
 class DOMRect;
 class DOMRectList;
 class DOMRectReadOnly;
@@ -840,6 +841,17 @@
     MockPaymentCoordinator& mockPaymentCoordinator(Document&);
 #endif
 
+    struct ImageOverlayText {
+        String text;
+        RefPtr<DOMPointReadOnly> topLeft;
+        RefPtr<DOMPointReadOnly> topRight;
+        RefPtr<DOMPointReadOnly> bottomRight;
+        RefPtr<DOMPointReadOnly> bottomLeft;
+
+        ~ImageOverlayText();
+    };
+    void installImageOverlay(Element&, Vector<ImageOverlayText>&&);
+
     bool isSystemPreviewLink(Element&) const;
     bool isSystemPreviewImage(Element&) const;
 

Modified: trunk/Source/WebCore/testing/Internals.idl (274394 => 274395)


--- trunk/Source/WebCore/testing/Internals.idl	2021-03-14 03:22:18 UTC (rev 274394)
+++ trunk/Source/WebCore/testing/Internals.idl	2021-03-14 03:32:31 UTC (rev 274395)
@@ -255,6 +255,17 @@
 
 [
     ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
+    JSGenerateToJSObject,
+] dictionary ImageOverlayText {
+    required DOMString text;
+    required DOMPointReadOnly topLeft;
+    required DOMPointReadOnly topRight;
+    required DOMPointReadOnly bottomRight;
+    required DOMPointReadOnly bottomLeft;
+};
+
+[
+    ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
     LegacyNoInterfaceObject,
 ] interface Internals {
     DOMString address(Node node);
@@ -870,6 +881,8 @@
     boolean isSystemPreviewLink(Element element);
     boolean isSystemPreviewImage(Element element);
 
+    undefined installImageOverlay(Element element, sequence<ImageOverlayText> allTextInfo);
+
     boolean usingAppleInternalSDK();
     boolean usingGStreamer();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to