Title: [105725] trunk/Source/WebCore
Revision
105725
Author
[email protected]
Date
2012-01-24 03:58:52 -0800 (Tue, 24 Jan 2012)

Log 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 AtkHypertext interface,
containing the related code from WebKitAccessibleWrapperAtk.cpp.

* accessibility/gtk/WebKitAccessibleInterfaceHypertext.cpp: Added.
(core):
(webkitAccessibleHypertextInterfaceInit):
(webkitAccessibleHypertextGetLink):
(webkitAccessibleHypertextGetNLinks):
(webkitAccessibleHypertextGetLinkIndex):
* accessibility/gtk/WebKitAccessibleInterfaceHypertext.h: Added.
* accessibility/gtk/WebKitAccessibleWrapperAtk.cpp: Remove code
related to the implementation of the AtkHypertext interface.

Add new files to build files.

* GNUmakefile.list.am: Add WebKitAccessibleInterfaceHypertext.[h|cpp].
* WebCore.gypi: Ditto.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (105724 => 105725)


--- trunk/Source/WebCore/ChangeLog	2012-01-24 11:55:18 UTC (rev 105724)
+++ trunk/Source/WebCore/ChangeLog	2012-01-24 11:58:52 UTC (rev 105725)
@@ -5,6 +5,31 @@
 
         Reviewed by Martin Robinson.
 
+        New files for the implementation of the AtkHypertext interface,
+        containing the related code from WebKitAccessibleWrapperAtk.cpp.
+
+        * accessibility/gtk/WebKitAccessibleInterfaceHypertext.cpp: Added.
+        (core):
+        (webkitAccessibleHypertextInterfaceInit):
+        (webkitAccessibleHypertextGetLink):
+        (webkitAccessibleHypertextGetNLinks):
+        (webkitAccessibleHypertextGetLinkIndex):
+        * accessibility/gtk/WebKitAccessibleInterfaceHypertext.h: Added.
+        * accessibility/gtk/WebKitAccessibleWrapperAtk.cpp: Remove code
+        related to the implementation of the AtkHypertext interface.
+
+        Add new files to build files.
+
+        * GNUmakefile.list.am: Add WebKitAccessibleInterfaceHypertext.[h|cpp].
+        * WebCore.gypi: Ditto.
+
+2012-01-24  Mario Sanchez Prada  <[email protected]>
+
+        [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 AtkHyperlinkImpl interface,
         containing the related code from WebKitAccessibleWrapperAtk.cpp.
 

Modified: trunk/Source/WebCore/GNUmakefile.list.am (105724 => 105725)


--- trunk/Source/WebCore/GNUmakefile.list.am	2012-01-24 11:55:18 UTC (rev 105724)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2012-01-24 11:58:52 UTC (rev 105725)
@@ -4431,6 +4431,8 @@
 	Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceEditableText.h \
 	Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceHyperlinkImpl.cpp \
 	Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceHyperlinkImpl.h \
+	Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceHypertext.cpp \
+	Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceHypertext.h \
 	Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.cpp \
 	Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.h \
 	Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp \

Modified: trunk/Source/WebCore/WebCore.gypi (105724 => 105725)


--- trunk/Source/WebCore/WebCore.gypi	2012-01-24 11:55:18 UTC (rev 105724)
+++ trunk/Source/WebCore/WebCore.gypi	2012-01-24 11:58:52 UTC (rev 105725)
@@ -1355,6 +1355,8 @@
             'accessibility/gtk/WebKitAccessibleInterfaceEditableText.h',
             'accessibility/gtk/WebKitAccessibleInterfaceHyperlinkImpl.cpp',
             'accessibility/gtk/WebKitAccessibleInterfaceHyperlinkImpl.h',
+            'accessibility/gtk/WebKitAccessibleInterfaceHypertext.cpp',
+            'accessibility/gtk/WebKitAccessibleInterfaceHypertext.h',
             'accessibility/gtk/WebKitAccessibleUtil.cpp',
             'accessibility/gtk/WebKitAccessibleUtil.h',
             'accessibility/gtk/WebKitAccessibleWrapperAtk.cpp',

Added: trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceHypertext.cpp (0 => 105725)


--- trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceHypertext.cpp	                        (rev 0)
+++ trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceHypertext.cpp	2012-01-24 11:58:52 UTC (rev 105725)
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2010, 2011, 2012 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitAccessibleInterfaceHypertext.h"
+
+#include "AccessibilityObject.h"
+#include "WebKitAccessibleWrapperAtk.h"
+
+using namespace WebCore;
+
+static AccessibilityObject* core(AtkHypertext* hypertext)
+{
+    if (!WEBKIT_IS_ACCESSIBLE(hypertext))
+        return 0;
+
+    return webkitAccessibleGetAccessibilityObject(WEBKIT_ACCESSIBLE(hypertext));
+}
+
+void webkitAccessibleHypertextInterfaceInit(AtkHypertextIface* iface)
+{
+    iface->get_link = webkitAccessibleHypertextGetLink;
+    iface->get_n_links = webkitAccessibleHypertextGetNLinks;
+    iface->get_link_index = webkitAccessibleHypertextGetLinkIndex;
+}
+
+AtkHyperlink* webkitAccessibleHypertextGetLink(AtkHypertext* hypertext, gint index)
+{
+    AccessibilityObject::AccessibilityChildrenVector children = core(hypertext)->children();
+    if (index < 0 || static_cast<unsigned>(index) >= children.size())
+        return 0;
+
+    gint currentLink = -1;
+    for (unsigned i = 0; i < children.size(); i++) {
+        AccessibilityObject* coreChild = children.at(i).get();
+        if (!coreChild->accessibilityIsIgnored()) {
+            AtkObject* axObject = coreChild->wrapper();
+            if (!axObject || !ATK_IS_HYPERLINK_IMPL(axObject))
+                continue;
+
+            currentLink++;
+            if (index != currentLink)
+                continue;
+
+            return atk_hyperlink_impl_get_hyperlink(ATK_HYPERLINK_IMPL(axObject));
+        }
+    }
+
+    return 0;
+}
+
+gint webkitAccessibleHypertextGetNLinks(AtkHypertext* hypertext)
+{
+    AccessibilityObject::AccessibilityChildrenVector children = core(hypertext)->children();
+    if (!children.size())
+        return 0;
+
+    gint linksFound = 0;
+    for (size_t i = 0; i < children.size(); i++) {
+        AccessibilityObject* coreChild = children.at(i).get();
+        if (!coreChild->accessibilityIsIgnored()) {
+            AtkObject* axObject = coreChild->wrapper();
+            if (axObject && ATK_IS_HYPERLINK_IMPL(axObject))
+                linksFound++;
+        }
+    }
+
+    return linksFound;
+}
+
+gint webkitAccessibleHypertextGetLinkIndex(AtkHypertext* hypertext, gint charIndex)
+{
+    size_t linksCount = webkitAccessibleHypertextGetNLinks(hypertext);
+    if (!linksCount)
+        return -1;
+
+    for (size_t i = 0; i < linksCount; i++) {
+        AtkHyperlink* hyperlink = ATK_HYPERLINK(webkitAccessibleHypertextGetLink(hypertext, i));
+        gint startIndex = atk_hyperlink_get_start_index(hyperlink);
+        gint endIndex = atk_hyperlink_get_end_index(hyperlink);
+
+        // Check if the char index in the link's offset range
+        if (startIndex <= charIndex && charIndex < endIndex)
+            return i;
+    }
+
+    // Not found if reached
+    return -1;
+}

Added: trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceHypertext.h (0 => 105725)


--- trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceHypertext.h	                        (rev 0)
+++ trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceHypertext.h	2012-01-24 11:58:52 UTC (rev 105725)
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2010, 2011, 2012 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebKitAccessibleInterfaceHypertext_h
+#define WebKitAccessibleInterfaceHypertext_h
+
+#include <atk/atk.h>
+
+void webkitAccessibleHypertextInterfaceInit(AtkHypertextIface*);
+AtkHyperlink* webkitAccessibleHypertextGetLink(AtkHypertext*, gint index);
+gint webkitAccessibleHypertextGetNLinks(AtkHypertext*);
+gint webkitAccessibleHypertextGetLinkIndex(AtkHypertext*, gint charIndex);
+
+#endif // WebKitAccessibleInterfaceHypertext_h

Modified: trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp (105724 => 105725)


--- trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp	2012-01-24 11:55:18 UTC (rev 105724)
+++ trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp	2012-01-24 11:58:52 UTC (rev 105725)
@@ -68,6 +68,7 @@
 #include "WebKitAccessibleInterfaceDocument.h"
 #include "WebKitAccessibleInterfaceEditableText.h"
 #include "WebKitAccessibleInterfaceHyperlinkImpl.h"
+#include "WebKitAccessibleInterfaceHypertext.h"
 #include "WebKitAccessibleUtil.h"
 #include "htmlediting.h"
 #include "visible_units.h"
@@ -132,11 +133,6 @@
     return core(ATK_OBJECT(table));
 }
 
-static AccessibilityObject* core(AtkHypertext* hypertext)
-{
-    return core(ATK_OBJECT(hypertext));
-}
-
 static AccessibilityObject* core(AtkValue* value)
 {
     return core(ATK_OBJECT(value));
@@ -2066,77 +2062,6 @@
     iface->get_row_description = webkit_accessible_table_get_row_description;
 }
 
-static AtkHyperlink* webkitAccessibleHypertextGetLink(AtkHypertext* hypertext, gint index)
-{
-    AccessibilityObject::AccessibilityChildrenVector children = core(hypertext)->children();
-    if (index < 0 || static_cast<unsigned>(index) >= children.size())
-        return 0;
-
-    gint currentLink = -1;
-    for (unsigned i = 0; i < children.size(); i++) {
-        AccessibilityObject* coreChild = children.at(i).get();
-        if (!coreChild->accessibilityIsIgnored()) {
-            AtkObject* axObject = coreChild->wrapper();
-            if (!axObject || !ATK_IS_HYPERLINK_IMPL(axObject))
-                continue;
-
-            currentLink++;
-            if (index != currentLink)
-                continue;
-
-            return atk_hyperlink_impl_get_hyperlink(ATK_HYPERLINK_IMPL(axObject));
-        }
-    }
-
-    return 0;
-}
-
-static gint webkitAccessibleHypertextGetNLinks(AtkHypertext* hypertext)
-{
-    AccessibilityObject::AccessibilityChildrenVector children = core(hypertext)->children();
-    if (!children.size())
-        return 0;
-
-    gint linksFound = 0;
-    for (size_t i = 0; i < children.size(); i++) {
-        AccessibilityObject* coreChild = children.at(i).get();
-        if (!coreChild->accessibilityIsIgnored()) {
-            AtkObject* axObject = coreChild->wrapper();
-            if (axObject && ATK_IS_HYPERLINK_IMPL(axObject))
-                linksFound++;
-        }
-    }
-
-    return linksFound;
-}
-
-static gint webkitAccessibleHypertextGetLinkIndex(AtkHypertext* hypertext, gint charIndex)
-{
-    size_t linksCount = webkitAccessibleHypertextGetNLinks(hypertext);
-    if (!linksCount)
-        return -1;
-
-    for (size_t i = 0; i < linksCount; i++) {
-        AtkHyperlink* hyperlink = ATK_HYPERLINK(webkitAccessibleHypertextGetLink(hypertext, i));
-        gint startIndex = atk_hyperlink_get_start_index(hyperlink);
-        gint endIndex = atk_hyperlink_get_end_index(hyperlink);
-
-        // Check if the char index in the link's offset range
-        if (startIndex <= charIndex && charIndex < endIndex)
-            return i;
-    }
-
-    // Not found if reached
-    return -1;
-}
-
-static void atkHypertextInterfaceInit(AtkHypertextIface* iface)
-{
-    iface->get_link = webkitAccessibleHypertextGetLink;
-    iface->get_n_links = webkitAccessibleHypertextGetNLinks;
-    iface->get_link_index = webkitAccessibleHypertextGetLinkIndex;
-}
-
 static void webkitAccessibleValueGetCurrentValue(AtkValue* value, GValue* gValue)
 {
     memset(gValue,  0, sizeof(GValue));
@@ -2205,8 +2130,7 @@
      (GInterfaceFinalizeFunc) 0, 0},
     {(GInterfaceInitFunc)atk_table_interface_init,
      (GInterfaceFinalizeFunc) 0, 0},
-    {(GInterfaceInitFunc)atkHypertextInterfaceInit,
-     (GInterfaceFinalizeFunc) 0, 0},
+    {reinterpret_cast<GInterfaceInitFunc>(webkitAccessibleHypertextInterfaceInit), 0, 0},
     {reinterpret_cast<GInterfaceInitFunc>(webkitAccessibleHyperlinkImplInterfaceInit), 0, 0},
     {reinterpret_cast<GInterfaceInitFunc>(webkitAccessibleDocumentInterfaceInit), 0, 0},
     {(GInterfaceInitFunc)atkValueInterfaceInit,
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to