Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Side by Side Diff: content/browser/accessibility/browser_accessibility.cc

Issue 1713723002: Implement accessibility support for CSS-transformed iframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/accessibility/browser_accessibility.h" 5 #include "content/browser/accessibility/browser_accessibility.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "content/browser/accessibility/browser_accessibility_manager.h" 15 #include "content/browser/accessibility/browser_accessibility_manager.h"
16 #include "content/common/accessibility_messages.h" 16 #include "content/common/accessibility_messages.h"
17 #include "ui/accessibility/ax_text_utils.h" 17 #include "ui/accessibility/ax_text_utils.h"
18 #include "ui/gfx/geometry/rect_f.h"
18 19
19 namespace content { 20 namespace content {
20 21
21 #if !defined(PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL) 22 #if !defined(PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL)
22 // static 23 // static
23 BrowserAccessibility* BrowserAccessibility::Create() { 24 BrowserAccessibility* BrowserAccessibility::Create() {
24 return new BrowserAccessibility(); 25 return new BrowserAccessibility();
25 } 26 }
26 #endif 27 #endif
27 28
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 continue; 871 continue;
871 } 872 }
872 873
873 // Union each additional child's bounds. 874 // Union each additional child's bounds.
874 bounds->Union(child_bounds); 875 bounds->Union(child_bounds);
875 } 876 }
876 } 877 }
877 878
878 gfx::Rect BrowserAccessibility::ElementBoundsToLocalBounds(gfx::Rect bounds) 879 gfx::Rect BrowserAccessibility::ElementBoundsToLocalBounds(gfx::Rect bounds)
879 const { 880 const {
881 // If this element has a transform, apply it and we're done.
882 if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA &&
883 GetParent() &&
884 GetParent()->manager() != manager() &&
885 manager()->delegate()) {
886 manager()->delegate()->AccessibilityTransformToRootCoordSpace(&bounds);
887 return bounds;
888 } else if (GetData().transform.get() &&
889 !GetData().transform->IsIdentity()) {
890 gfx::RectF boundsf(bounds);
891 GetData().transform->TransformRect(&boundsf);
892 return gfx::Rect(boundsf.x(), boundsf.y(),
893 boundsf.width(), boundsf.height());
894 }
895
880 // Walk up the parent chain. Every time we encounter a Web Area, offset 896 // Walk up the parent chain. Every time we encounter a Web Area, offset
881 // based on the scroll bars and then offset based on the origin of that 897 // based on the scroll bars and then offset based on the origin of that
882 // nested web area. 898 // nested web area.
883 BrowserAccessibility* parent = GetParent(); 899 BrowserAccessibility* parent = GetParent();
884 bool need_to_offset_web_area = 900 bool need_to_offset_web_area =
885 (GetRole() == ui::AX_ROLE_WEB_AREA || 901 (GetRole() == ui::AX_ROLE_WEB_AREA ||
886 GetRole() == ui::AX_ROLE_ROOT_WEB_AREA); 902 GetRole() == ui::AX_ROLE_ROOT_WEB_AREA);
887 while (parent) { 903 while (parent) {
904 bool parent_is_in_different_tree = parent->manager() != manager();
905
906 bool parent_transform_is_identity = !parent->GetData().transform.get() ||
907 parent->GetData().transform->IsIdentity();
908
888 if (need_to_offset_web_area && 909 if (need_to_offset_web_area &&
889 parent->GetLocation().width() > 0 && 910 parent->GetLocation().width() > 0 &&
890 parent->GetLocation().height() > 0) { 911 parent->GetLocation().height() > 0 &&
912 parent_transform_is_identity &&
913 !parent_is_in_different_tree) {
891 bounds.Offset(parent->GetLocation().x(), parent->GetLocation().y()); 914 bounds.Offset(parent->GetLocation().x(), parent->GetLocation().y());
892 need_to_offset_web_area = false; 915 need_to_offset_web_area = false;
893 } 916 }
894 917
895 // On some platforms, we don't want to take the root scroll offsets 918 // On some platforms, we don't want to take the root scroll offsets
896 // into account. 919 // into account.
897 if (parent->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA && 920 if (parent->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA &&
898 !manager()->UseRootScrollOffsetsWhenComputingBounds()) { 921 !manager()->UseRootScrollOffsetsWhenComputingBounds()) {
899 break; 922 break;
900 } 923 }
901 924
902 if (parent->GetRole() == ui::AX_ROLE_WEB_AREA || 925 if (parent->GetRole() == ui::AX_ROLE_WEB_AREA ||
903 parent->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA) { 926 parent->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA) {
904 int sx = 0; 927 int sx = 0;
905 int sy = 0; 928 int sy = 0;
906 if (parent->GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && 929 if (parent->GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) &&
907 parent->GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { 930 parent->GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) {
908 bounds.Offset(-sx, -sy); 931 bounds.Offset(-sx, -sy);
909 } 932 }
910 need_to_offset_web_area = true; 933 need_to_offset_web_area = true;
934
935 if (parent_is_in_different_tree && manager()->delegate()) {
936 manager()->delegate()->AccessibilityTransformToRootCoordSpace(&bounds);
937 break;
938 } else if (!parent_transform_is_identity) {
939 gfx::RectF boundsf(bounds);
940 parent->GetData().transform->TransformRect(&boundsf);
941 bounds = gfx::Rect(boundsf.x(), boundsf.y(),
942 boundsf.width(), boundsf.height());
943 need_to_offset_web_area = false;
944 }
911 } 945 }
946
912 parent = parent->GetParent(); 947 parent = parent->GetParent();
913 } 948 }
914 949
915 return bounds; 950 return bounds;
916 } 951 }
917 952
918 } // namespace content 953 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698