[orca] Fix for bug 584540 - Orca should not duplicate images and lines of text on facebook
- From: Joanmarie Diggs <joanied src gnome org>
- To: svn-commits-list gnome org
- Subject: [orca] Fix for bug 584540 - Orca should not duplicate images and lines of text on facebook
- Date: Mon, 13 Jul 2009 17:20:15 +0000 (UTC)
commit fbd362f0c2b72dc21dd57dd79628984d070b7345
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date: Sun Jul 12 13:00:52 2009 -0400
Fix for bug 584540 - Orca should not duplicate images and lines of text on facebook
Arguably, Facebook should not duplicate images and expect screen readers to
filter out their extraneous garbage. But who am I to judge? :-)
src/orca/scripts/toolkits/Gecko/script.py | 45 +++++++++++++++++++++-
test/html/images-in-links.html | 3 +
test/keystrokes/firefox/images_in_links.py | 59 +++++++++++++++++++++------
3 files changed, 93 insertions(+), 14 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index fbc3df5..2721544 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -3432,7 +3432,50 @@ class Script(default.Script):
[pyatspi.ROLE_LINK],
[pyatspi.ROLE_DOCUMENT_FRAME])
if link:
- useless = False
+ if obj.getRole() == pyatspi.ROLE_IMAGE:
+ # If this object had alternative text and/or a title,
+ # we wouldn't be here. We need to determine if this
+ # image is indeed worth presenting and not a duplicate
+ # piece of information. See Facebook's timeline and/or
+ # bug 584540.
+ #
+ for child in obj.parent:
+ if self.getDisplayedText(child):
+ # Some other sibling is presenting information.
+ # We'll treat this image as useless.
+ #
+ break
+ else:
+ # No other siblings are presenting information.
+ #
+ if obj.parent.getRole() == pyatspi.ROLE_LINK:
+ if not link.name:
+ # If no siblings are presenting information,
+ # but the link had a name, then we'd know we
+ # had text along with the image(s). Given the
+ # lack of name, we'll treat the first image as
+ # the useful one and ignore the rest.
+ #
+ useless = obj.getIndexInParent() > 0
+ else:
+ # The image must be in a paragraph or section or
+ # heading or something else that might result in
+ # it being on its own line.
+ #
+ textObj = self.queryNonEmptyText(obj.parent)
+ if textObj:
+ text = textObj.getText(0, -1).decode("UTF-8")
+ text = text.replace(\
+ self.EMBEDDED_OBJECT_CHARACTER, "").strip()
+ if not text:
+ # There's no other text on this line inside
+ # of this link. We don't want to skip over
+ # this line, so we'll treat the first image
+ # as useful.
+ #
+ useless = obj.getIndexInParent() > 0
+ else:
+ useless = False
return useless
diff --git a/test/html/images-in-links.html b/test/html/images-in-links.html
index da3f42c..3801295 100644
--- a/test/html/images-in-links.html
+++ b/test/html/images-in-links.html
@@ -30,5 +30,8 @@ Two "useless" images along with some text in a link: <a href="foo"><img src=orca
<p>
Two "useless" images in a paragraph that is inside of a link along with text that is not in the paragraph: <a href="foo">Before the paragraph<p><img src=orca-for-tests.jpg /><img src=orca-for-tests.jpg /></p>After the paragraph</a>
</p>
+<p>
+Two "useless" images and some additional text in a paragraph that is inside of a link along with text that is not in the paragraph: <a href="foo">Before the paragraph<p><img src=orca-for-tests.jpg />silly link<img src=orca-for-tests.jpg /></p>After the paragraph</a>
+</p>
</body>
</html>
diff --git a/test/keystrokes/firefox/images_in_links.py b/test/keystrokes/firefox/images_in_links.py
index 9ec0df6..fb71698 100644
--- a/test/keystrokes/firefox/images_in_links.py
+++ b/test/keystrokes/firefox/images_in_links.py
@@ -72,7 +72,7 @@ sequence.append(utils.AssertPresentationAction(
"4. line Down",
["BRAILLE LINE: 'Two \"useless\" images in a link: foo Image foo Image'",
" VISIBLE: 'Two \"useless\" images in a link: ', cursor=1",
- "SPEECH OUTPUT: 'Two \"useless\" images in a link: foo link image foo link image'"]))
+ "SPEECH OUTPUT: 'Two \"useless\" images in a link: foo link image'"]))
sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
@@ -80,7 +80,7 @@ sequence.append(utils.AssertPresentationAction(
"5. line Down",
["BRAILLE LINE: 'Two \"useless\" images in a paragraph that is inside of a link: foo Image foo Image'",
" VISIBLE: 'Two \"useless\" images in a paragr', cursor=1",
- "SPEECH OUTPUT: 'Two \"useless\" images in a paragraph that is inside of a link: foo link image foo link image'"]))
+ "SPEECH OUTPUT: 'Two \"useless\" images in a paragraph that is inside of a link: foo link image"]))
sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
@@ -88,7 +88,7 @@ sequence.append(utils.AssertPresentationAction(
"6. line Down",
["BRAILLE LINE: 'One \"useless\" image and one \"useful\" image in a link: Orca logo Image foo Image'",
" VISIBLE: 'One \"useless\" image and one \"use', cursor=1",
- "SPEECH OUTPUT: 'One \"useless\" image and one \"useful\" image in a link: Orca logo link image foo link image'"]))
+ "SPEECH OUTPUT: 'One \"useless\" image and one \"useful\" image in a link: Orca logo link image"]))
sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
@@ -96,7 +96,7 @@ sequence.append(utils.AssertPresentationAction(
"7. line Down",
["BRAILLE LINE: 'Two \"useless\" images along with some text in a link: foo Image silly link foo Image'",
" VISIBLE: 'Two \"useless\" images along with ', cursor=1",
- "SPEECH OUTPUT: 'Two \"useless\" images along with some text in a link: foo link image silly link link image foo link image'"]))
+ "SPEECH OUTPUT: 'Two \"useless\" images along with some text in a link: silly link link image'"]))
sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
@@ -110,9 +110,9 @@ sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
"9. line Down",
- ["BRAILLE LINE: 'foo Image foo Image'",
- " VISIBLE: 'foo Image foo Image', cursor=1",
- "SPEECH OUTPUT: 'foo link image foo link image'"]))
+ ["BRAILLE LINE: 'foo Image'",
+ " VISIBLE: 'foo Image', cursor=1",
+ "SPEECH OUTPUT: 'foo link image'"]))
sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
@@ -122,12 +122,45 @@ sequence.append(utils.AssertPresentationAction(
" VISIBLE: 'After the paragraph', cursor=1",
"SPEECH OUTPUT: 'After the paragraph link'"]))
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Down"))
+sequence.append(utils.AssertPresentationAction(
+ "11. line Down",
+ ["BRAILLE LINE: 'Two \"useless\" images and some additional text in a paragraph that is inside of a link along with text that is not in the paragraph: Before the paragraph'",
+ " VISIBLE: 'Two \"useless\" images and some ad', cursor=1",
+ "SPEECH OUTPUT: 'Two \"useless\" images and some additional text in a paragraph that is inside of a link along with text that is not in the paragraph: Before the paragraph link'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Down"))
+sequence.append(utils.AssertPresentationAction(
+ "12. line Down",
+ ["BRAILLE LINE: 'silly link foo Image'",
+ " VISIBLE: 'silly link foo Image', cursor=1",
+ "SPEECH OUTPUT: 'silly link'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Down"))
+sequence.append(utils.AssertPresentationAction(
+ "13. line Down",
+ ["BRAILLE LINE: 'After the paragraph'",
+ " VISIBLE: 'After the paragraph', cursor=1",
+ "SPEECH OUTPUT: 'After the paragraph link'"]))
+
########################################################################
# Shift+Tab to give focus to each link.
#
sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("<Shift>Tab"))
sequence.append(utils.AssertPresentationAction(
+ "0. Shift+Tab",
+ ["BUG? - We're missing a space between the two parts of the link in the speech output",
+ "BRAILLE LINE: 'Two \"useless\" images in a paragraph that is inside of a link along with text that is not in the paragraph: Before the paragraph'",
+ " VISIBLE: 'Before the paragraph', cursor=1",
+ "SPEECH OUTPUT: 'Before the paragraphAfter the paragraph link'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("<Shift>Tab"))
+sequence.append(utils.AssertPresentationAction(
"1. Shift+Tab",
["BRAILLE LINE: 'foo Image'",
" VISIBLE: 'foo Image', cursor=1",
@@ -137,24 +170,24 @@ sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("<Shift>Tab"))
sequence.append(utils.AssertPresentationAction(
"2. Shift+Tab",
- ["BRAILLE LINE: 'Orca logo Image foo Image'",
- " VISIBLE: 'Orca logo Image foo Image', cursor=1",
+ ["BRAILLE LINE: 'Orca logo Image'",
+ " VISIBLE: 'Orca logo Image', cursor=1",
"SPEECH OUTPUT: 'Orca logo link image'"]))
sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("<Shift>Tab"))
sequence.append(utils.AssertPresentationAction(
"3. Shift+Tab",
- ["BRAILLE LINE: 'foo Image foo Image'",
- " VISIBLE: 'foo Image foo Image', cursor=1",
+ ["BRAILLE LINE: 'foo Image'",
+ " VISIBLE: 'foo Image', cursor=1",
"SPEECH OUTPUT: 'foo link'"]))
sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("<Shift>Tab"))
sequence.append(utils.AssertPresentationAction(
"4. Shift+Tab",
- ["BRAILLE LINE: 'foo Image foo Image'",
- " VISIBLE: 'foo Image foo Image', cursor=1",
+ ["BRAILLE LINE: 'foo Image'",
+ " VISIBLE: 'foo Image', cursor=1",
"SPEECH OUTPUT: 'foo link image'"]))
sequence.append(utils.StartRecordingAction())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]