Skip to content

Commit

Permalink
Support presentational iframes and make use of them in the uber frame.
Browse files Browse the repository at this point in the history
A presentational iframe, e.g. <iframe role="presentation">, is one where the
web author is indicating that the frame is an implementation detail. Suppress
the normal role for the frame and for its inner document / web area, so that
accessibility clients see the frame as if it was part of the parent document.

Make use of this in the uber frame for settings, history, and extensions.

BUG=436186

Review URL: https://codereview.chromium.org/755173004

Cr-Commit-Position: refs/heads/master@{#308859}
  • Loading branch information
minorninth authored and Commit bot committed Dec 17, 2014
1 parent 0b8e89d commit 8b43c60
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 3 deletions.
2 changes: 1 addition & 1 deletion chrome/browser/resources/uber/uber.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<body>

<div id="navigation"><iframe src="chrome://uber-frame/" name="chrome"></iframe></div>
<div id="navigation"><iframe src="chrome://uber-frame/" name="chrome" role="presentation"></iframe></div>

<div class="iframe-container"
i18n-values="id:historyHost; data-url:historyFrameURL;"
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/resources/uber/uber.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ cr.define('uber', function() {
if (!frame) {
frame = container.ownerDocument.createElement('iframe');
frame.name = pageId;
frame.setAttribute('role', 'presentation');
container.appendChild(frame);
frame.src = sourceUrl;
} else {
Expand Down
1 change: 1 addition & 0 deletions chrome/common/extensions/api/automation.idl
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
group,
heading,
iframe,
iframePresentational,
ignored,
imageMapLink,
imageMap,
Expand Down
17 changes: 17 additions & 0 deletions content/browser/accessibility/browser_accessibility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,23 @@ bool BrowserAccessibility::IsEditableText() const {
GetRole() == ui::AX_ROLE_TEXT_AREA);
}

bool BrowserAccessibility::IsWebAreaForPresentationalIframe() const {
if (GetRole() != ui::AX_ROLE_WEB_AREA &&
GetRole() != ui::AX_ROLE_ROOT_WEB_AREA) {
return false;
}

BrowserAccessibility* parent = GetParent();
if (!parent)
return false;

BrowserAccessibility* grandparent = parent->GetParent();
if (!grandparent)
return false;

return grandparent->GetRole() == ui::AX_ROLE_IFRAME_PRESENTATIONAL;
}

std::string BrowserAccessibility::GetTextRecursive() const {
if (!name_.empty()) {
return name_;
Expand Down
3 changes: 3 additions & 0 deletions content/browser/accessibility/browser_accessibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ class CONTENT_EXPORT BrowserAccessibility {
// Returns true if this node is an editable text field of any kind.
bool IsEditableText() const;

// True if this is a web area, and its grandparent is a presentational iframe.
bool IsWebAreaForPresentationalIframe() const;

// Append the text from this node and its children.
std::string GetTextRecursive() const;

Expand Down
12 changes: 10 additions & 2 deletions content/browser/accessibility/browser_accessibility_cocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,13 @@ - (NSString*)role {
else
return NSAccessibilityButtonRole;
}

// If this is a web area for a presentational iframe, give it a role of
// something other than WebArea so that the fact that it's a separate doc
// is not exposed to AT.
if (browserAccessibility_->IsWebAreaForPresentationalIframe())
return NSAccessibilityGroupRole;

return [AXPlatformNodeCocoa nativeRoleFromAXRole:role];
}

Expand All @@ -557,8 +564,9 @@ - (NSString*)roleDescription {
IDS_AX_ROLE_HEADING));
}

if ([role isEqualToString:NSAccessibilityGroupRole] ||
[role isEqualToString:NSAccessibilityRadioButtonRole]) {
if (([role isEqualToString:NSAccessibilityGroupRole] ||
[role isEqualToString:NSAccessibilityRadioButtonRole]) &&
!browserAccessibility_->IsWebAreaForPresentationalIframe()) {
std::string role;
if (browserAccessibility_->GetHtmlAttribute("role", &role)) {
ui::AXRole internalRole = [self internalRole];
Expand Down
11 changes: 11 additions & 0 deletions content/browser/accessibility/browser_accessibility_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3088,6 +3088,14 @@ void BrowserAccessibilityWin::OnDataChanged() {
relation->AddTarget(title_elem_id);
relations_.push_back(relation);
}

// If this is a web area for a presentational iframe, give it a role of
// something other than DOCUMENT so that the fact that it's a separate doc
// is not exposed to AT.
if (IsWebAreaForPresentationalIframe()) {
ia_role_ = ROLE_SYSTEM_GROUPING;
ia2_role_ = ROLE_SYSTEM_GROUPING;
}
}

void BrowserAccessibilityWin::OnUpdateFinished() {
Expand Down Expand Up @@ -3550,6 +3558,9 @@ void BrowserAccessibilityWin::InitRoleAndState() {
ia2_role_ = IA2_ROLE_INTERNAL_FRAME;
ia_state_ = STATE_SYSTEM_READONLY;
break;
case ui::AX_ROLE_IFRAME_PRESENTATIONAL:
ia_role_ = ROLE_SYSTEM_GROUPING;
break;
case ui::AX_ROLE_IMAGE:
ia_role_ = ROLE_SYSTEM_GRAPHIC;
ia_state_ |= STATE_SYSTEM_READONLY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,11 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
RunTest(FILE_PATH_LITERAL("iframe-coordinates.html"));
}

IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
AccessibilityIframePresentational) {
RunTest(FILE_PATH_LITERAL("iframe-presentational.html"));
}

IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityImg) {
RunTest(FILE_PATH_LITERAL("img.html"));
}
Expand Down
2 changes: 2 additions & 0 deletions content/renderer/accessibility/blink_ax_enum_conversion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ ui::AXRole AXRoleFromBlink(blink::WebAXRole role) {
return ui::AX_ROLE_HEADING;
case blink::WebAXRoleIframe:
return ui::AX_ROLE_IFRAME;
case blink::WebAXRoleIframePresentational:
return ui::AX_ROLE_IFRAME_PRESENTATIONAL;
case blink::WebAXRoleIgnored:
return ui::AX_ROLE_IGNORED;
case blink::WebAXRoleImage:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
android.webkit.WebView focusable focused scrollable
android.view.View
android.view.View
android.view.View
android.view.View scrollable
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
AXWebArea AXRoleDescription='HTML content'
AXGroup AXRoleDescription='group'
AXGroup AXRoleDescription='presentation'
AXUnknown AXRoleDescription='unknown'
AXGroup AXRoleDescription='group'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
IA2_ROLE_SECTION
ROLE_SYSTEM_GROUPING FOCUSABLE
IA2_ROLE_SCROLL_PANE
ROLE_SYSTEM_GROUPING READONLY FOCUSABLE
10 changes: 10 additions & 0 deletions content/test/data/accessibility/iframe-presentational.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!--
@MAC-ALLOW:AXRole*
-->
<!DOCTYPE html>
<html>
<body>
<iframe src="iframesrc.html" role="presentation">
</iframe>
</body>
</html>
1 change: 1 addition & 0 deletions ui/accessibility/ax_enums.idl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
group,
heading,
iframe,
iframe_presentational,
ignored,
image_map_link,
image_map,
Expand Down
1 change: 1 addition & 0 deletions ui/accessibility/platform/ax_platform_node_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ RoleMap BuildRoleMap() {
{ui::AX_ROLE_GROUP, NSAccessibilityGroupRole},
{ui::AX_ROLE_HEADING, @"AXHeading"},
{ui::AX_ROLE_IFRAME, NSAccessibilityGroupRole},
{ui::AX_ROLE_IFRAME_PRESENTATIONAL, NSAccessibilityGroupRole},
{ui::AX_ROLE_IGNORED, NSAccessibilityUnknownRole},
{ui::AX_ROLE_IMAGE, NSAccessibilityImageRole},
{ui::AX_ROLE_IMAGE_MAP, NSAccessibilityGroupRole},
Expand Down

0 comments on commit 8b43c60

Please sign in to comment.