[orca] Fix for bug #630328 - Orca provides no access to WebKitGtk content whatsoever. Nada. Zilch.



commit 4c7e023e7ebf30efcad4049d60cf0f4e1ad6a36d
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Fri Sep 3 10:40:18 2010 -0400

    Fix for bug #630328 - Orca provides no access to WebKitGtk content whatsoever. Nada. Zilch.
    
    Note: We are just now starting work on WebKitGtk and Epiphany scripts
    in Orca. There will be tons more work that needs to be done. You
    should not assume that this commit means we're done or that we are
    not aware of remaining issues. Patience is a virtue. Remember to floss.
    Have a nice day.

 configure.in                                       |    2 +
 po/POTFILES.in                                     |    2 +
 src/orca/scripts/apps/Makefile.am                  |    1 +
 src/orca/scripts/apps/epiphany/Makefile.am         |    7 +
 src/orca/scripts/apps/epiphany/__init__.py         |   20 +++
 src/orca/scripts/apps/epiphany/script.py           |   70 +++++++++
 src/orca/scripts/toolkits/Makefile.am              |    2 +-
 src/orca/scripts/toolkits/WebKitGtk/Makefile.am    |   11 ++
 src/orca/scripts/toolkits/WebKitGtk/__init__.py    |    1 +
 src/orca/scripts/toolkits/WebKitGtk/script.py      |  163 ++++++++++++++++++++
 .../toolkits/WebKitGtk/structural_navigation.py    |   62 ++++++++
 test/harness/runone.sh                             |   17 ++
 test/html/EpiphanyProfile/bookmarks.rdf            |   38 +++++
 test/html/EpiphanyProfile/states.xml               |   27 ++++
 14 files changed, 422 insertions(+), 1 deletions(-)
---
diff --git a/configure.in b/configure.in
index 2f0e1f7..e9eaf0a 100644
--- a/configure.in
+++ b/configure.in
@@ -93,6 +93,7 @@ src/orca/scripts/apps/ddu/Makefile
 src/orca/scripts/apps/Eclipse/Makefile
 src/orca/scripts/apps/ekiga/Makefile
 src/orca/scripts/apps/empathy/Makefile
+src/orca/scripts/apps/epiphany/Makefile
 src/orca/scripts/apps/evolution/Makefile
 src/orca/scripts/apps/gajim/Makefile
 src/orca/scripts/apps/gcalctool/Makefile
@@ -126,6 +127,7 @@ src/orca/scripts/toolkits/Makefile
 src/orca/scripts/toolkits/Gecko/Makefile
 src/orca/scripts/toolkits/J2SE-access-bridge/Makefile
 src/orca/scripts/toolkits/CALLY/Makefile
+src/orca/scripts/toolkits/WebKitGtk/Makefile
 src/orca/orca
 src/orca/orca_i18n.py
 src/orca/orca_platform.py
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6248cce..196c969 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -65,6 +65,8 @@ src/orca/scripts/toolkits/Gecko/bookmarks.py
 src/orca/scripts/toolkits/Gecko/braille_generator.py
 src/orca/scripts/toolkits/Gecko/script.py
 src/orca/scripts/toolkits/Gecko/speech_generator.py
+src/orca/scripts/toolkits/WebKitGtk/braille_generator.py
+src/orca/scripts/toolkits/WebKitGtk/speech_generator.py
 src/orca/settings.py
 src/orca/speechdispatcherfactory.py
 src/orca/speech_generator.py
diff --git a/src/orca/scripts/apps/Makefile.am b/src/orca/scripts/apps/Makefile.am
index 1b9c86f..d5b01cf 100644
--- a/src/orca/scripts/apps/Makefile.am
+++ b/src/orca/scripts/apps/Makefile.am
@@ -5,6 +5,7 @@ SUBDIRS = \
 	Eclipse \
 	ekiga \
 	empathy \
+	epiphany \
 	evolution \
 	gajim \
 	gcalctool \
diff --git a/src/orca/scripts/apps/epiphany/Makefile.am b/src/orca/scripts/apps/epiphany/Makefile.am
new file mode 100644
index 0000000..3b781de
--- /dev/null
+++ b/src/orca/scripts/apps/epiphany/Makefile.am
@@ -0,0 +1,7 @@
+orca_pathdir=$(pyexecdir)
+
+orca_python_PYTHON = \
+	__init__.py \
+	script.py
+
+orca_pythondir=$(pyexecdir)/orca/scripts/apps/epiphany
\ No newline at end of file
diff --git a/src/orca/scripts/apps/epiphany/__init__.py b/src/orca/scripts/apps/epiphany/__init__.py
new file mode 100644
index 0000000..c81df83
--- /dev/null
+++ b/src/orca/scripts/apps/epiphany/__init__.py
@@ -0,0 +1,20 @@
+# Orca
+#
+# Copyright 2010 Joanmarie Diggs
+#
+# 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; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA  02110-1301 USA.
+
+from script import Script
diff --git a/src/orca/scripts/apps/epiphany/script.py b/src/orca/scripts/apps/epiphany/script.py
new file mode 100644
index 0000000..6f771f5
--- /dev/null
+++ b/src/orca/scripts/apps/epiphany/script.py
@@ -0,0 +1,70 @@
+# Orca
+#
+# Copyright 2010 Joanmarie Diggs.
+#
+# 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; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA  02110-1301 USA.
+
+"""Custom script for Epiphany."""
+
+__id__        = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2010 Joanmarie Diggs."
+__license__   = "LGPL"
+
+import orca.scripts.toolkits.WebKitGtk as WebKitGtk
+
+from orca.structural_navigation import StructuralNavigation
+
+########################################################################
+#                                                                      #
+# The Epiphany script class.                                           #
+#                                                                      #
+########################################################################
+
+class Script(WebKitGtk.Script):
+
+    def __init__(self, app):
+        """Creates a new script for the given application."""
+
+        WebKitGtk.Script.__init__(self, app)
+
+    def getEnabledStructuralNavigationTypes(self):
+        """Returns a list of the structural navigation object types
+        enabled in this script."""
+
+        enabledTypes = [StructuralNavigation.ANCHOR,
+                        StructuralNavigation.BLOCKQUOTE,
+                        StructuralNavigation.BUTTON,
+                        StructuralNavigation.CHECK_BOX,
+                        StructuralNavigation.CHUNK,
+                        StructuralNavigation.COMBO_BOX,
+                        StructuralNavigation.ENTRY,
+                        StructuralNavigation.FORM_FIELD,
+                        StructuralNavigation.HEADING,
+                        StructuralNavigation.LANDMARK,
+                        StructuralNavigation.LIST,
+                        StructuralNavigation.LIST_ITEM,
+                        StructuralNavigation.LIVE_REGION,
+                        StructuralNavigation.PARAGRAPH,
+                        StructuralNavigation.RADIO_BUTTON,
+                        StructuralNavigation.SEPARATOR,
+                        StructuralNavigation.TABLE,
+                        StructuralNavigation.TABLE_CELL,
+                        StructuralNavigation.UNVISITED_LINK,
+                        StructuralNavigation.VISITED_LINK]
+
+        return enabledTypes
diff --git a/src/orca/scripts/toolkits/Makefile.am b/src/orca/scripts/toolkits/Makefile.am
index f1916e8..5d30819 100644
--- a/src/orca/scripts/toolkits/Makefile.am
+++ b/src/orca/scripts/toolkits/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = Gecko J2SE-access-bridge CALLY
+SUBDIRS = Gecko J2SE-access-bridge CALLY WebKitGtk
 
 orca_pathdir=$(pyexecdir)
 
diff --git a/src/orca/scripts/toolkits/WebKitGtk/Makefile.am b/src/orca/scripts/toolkits/WebKitGtk/Makefile.am
new file mode 100644
index 0000000..308fda1
--- /dev/null
+++ b/src/orca/scripts/toolkits/WebKitGtk/Makefile.am
@@ -0,0 +1,11 @@
+orca_pathdir=$(pyexecdir)
+
+orca_python_PYTHON = \
+	__init__.py \
+	braille_generator.py \
+	script.py \
+	speech_generator.py \
+	script_utilities.py \
+	structural_navigation.py
+
+orca_pythondir=$(pyexecdir)/orca/scripts/toolkits/WebKitGtk
\ No newline at end of file
diff --git a/src/orca/scripts/toolkits/WebKitGtk/__init__.py b/src/orca/scripts/toolkits/WebKitGtk/__init__.py
new file mode 100644
index 0000000..1d50af9
--- /dev/null
+++ b/src/orca/scripts/toolkits/WebKitGtk/__init__.py
@@ -0,0 +1 @@
+from script import Script
diff --git a/src/orca/scripts/toolkits/WebKitGtk/script.py b/src/orca/scripts/toolkits/WebKitGtk/script.py
new file mode 100644
index 0000000..57d5fa7
--- /dev/null
+++ b/src/orca/scripts/toolkits/WebKitGtk/script.py
@@ -0,0 +1,163 @@
+# Orca
+#
+# Copyright (C) 2010 Joanmarie Diggs
+#
+# Author: Joanmarie Diggs <joanied gnome org>
+#
+# 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; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA  02110-1301 USA.
+
+__id__        = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2010 Joanmarie Diggs"
+__license__   = "LGPL"
+
+import pyatspi
+
+import orca.default as default
+import orca.orca as orca
+import orca.orca_state as orca_state
+import orca.speech as speech
+
+from structural_navigation import StructuralNavigation
+from braille_generator import BrailleGenerator
+from speech_generator import SpeechGenerator
+from script_utilities import Utilities
+
+########################################################################
+#                                                                      #
+# The WebKitGtk script class.                                          #
+#                                                                      #
+########################################################################
+
+class Script(default.Script):
+
+    def __init__(self, app):
+        """Creates a new script for WebKitGtk applications.
+
+        Arguments:
+        - app: the application to create a script for.
+        """
+
+        default.Script.__init__(self, app)
+
+    def setupInputEventHandlers(self):
+        """Defines InputEventHandler fields for this script that can be
+        called by the key and braille bindings."""
+
+        default.Script.setupInputEventHandlers(self)
+        self.inputEventHandlers.update(
+            self.structuralNavigation.inputEventHandlers)
+
+    def getKeyBindings(self):
+        """Defines the key bindings for this script. Setup the default
+        key bindings, then add one in for reading the input line.
+
+        Returns an instance of keybindings.KeyBindings.
+        """
+
+        keyBindings = default.Script.getKeyBindings(self)
+        bindings = self.structuralNavigation.keyBindings
+        for keyBinding in bindings.keyBindings:
+            keyBindings.add(keyBinding)
+
+        return keyBindings
+
+    def getBrailleGenerator(self):
+        """Returns the braille generator for this script."""
+
+        return BrailleGenerator(self)
+
+    def getSpeechGenerator(self):
+        """Returns the speech generator for this script."""
+
+        return SpeechGenerator(self)
+
+    def getStructuralNavigation(self):
+        """Returns the 'structural navigation' class for this script."""
+
+        types = self.getEnabledStructuralNavigationTypes()
+        return StructuralNavigation(self, types, True)
+
+    def getUtilities(self):
+        """Returns the utilites for this script."""
+
+        return Utilities(self)
+
+    def onCaretMoved(self, event):
+        """Called whenever the caret moves.
+
+        Arguments:
+        - event: the Event
+        """
+
+        orca.setLocusOfFocus(event, event.source, False)
+        default.Script.onCaretMoved(self, event)
+
+    def onTextSelectionChanged(self, event):
+        """Called when an object's text selection changes.
+
+        Arguments:
+        - event: the Event
+        """
+
+        # The default script's method attempts to handle various and sundry
+        # complications that simply do not apply here.
+        #
+        spokenRange = self.pointOfReference.get("spokenTextRange") or [0, 0]
+        startOffset, endOffset = spokenRange
+
+        self.speakTextSelectionState(event.source, startOffset, endOffset)
+
+    def sayCharacter(self, obj):
+        """Speak the character at the caret.
+
+        Arguments:
+        - obj: an Accessible object that implements the AccessibleText
+          interface
+        """
+
+        if obj.getRole() == pyatspi.ROLE_SEPARATOR:
+            speech.speak(self.speechGenerator.generateSpeech(obj))
+            return
+
+        default.Script.sayCharacter(self, obj)
+
+    def useStructuralNavigationModel(self):
+        """Returns True if we should do our own structural navigation.
+        This should return False if we're in a form field, or not in
+        document content.
+        """
+
+        doNotHandleRoles = [pyatspi.ROLE_ENTRY,
+                            pyatspi.ROLE_TEXT,
+                            pyatspi.ROLE_PASSWORD_TEXT,
+                            pyatspi.ROLE_LIST,
+                            pyatspi.ROLE_LIST_ITEM,
+                            pyatspi.ROLE_MENU_ITEM]
+
+        if not self.structuralNavigation.enabled:
+            return False
+
+        if not self.utilities.isWebKitGtk(orca_state.locusOfFocus):
+            return False
+
+        if orca_state.locusOfFocus.getRole() in doNotHandleRoles:
+            states = orca_state.locusOfFocus.getState()
+            if states.contains(pyatspi.STATE_FOCUSED):
+                return False
+
+        return True
diff --git a/src/orca/scripts/toolkits/WebKitGtk/structural_navigation.py b/src/orca/scripts/toolkits/WebKitGtk/structural_navigation.py
new file mode 100644
index 0000000..77ca6d5
--- /dev/null
+++ b/src/orca/scripts/toolkits/WebKitGtk/structural_navigation.py
@@ -0,0 +1,62 @@
+# Orca
+#
+# Copyright (C) 2010 Joanmarie Diggs
+#
+# Author: Joanmarie Diggs <joanied gnome org>
+#
+# 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; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA  02110-1301 USA.
+
+__id__        = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2010 Joanmarie Diggs"
+__license__   = "LGPL"
+
+import pyatspi
+
+import orca.structural_navigation as structural_navigation
+
+########################################################################
+#                                                                      #
+# Custom Structural Navigation                                         #
+#                                                                      #
+########################################################################
+
+class StructuralNavigation(structural_navigation.StructuralNavigation):
+
+    def __init__(self, script, enabledTypes, enabled):
+        """WebKitGtk specific Structural Navigation."""
+
+        structural_navigation.StructuralNavigation.__init__(self,
+                                                            script,
+                                                            enabledTypes,
+                                                            enabled)
+        self.collectionEnabled = False
+
+    def _getCaretPosition(self, obj):
+        """Returns the [obj, characterOffset] where the caret should be
+        positioned. For most scripts, the object should not change and
+        the offset should be 0.
+
+        Arguments:
+        - obj: the accessible object in which the caret should be
+          positioned.
+        """
+
+        if obj.getRole() == pyatspi.ROLE_LIST and obj.childCount:
+            obj = obj[0]
+
+        return [obj, 0]
diff --git a/test/harness/runone.sh b/test/harness/runone.sh
index 1237aea..f7be6f0 100755
--- a/test/harness/runone.sh
+++ b/test/harness/runone.sh
@@ -131,6 +131,17 @@ then
     ARGS="-profile $FF_PROFILE_DIR"
 fi
 
+# Consistent profile for testing Epiphany.
+#
+if [ "$APP_NAME" = "epiphany" ]
+then
+    EWB_PROFILE_DIR=/tmp/EpiphanyProfile
+    mkdir -p $EWB_PROFILE_DIR
+    cp $harnessDir/../html/EpiphanyProfile/bookmarks.rdf $EWB_PROFILE_DIR
+    cp $harnessDir/../html/EpiphanyProfile/states.xml $EWB_PROFILE_DIR
+    ARGS="-p --profile=$EWB_PROFILE_DIR"
+fi
+
 if [ $orcaRunning -eq 0 ]
 then
     # Run orca and let it settle in.
@@ -178,6 +189,12 @@ then
     APP_PID=$(ps -eo pid,ruid,args | grep norestore | grep -v grep | awk '{ print $1 }')
 fi
 
+if [ "$APP_NAME" == "epiphany" ]
+then
+    pkill epiphany > /dev/null 2>&1
+    rm -rf $EWB_PROFILE_DIR
+fi
+
 if [ "$APP_NAME" == "firefox" ]
 then
     #echo killing firefox
diff --git a/test/html/EpiphanyProfile/bookmarks.rdf b/test/html/EpiphanyProfile/bookmarks.rdf
new file mode 100644
index 0000000..a94bd00
--- /dev/null
+++ b/test/html/EpiphanyProfile/bookmarks.rdf
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<rdf:RDF xmlns="http://purl.org/rss/1.0/"; xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:ephy="http://gnome.org/ns/epiphany#"; xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
+  <channel rdf:about="file:///home/jd/orca/test/html/EpiphanyProfile/bookmarks.rdf">
+    <title>Epiphany bookmarks</title>
+    <link>http://www.gnome.org/projects/epiphany/</link>
+    <items>
+      <rdf:Seq>
+        <rdf:li rdf:resource="http://www.google.com"/>
+        <rdf:li rdf:resource="http://www.debian.org/"/>
+        <rdf:li rdf:resource="http://www.gnome.org/"/>
+        <rdf:li rdf:resource="http://planet.debian.org/"/>
+        <rdf:li rdf:resource="http://bugs.debian.org"/>
+      </rdf:Seq>
+    </items>
+  </channel>
+  <item rdf:about="http://www.google.com";>
+    <title>Search the web</title>
+    <link>http://www.google.com</link>
+    <ephy:smartlink>http://www.google.com/search?client=ubuntu&amp;channel=es&amp;q=%s&amp;ie=UTF-8&amp;oe=UTF-8</ephy:smartlink>
+  </item>
+  <item rdf:about="http://www.debian.org/";>
+    <title>Debian</title>
+    <link>http://www.debian.org/</link>
+  </item>
+  <item rdf:about="http://www.gnome.org/";>
+    <title>GNOME</title>
+    <link>http://www.gnome.org/</link>
+  </item>
+  <item rdf:about="http://planet.debian.org/";>
+    <title>Planet Debian</title>
+    <link>http://planet.debian.org/</link>
+  </item>
+  <item rdf:about="http://bugs.debian.org";>
+    <title>Debian Bug Tracking System</title>
+    <link>http://bugs.debian.org</link>
+    <ephy:smartlink>http://bugs.debian.org/%s</ephy:smartlink>
+  </item>
+</rdf:RDF>
diff --git a/test/html/EpiphanyProfile/states.xml b/test/html/EpiphanyProfile/states.xml
new file mode 100644
index 0000000..a8d40e7
--- /dev/null
+++ b/test/html/EpiphanyProfile/states.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<ephy_states version="1.0">
+  <node id="30">
+    <property id="2" value_type="gchararray">main_window</property>
+    <property id="3" value_type="gint">994</property>
+    <property id="4" value_type="gint">687</property>
+    <property id="5" value_type="gboolean">0</property>
+    <property id="8" value_type="gboolean">1</property>
+    <parent id="4"/>
+  </node>
+  <node id="31">
+    <property id="2" value_type="gchararray">prefs_dialog</property>
+    <property id="3" value_type="gint">388</property>
+    <property id="4" value_type="gint">489</property>
+    <property id="5" value_type="gboolean">0</property>
+    <property id="8" value_type="gboolean">1</property>
+    <parent id="4"/>
+  </node>
+  <node id="32">
+    <property id="2" value_type="gchararray">add_language_dialog</property>
+    <property id="3" value_type="gint">491</property>
+    <property id="4" value_type="gint">230</property>
+    <property id="5" value_type="gboolean">0</property>
+    <property id="8" value_type="gboolean">1</property>
+    <parent id="4"/>
+  </node>
+</ephy_states>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]