[ATK] Implement AtkComponentIface scroll_to methods
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Apr 2019 10:47:45 +0000 (10:47 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Apr 2019 10:47:45 +0000 (10:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196856

Patch by Carlos Garcia Campos <cgarcia@igalia.com> on 2019-04-23
Reviewed by Michael Catanzaro.

Source/WebCore:

Implement scroll_to and scroll_to_point when ATK >= 2.30.

Fixes: accessibility/scroll-to-global-point-iframe-nested.html
       accessibility/scroll-to-global-point-iframe.html
       accessibility/scroll-to-global-point-main-window.html
       accessibility/scroll-to-global-point-nested.html
       accessibility/scroll-to-make-visible-div-overflow.html
       accessibility/scroll-to-make-visible-iframe.html
       accessibility/scroll-to-make-visible-nested-2.html
       accessibility/scroll-to-make-visible-nested.html

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::scrollToMakeVisible const): Add new method receiving the
ScrollRectToVisibleOptions since ATK interface has a parameter to decide how to scroll.
* accessibility/AccessibilityObject.h:
* accessibility/atk/WebKitAccessibleInterfaceComponent.cpp:
(atkToContents):
(webkitAccessibleComponentRefAccessibleAtPoint):
(webkitAccessibleComponentGetExtents):
(webkitAccessibleComponentGrabFocus):
(webkitAccessibleComponentScrollTo):
(webkitAccessibleComponentScrollToPoint):
(webkitAccessibleComponentInterfaceInit):
(core): Deleted.

Tools:

* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
(WTR::AccessibilityUIElement::scrollToMakeVisible): Call atk_component_scroll_to().
(WTR::AccessibilityUIElement::scrollToGlobalPoint): Call atk_component_scroll_to_point().
* gtk/jhbuild.modules: Bump atk, at-spi2-core and at-spi2-atk to their latest stable version.

LayoutTests:

Remove expectations for tests that are passing now.

* platform/gtk/TestExpectations:

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

LayoutTests/ChangeLog
LayoutTests/platform/gtk/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceComponent.cpp
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp
Tools/gtk/jhbuild.modules

index f67b102..4f93c5c 100644 (file)
@@ -1,3 +1,14 @@
+2019-04-23  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [ATK] Implement AtkComponentIface scroll_to methods
+        https://bugs.webkit.org/show_bug.cgi?id=196856
+
+        Reviewed by Michael Catanzaro.
+
+        Remove expectations for tests that are passing now.
+
+        * platform/gtk/TestExpectations:
+
 2019-04-22  Zalan Bujtas  <zalan@apple.com>
 
         [ContentChangeObserver] Some dropdown menus may close without user gesture on americanexpress.com
index c2d93b8..c37ff0c 100644 (file)
@@ -817,8 +817,6 @@ webkit.org/b/131347 svg/text/hidpi-text-selection-rect-position.html [ ImageOnly
 # No support for Filters Level 2 on GTK yet
 webkit.org/b/169988 css3/filters/backdrop [ Skip ]
 
-webkit.org/b/141072 accessibility/frame-disconnect-textmarker-cache-crash.html [ Failure ]
-
 webkit.org/b/141423 fast/css/font-shorthand-from-longhands.html [ Failure ]
 webkit.org/b/141423 fast/css/font-shorthand-line-height.html [ Failure ]
 webkit.org/b/141423 fast/css/getComputedStyle/computed-style-font.html [ Failure ]
@@ -907,6 +905,7 @@ webkit.org/b/146731 fast/backgrounds/hidpi-background-image-contain-cover-scale-
 
 # Text marker tests are not supported
 webkit.org/b/153292 accessibility/text-marker [ Skip ]
+webkit.org/b/141072 accessibility/frame-disconnect-textmarker-cache-crash.html [ Skip ]
 
 # WebKitGTK+ doesn't have killring support.
 webkit.org/b/152379 editing/pasteboard/emacs-killring-alternating-append-prepend.html [ Failure ]
@@ -3110,14 +3109,6 @@ webkit.org/b/145432 media/video-transformed-by-javascript.html [ Failure ]
 webkit.org/b/148932 imported/w3c/web-platform-tests/css/css-color/t424-hsl-basic-a.xht [ ImageOnlyFailure Pass ]
 webkit.org/b/148932 imported/w3c/web-platform-tests/css/css-color/t425-hsla-clip-outside-device-gamut-b.xht [ ImageOnlyFailure ]
 
-webkit.org/b/148935 accessibility/scroll-to-global-point-iframe-nested.html [ Failure ]
-webkit.org/b/148935 accessibility/scroll-to-global-point-iframe.html [ Failure ]
-webkit.org/b/148935 accessibility/scroll-to-global-point-main-window.html [ Failure ]
-webkit.org/b/148935 accessibility/scroll-to-global-point-nested.html [ Failure ]
-webkit.org/b/148935 accessibility/scroll-to-make-visible-div-overflow.html [ Failure ]
-webkit.org/b/148935 accessibility/scroll-to-make-visible-iframe.html [ Failure ]
-webkit.org/b/148935 accessibility/scroll-to-make-visible-nested-2.html [ Failure ]
-webkit.org/b/148935 accessibility/scroll-to-make-visible-nested.html [ Failure ]
 webkit.org/b/148935 accessibility/scroll-to-make-visible-with-subfocus.html [ Failure ]
 
 webkit.org/b/149128 fast/text/control-characters [ ImageOnlyFailure ]
index c21839e..5184acc 100644 (file)
@@ -1,3 +1,35 @@
+2019-04-23  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [ATK] Implement AtkComponentIface scroll_to methods
+        https://bugs.webkit.org/show_bug.cgi?id=196856
+
+        Reviewed by Michael Catanzaro.
+
+        Implement scroll_to and scroll_to_point when ATK >= 2.30.
+
+        Fixes: accessibility/scroll-to-global-point-iframe-nested.html
+               accessibility/scroll-to-global-point-iframe.html
+               accessibility/scroll-to-global-point-main-window.html
+               accessibility/scroll-to-global-point-nested.html
+               accessibility/scroll-to-make-visible-div-overflow.html
+               accessibility/scroll-to-make-visible-iframe.html
+               accessibility/scroll-to-make-visible-nested-2.html
+               accessibility/scroll-to-make-visible-nested.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::scrollToMakeVisible const): Add new method receiving the
+        ScrollRectToVisibleOptions since ATK interface has a parameter to decide how to scroll.
+        * accessibility/AccessibilityObject.h:
+        * accessibility/atk/WebKitAccessibleInterfaceComponent.cpp:
+        (atkToContents):
+        (webkitAccessibleComponentRefAccessibleAtPoint):
+        (webkitAccessibleComponentGetExtents):
+        (webkitAccessibleComponentGrabFocus):
+        (webkitAccessibleComponentScrollTo):
+        (webkitAccessibleComponentScrollToPoint):
+        (webkitAccessibleComponentInterfaceInit):
+        (core): Deleted.
+
 2019-04-22  Youenn Fablet  <youenn@apple.com>
 
         Update libwebrtc logging when WebCore WebRTC logging is updated
index c00557e..24d0496 100644 (file)
@@ -3064,14 +3064,19 @@ bool AccessibilityObject::isOnscreen() const
 
 void AccessibilityObject::scrollToMakeVisible() const
 {
+    scrollToMakeVisible({ SelectionRevealMode::Reveal, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling::Yes });
+}
+
+void AccessibilityObject::scrollToMakeVisible(const ScrollRectToVisibleOptions& options) const
+{
     if (dispatchAccessibilityEventWithType(AccessibilityEventType::ScrollIntoView))
         return;
-    
+
     if (isScrollView() && parentObject())
         parentObject()->scrollToMakeVisible();
 
     if (auto* renderer = this->renderer())
-        renderer->scrollRectToVisible(boundingBoxRect(), false, { SelectionRevealMode::Reveal, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling::Yes });
+        renderer->scrollRectToVisible(boundingBoxRect(), false, options);
 }
 
 void AccessibilityObject::scrollToMakeVisibleWithSubFocus(const IntRect& subfocus) const
index 1856767..aec9c9b 100644 (file)
@@ -81,6 +81,7 @@ class RenderObject;
 class ScrollableArea;
 class ScrollView;
 class Widget;
+struct ScrollRectToVisibleOptions;
 
 enum class AccessibilityTextSource {
     Alternative,
@@ -882,6 +883,7 @@ public:
     IntPoint scrollPosition() const;
     IntSize scrollContentsSize() const;    
     IntRect scrollVisibleContentRect() const;
+    void scrollToMakeVisible(const ScrollRectToVisibleOptions&) const;
     
     bool lastKnownIsIgnoredValue();
     void setLastKnownIsIgnoredValue(bool);
index 5e25e49..1de6e40 100644 (file)
 #include "AccessibilityObject.h"
 #include "FrameView.h"
 #include "IntRect.h"
+#include "RenderLayer.h"
 #include "WebKitAccessible.h"
 #include "WebKitAccessibleUtil.h"
 
 using namespace WebCore;
 
-static AccessibilityObject* core(AtkComponent* component)
+static IntPoint atkToContents(const AccessibilityObject& coreObject, AtkCoordType coordType, gint x, gint y)
 {
-    if (!WEBKIT_IS_ACCESSIBLE(component))
-        return 0;
-
-    return &webkitAccessibleGetAccessibilityObject(WEBKIT_ACCESSIBLE(component));
-}
-
-static IntPoint atkToContents(AccessibilityObject* coreObject, AtkCoordType coordType, gint x, gint y)
-{
-    IntPoint pos(x, y);
-
-    FrameView* frameView = coreObject->documentFrameView();
-    if (frameView) {
-        switch (coordType) {
-        case ATK_XY_SCREEN:
-            return frameView->screenToContents(pos);
-        case ATK_XY_WINDOW:
-            return frameView->windowToContents(pos);
+    auto* frameView = coreObject.documentFrameView();
+    if (!frameView)
+        return { x, y };
+
+    switch (coordType) {
+    case ATK_XY_SCREEN:
+        return frameView->screenToContents({ x, y });
+    case ATK_XY_WINDOW:
+        return frameView->windowToContents({ x, y });
 #if ATK_CHECK_VERSION(2, 30, 0)
-        case ATK_XY_PARENT:
-            RELEASE_ASSERT_NOT_REACHED();
+    case ATK_XY_PARENT:
+        RELEASE_ASSERT_NOT_REACHED();
 #endif
-        }
     }
 
-    return pos;
+    return { x, y };
 }
 
 static AtkObject* webkitAccessibleComponentRefAccessibleAtPoint(AtkComponent* component, gint x, gint y, AtkCoordType coordType)
 {
-    g_return_val_if_fail(ATK_IS_COMPONENT(component), 0);
-    returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(component), 0);
+    auto* accessible = WEBKIT_ACCESSIBLE(component);
+    returnValIfWebKitAccessibleIsInvalid(accessible, nullptr);
 
-    IntPoint pos = atkToContents(core(component), coordType, x, y);
-
-    AccessibilityObject* target = downcast<AccessibilityObject>(core(component)->accessibilityHitTest(pos));
+    auto& coreObject = webkitAccessibleGetAccessibilityObject(accessible);
+    auto* target = downcast<AccessibilityObject>(coreObject.accessibilityHitTest(atkToContents(coreObject, coordType, x, y)));
     if (!target)
-        return 0;
-    g_object_ref(target->wrapper());
-    return ATK_OBJECT(target->wrapper());
+        return nullptr;
+
+    if (auto* wrapper = target->wrapper())
+        return ATK_OBJECT(g_object_ref(wrapper));
+
+    return nullptr;
 }
 
 static void webkitAccessibleComponentGetExtents(AtkComponent* component, gint* x, gint* y, gint* width, gint* height, AtkCoordType coordType)
 {
-    g_return_if_fail(ATK_IS_COMPONENT(component));
-    returnIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(component));
+    auto* accessible = WEBKIT_ACCESSIBLE(component);
+    returnIfWebKitAccessibleIsInvalid(accessible);
 
-    IntRect rect = snappedIntRect(core(component)->elementRect());
-    contentsRelativeToAtkCoordinateType(core(component), coordType, rect, x, y, width, height);
+    auto& coreObject = webkitAccessibleGetAccessibilityObject(accessible);
+    contentsRelativeToAtkCoordinateType(&coreObject, coordType, snappedIntRect(coreObject.elementRect()), x, y, width, height);
 }
 
 static gboolean webkitAccessibleComponentGrabFocus(AtkComponent* component)
 {
-    g_return_val_if_fail(ATK_IS_COMPONENT(component), FALSE);
-    returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(component), FALSE);
+    auto* accessible = WEBKIT_ACCESSIBLE(component);
+    returnValIfWebKitAccessibleIsInvalid(accessible, FALSE);
+
+    auto& coreObject = webkitAccessibleGetAccessibilityObject(accessible);
+    coreObject.setFocused(true);
+    return coreObject.isFocused();
+}
+
+#if ATK_CHECK_VERSION(2, 30, 0)
+static gboolean webkitAccessibleComponentScrollTo(AtkComponent* component, AtkScrollType scrollType)
+{
+    auto* accessible = WEBKIT_ACCESSIBLE(component);
+    returnValIfWebKitAccessibleIsInvalid(accessible, FALSE);
+
+    ScrollAlignment alignX;
+    ScrollAlignment alignY;
+
+    switch (scrollType) {
+    case ATK_SCROLL_TOP_LEFT:
+        alignX = ScrollAlignment::alignLeftAlways;
+        alignY = ScrollAlignment::alignTopAlways;
+        break;
+    case ATK_SCROLL_BOTTOM_RIGHT:
+        alignX = ScrollAlignment::alignRightAlways;
+        alignY = ScrollAlignment::alignBottomAlways;
+        break;
+    case ATK_SCROLL_TOP_EDGE:
+    case ATK_SCROLL_BOTTOM_EDGE:
+        // Align to a particular edge is not supported, it's always the closest edge.
+        alignX = ScrollAlignment::alignCenterIfNeeded;
+        alignY = ScrollAlignment::alignToEdgeIfNeeded;
+        break;
+    case ATK_SCROLL_LEFT_EDGE:
+    case ATK_SCROLL_RIGHT_EDGE:
+        // Align to a particular edge is not supported, it's always the closest edge.
+        alignX = ScrollAlignment::alignToEdgeIfNeeded;
+        alignY = ScrollAlignment::alignCenterIfNeeded;
+        break;
+    case ATK_SCROLL_ANYWHERE:
+        alignX = ScrollAlignment::alignCenterIfNeeded;
+        alignY = ScrollAlignment::alignCenterIfNeeded;
+        break;
+    }
+
+    auto& coreObject = webkitAccessibleGetAccessibilityObject(accessible);
+    coreObject.scrollToMakeVisible({ SelectionRevealMode::Reveal, alignX, alignY, ShouldAllowCrossOriginScrolling::Yes });
+
+    return TRUE;
+}
+
+static gboolean webkitAccessibleComponentScrollToPoint(AtkComponent* component, AtkCoordType coordType, gint x, gint y)
+{
+    auto* accessible = WEBKIT_ACCESSIBLE(component);
+    returnValIfWebKitAccessibleIsInvalid(accessible, FALSE);
+
+    auto& coreObject = webkitAccessibleGetAccessibilityObject(accessible);
 
-    core(component)->setFocused(true);
-    return core(component)->isFocused();
+    IntPoint point(x, y);
+    if (coordType == ATK_XY_SCREEN) {
+        if (auto* frameView = coreObject.documentFrameView())
+            point = frameView->contentsToWindow(frameView->screenToContents(point));
+    }
+
+    coreObject.scrollToGlobalPoint(point);
+
+    return TRUE;
 }
+#endif
 
 void webkitAccessibleComponentInterfaceInit(AtkComponentIface* iface)
 {
     iface->ref_accessible_at_point = webkitAccessibleComponentRefAccessibleAtPoint;
     iface->get_extents = webkitAccessibleComponentGetExtents;
     iface->grab_focus = webkitAccessibleComponentGrabFocus;
+#if ATK_CHECK_VERSION(2, 30, 0)
+    iface->scroll_to = webkitAccessibleComponentScrollTo;
+    iface->scroll_to_point = webkitAccessibleComponentScrollToPoint;
+#endif
 }
 
-#endif
+#endif // HAVE(ACCESSIBILITY)
index ad18b66..49e9887 100644 (file)
@@ -1,3 +1,15 @@
+2019-04-23  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [ATK] Implement AtkComponentIface scroll_to methods
+        https://bugs.webkit.org/show_bug.cgi?id=196856
+
+        Reviewed by Michael Catanzaro.
+
+        * WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
+        (WTR::AccessibilityUIElement::scrollToMakeVisible): Call atk_component_scroll_to().
+        (WTR::AccessibilityUIElement::scrollToGlobalPoint): Call atk_component_scroll_to_point().
+        * gtk/jhbuild.modules: Bump atk, at-spi2-core and at-spi2-atk to their latest stable version.
+
 2019-04-22  Aakash Jain  <aakash_jain@apple.com>
 
         [ews-build] Improve summary for UploadBuiltProduct step
index ec70318..d62a8e4 100644 (file)
@@ -2332,14 +2332,24 @@ bool AccessibilityUIElement::setSelectedVisibleTextRange(AccessibilityTextMarker
 
 void AccessibilityUIElement::scrollToMakeVisible()
 {
-    // FIXME: implement
+#if ATK_CHECK_VERSION(2, 30, 0)
+    if (!ATK_IS_COMPONENT(m_element.get()))
+        return;
+
+    atk_component_scroll_to(ATK_COMPONENT(m_element.get()), ATK_SCROLL_ANYWHERE);
+#endif
 }
-    
+
 void AccessibilityUIElement::scrollToGlobalPoint(int x, int y)
 {
-    // FIXME: implement
+#if ATK_CHECK_VERSION(2, 30, 0)
+    if (!ATK_IS_COMPONENT(m_element.get()))
+        return;
+
+    atk_component_scroll_to_point(ATK_COMPONENT(m_element.get()), ATK_XY_WINDOW, x, y);
+#endif
 }
-    
+
 void AccessibilityUIElement::scrollToMakeVisibleWithSubFocus(int x, int y, int width, int height)
 {
     // FIXME: implement
index 1ecebc3..480d8d2 100644 (file)
             hash="sha256:ccf79ff3bd340254737ce4d28b87f0ccee4b3358cd3cd5cd11dc7b42f41b272a"/>
   </autotools>
 
-  <autotools id="atk"
-             autogen-sh="configure"
-             autogenargs="--disable-introspection">
-    <branch module="pub/GNOME/sources/atk/2.25/atk-2.25.2.tar.xz" version="2.25.2"
+  <meson id="atk" mesonargs="-Dintrospection=false">
+    <branch module="pub/GNOME/sources/atk/2.32/atk-2.32.0.tar.xz" version="2.32.0"
             repo="ftp.gnome.org"
-            hash="sha256:75ac1f63e845f895dec8d72d4645ef5f362e32c921cc78987f2f19c2ce212a24"/>
-  </autotools>
+            hash="sha256:cb41feda7fe4ef0daa024471438ea0219592baf7c291347e5a858bb64e4091cc"/>
+  </meson>
 
-  <autotools id="at-spi2-core"
-             autogen-sh="configure"
-             autogenargs="--disable-introspection">
-    <branch module="pub/GNOME/sources/at-spi2-core/2.25/at-spi2-core-2.25.4.tar.xz" version="2.25.4"
+  <meson id="at-spi2-core" mesonargs="-Dintrospection=no">
+    <branch module="pub/GNOME/sources/at-spi2-core/2.32/at-spi2-core-2.32.1.tar.xz" version="2.32.1"
             repo="ftp.gnome.org"
-            hash="sha256:baeccbf92e84e64bb4a853f076c27b78ab44edf1fa5414a9c6e59a9b180bc9d8">
+            hash="sha256:3c2aa937ebfaca2c86569bce9b16a34fbe20d69ef0c58846313b1c42f53b0d53">
     </branch>
     <dependencies>
       <dep package="glib"/>
     </dependencies>
-  </autotools>
+  </meson>
 
-  <autotools id="at-spi2-atk"
-             autogen-sh="configure">
-    <branch module="pub/GNOME/sources/at-spi2-atk/2.25/at-spi2-atk-2.25.3.tar.xz" version="2.25.3"
+  <meson id="at-spi2-atk">
+    <branch module="pub/GNOME/sources/at-spi2-atk/2.32/at-spi2-atk-2.32.0.tar.xz" version="2.32.0"
             repo="ftp.gnome.org"
-            hash="sha256:b7aab1a4ee7182083fcfafb595b7b3fe4df34aa2230c775050fe6015b01f84e1">
+            hash="sha256:0b51e6d339fa2bcca3a3e3159ccea574c67b107f1ac8b00047fa60e34ce7a45c">
     </branch>
     <dependencies>
       <dep package="glib"/>
       <dep package="atk"/>
       <dep package="at-spi2-core"/>
     </dependencies>
-  </autotools>
+  </meson>
 
   <autotools id="libxml2" supports-non-srcdir-builds="no"
              autogen-sh="./autogen.sh; ./configure --with-python=no">