Changeset 105716 in webkit


Ignore:
Timestamp:
Jan 24, 2012 3:03:51 AM (12 years ago)
Author:
mario@webkit.org
Message:

[GTK] Refactor GTK's accessibilitity code to be more modular
https://bugs.webkit.org/show_bug.cgi?id=76783

Reviewed by Martin Robinson.

New files for the implementation of the AtkComponent interface,
containing the related code from WebKitAccessibleWrapperAtk.cpp.

  • accessibility/gtk/WebKitAccessibleInterfaceComponent.cpp: Added.

(core):
(atkToContents):
(webkitAccessibleComponentInterfaceInit):
(webkitAccessibleComponentRefAccessibleAtPoint):
(webkitAccessibleComponentGetExtents):
(webkitAccessibleComponentGrabFocus):

  • accessibility/gtk/WebKitAccessibleInterfaceComponent.h: Added.

Move common function contentsToAtk() out from the wrapper to the
utility file, used from WebKitAccessibleInterfaceComponent.cpp.

  • accessibility/gtk/WebKitAccessibleUtil.cpp:

(contentsRelativeToAtkCoordinateType): Taken from WebKitAccessibleWrapperAtk.cpp.

  • accessibility/gtk/WebKitAccessibleUtil.h:
  • accessibility/gtk/WebKitAccessibleWrapperAtk.cpp: Remove local

implementation of contentsToAtk, as well as all the code related
to the implementation of the AtkComponent interface.

Add new files to build files.

  • GNUmakefile.list.am: Add WebKitAccessibleInterfaceComponent.[h|cpp].
  • WebCore.gypi: Ditto.
Location:
trunk/Source/WebCore
Files:
1 added
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r105714 r105716  
     12012-01-24  Mario Sanchez Prada  <msanchez@igalia.com>
     2
     3        [GTK] Refactor GTK's accessibilitity code to be more modular
     4        https://bugs.webkit.org/show_bug.cgi?id=76783
     5
     6        Reviewed by Martin Robinson.
     7
     8        New files for the implementation of the AtkComponent interface,
     9        containing the related code from WebKitAccessibleWrapperAtk.cpp.
     10
     11        * accessibility/gtk/WebKitAccessibleInterfaceComponent.cpp: Added.
     12        (core):
     13        (atkToContents):
     14        (webkitAccessibleComponentInterfaceInit):
     15        (webkitAccessibleComponentRefAccessibleAtPoint):
     16        (webkitAccessibleComponentGetExtents):
     17        (webkitAccessibleComponentGrabFocus):
     18        * accessibility/gtk/WebKitAccessibleInterfaceComponent.h: Added.
     19
     20        Move common function contentsToAtk() out from the wrapper to the
     21        utility file, used from WebKitAccessibleInterfaceComponent.cpp.
     22
     23        * accessibility/gtk/WebKitAccessibleUtil.cpp:
     24        (contentsRelativeToAtkCoordinateType): Taken from WebKitAccessibleWrapperAtk.cpp.
     25        * accessibility/gtk/WebKitAccessibleUtil.h:
     26        * accessibility/gtk/WebKitAccessibleWrapperAtk.cpp: Remove local
     27        implementation of contentsToAtk, as well as all the code related
     28        to the implementation of the AtkComponent interface.
     29
     30        Add new files to build files.
     31
     32        * GNUmakefile.list.am: Add WebKitAccessibleInterfaceComponent.[h|cpp].
     33        * WebCore.gypi: Ditto.
     34
    1352012-01-24  Kentaro Hara  <haraken@chromium.org>
    236
  • trunk/Source/WebCore/GNUmakefile.list.am

    r105648 r105716  
    44244424        Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceAction.cpp \
    44254425        Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceAction.h \
     4426        Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceComponent.cpp \
     4427        Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceComponent.h \
    44264428        Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.cpp \
    44274429        Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.h \
  • trunk/Source/WebCore/WebCore.gypi

    r105705 r105716  
    13481348            'accessibility/gtk/WebKitAccessibleInterfaceAction.cpp',
    13491349            'accessibility/gtk/WebKitAccessibleInterfaceAction.h',
     1350            'accessibility/gtk/WebKitAccessibleInterfaceComponent.cpp',
     1351            'accessibility/gtk/WebKitAccessibleInterfaceComponent.h',
    13501352            'accessibility/gtk/WebKitAccessibleUtil.cpp',
    13511353            'accessibility/gtk/WebKitAccessibleUtil.h',
  • trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceComponent.h

    r105715 r105716  
    22 * Copyright (C) 2008 Nuanti Ltd.
    33 * Copyright (C) 2009 Jan Alonzo
    4  * Copyright (C) 2009, 2010, 2012 Igalia S.L.
     4 * Copyright (C) 2009, 2012 Igalia S.L.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    2020 */
    2121
    22 #ifndef WebKitAccessibleUtil_h
    23 #define WebKitAccessibleUtil_h
     22#ifndef WebKitAccessibleInterfaceComponent_h
     23#define WebKitAccessibleInterfaceComponent_h
    2424
    25 #include <wtf/text/WTFString.h>
     25#include <atk/atk.h>
    2626
    27 // Returns a const char* pointing to a statically allocated string.
    28 const char* returnString(const String&);
     27void webkitAccessibleComponentInterfaceInit(AtkComponentIface*);
     28AtkObject* webkitAccessibleComponentRefAccessibleAtPoint(AtkComponent*, gint x, gint y, AtkCoordType);
     29void webkitAccessibleComponentGetExtents(AtkComponent*, gint* x, gint* y, gint* width, gint* height, AtkCoordType);
     30gboolean webkitAccessibleComponentGrabFocus(AtkComponent*);
    2931
    30 #endif // WebKitAccessibleUtil_h
     32#endif // WebKitAccessibleInterfaceComponent_h
  • trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.cpp

    r105610 r105716  
    3232#include "WebKitAccessibleUtil.h"
    3333
     34#include "AccessibilityObject.h"
     35#include "FrameView.h"
     36#include "IntRect.h"
     37
    3438#include <wtf/text/AtomicString.h>
    3539#include <wtf/text/CString.h>
     40
     41using namespace WebCore;
     42
     43void contentsRelativeToAtkCoordinateType(AccessibilityObject* coreObject, AtkCoordType coordType, IntRect rect, gint* x, gint* y, gint* width, gint* height)
     44{
     45    FrameView* frameView = coreObject->documentFrameView();
     46
     47    if (frameView) {
     48        switch (coordType) {
     49        case ATK_XY_WINDOW:
     50            rect = frameView->contentsToWindow(rect);
     51            break;
     52        case ATK_XY_SCREEN:
     53            rect = frameView->contentsToScreen(rect);
     54            break;
     55        }
     56    }
     57
     58    if (x)
     59        *x = rect.x();
     60    if (y)
     61        *y = rect.y();
     62    if (width)
     63        *width = rect.width();
     64    if (height)
     65        *height = rect.height();
     66}
    3667
    3768// Used to provide const char* returns.
  • trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.h

    r105610 r105716  
    2323#define WebKitAccessibleUtil_h
    2424
     25#include <atk/atk.h>
    2526#include <wtf/text/WTFString.h>
    2627
    27 // Returns a const char* pointing to a statically allocated string.
     28namespace WebCore {
     29class AccessibilityObject;
     30class IntRect;
     31}
     32
     33void contentsRelativeToAtkCoordinateType(WebCore::AccessibilityObject*, AtkCoordType, WebCore::IntRect, gint* x, gint* y, gint* width = 0, gint* height = 0);
     34
    2835const char* returnString(const String&);
    2936
  • trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp

    r105618 r105716  
    6565#include "WebKitAccessibleHyperlink.h"
    6666#include "WebKitAccessibleInterfaceAction.h"
     67#include "WebKitAccessibleInterfaceComponent.h"
    6768#include "WebKitAccessibleUtil.h"
    6869#include "htmlediting.h"
     
    124125{
    125126    return core(ATK_OBJECT(text));
    126 }
    127 
    128 static AccessibilityObject* core(AtkComponent* component)
    129 {
    130     return core(ATK_OBJECT(component));
    131127}
    132128
     
    19411937}
    19421938
    1943 static void contentsToAtk(AccessibilityObject* coreObject, AtkCoordType coordType, IntRect rect, gint* x, gint* y, gint* width = 0, gint* height = 0)
    1944 {
    1945     FrameView* frameView = coreObject->documentFrameView();
    1946 
    1947     if (frameView) {
    1948         switch (coordType) {
    1949         case ATK_XY_WINDOW:
    1950             rect = frameView->contentsToWindow(rect);
    1951             break;
    1952         case ATK_XY_SCREEN:
    1953             rect = frameView->contentsToScreen(rect);
    1954             break;
    1955         }
    1956     }
    1957 
    1958     if (x)
    1959         *x = rect.x();
    1960     if (y)
    1961         *y = rect.y();
    1962     if (width)
    1963         *width = rect.width();
    1964     if (height)
    1965         *height = rect.height();
    1966 }
    1967 
    1968 static IntPoint atkToContents(AccessibilityObject* coreObject, AtkCoordType coordType, gint x, gint y)
    1969 {
    1970     IntPoint pos(x, y);
    1971 
    1972     FrameView* frameView = coreObject->documentFrameView();
    1973     if (frameView) {
    1974         switch (coordType) {
    1975         case ATK_XY_SCREEN:
    1976             return frameView->screenToContents(pos);
    1977         case ATK_XY_WINDOW:
    1978             return frameView->windowToContents(pos);
    1979         }
    1980     }
    1981 
    1982     return pos;
    1983 }
    1984 
    1985 static AtkObject* webkit_accessible_component_ref_accessible_at_point(AtkComponent* component, gint x, gint y, AtkCoordType coordType)
    1986 {
    1987     IntPoint pos = atkToContents(core(component), coordType, x, y);
    1988    
    1989     AccessibilityObject* target = core(component)->accessibilityHitTest(pos);
    1990     if (!target)
    1991         return 0;
    1992     g_object_ref(target->wrapper());
    1993     return target->wrapper();
    1994 }
    1995 
    1996 static void webkit_accessible_component_get_extents(AtkComponent* component, gint* x, gint* y, gint* width, gint* height, AtkCoordType coordType)
    1997 {
    1998     IntRect rect = core(component)->elementRect();
    1999     contentsToAtk(core(component), coordType, rect, x, y, width, height);
    2000 }
    2001 
    2002 static gboolean webkit_accessible_component_grab_focus(AtkComponent* component)
    2003 {
    2004     core(component)->setFocused(true);
    2005     return core(component)->isFocused();
    2006 }
    2007 
    2008 static void atk_component_interface_init(AtkComponentIface* iface)
    2009 {
    2010     iface->ref_accessible_at_point = webkit_accessible_component_ref_accessible_at_point;
    2011     iface->get_extents = webkit_accessible_component_get_extents;
    2012     iface->grab_focus = webkit_accessible_component_grab_focus;
    2013 }
    2014 
    20151939// Image
    20161940
     
    20181942{
    20191943    IntRect rect = core(image)->elementRect();
    2020     contentsToAtk(core(image), coordType, rect, x, y);
     1944    contentsRelativeToAtkCoordinateType(core(image), coordType, rect, x, y);
    20211945}
    20221946
     
    24472371    {(GInterfaceInitFunc)atk_text_interface_init,
    24482372     (GInterfaceFinalizeFunc) 0, 0},
    2449     {(GInterfaceInitFunc)atk_component_interface_init,
    2450      (GInterfaceFinalizeFunc) 0, 0},
     2373    {reinterpret_cast<GInterfaceInitFunc>(webkitAccessibleComponentInterfaceInit), 0, 0},
    24512374    {(GInterfaceInitFunc)atk_image_interface_init,
    24522375     (GInterfaceFinalizeFunc) 0, 0},
Note: See TracChangeset for help on using the changeset viewer.