AX: WebKit hanging when VoiceOver attempts to focus in on page
authorn_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Feb 2016 08:53:51 +0000 (08:53 +0000)
committern_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Feb 2016 08:53:51 +0000 (08:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153899
<rdar://problem/24506603>

Reviewed by Chris Fleizach.

Source/WebCore:

The VisiblePosition to CharacterOffset conversion will lead to an infinite loop if the
nextVisiblePostion call is returning the original VisiblePosition. Fixed it by breaking out
of the loop early in that situation.

Test: accessibility/text-marker/character-offset-visible-position-conversion-hang.html

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::characterOffsetFromVisiblePosition):

LayoutTests:

* accessibility/text-marker/character-offset-visible-position-conversion-hang-expected.txt: Added.
* accessibility/text-marker/character-offset-visible-position-conversion-hang.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196167 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/accessibility/text-marker/character-offset-visible-position-conversion-hang-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/text-marker/character-offset-visible-position-conversion-hang.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AXObjectCache.cpp

index deed41734a6b9b4907e391916934e9f6a8ccef29..8004e7e516ec952e16f3f983d29e70dd2df37711 100644 (file)
@@ -1,3 +1,14 @@
+2016-02-05  Nan Wang  <n_wang@apple.com>
+
+        AX: WebKit hanging when VoiceOver attempts to focus in on page
+        https://bugs.webkit.org/show_bug.cgi?id=153899
+        <rdar://problem/24506603>
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/text-marker/character-offset-visible-position-conversion-hang-expected.txt: Added.
+        * accessibility/text-marker/character-offset-visible-position-conversion-hang.html: Added.
+
 2016-02-04  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: InspectorTimelineAgent doesn't need to recompile functions because it now uses the sampling profiler
diff --git a/LayoutTests/accessibility/text-marker/character-offset-visible-position-conversion-hang-expected.txt b/LayoutTests/accessibility/text-marker/character-offset-visible-position-conversion-hang-expected.txt
new file mode 100644 (file)
index 0000000..8aaab77
--- /dev/null
@@ -0,0 +1,13 @@
+Text
+
+This tests that getting the end text marker of the page won't hang.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+request10005.pdf
diff --git a/LayoutTests/accessibility/text-marker/character-offset-visible-position-conversion-hang.html b/LayoutTests/accessibility/text-marker/character-offset-visible-position-conversion-hang.html
new file mode 100644 (file)
index 0000000..23fd681
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body id="body" onload="loadFunction()">
+
+<p id="text"><b>Text</b></p>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that getting the end text marker of the page won't hang.");
+    
+    if (window.accessibilityController) {
+        function loadFunction() {
+            var text = accessibilityController.accessibleElementById("text");
+            var endMarker = text.endTextMarker;
+        }
+    }
+
+</script>
+
+<div class="Apple-web-attachment-container" contenteditable="false" title="attachment.pdf" role="img">
+  <img class="Apple-web-attachment-icon" src="Attachment.tiff" style="display:none">
+  <canvas class="Apple-web-attachment-canvas" style="width: 126px; height: 79px;" width="100" height="100"></canvas>
+  <div class="Apple-web-attachment-printable-version"><div class="iconContainer">
+    <img src="Attachment.tiff" height="38.400000" width="38.400000"></div>
+    <div class="filenameContainer">request10005.pdf</div>
+  </div>
+</div>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
index 685797f6fd78781c12b38cf261c8ee641cd7ff94..decc47a528cf5bcfe5db0e6491ee87bfb4919211 100644 (file)
@@ -1,3 +1,20 @@
+2016-02-05  Nan Wang  <n_wang@apple.com>
+
+        AX: WebKit hanging when VoiceOver attempts to focus in on page
+        https://bugs.webkit.org/show_bug.cgi?id=153899
+        <rdar://problem/24506603>
+
+        Reviewed by Chris Fleizach.
+
+        The VisiblePosition to CharacterOffset conversion will lead to an infinite loop if the
+        nextVisiblePostion call is returning the original VisiblePosition. Fixed it by breaking out
+        of the loop early in that situation. 
+
+        Test: accessibility/text-marker/character-offset-visible-position-conversion-hang.html
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::characterOffsetFromVisiblePosition):
+
 2016-02-04  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: InspectorTimelineAgent doesn't need to recompile functions because it now uses the sampling profiler
index d430c02de893d37b0f63c7c6d21d18001aa12578..5a516ebd2b1ef67eb9ca8e85b265ba3cfc3a6431 100644 (file)
@@ -1753,9 +1753,15 @@ CharacterOffset AXObjectCache::characterOffsetFromVisiblePosition(AccessibilityO
     int characterOffset = 0;
     Position vpDeepPos = vp.deepEquivalent();
     
+    VisiblePosition previousVisiblePos;
     while (!vpDeepPos.isNull() && !deepPos.equals(vpDeepPos)) {
+        previousVisiblePos = vp;
         vp = obj->nextVisiblePosition(vp);
         vpDeepPos = vp.deepEquivalent();
+        // Sometimes nextVisiblePosition will give the same VisiblePostion,
+        // we break here to avoid infinite loop.
+        if (vpDeepPos.equals(previousVisiblePos.deepEquivalent()))
+            break;
         characterOffset++;
     }