[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 AtkEditableText interface,
containing the related code from WebKitAccessibleWrapperAtk.cpp.
* accessibility/gtk/WebKitAccessibleInterfaceEditableText.cpp: Added.
(core):
(webkitAccessibleEditableTextInterfaceInit):
(webkitAccessibleEditableTextSetRunAttributes):
(webkitAccessibleEditableTextSetTextContents):
(webkitAccessibleEditableTextInsertText):
(webkitAccessibleEditableTextCopyText):
(webkitAccessibleEditableTextCutText):
(webkitAccessibleEditableTextDeleteText):
(webkitAccessibleEditableTextPasteText):
* accessibility/gtk/WebKitAccessibleInterfaceEditableText.h: Added.
* accessibility/gtk/WebKitAccessibleWrapperAtk.cpp: Remove code
related to the implementation of the AtkEditableText interface.
Add new files to build files.
* GNUmakefile.list.am: Add WebKitAccessibleInterfaceEditableText.[h|cpp].
* WebCore.gypi: Ditto.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index adad5a9..76c66ac 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -5,6 +5,35 @@
Reviewed by Martin Robinson.
+ New files for the implementation of the AtkEditableText interface,
+ containing the related code from WebKitAccessibleWrapperAtk.cpp.
+
+ * accessibility/gtk/WebKitAccessibleInterfaceEditableText.cpp: Added.
+ (core):
+ (webkitAccessibleEditableTextInterfaceInit):
+ (webkitAccessibleEditableTextSetRunAttributes):
+ (webkitAccessibleEditableTextSetTextContents):
+ (webkitAccessibleEditableTextInsertText):
+ (webkitAccessibleEditableTextCopyText):
+ (webkitAccessibleEditableTextCutText):
+ (webkitAccessibleEditableTextDeleteText):
+ (webkitAccessibleEditableTextPasteText):
+ * accessibility/gtk/WebKitAccessibleInterfaceEditableText.h: Added.
+ * accessibility/gtk/WebKitAccessibleWrapperAtk.cpp: Remove code
+ related to the implementation of the AtkEditableText interface.
+
+ Add new files to build files.
+
+ * GNUmakefile.list.am: Add WebKitAccessibleInterfaceEditableText.[h|cpp].
+ * WebCore.gypi: Ditto.
+
+2012-01-24 Mario Sanchez Prada <msanchez@igalia.com>
+
+ [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 AtkDocument interface,
containing the related code from WebKitAccessibleWrapperAtk.cpp.
diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am
index 23e310a..5a285f1 100644
--- a/Source/WebCore/GNUmakefile.list.am
+++ b/Source/WebCore/GNUmakefile.list.am
@@ -4427,6 +4427,8 @@
Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceComponent.h \
Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceDocument.cpp \
Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceDocument.h \
+ Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceEditableText.cpp \
+ Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceEditableText.h \
Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.cpp \
Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.h \
Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp \
diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi
index ea04773..1247408 100644
--- a/Source/WebCore/WebCore.gypi
+++ b/Source/WebCore/WebCore.gypi
@@ -1351,6 +1351,8 @@
'accessibility/gtk/WebKitAccessibleInterfaceComponent.h',
'accessibility/gtk/WebKitAccessibleInterfaceDocument.cpp',
'accessibility/gtk/WebKitAccessibleInterfaceDocument.h',
+ 'accessibility/gtk/WebKitAccessibleInterfaceEditableText.cpp',
+ 'accessibility/gtk/WebKitAccessibleInterfaceEditableText.h',
'accessibility/gtk/WebKitAccessibleUtil.cpp',
'accessibility/gtk/WebKitAccessibleUtil.h',
'accessibility/gtk/WebKitAccessibleWrapperAtk.cpp',
diff --git a/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceEditableText.cpp b/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceEditableText.cpp
new file mode 100644
index 0000000..cc2620d
--- /dev/null
+++ b/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceEditableText.cpp
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2008 Nuanti Ltd.
+ * Copyright (C) 2009 Jan Alonzo
+ * Copyright (C) 2011, 2012 Igalia S.L.
+ *
+ * Portions from Mozilla a11y, copyright as follows:
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Sun Microsystems, Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2002
+ * the Initial Developer. All Rights Reserved.
+ *
+ * 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 "WebKitAccessibleInterfaceEditableText.h"
+
+#include "AccessibilityObject.h"
+#include "Document.h"
+#include "Frame.h"
+#include "NotImplemented.h"
+#include "WebKitAccessibleWrapperAtk.h"
+
+using namespace WebCore;
+
+static AccessibilityObject* core(AtkEditableText* text)
+{
+ if (!WEBKIT_IS_ACCESSIBLE(text))
+ return 0;
+
+ return webkitAccessibleGetAccessibilityObject(WEBKIT_ACCESSIBLE(text));
+}
+
+void webkitAccessibleEditableTextInterfaceInit(AtkEditableTextIface* iface)
+{
+ iface->set_run_attributes = webkitAccessibleEditableTextSetRunAttributes;
+ iface->set_text_contents = webkitAccessibleEditableTextSetTextContents;
+ iface->insert_text = webkitAccessibleEditableTextInsertText;
+ iface->copy_text = webkitAccessibleEditableTextCopyText;
+ iface->cut_text = webkitAccessibleEditableTextCutText;
+ iface->delete_text = webkitAccessibleEditableTextDeleteText;
+ iface->paste_text = webkitAccessibleEditableTextPasteText;
+}
+
+gboolean webkitAccessibleEditableTextSetRunAttributes(AtkEditableText*, AtkAttributeSet*, gint, gint)
+{
+ notImplemented();
+ return FALSE;
+}
+
+void webkitAccessibleEditableTextSetTextContents(AtkEditableText* text, const gchar* string)
+{
+ // FIXME: string nullcheck?
+ core(text)->setValue(String::fromUTF8(string));
+}
+
+void webkitAccessibleEditableTextInsertText(AtkEditableText* text, const gchar* string, gint length, gint* position)
+{
+ // FIXME: string nullcheck?
+
+ AccessibilityObject* coreObject = core(text);
+ // FIXME: Not implemented in WebCore
+ // coreObject->setSelectedTextRange(PlainTextRange(*position, 0));
+ // coreObject->setSelectedText(String::fromUTF8(string));
+
+ Document* document = coreObject->document();
+ if (!document || !document->frame())
+ return;
+
+ coreObject->setSelectedVisiblePositionRange(coreObject->visiblePositionRangeForRange(PlainTextRange(*position, 0)));
+ coreObject->setFocused(true);
+ // FIXME: We should set position to the actual inserted text length, which may be less than that requested.
+ if (document->frame()->editor()->insertTextWithoutSendingTextEvent(String::fromUTF8(string), false, 0))
+ *position += length;
+}
+
+void webkitAccessibleEditableTextCopyText(AtkEditableText*, gint, gint)
+{
+ notImplemented();
+}
+
+void webkitAccessibleEditableTextCutText(AtkEditableText*, gint, gint)
+{
+ notImplemented();
+}
+
+void webkitAccessibleEditableTextDeleteText(AtkEditableText* text, gint startPos, gint endPos)
+{
+ AccessibilityObject* coreObject = core(text);
+ // FIXME: Not implemented in WebCore
+ // coreObject->setSelectedTextRange(PlainTextRange(startPos, endPos - startPos));
+ // coreObject->setSelectedText(String());
+
+ Document* document = coreObject->document();
+ if (!document || !document->frame())
+ return;
+
+ coreObject->setSelectedVisiblePositionRange(coreObject->visiblePositionRangeForRange(PlainTextRange(startPos, endPos - startPos)));
+ coreObject->setFocused(true);
+ document->frame()->editor()->performDelete();
+}
+
+void webkitAccessibleEditableTextPasteText(AtkEditableText*, gint)
+{
+ notImplemented();
+}
diff --git a/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceEditableText.h b/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceEditableText.h
new file mode 100644
index 0000000..97d1265
--- /dev/null
+++ b/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceEditableText.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2008 Nuanti Ltd.
+ * Copyright (C) 2009 Jan Alonzo
+ * Copyright (C) 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 WebKitAccessibleInterfaceEditableText_h
+#define WebKitAccessibleInterfaceEditableText_h
+
+#include <atk/atk.h>
+
+void webkitAccessibleEditableTextInterfaceInit(AtkEditableTextIface*);
+gboolean webkitAccessibleEditableTextSetRunAttributes(AtkEditableText*, AtkAttributeSet*, gint startOffset, gint endOffset);
+void webkitAccessibleEditableTextSetTextContents(AtkEditableText*, const gchar*);
+void webkitAccessibleEditableTextInsertText(AtkEditableText*, const gchar*, gint length, gint* position);
+void webkitAccessibleEditableTextCopyText(AtkEditableText*, gint startPos, gint endPos);
+void webkitAccessibleEditableTextCutText(AtkEditableText*, gint startPos, gint endPos);
+void webkitAccessibleEditableTextDeleteText(AtkEditableText*, gint startPos, gint endPos);
+void webkitAccessibleEditableTextPasteText(AtkEditableText*, gint position);
+
+#endif // WebKitAccessibleInterfaceEditableText_h
diff --git a/Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp b/Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp
index fd05ed8..466fc36 100644
--- a/Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp
+++ b/Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp
@@ -66,6 +66,7 @@
#include "WebKitAccessibleInterfaceAction.h"
#include "WebKitAccessibleInterfaceComponent.h"
#include "WebKitAccessibleInterfaceDocument.h"
+#include "WebKitAccessibleInterfaceEditableText.h"
#include "WebKitAccessibleUtil.h"
#include "htmlediting.h"
#include "visible_units.h"
@@ -122,11 +123,6 @@
return core(ATK_OBJECT(text));
}
-static AccessibilityObject* core(AtkEditableText* text)
-{
- return core(ATK_OBJECT(text));
-}
-
static AccessibilityObject* core(AtkImage* image)
{
return core(ATK_OBJECT(image));
@@ -1846,82 +1842,6 @@
iface->set_caret_offset = webkit_accessible_text_set_caret_offset;
}
-// EditableText
-
-static gboolean webkit_accessible_editable_text_set_run_attributes(AtkEditableText* text, AtkAttributeSet* attrib_set, gint start_offset, gint end_offset)
-{
- notImplemented();
- return FALSE;
-}
-
-static void webkit_accessible_editable_text_set_text_contents(AtkEditableText* text, const gchar* string)
-{
- // FIXME: string nullcheck?
- core(text)->setValue(String::fromUTF8(string));
-}
-
-static void webkit_accessible_editable_text_insert_text(AtkEditableText* text, const gchar* string, gint length, gint* position)
-{
- // FIXME: string nullcheck?
-
- AccessibilityObject* coreObject = core(text);
- // FIXME: Not implemented in WebCore
- // coreObject->setSelectedTextRange(PlainTextRange(*position, 0));
- // coreObject->setSelectedText(String::fromUTF8(string));
-
- Document* document = coreObject->document();
- if (!document || !document->frame())
- return;
-
- coreObject->setSelectedVisiblePositionRange(coreObject->visiblePositionRangeForRange(PlainTextRange(*position, 0)));
- coreObject->setFocused(true);
- // FIXME: We should set position to the actual inserted text length, which may be less than that requested.
- if (document->frame()->editor()->insertTextWithoutSendingTextEvent(String::fromUTF8(string), false, 0))
- *position += length;
-}
-
-static void webkit_accessible_editable_text_copy_text(AtkEditableText* text, gint start_pos, gint end_pos)
-{
- notImplemented();
-}
-
-static void webkit_accessible_editable_text_cut_text(AtkEditableText* text, gint start_pos, gint end_pos)
-{
- notImplemented();
-}
-
-static void webkit_accessible_editable_text_delete_text(AtkEditableText* text, gint start_pos, gint end_pos)
-{
- AccessibilityObject* coreObject = core(text);
- // FIXME: Not implemented in WebCore
- // coreObject->setSelectedTextRange(PlainTextRange(start_pos, end_pos - start_pos));
- // coreObject->setSelectedText(String());
-
- Document* document = coreObject->document();
- if (!document || !document->frame())
- return;
-
- coreObject->setSelectedVisiblePositionRange(coreObject->visiblePositionRangeForRange(PlainTextRange(start_pos, end_pos - start_pos)));
- coreObject->setFocused(true);
- document->frame()->editor()->performDelete();
-}
-
-static void webkit_accessible_editable_text_paste_text(AtkEditableText* text, gint position)
-{
- notImplemented();
-}
-
-static void atk_editable_text_interface_init(AtkEditableTextIface* iface)
-{
- iface->set_run_attributes = webkit_accessible_editable_text_set_run_attributes;
- iface->set_text_contents = webkit_accessible_editable_text_set_text_contents;
- iface->insert_text = webkit_accessible_editable_text_insert_text;
- iface->copy_text = webkit_accessible_editable_text_copy_text;
- iface->cut_text = webkit_accessible_editable_text_cut_text;
- iface->delete_text = webkit_accessible_editable_text_delete_text;
- iface->paste_text = webkit_accessible_editable_text_paste_text;
-}
-
// Image
static void webkit_accessible_image_get_image_position(AtkImage* image, gint* x, gint* y, AtkCoordType coordType)
@@ -2295,8 +2215,7 @@
{reinterpret_cast<GInterfaceInitFunc>(webkitAccessibleActionInterfaceInit), 0, 0},
{(GInterfaceInitFunc)atk_selection_interface_init,
(GInterfaceFinalizeFunc) 0, 0},
- {(GInterfaceInitFunc)atk_editable_text_interface_init,
- (GInterfaceFinalizeFunc) 0, 0},
+ {reinterpret_cast<GInterfaceInitFunc>(webkitAccessibleEditableTextInterfaceInit), 0, 0},
{(GInterfaceInitFunc)atk_text_interface_init,
(GInterfaceFinalizeFunc) 0, 0},
{reinterpret_cast<GInterfaceInitFunc>(webkitAccessibleComponentInterfaceInit), 0, 0},