in page anchor and keyboard navigation
authormario@webkit.org <mario@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Apr 2012 10:28:26 +0000 (10:28 +0000)
committermario@webkit.org <mario@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Apr 2012 10:28:26 +0000 (10:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=17450

Reviewed by Chris Fleizach.

Source/WebCore:

Ensure that the position of the caret and the focused element
get updated when following an anchor link.

The implementation is moved from platform specific files out to
AXObjectCache.cpp since it should be a cross-platform valid
solution. However, the new code is currently activated for the Mac
and GTK ports only, since the windows and chromium ports provide
their own specific code, and removing it now might break things.

Test: accessibility/anchor-link-selection-and-focus.html

* accessibility/AXObjectCache.cpp:
(WebCore):
(WebCore::AXObjectCache::handleScrolledToAnchor): Cross-platform
implementation of the fix, only activated for Mac and GTK for now.
* accessibility/gtk/AXObjectCacheAtk.cpp: Removed the GTK-specific
implementation of WebCore::AXObjectCache::handleScrolledToAnchor.
* accessibility/mac/AXObjectCacheMac.mm: Removed the Mac-specific
implementation of WebCore::AXObjectCache::handleScrolledToAnchor.

LayoutTests:

Added new test and expectations.

* accessibility/anchor-link-selection-and-focus-expected.txt: Added.
* accessibility/anchor-link-selection-and-focus.html: Added.
* platform/gtk/accessibility/anchor-link-selection-and-focus-expected.txt: Added.
* platform/chromium/test_expectations.txt: Skipped test for chromium.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/anchor-link-selection-and-focus-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/anchor-link-selection-and-focus.html [new file with mode: 0644]
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/gtk/accessibility/anchor-link-selection-and-focus-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AXObjectCache.cpp
Source/WebCore/accessibility/gtk/AXObjectCacheAtk.cpp
Source/WebCore/accessibility/mac/AXObjectCacheMac.mm

index f927427..7bc0cd6 100644 (file)
@@ -1,3 +1,17 @@
+2012-04-02  Mario Sanchez Prada  <msanchez@igalia.com>
+
+        in page anchor and keyboard navigation
+        https://bugs.webkit.org/show_bug.cgi?id=17450
+
+        Reviewed by Chris Fleizach.
+
+        Added new test and expectations.
+
+        * accessibility/anchor-link-selection-and-focus-expected.txt: Added.
+        * accessibility/anchor-link-selection-and-focus.html: Added.
+        * platform/gtk/accessibility/anchor-link-selection-and-focus-expected.txt: Added.
+        * platform/chromium/test_expectations.txt: Skipped test for chromium.
+
 2012-04-02  Philippe Normand  <pnormand@igalia.com>
 
         Unreviewed, skipping 2 crashing svg tests in GTK.
diff --git a/LayoutTests/accessibility/anchor-link-selection-and-focus-expected.txt b/LayoutTests/accessibility/anchor-link-selection-and-focus-expected.txt
new file mode 100644 (file)
index 0000000..fc52077
--- /dev/null
@@ -0,0 +1,19 @@
+A link pointing to an anchor at the end of the document
+
+A paragraph with a some text in the middle
+
+The Anchor
+
+This tests that the caret position is properly updated when following anchor links.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+axLink.role is: 'AXRole: AXLink'
+axAnchor.role is: 'AXRole: AXLink'
+PASS axLink.isFocused is true
+PASS axAnchor.isFocused is false
+PASS getSelection().anchorNode.nodeValue is 'The Anchor'
+PASS axLink.isFocused is false
+PASS axAnchor.isFocused is true
+
diff --git a/LayoutTests/accessibility/anchor-link-selection-and-focus.html b/LayoutTests/accessibility/anchor-link-selection-and-focus.html
new file mode 100644 (file)
index 0000000..7703464
--- /dev/null
@@ -0,0 +1,53 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script>
+var successfullyParsed = false;
+</script>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<p><a id="link" href="#anchor">A link pointing to an anchor at the end of the document</a></p>
+<p>A paragraph with a some text in the middle</p>
+<p><a id="anchor" name="anchor" href="">The Anchor</a></p>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description("This tests that the caret position is properly updated when following anchor links.");
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+
+    if (window.accessibilityController) {
+        var link = document.getElementById("link");
+        var anchor = document.getElementById("anchor");
+
+        // Get needed objects.
+        link.focus();
+        var axLink = accessibilityController.focusedElement;
+        debug("axLink.role is: '" + axLink.role + "'");
+        anchor.focus();
+        var axAnchor = accessibilityController.focusedElement;
+        debug("axAnchor.role is: '" + axAnchor.role + "'");
+
+        // Focus on the link and check initial state.
+        link.focus();
+        shouldBe("axLink.isFocused", "true");
+        shouldBe("axAnchor.isFocused", "false");
+
+        // Execute action and check state.
+        axLink.press()
+
+        // Check final state.
+        shouldBe("getSelection().anchorNode.nodeValue", "'The Anchor'");
+        shouldBe("axLink.isFocused", "false");
+        shouldBe("axAnchor.isFocused", "true");
+    }
+}
+
+successfullyParsed = true;
+</script>
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 3558bd5..57fce59 100644 (file)
@@ -1275,6 +1275,7 @@ BUGCR45747 : svg/text/text-fill-opacity.svg = PASS FAIL
 
 BUGCR10322 SKIP : platform/mac/accessibility = PASS FAIL
 BUGCR10322 SKIP : platform/win/accessibility = PASS FAIL
+BUGCR10322 SKIP : accessibility/anchor-link-selection-and-focus.html = TEXT
 BUGCR10322 SKIP : accessibility/aria-activedescendant-crash.html = TEXT
 BUGCR10322 SKIP : accessibility/aria-combobox.html = TEXT
 BUGCR10322 SKIP : accessibility/aria-controls-with-tabs.html = TEXT
diff --git a/LayoutTests/platform/gtk/accessibility/anchor-link-selection-and-focus-expected.txt b/LayoutTests/platform/gtk/accessibility/anchor-link-selection-and-focus-expected.txt
new file mode 100644 (file)
index 0000000..d8566ab
--- /dev/null
@@ -0,0 +1,19 @@
+A link pointing to an anchor at the end of the document
+
+A paragraph with a some text in the middle
+
+The Anchor
+
+This tests that the caret position is properly updated when following anchor links.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+axLink.role is: 'AXRole: link'
+axAnchor.role is: 'AXRole: link'
+PASS axLink.isFocused is true
+PASS axAnchor.isFocused is false
+PASS getSelection().anchorNode.nodeValue is 'The Anchor'
+PASS axLink.isFocused is false
+PASS axAnchor.isFocused is true
+
index b04325e..715d68d 100644 (file)
@@ -1,3 +1,30 @@
+2012-04-02  Mario Sanchez Prada  <msanchez@igalia.com>
+
+        in page anchor and keyboard navigation
+        https://bugs.webkit.org/show_bug.cgi?id=17450
+
+        Reviewed by Chris Fleizach.
+
+        Ensure that the position of the caret and the focused element
+        get updated when following an anchor link.
+
+        The implementation is moved from platform specific files out to
+        AXObjectCache.cpp since it should be a cross-platform valid
+        solution. However, the new code is currently activated for the Mac
+        and GTK ports only, since the windows and chromium ports provide
+        their own specific code, and removing it now might break things.
+
+        Test: accessibility/anchor-link-selection-and-focus.html
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore):
+        (WebCore::AXObjectCache::handleScrolledToAnchor): Cross-platform
+        implementation of the fix, only activated for Mac and GTK for now.
+        * accessibility/gtk/AXObjectCacheAtk.cpp: Removed the GTK-specific
+        implementation of WebCore::AXObjectCache::handleScrolledToAnchor.
+        * accessibility/mac/AXObjectCacheMac.mm: Removed the Mac-specific
+        implementation of WebCore::AXObjectCache::handleScrolledToAnchor.
+
 2012-04-02  Hayato Ito  <hayato@chromium.org>
 
         [Shadow DOM] Introduce ComposedShadowTreeWalker as a successor of ReifiedTreeTraversal APIs
index 02d5bfb..cfe6d8e 100644 (file)
@@ -54,6 +54,7 @@
 #include "Document.h"
 #include "FocusController.h"
 #include "Frame.h"
+#include "FrameSelection.h"
 #include "HTMLAreaElement.h"
 #include "HTMLImageElement.h"
 #include "HTMLInputElement.h"
@@ -71,7 +72,8 @@
 #include "RenderTableRow.h"
 #include "RenderView.h"
 #include "ScrollView.h"
-
+#include "TextAffinity.h"
+#include "htmlediting.h"
 #include <wtf/PassRefPtr.h>
 
 namespace WebCore {
@@ -156,6 +158,31 @@ AccessibilityObject* AXObjectCache::focusedUIElementForPage(const Page* page)
     return obj;
 }
 
+#if HAVE(ACCESSIBILITY) && (PLATFORM(MAC) || PLATFORM(GTK))
+void AXObjectCache::handleScrolledToAnchor(const Node* node)
+{
+    ASSERT(node);
+
+    Document* document = node->document();
+    if (!document)
+        return;
+
+    RefPtr<Node> refNode = const_cast<Node*>(node);
+    document->setFocusedNode(refNode);
+
+    Frame* frame = document->frame();
+    if (!frame)
+        return;
+
+    FrameSelection* selection = frame->selection();
+    if (!selection)
+        return;
+
+    Position targetPosition = firstPositionInOrBeforeNode(refNode.get());
+    selection->moveTo(targetPosition, DOWNSTREAM);
+}
+#endif
+
 AccessibilityObject* AXObjectCache::get(Widget* widget)
 {
     if (!widget)
index 9b46b38..153967d 100644 (file)
@@ -231,8 +231,4 @@ void AXObjectCache::handleFocusedUIElementChanged(RenderObject* oldFocusedRender
     }
 }
 
-void AXObjectCache::handleScrolledToAnchor(const Node*)
-{
-}
-
 } // namespace WebCore
index acbc25f..d352623 100644 (file)
@@ -144,10 +144,6 @@ void AXObjectCache::handleFocusedUIElementChanged(RenderObject*, RenderObject*)
     wkAccessibilityHandleFocusChanged();
 }
 
-void AXObjectCache::handleScrolledToAnchor(const Node*)
-{
-}
-
 }
 
 #endif // HAVE(ACCESSIBILITY)