Commit bd85185f authored by Katie Dektar's avatar Katie Dektar Committed by Commit Bot

Removes Offscreen from internal ax states, leave in Automation.

Offscreen is now calculated separately and is no longer in the state
list.

Bug: 717677
Change-Id: I6957d3de38e3b4c8356be1ff5f818c2c205ccc46
Reviewed-on: https://chromium-review.googlesource.com/688498
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505293}
parent 6cb8d795
...@@ -1004,10 +1004,8 @@ void AutomationInternalCustomBindings::GetState( ...@@ -1004,10 +1004,8 @@ void AutomationInternalCustomBindings::GetState(
gin::DataObjectBuilder state(isolate); gin::DataObjectBuilder state(isolate);
uint32_t state_pos = 0, state_shifter = node->data().state; uint32_t state_pos = 0, state_shifter = node->data().state;
while (state_shifter) { while (state_shifter) {
if (state_pos != ui::AX_STATE_OFFSCREEN) { if (state_shifter & 1)
if (state_shifter & 1) state.Set(ToString(static_cast<ui::AXState>(state_pos)), true);
state.Set(ToString(static_cast<ui::AXState>(state_pos)), true);
}
state_shifter = state_shifter >> 1; state_shifter = state_shifter >> 1;
state_pos++; state_pos++;
} }
...@@ -1022,12 +1020,12 @@ void AutomationInternalCustomBindings::GetState( ...@@ -1022,12 +1020,12 @@ void AutomationInternalCustomBindings::GetState(
focused_cache == cache && focused_node == node) || focused_cache == cache && focused_node == node) ||
cache->tree.data().focus_id == node->id(); cache->tree.data().focus_id == node->id();
if (focused) if (focused)
state.Set("focused", true); state.Set(ToString(api::automation::STATE_TYPE_FOCUSED), true);
bool offscreen = false; bool offscreen = false;
ComputeGlobalNodeBounds(cache, node, gfx::RectF(), &offscreen); ComputeGlobalNodeBounds(cache, node, gfx::RectF(), &offscreen);
if (offscreen) if (offscreen)
state.Set(ToString(ui::AX_STATE_OFFSCREEN), true); state.Set(ToString(api::automation::STATE_TYPE_OFFSCREEN), true);
args.GetReturnValue().Set(state.Build()); args.GetReturnValue().Set(state.Build());
} }
......
...@@ -30,6 +30,9 @@ AccessibilityTreeFormatterBlink::~AccessibilityTreeFormatterBlink() { ...@@ -30,6 +30,9 @@ AccessibilityTreeFormatterBlink::~AccessibilityTreeFormatterBlink() {
const char* const TREE_DATA_ATTRIBUTES[] = {"TreeData.textSelStartOffset", const char* const TREE_DATA_ATTRIBUTES[] = {"TreeData.textSelStartOffset",
"TreeData.textSelEndOffset"}; "TreeData.textSelEndOffset"};
const char* STATE_FOCUSED = "focused";
const char* STATE_OFFSCREEN = "offscreen";
uint32_t AccessibilityTreeFormatterBlink::ChildCount( uint32_t AccessibilityTreeFormatterBlink::ChildCount(
const BrowserAccessibility& node) const { const BrowserAccessibility& node) const {
if (node.HasIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)) if (node.HasIntAttribute(ui::AX_ATTR_CHILD_TREE_ID))
...@@ -152,15 +155,13 @@ void AccessibilityTreeFormatterBlink::AddProperties( ...@@ -152,15 +155,13 @@ void AccessibilityTreeFormatterBlink::AddProperties(
for (int state_index = ui::AX_STATE_NONE; for (int state_index = ui::AX_STATE_NONE;
state_index <= ui::AX_STATE_LAST; state_index <= ui::AX_STATE_LAST;
++state_index) { ++state_index) {
if (state_index == ui::AX_STATE_OFFSCREEN)
continue;
auto state = static_cast<ui::AXState>(state_index); auto state = static_cast<ui::AXState>(state_index);
if (node.HasState(state)) if (node.HasState(state))
dict->SetBoolean(ui::ToString(state), true); dict->SetBoolean(ui::ToString(state), true);
} }
if (offscreen) if (offscreen)
dict->SetBoolean(ui::ToString(ui::AX_STATE_OFFSCREEN), true); dict->SetBoolean(STATE_OFFSCREEN, true);
for (int attr_index = ui::AX_STRING_ATTRIBUTE_NONE; for (int attr_index = ui::AX_STRING_ATTRIBUTE_NONE;
attr_index <= ui::AX_STRING_ATTRIBUTE_LAST; attr_index <= ui::AX_STRING_ATTRIBUTE_LAST;
...@@ -267,6 +268,15 @@ base::string16 AccessibilityTreeFormatterBlink::ToString( ...@@ -267,6 +268,15 @@ base::string16 AccessibilityTreeFormatterBlink::ToString(
WriteAttribute(false, ui::ToString(state), &line); WriteAttribute(false, ui::ToString(state), &line);
} }
// Offscreen and Focused states are not in the state list.
bool value = false;
dict.GetBoolean(STATE_OFFSCREEN, &value);
if (value)
WriteAttribute(false, STATE_OFFSCREEN, &line);
dict.GetBoolean(STATE_FOCUSED, &value);
if (value)
WriteAttribute(false, STATE_FOCUSED, &line);
WriteAttribute(false, WriteAttribute(false,
FormatCoordinates("location", "boundsX", "boundsY", dict), FormatCoordinates("location", "boundsX", "boundsY", dict),
&line); &line);
......
...@@ -882,6 +882,12 @@ gfx::Rect BrowserAccessibility::RelativeToAbsoluteBounds( ...@@ -882,6 +882,12 @@ gfx::Rect BrowserAccessibility::RelativeToAbsoluteBounds(
return gfx::ToEnclosingRect(bounds); return gfx::ToEnclosingRect(bounds);
} }
bool BrowserAccessibility::IsOffscreen() const {
bool offscreen = false;
RelativeToAbsoluteBounds(gfx::RectF(), false, &offscreen);
return offscreen;
}
gfx::NativeViewAccessible BrowserAccessibility::GetNativeViewAccessible() { gfx::NativeViewAccessible BrowserAccessibility::GetNativeViewAccessible() {
// TODO(703369) On Windows, where we have started to migrate to an // TODO(703369) On Windows, where we have started to migrate to an
// AXPlatformNode implementation, the BrowserAccessibilityWin subclass has // AXPlatformNode implementation, the BrowserAccessibilityWin subclass has
......
...@@ -345,6 +345,7 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate { ...@@ -345,6 +345,7 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate {
gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override; gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override;
bool AccessibilityPerformAction(const ui::AXActionData& data) override; bool AccessibilityPerformAction(const ui::AXActionData& data) override;
bool ShouldIgnoreHoveredStateForTesting() override; bool ShouldIgnoreHoveredStateForTesting() override;
bool IsOffscreen() const override;
protected: protected:
using AXPlatformPositionInstance = AXPlatformPosition::AXPositionInstance; using AXPlatformPositionInstance = AXPlatformPosition::AXPositionInstance;
......
...@@ -144,12 +144,9 @@ void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( ...@@ -144,12 +144,9 @@ void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent(
GetRoot()); GetRoot());
} }
if (!can_fire_events && if (!can_fire_events && !load_complete_pending_ &&
!load_complete_pending_ && event_type == ui::AX_EVENT_LOAD_COMPLETE && GetRoot() &&
event_type == ui::AX_EVENT_LOAD_COMPLETE && !GetRoot()->IsOffscreen() && GetRoot()->PlatformChildCount() > 0) {
GetRoot() &&
!GetRoot()->HasState(ui::AX_STATE_OFFSCREEN) &&
GetRoot()->PlatformChildCount() > 0) {
load_complete_pending_ = true; load_complete_pending_ = true;
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "content/browser/accessibility/browser_accessibility.h" #include "content/browser/accessibility/browser_accessibility.h"
#include "content/browser/accessibility/browser_accessibility_manager.h" #include "content/browser/accessibility/browser_accessibility_manager.h"
#include "ui/accessibility/ax_enums.h" #include "ui/accessibility/ax_enums.h"
#include "ui/accessibility/ax_node.h"
#include "ui/accessibility/ax_role_properties.h" #include "ui/accessibility/ax_role_properties.h"
namespace content { namespace content {
...@@ -183,8 +184,7 @@ bool OneShotAccessibilityTreeSearch::Matches(BrowserAccessibility* node) { ...@@ -183,8 +184,7 @@ bool OneShotAccessibilityTreeSearch::Matches(BrowserAccessibility* node) {
} }
if (visible_only_) { if (visible_only_) {
if (node->HasState(ui::AX_STATE_INVISIBLE) || if (node->HasState(ui::AX_STATE_INVISIBLE) || node->IsOffscreen()) {
node->HasState(ui::AX_STATE_OFFSCREEN)) {
return false; return false;
} }
} }
......
...@@ -54,6 +54,7 @@ void MAYBE_OneShotAccessibilityTreeSearchTest::SetUp() { ...@@ -54,6 +54,7 @@ void MAYBE_OneShotAccessibilityTreeSearchTest::SetUp() {
root.id = 1; root.id = 1;
root.SetName("Document"); root.SetName("Document");
root.role = ui::AX_ROLE_ROOT_WEB_AREA; root.role = ui::AX_ROLE_ROOT_WEB_AREA;
root.location = gfx::RectF(0, 0, 800, 600);
root.child_ids.push_back(2); root.child_ids.push_back(2);
root.child_ids.push_back(3); root.child_ids.push_back(3);
root.child_ids.push_back(6); root.child_ids.push_back(6);
...@@ -83,7 +84,7 @@ void MAYBE_OneShotAccessibilityTreeSearchTest::SetUp() { ...@@ -83,7 +84,7 @@ void MAYBE_OneShotAccessibilityTreeSearchTest::SetUp() {
footer.id = 6; footer.id = 6;
footer.SetName("Footer"); footer.SetName("Footer");
footer.role = ui::AX_ROLE_FOOTER; footer.role = ui::AX_ROLE_FOOTER;
footer.AddState(ui::AX_STATE_OFFSCREEN); footer.location = gfx::RectF(0, 650, 100, 800);
tree_.reset(new TestBrowserAccessibilityManager( tree_.reset(new TestBrowserAccessibilityManager(
MakeAXTreeUpdate(root, heading, list, list_item_1, list_item_2, footer))); MakeAXTreeUpdate(root, heading, list, list_item_1, list_item_2, footer)));
......
...@@ -40,9 +40,6 @@ uint32_t AXStateFromBlink(const blink::WebAXObject& o) { ...@@ -40,9 +40,6 @@ uint32_t AXStateFromBlink(const blink::WebAXObject& o) {
if (o.IsMultiSelectable()) if (o.IsMultiSelectable())
state |= (1 << ui::AX_STATE_MULTISELECTABLE); state |= (1 << ui::AX_STATE_MULTISELECTABLE);
if (o.IsOffScreen())
state |= (1 << ui::AX_STATE_OFFSCREEN);
if (o.IsPasswordField()) if (o.IsPasswordField())
state |= (1 << ui::AX_STATE_PROTECTED); state |= (1 << ui::AX_STATE_PROTECTED);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
@WIN-ALLOW:description* @WIN-ALLOW:description*
@WIN-ALLOW:IA2_STATE_MULTI_LINE @WIN-ALLOW:IA2_STATE_MULTI_LINE
@BLINK-ALLOW:description* @BLINK-ALLOW:description*
@BLINK-ALLOW:focus* @BLINK-ALLOW:focusable*
@BLINK-ALLOW:multiline @BLINK-ALLOW:multiline
--> -->
<html> <html>
......
...@@ -91,6 +91,8 @@ def CheckEnumsMatch(input_api, output_api): ...@@ -91,6 +91,8 @@ def CheckEnumsMatch(input_api, output_api):
# Focused state only exists in automation. # Focused state only exists in automation.
automation_enums['StateType'].remove('focused') automation_enums['StateType'].remove('focused')
# Offscreen state only exists in automation.
automation_enums['StateType'].remove('offscreen')
errs = [] errs = []
CheckMatchingEnum(ax_enums, 'AXRole', automation_enums, 'RoleType', errs, CheckMatchingEnum(ax_enums, 'AXRole', automation_enums, 'RoleType', errs,
......
...@@ -217,7 +217,6 @@ ...@@ -217,7 +217,6 @@
linked, linked,
multiline, multiline,
multiselectable, multiselectable,
offscreen,
protected, protected,
required, required,
richly_editable, richly_editable,
......
...@@ -76,6 +76,9 @@ class AX_EXPORT AXPlatformNodeDelegate { ...@@ -76,6 +76,9 @@ class AX_EXPORT AXPlatformNodeDelegate {
// has focus. // has focus.
virtual gfx::NativeViewAccessible GetFocus() = 0; virtual gfx::NativeViewAccessible GetFocus() = 0;
// Get whether this node is offscreen.
virtual bool IsOffscreen() const = 0;
virtual AXPlatformNode* GetFromNodeID(int32_t id) = 0; virtual AXPlatformNode* GetFromNodeID(int32_t id) = 0;
// //
......
...@@ -3572,7 +3572,7 @@ int AXPlatformNodeWin::MSAAState() { ...@@ -3572,7 +3572,7 @@ int AXPlatformNodeWin::MSAAState() {
msaa_state |= STATE_SYSTEM_MULTISELECTABLE; msaa_state |= STATE_SYSTEM_MULTISELECTABLE;
} }
if (data.HasState(AX_STATE_OFFSCREEN)) if (delegate_->IsOffscreen())
msaa_state |= STATE_SYSTEM_OFFSCREEN; msaa_state |= STATE_SYSTEM_OFFSCREEN;
if (data.HasState(AX_STATE_PROTECTED)) if (data.HasState(AX_STATE_PROTECTED))
......
...@@ -119,4 +119,8 @@ bool AXSystemCaretWin::ShouldIgnoreHoveredStateForTesting() { ...@@ -119,4 +119,8 @@ bool AXSystemCaretWin::ShouldIgnoreHoveredStateForTesting() {
return false; return false;
} }
bool AXSystemCaretWin::IsOffscreen() const {
return false;
}
} // namespace ui } // namespace ui
...@@ -48,6 +48,7 @@ class AX_EXPORT AXSystemCaretWin : private AXPlatformNodeDelegate { ...@@ -48,6 +48,7 @@ class AX_EXPORT AXSystemCaretWin : private AXPlatformNodeDelegate {
gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override; gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override;
bool AccessibilityPerformAction(const AXActionData& data) override; bool AccessibilityPerformAction(const AXActionData& data) override;
bool ShouldIgnoreHoveredStateForTesting() override; bool ShouldIgnoreHoveredStateForTesting() override;
bool IsOffscreen() const override;
AXPlatformNodeWin* caret_; AXPlatformNodeWin* caret_;
gfx::AcceleratedWidget event_target_; gfx::AcceleratedWidget event_target_;
......
...@@ -225,6 +225,10 @@ bool TestAXNodeWrapper::ShouldIgnoreHoveredStateForTesting() { ...@@ -225,6 +225,10 @@ bool TestAXNodeWrapper::ShouldIgnoreHoveredStateForTesting() {
return true; return true;
} }
bool TestAXNodeWrapper::IsOffscreen() const {
return false;
}
TestAXNodeWrapper::TestAXNodeWrapper(AXTree* tree, AXNode* node) TestAXNodeWrapper::TestAXNodeWrapper(AXTree* tree, AXNode* node)
: tree_(tree), : tree_(tree),
node_(node), node_(node),
......
...@@ -45,6 +45,7 @@ class TestAXNodeWrapper : public AXPlatformNodeDelegate { ...@@ -45,6 +45,7 @@ class TestAXNodeWrapper : public AXPlatformNodeDelegate {
gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override; gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override;
bool AccessibilityPerformAction(const AXActionData& data) override; bool AccessibilityPerformAction(const AXActionData& data) override;
bool ShouldIgnoreHoveredStateForTesting() override; bool ShouldIgnoreHoveredStateForTesting() override;
bool IsOffscreen() const override;
private: private:
TestAXNodeWrapper(AXTree* tree, AXNode* node); TestAXNodeWrapper(AXTree* tree, AXNode* node);
......
...@@ -106,6 +106,11 @@ class AuraLinuxApplication ...@@ -106,6 +106,11 @@ class AuraLinuxApplication
return nullptr; return nullptr;
} }
bool IsOffscreen() const override {
// TODO: need to implement.
return false;
}
int GetIndexInParent() const override { return -1; } int GetIndexInParent() const override { return -1; }
ui::AXPlatformNode* GetFromNodeID(int32_t id) override { return nullptr; } ui::AXPlatformNode* GetFromNodeID(int32_t id) override { return nullptr; }
......
...@@ -221,6 +221,11 @@ bool NativeViewAccessibilityBase::ShouldIgnoreHoveredStateForTesting() { ...@@ -221,6 +221,11 @@ bool NativeViewAccessibilityBase::ShouldIgnoreHoveredStateForTesting() {
return false; return false;
} }
bool NativeViewAccessibilityBase::IsOffscreen() const {
// TODO: need to implement.
return false;
}
void NativeViewAccessibilityBase::OnWidgetDestroying(Widget* widget) { void NativeViewAccessibilityBase::OnWidgetDestroying(Widget* widget) {
if (parent_widget_ == widget) { if (parent_widget_ == widget) {
parent_widget_->RemoveObserver(this); parent_widget_->RemoveObserver(this);
......
...@@ -52,6 +52,7 @@ class VIEWS_EXPORT NativeViewAccessibilityBase ...@@ -52,6 +52,7 @@ class VIEWS_EXPORT NativeViewAccessibilityBase
gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override; gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override;
bool AccessibilityPerformAction(const ui::AXActionData& data) override; bool AccessibilityPerformAction(const ui::AXActionData& data) override;
bool ShouldIgnoreHoveredStateForTesting() override; bool ShouldIgnoreHoveredStateForTesting() override;
bool IsOffscreen() const override;
// WidgetObserver // WidgetObserver
void OnWidgetDestroying(Widget* widget) override; void OnWidgetDestroying(Widget* widget) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment