[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

mario at webkit.org mario at webkit.org
Wed Dec 22 18:36:18 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 6a24ba1cc656e6329f5fb35cff0198440c6bb64d
Author: mario at webkit.org <mario at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Dec 14 15:35:22 2010 +0000

    2010-12-14  Mario Sanchez Prada  <msanchez at igalia.com>
    
            Reviewed by Xan Lopez.
    
            [Gtk] Implement STATE_FOCUSED, STATE_FOCUSABLE, and corresponding events for text objects
            https://bugs.webkit.org/show_bug.cgi?id=27048
    
            Added a new GTK-specific test to check focus{able|ed} states are
            properly set when moving the caret across text objects.
    
            * platform/gtk/accessibility/caret-browsing-text-focus-expected.txt: Added.
            * platform/gtk/accessibility/caret-browsing-text-focus.html: Added.
    2010-12-14  Mario Sanchez Prada  <msanchez at igalia.com>
    
            Reviewed by Xan Lopez.
    
            [Gtk] Implement STATE_FOCUSED, STATE_FOCUSABLE, and corresponding events for text objects
            https://bugs.webkit.org/show_bug.cgi?id=27048
    
            Handle focus change for text objects based in caret changes.
    
            As text objects (such as paragraphs) seem not to accept focus in
            WebCore in the same way other objects (text controls) do, a
            Gtk-specific workaround is needed to expose this states and the
            related events to ATK-based assistive technologies.
    
            Test: platform/gtk/accessibility/caret-browsing-text-focus.html
    
            Ensure that text objects are exposed with the ATK_STATE_FOCUSABLE
            state, and that the ATK_STATE_FOCUSED state is added to those
            text objects containing the currently active caret selection.
    
            * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
            (selectionBelongsToObject): Moved upwards to use it from
            the new isTextWithCaret() function.
            (isTextWithCaret): New, checks whether an accessibility object
            represents a text object with the current caret selection on it.
            (setAtkStateSetFromCoreObject): Add the ATK_STATE_FOCUSED state
            when also when isTextWithCaret(coreObject) returns true.
            (webkit_accessible_ref_state_set): Add the ATK_STATE_FOCUSABLE
            state to text objects and those with the ATK_ROLE_PARAGRAPH role.
            (webkit_accessible_text_get_n_selections): Optimize return expression.
    
            Make sure the proper events associated to a change of focus are
            emitted, based on caret changes across different accessibility
            objects. Also, refactored the code in more manageable and
            understandable helper functions.
    
            * editing/gtk/SelectionControllerGtk.cpp:
            (WebCore::emitTextSelectionChange): New, includes the specific
            code formerly placed in notifyAccessibilityForSelectionChange() to
            emit the 'text-caret-moved' and 'text-selection-change' signals.
            (WebCore::maybeEmitTextFocusChange): New, takes care of emitting
            the 'focus-event' and 'state-changed::focused' signals when
            needed, that is, when a change in the selection happens across
            different accessible objects.
            (WebCore::SelectionController::notifyAccessibilityForSelectionChange):
            Refactored some code here, by using the new helper functions.
    2010-12-14  Mario Sanchez Prada  <msanchez at igalia.com>
    
            Reviewed by Xan Lopez.
    
            [Gtk] Implement STATE_FOCUSED, STATE_FOCUSABLE, and corresponding events for text objects
            https://bugs.webkit.org/show_bug.cgi?id=27048
    
            Add support in DRT for checking whether an accessibility UI
            element is focusable and/or focused. Implemented for GTK.
    
            * DumpRenderTree/AccessibilityUIElement.cpp:
            (getIsFocusedCallback): New.
            (getIsFocusableCallback): New.
            (AccessibilityUIElement::getJSClass): Add the new available
            callbacks for isFocused and isFocusable.
            * DumpRenderTree/AccessibilityUIElement.h:
            * DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp:
            (AccessibilityUIElement::isFocused): New, implemented by checking
            whether the related AtkState value is in the object's state set.
            (AccessibilityUIElement::isFocusable): Ditto.
            * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
            (AccessibilityUIElement::isFocused): New, dummy implementation.
            (AccessibilityUIElement::isFocusable): Ditto.
            * DumpRenderTree/win/AccessibilityUIElementWin.cpp:
            (AccessibilityUIElement::isFocused): Ditto.
            (AccessibilityUIElement::isFocusable): Ditto.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74025 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 79dfeb9..8dfc4b1 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2010-12-14  Mario Sanchez Prada  <msanchez at igalia.com>
+
+        Reviewed by Xan Lopez.
+
+        [Gtk] Implement STATE_FOCUSED, STATE_FOCUSABLE, and corresponding events for text objects
+        https://bugs.webkit.org/show_bug.cgi?id=27048
+
+        Added a new GTK-specific test to check focus{able|ed} states are
+        properly set when moving the caret across text objects.
+
+        * platform/gtk/accessibility/caret-browsing-text-focus-expected.txt: Added.
+        * platform/gtk/accessibility/caret-browsing-text-focus.html: Added.
+
 2010-12-14  Pavel Feldman  <pfeldman at chromium.org>
 
         Not reviwed. Chromium expectations updated.
diff --git a/LayoutTests/platform/gtk/accessibility/caret-browsing-text-focus-expected.txt b/LayoutTests/platform/gtk/accessibility/caret-browsing-text-focus-expected.txt
new file mode 100644
index 0000000..b1c9f35
--- /dev/null
+++ b/LayoutTests/platform/gtk/accessibility/caret-browsing-text-focus-expected.txt
@@ -0,0 +1,30 @@
+A paragraph with a
+line break in the middle
+
+A paragraph with a single line
+
+This tests the FOCUSABLE and FOCUSED states for text objects.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS axPar1.role is 'AXRole: paragraph'
+PASS axPar2.role is 'AXRole: paragraph'
+PASS axPar1.isFocusable is true
+PASS axPar2.isFocusable is true
+PASS axPar1.isFocused is false
+PASS axPar2.isFocused is false
+PASS axPar1.isFocused is true
+PASS axPar2.isFocused is false
+PASS axPar1.isFocused is true
+PASS axPar2.isFocused is false
+PASS axPar1.isFocused is false
+PASS axPar2.isFocused is true
+PASS axPar1.isFocused is true
+PASS axPar2.isFocused is false
+PASS axPar1.isFocused is false
+PASS axPar2.isFocused is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/gtk/accessibility/caret-browsing-text-focus.html b/LayoutTests/platform/gtk/accessibility/caret-browsing-text-focus.html
new file mode 100644
index 0000000..265620f
--- /dev/null
+++ b/LayoutTests/platform/gtk/accessibility/caret-browsing-text-focus.html
@@ -0,0 +1,69 @@
+<!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 id="par1">A paragraph with a<br />line break in the middle</p>
+<p id="par2">A paragraph with a single line</p>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description("This tests the FOCUSABLE and FOCUSED states for text objects.");
+
+if (window.layoutTestController) {
+  layoutTestController.overridePreference("WebKitEnableCaretBrowsing", true);
+  layoutTestController.dumpAsText();
+
+  if (window.accessibilityController) {
+
+    document.getElementById("body").focus();
+    var webArea = accessibilityController.focusedElement;
+
+    var axPar1 = webArea.childAtIndex(0);
+    var axPar2 = webArea.childAtIndex(1);
+
+    // Check roles and initial states
+    shouldBe("axPar1.role", "'AXRole: paragraph'");
+    shouldBe("axPar2.role", "'AXRole: paragraph'");
+    shouldBe("axPar1.isFocusable", "true");
+    shouldBe("axPar2.isFocusable", "true");
+    shouldBe("axPar1.isFocused", "false");
+    shouldBe("axPar2.isFocused", "false");
+
+    // Set caret in the first line of the first paragraph
+    var par1 = document.getElementById("par1");
+    window.getSelection().setPosition(par1.childNodes.item(0), 10);
+    shouldBe("axPar1.isFocused", "true");
+    shouldBe("axPar2.isFocused", "false");
+
+    // Move the caret down to the second line (same paragraph)
+    eventSender.keyDown("downArrow");
+    shouldBe("axPar1.isFocused", "true");
+    shouldBe("axPar2.isFocused", "false");
+
+    // Move the caret down and up (across different paragraphs)
+    eventSender.keyDown("downArrow");
+    shouldBe("axPar1.isFocused", "false");
+    shouldBe("axPar2.isFocused", "true");
+    eventSender.keyDown("upArrow");
+    shouldBe("axPar1.isFocused", "true");
+    shouldBe("axPar2.isFocused", "false");
+
+    // Explicitly put the caret in the middle of the second paragraph
+    var par2 = document.getElementById("par2");
+    window.getSelection().setPosition(par2.childNodes.item(0), 10);
+    shouldBe("axPar1.isFocused", "false");
+    shouldBe("axPar2.isFocused", "true");
+  }
+}
+
+successfullyParsed = true;
+</script>
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 8121205..c0db715 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,50 @@
+2010-12-14  Mario Sanchez Prada  <msanchez at igalia.com>
+
+        Reviewed by Xan Lopez.
+
+        [Gtk] Implement STATE_FOCUSED, STATE_FOCUSABLE, and corresponding events for text objects
+        https://bugs.webkit.org/show_bug.cgi?id=27048
+
+        Handle focus change for text objects based in caret changes.
+
+        As text objects (such as paragraphs) seem not to accept focus in
+        WebCore in the same way other objects (text controls) do, a
+        Gtk-specific workaround is needed to expose this states and the
+        related events to ATK-based assistive technologies.
+
+        Test: platform/gtk/accessibility/caret-browsing-text-focus.html
+
+        Ensure that text objects are exposed with the ATK_STATE_FOCUSABLE
+        state, and that the ATK_STATE_FOCUSED state is added to those
+        text objects containing the currently active caret selection.
+
+        * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
+        (selectionBelongsToObject): Moved upwards to use it from
+        the new isTextWithCaret() function.
+        (isTextWithCaret): New, checks whether an accessibility object
+        represents a text object with the current caret selection on it.
+        (setAtkStateSetFromCoreObject): Add the ATK_STATE_FOCUSED state
+        when also when isTextWithCaret(coreObject) returns true.
+        (webkit_accessible_ref_state_set): Add the ATK_STATE_FOCUSABLE
+        state to text objects and those with the ATK_ROLE_PARAGRAPH role.
+        (webkit_accessible_text_get_n_selections): Optimize return expression.
+
+        Make sure the proper events associated to a change of focus are
+        emitted, based on caret changes across different accessibility
+        objects. Also, refactored the code in more manageable and
+        understandable helper functions.
+
+        * editing/gtk/SelectionControllerGtk.cpp:
+        (WebCore::emitTextSelectionChange): New, includes the specific
+        code formerly placed in notifyAccessibilityForSelectionChange() to
+        emit the 'text-caret-moved' and 'text-selection-change' signals.
+        (WebCore::maybeEmitTextFocusChange): New, takes care of emitting
+        the 'focus-event' and 'state-changed::focused' signals when
+        needed, that is, when a change in the selection happens across
+        different accessible objects.
+        (WebCore::SelectionController::notifyAccessibilityForSelectionChange):
+        Refactored some code here, by using the new helper functions.
+
 2010-12-14  Ilya Tikhonovsky  <loislo at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
index 5a55bb1..714ae54 100644
--- a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
+++ b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
@@ -59,6 +59,7 @@
 #include "RenderListMarker.h"
 #include "RenderText.h"
 #include "SelectElement.h"
+#include "Settings.h"
 #include "TextEncoding.h"
 #include "TextIterator.h"
 #include "WebKitAccessibleHyperlink.h"
@@ -477,6 +478,61 @@ static AtkRole webkit_accessible_get_role(AtkObject* object)
     return atkRole(axObject->roleValue());
 }
 
+static bool selectionBelongsToObject(AccessibilityObject* coreObject, VisibleSelection& selection)
+{
+    if (!coreObject || !coreObject->isAccessibilityRenderObject())
+        return false;
+
+    if (selection.isNone())
+        return false;
+
+    RefPtr<Range> range = selection.toNormalizedRange();
+    if (!range)
+        return false;
+
+    // We want to check that both the selection intersects the node
+    // AND that the selection is not just "touching" one of the
+    // boundaries for the selected node. We want to check whether the
+    // node is actually inside the region, at least partially.
+    Node* node = coreObject->node();
+    Node* lastDescendant = node->lastDescendant();
+    ExceptionCode ec = 0;
+    return (range->intersectsNode(node, ec)
+            && (range->endContainer() != node || range->endOffset())
+            && (range->startContainer() != lastDescendant || range->startOffset() != lastOffsetInNode(lastDescendant)));
+}
+
+static bool isTextWithCaret(AccessibilityObject* coreObject)
+{
+    if (!coreObject || !coreObject->isAccessibilityRenderObject())
+        return false;
+
+    Document* document = coreObject->document();
+    if (!document)
+        return false;
+
+    Frame* frame = document->frame();
+    if (!frame)
+        return false;
+
+    Settings* settings = frame->settings();
+    if (!settings || !settings->caretBrowsingEnabled())
+        return false;
+
+    // Check text objects and paragraphs only.
+    AtkObject* axObject = coreObject->wrapper();
+    AtkRole role = axObject ? atk_object_get_role(axObject) : ATK_ROLE_INVALID;
+    if (role != ATK_ROLE_TEXT && role != ATK_ROLE_PARAGRAPH)
+        return false;
+
+    // Finally, check whether the caret is set in the current object.
+    VisibleSelection selection = coreObject->selection();
+    if (!selection.isCaret())
+        return false;
+
+    return selectionBelongsToObject(coreObject, selection);
+}
+
 static void setAtkStateSetFromCoreObject(AccessibilityObject* coreObject, AtkStateSet* stateSet)
 {
     AccessibilityObject* parent = coreObject->parentObject();
@@ -510,7 +566,7 @@ static void setAtkStateSetFromCoreObject(AccessibilityObject* coreObject, AtkSta
     if (coreObject->canSetFocusAttribute())
         atk_state_set_add_state(stateSet, ATK_STATE_FOCUSABLE);
 
-    if (coreObject->isFocused())
+    if (coreObject->isFocused() || isTextWithCaret(coreObject))
         atk_state_set_add_state(stateSet, ATK_STATE_FOCUSED);
 
     // TODO: ATK_STATE_HORIZONTAL
@@ -579,8 +635,12 @@ static AtkStateSet* webkit_accessible_ref_state_set(AtkObject* object)
         return stateSet;
     }
 
-    setAtkStateSetFromCoreObject(coreObject, stateSet);
+    // Text objects must be focusable.
+    AtkRole role = atk_object_get_role(object);
+    if (role == ATK_ROLE_TEXT || role == ATK_ROLE_PARAGRAPH)
+        atk_state_set_add_state(stateSet, ATK_STATE_FOCUSABLE);
 
+    setAtkStateSetFromCoreObject(coreObject, stateSet);
     return stateSet;
 }
 
@@ -1485,27 +1545,6 @@ static gint webkit_accessible_text_get_offset_at_point(AtkText* text, gint x, gi
     return range.start;
 }
 
-static bool selectionBelongsToObject(AccessibilityObject* coreObject, VisibleSelection& selection)
-{
-    if (!coreObject->isAccessibilityRenderObject())
-        return false;
-
-    RefPtr<Range> range = selection.toNormalizedRange();
-    if (!range)
-        return false;
-
-    // We want to check that both the selection intersects the node
-    // AND that the selection is not just "touching" one of the
-    // boundaries for the selected node. We want to check whether the
-    // node is actually inside the region, at least partially
-    Node* node = coreObject->node();
-    Node* lastDescendant = node->lastDescendant();
-    ExceptionCode ec = 0;
-    return (range->intersectsNode(node, ec)
-            && (range->endContainer() != node || range->endOffset())
-            && (range->startContainer() != lastDescendant || range->startOffset() != lastOffsetInNode(lastDescendant)));
-}
-
 static void getSelectionOffsetsForObject(AccessibilityObject* coreObject, VisibleSelection& selection, gint& startOffset, gint& endOffset)
 {
     if (!coreObject->isAccessibilityRenderObject())
@@ -1569,7 +1608,7 @@ static gint webkit_accessible_text_get_n_selections(AtkText* text)
     // belong to the currently selected object. We have to check since
     // there's no way to get the selection for a given object, only
     // the global one (the API is a bit confusing)
-    return !selectionBelongsToObject(coreObject, selection) || selection.isNone() ? 0 : 1;
+    return selectionBelongsToObject(coreObject, selection) ? 1 : 0;
 }
 
 static gchar* webkit_accessible_text_get_selection(AtkText* text, gint selectionNum, gint* startOffset, gint* endOffset)
diff --git a/WebCore/editing/gtk/SelectionControllerGtk.cpp b/WebCore/editing/gtk/SelectionControllerGtk.cpp
index 5626110..19097b2 100644
--- a/WebCore/editing/gtk/SelectionControllerGtk.cpp
+++ b/WebCore/editing/gtk/SelectionControllerGtk.cpp
@@ -23,34 +23,83 @@
 #include "AccessibilityObjectWrapperAtk.h"
 #include "AXObjectCache.h"
 #include "Frame.h"
+#include "RefPtr.h"
 
 #include <gtk/gtk.h>
 
 namespace WebCore {
 
-void SelectionController::notifyAccessibilityForSelectionChange()
+static void emitTextSelectionChange(AccessibilityObject* object, VisibleSelection selection, int offset)
+{
+    AtkObject* axObject = object->wrapper();
+    if (!axObject || !ATK_IS_TEXT(axObject))
+        return;
+
+    g_signal_emit_by_name(axObject, "text-caret-moved", offset);
+    if (selection.isRange())
+        g_signal_emit_by_name(axObject, "text-selection-changed");
+}
+
+static void maybeEmitTextFocusChange(PassRefPtr<AccessibilityObject> prpObject)
 {
-    if (AXObjectCache::accessibilityEnabled() && m_selection.start().isNotNull() && m_selection.end().isNotNull()) {
-        RenderObject* focusedNode = m_selection.end().node()->renderer();
-        AccessibilityObject* accessibilityObject = m_frame->document()->axObjectCache()->getOrCreate(focusedNode);
-
-        // need to check this as getOrCreate could return 0
-        if (!accessibilityObject)
-            return;
-
-        int offset;
-        // Always report the events w.r.t. the non-linked unignored parent. (i.e. ignoreLinks == true)
-        AccessibilityObject* object = objectAndOffsetUnignored(accessibilityObject, offset, true);
-        if (!object)
-            return;
-
-        AtkObject* wrapper = object->wrapper();
-        if (ATK_IS_TEXT(wrapper)) {
-            g_signal_emit_by_name(wrapper, "text-caret-moved", offset);
-            if (m_selection.isRange())
-                g_signal_emit_by_name(wrapper, "text-selection-changed");
+    // This static variable is needed to keep track of the old object
+    // as per previous calls to this function, in order to properly
+    // decide whether to emit some signals or not.
+    DEFINE_STATIC_LOCAL(RefPtr<AccessibilityObject>, oldObject, ());
+
+    RefPtr<AccessibilityObject> object = prpObject;
+
+    // Ensure the oldObject belongs to the same document that the
+    // current object so further comparisons make sense. Otherwise,
+    // just reset oldObject to 0 so it won't be taken into account in
+    // the immediately following call to this function.
+    if (object && oldObject && oldObject->document() != object->document())
+        oldObject = 0;
+
+    AtkObject* axObject = object ? object->wrapper() : 0;
+    AtkObject* oldAxObject = oldObject ? oldObject->wrapper() : 0;
+
+    if (axObject != oldAxObject) {
+        if (oldAxObject && ATK_IS_TEXT(oldAxObject)) {
+            g_signal_emit_by_name(oldAxObject, "focus-event", false);
+            g_signal_emit_by_name(oldAxObject, "state-change", "focused", false);
+        }
+        if (axObject && ATK_IS_TEXT(axObject)) {
+            g_signal_emit_by_name(axObject, "focus-event", true);
+            g_signal_emit_by_name(axObject, "state-change", "focused", true);
         }
     }
+
+    // Update pointer to last focused object.
+    oldObject = object;
+}
+
+
+void SelectionController::notifyAccessibilityForSelectionChange()
+{
+    if (!AXObjectCache::accessibilityEnabled())
+        return;
+
+    // Reset lastFocuseNode and return for no valid selections.
+    if (!m_selection.start().isNotNull() || !m_selection.end().isNotNull())
+        return;
+
+    RenderObject* focusedNode = m_selection.end().node()->renderer();
+    AccessibilityObject* accessibilityObject = m_frame->document()->axObjectCache()->getOrCreate(focusedNode);
+
+    // Need to check this as getOrCreate could return 0,
+    if (!accessibilityObject)
+        return;
+
+    int offset;
+    // Always report the events w.r.t. the non-linked unignored parent. (i.e. ignoreLinks == true).
+    RefPtr<AccessibilityObject> object = objectAndOffsetUnignored(accessibilityObject, offset, true);
+    if (!object)
+        return;
+
+    // Emit relatedsignals.
+    emitTextSelectionChange(object.get(), m_selection, offset);
+    maybeEmitTextFocusChange(object.release());
 }
 
 } // namespace WebCore
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 6cd2fa9..b4d3288 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,30 @@
+2010-12-14  Mario Sanchez Prada  <msanchez at igalia.com>
+
+        Reviewed by Xan Lopez.
+
+        [Gtk] Implement STATE_FOCUSED, STATE_FOCUSABLE, and corresponding events for text objects
+        https://bugs.webkit.org/show_bug.cgi?id=27048
+
+        Add support in DRT for checking whether an accessibility UI
+        element is focusable and/or focused. Implemented for GTK.
+
+        * DumpRenderTree/AccessibilityUIElement.cpp:
+        (getIsFocusedCallback): New.
+        (getIsFocusableCallback): New.
+        (AccessibilityUIElement::getJSClass): Add the new available
+        callbacks for isFocused and isFocusable.
+        * DumpRenderTree/AccessibilityUIElement.h:
+        * DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp:
+        (AccessibilityUIElement::isFocused): New, implemented by checking
+        whether the related AtkState value is in the object's state set.
+        (AccessibilityUIElement::isFocusable): Ditto.
+        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
+        (AccessibilityUIElement::isFocused): New, dummy implementation.
+        (AccessibilityUIElement::isFocusable): Ditto.
+        * DumpRenderTree/win/AccessibilityUIElementWin.cpp:
+        (AccessibilityUIElement::isFocused): Ditto.
+        (AccessibilityUIElement::isFocusable): Ditto.
+
 2010-12-14  Eric Seidel  <eric at webkit.org>
 
         Reviewed by Ojan Vafai.
diff --git a/WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp b/WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp
index 4d0bfa8..57b4e54 100644
--- a/WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp
+++ b/WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp
@@ -664,6 +664,16 @@ static JSValueRef getIsRequiredCallback(JSContextRef context, JSObjectRef thisOb
     return JSValueMakeBoolean(context, toAXElement(thisObject)->isRequired());
 }
 
+static JSValueRef getIsFocusedCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
+{
+    return JSValueMakeBoolean(context, toAXElement(thisObject)->isFocused());
+}
+
+static JSValueRef getIsFocusableCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
+{
+    return JSValueMakeBoolean(context, toAXElement(thisObject)->isFocusable());
+}
+
 static JSValueRef getIsSelectedCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
 {
     return JSValueMakeBoolean(context, toAXElement(thisObject)->isSelected());
@@ -875,6 +885,8 @@ JSClassRef AccessibilityUIElement::getJSClass()
         { "selectedTextRange", getSelectedTextRangeCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "isEnabled", getIsEnabledCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "isRequired", getIsRequiredCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "isFocused", getIsFocusedCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "isFocusable", getIsFocusableCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "isSelected", getIsSelectedCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "isSelectable", getIsSelectableCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "isMultiSelectable", getIsMultiSelectableCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
diff --git a/WebKitTools/DumpRenderTree/AccessibilityUIElement.h b/WebKitTools/DumpRenderTree/AccessibilityUIElement.h
index 3eb396d..d321b4f 100644
--- a/WebKitTools/DumpRenderTree/AccessibilityUIElement.h
+++ b/WebKitTools/DumpRenderTree/AccessibilityUIElement.h
@@ -131,6 +131,8 @@ public:
     bool isEnabled();
     bool isRequired() const;
     
+    bool isFocused() const;
+    bool isFocusable() const;
     bool isSelected() const;
     bool isSelectable() const;
     bool isMultiSelectable() const;
diff --git a/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp b/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp
index c195e77..7e1a9c2 100644
--- a/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp
@@ -403,6 +403,17 @@ bool AccessibilityUIElement::isRequired() const
     return false;
 }
 
+bool AccessibilityUIElement::isFocused() const
+{
+    if (!ATK_IS_OBJECT(m_element))
+        return false;
+
+    PlatformRefPtr<AtkStateSet> stateSet = adoptPlatformRef(atk_object_ref_state_set(ATK_OBJECT(m_element)));
+    gboolean isFocused = atk_state_set_contains_state(stateSet.get(), ATK_STATE_FOCUSED);
+
+    return isFocused;
+}
+
 bool AccessibilityUIElement::isSelected() const
 {
     return checkElementState(m_element, ATK_STATE_SELECTED);
@@ -654,6 +665,17 @@ void AccessibilityUIElement::removeNotificationListener()
     // FIXME: implement
 }
 
+bool AccessibilityUIElement::isFocusable() const
+{
+    if (!ATK_IS_OBJECT(m_element))
+        return false;
+
+    PlatformRefPtr<AtkStateSet> stateSet = adoptPlatformRef(atk_object_ref_state_set(ATK_OBJECT(m_element)));
+    gboolean isFocusable = atk_state_set_contains_state(stateSet.get(), ATK_STATE_FOCUSABLE);
+
+    return isFocusable;
+}
+
 bool AccessibilityUIElement::isSelectable() const
 {
     // FIXME: implement
diff --git a/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm b/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
index e27ee0e..e2f0597 100644
--- a/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
+++ b/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
@@ -761,6 +761,12 @@ bool AccessibilityUIElement::isRequired() const
     return false;
 }
 
+bool AccessibilityUIElement::isFocused() const
+{
+    // FIXME: implement
+    return false;
+}
+
 bool AccessibilityUIElement::isSelected() const
 {
     BEGIN_AX_OBJC_EXCEPTIONS
@@ -1181,6 +1187,12 @@ void AccessibilityUIElement::removeNotificationListener()
     m_notificationHandler = nil;
 }
 
+bool AccessibilityUIElement::isFocusable() const
+{
+    // FIXME: implement
+    return false;
+}
+
 bool AccessibilityUIElement::isSelectable() const
 {
     // FIXME: implement
diff --git a/WebKitTools/DumpRenderTree/win/AccessibilityUIElementWin.cpp b/WebKitTools/DumpRenderTree/win/AccessibilityUIElementWin.cpp
index 5b771b2..47ce7dc 100644
--- a/WebKitTools/DumpRenderTree/win/AccessibilityUIElementWin.cpp
+++ b/WebKitTools/DumpRenderTree/win/AccessibilityUIElementWin.cpp
@@ -329,6 +329,12 @@ static DWORD accessibilityState(COMPtr<IAccessible> element)
     return result;
 }
 
+bool AccessibilityUIElement::isFocused() const
+{
+    // FIXME: implement
+    return false;
+}
+
 bool AccessibilityUIElement::isSelected() const
 {
     DWORD state = accessibilityState(m_element);
@@ -605,6 +611,12 @@ void AccessibilityUIElement::removeNotificationListener()
     // FIXME: implement
 }
 
+bool AccessibilityUIElement::isFocusable() const
+{
+    // FIXME: implement
+    return false;
+}
+
 bool AccessibilityUIElement::isSelectable() const
 {
     DWORD state = accessibilityState(m_element);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list