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

Side by Side Diff: third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp

Issue 2956053005: Keep track of fixed positioning in accessibility tree.
Patch Set: GetSimpleRelativeBounds, add failing test for fixed with transform Created 3 years, 5 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 /* 1 /*
2 * Copyright (C) 2012, Google Inc. All rights reserved. 2 * Copyright (C) 2012, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 html_element = ToHTMLElement(GetNode()); 2057 html_element = ToHTMLElement(GetNode());
2058 if (html_element && IsLabelableElement(html_element)) { 2058 if (html_element && IsLabelableElement(html_element)) {
2059 if (ToLabelableElement(html_element)->labels() && 2059 if (ToLabelableElement(html_element)->labels() &&
2060 ToLabelableElement(html_element)->labels()->length() > 0) 2060 ToLabelableElement(html_element)->labels()->length() > 0)
2061 return true; 2061 return true;
2062 } 2062 }
2063 2063
2064 return false; 2064 return false;
2065 } 2065 }
2066 2066
2067 void AXNodeObject::GetRelativeBounds( 2067 void AXNodeObject::GetRelativeBounds(AXObject** out_container,
2068 AXObject** out_container, 2068 FloatRect& out_bounds_in_container,
2069 FloatRect& out_bounds_in_container, 2069 SkMatrix44& out_container_transform,
2070 SkMatrix44& out_container_transform) const { 2070 bool& out_is_fixed_positioned) const {
2071 if (LayoutObjectForRelativeBounds()) { 2071 if (LayoutObjectForRelativeBounds()) {
2072 AXObject::GetRelativeBounds(out_container, out_bounds_in_container, 2072 AXObject::GetRelativeBounds(out_container, out_bounds_in_container,
2073 out_container_transform); 2073 out_container_transform,
2074 out_is_fixed_positioned);
2074 return; 2075 return;
2075 } 2076 }
2076 2077
2077 *out_container = nullptr; 2078 *out_container = nullptr;
2078 out_bounds_in_container = FloatRect(); 2079 out_bounds_in_container = FloatRect();
2079 out_container_transform.setIdentity(); 2080 out_container_transform.setIdentity();
2080 2081
2081 // First check if it has explicit bounds, for example if this element is tied 2082 // First check if it has explicit bounds, for example if this element is tied
2082 // to a canvas path. When explicit coordinates are provided, the ID of the 2083 // to a canvas path. When explicit coordinates are provided, the ID of the
2083 // explicit container element that the coordinates are relative to must be 2084 // explicit container element that the coordinates are relative to must be
2084 // provided too. 2085 // provided too.
2085 if (!explicit_element_rect_.IsEmpty()) { 2086 if (!explicit_element_rect_.IsEmpty()) {
2086 *out_container = AxObjectCache().ObjectFromAXID(explicit_container_id_); 2087 *out_container = AxObjectCache().ObjectFromAXID(explicit_container_id_);
2087 if (*out_container) { 2088 if (*out_container) {
2088 out_bounds_in_container = FloatRect(explicit_element_rect_); 2089 out_bounds_in_container = FloatRect(explicit_element_rect_);
2089 return; 2090 return;
2090 } 2091 }
2091 } 2092 }
2092 2093
2093 // If it's in a canvas but doesn't have an explicit rect, get the bounding 2094 // If it's in a canvas but doesn't have an explicit rect, get the bounding
2094 // rect of its children. 2095 // rect of its children.
2095 if (GetNode()->parentElement()->IsInCanvasSubtree()) { 2096 if (GetNode()->parentElement()->IsInCanvasSubtree()) {
2096 Vector<FloatRect> rects; 2097 Vector<FloatRect> rects;
2097 for (Node& child : NodeTraversal::ChildrenOf(*GetNode())) { 2098 for (Node& child : NodeTraversal::ChildrenOf(*GetNode())) {
2098 if (child.IsHTMLElement()) { 2099 if (child.IsHTMLElement()) {
2099 if (AXObject* obj = AxObjectCache().Get(&child)) { 2100 if (AXObject* obj = AxObjectCache().Get(&child)) {
2100 AXObject* container; 2101 AXObject* container;
2101 FloatRect bounds; 2102 FloatRect bounds;
2102 obj->GetRelativeBounds(&container, bounds, out_container_transform); 2103 obj->GetRelativeBounds(&container, bounds, out_container_transform,
2104 out_is_fixed_positioned);
2103 if (container) { 2105 if (container) {
2104 *out_container = container; 2106 *out_container = container;
2105 rects.push_back(bounds); 2107 rects.push_back(bounds);
2106 } 2108 }
2107 } 2109 }
2108 } 2110 }
2109 } 2111 }
2110 2112
2111 if (*out_container) { 2113 if (*out_container) {
2112 out_bounds_in_container = UnionRect(rects); 2114 out_bounds_in_container = UnionRect(rects);
2113 return; 2115 return;
2114 } 2116 }
2115 } 2117 }
2116 2118
2117 // If this object doesn't have an explicit element rect or computable from its 2119 // If this object doesn't have an explicit element rect or computable from its
2118 // children, for now, let's return the position of the ancestor that does have 2120 // children, for now, let's return the position of the ancestor that does have
2119 // a position, and make it the width of that parent, and about the height of a 2121 // a position, and make it the width of that parent, and about the height of a
2120 // line of text, so that it's clear the object is a child of the parent. 2122 // line of text, so that it's clear the object is a child of the parent.
2121 for (AXObject* position_provider = ParentObject(); position_provider; 2123 for (AXObject* position_provider = ParentObject(); position_provider;
2122 position_provider = position_provider->ParentObject()) { 2124 position_provider = position_provider->ParentObject()) {
2123 if (position_provider->IsAXLayoutObject()) { 2125 if (position_provider->IsAXLayoutObject()) {
2124 position_provider->GetRelativeBounds( 2126 position_provider->GetRelativeBounds(
2125 out_container, out_bounds_in_container, out_container_transform); 2127 out_container, out_bounds_in_container, out_container_transform,
2128 out_is_fixed_positioned);
2126 if (*out_container) 2129 if (*out_container)
2127 out_bounds_in_container.SetSize( 2130 out_bounds_in_container.SetSize(
2128 FloatSize(out_bounds_in_container.Width(), 2131 FloatSize(out_bounds_in_container.Width(),
2129 std::min(10.0f, out_bounds_in_container.Height()))); 2132 std::min(10.0f, out_bounds_in_container.Height())));
2130 break; 2133 break;
2131 } 2134 }
2132 } 2135 }
2133 } 2136 }
2134 2137
2135 static Node* GetParentNodeForComputeParent(Node* node) { 2138 static Node* GetParentNodeForComputeParent(Node* node) {
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
3258 return String(); 3261 return String();
3259 return ToTextControlElement(node)->StrippedPlaceholder(); 3262 return ToTextControlElement(node)->StrippedPlaceholder();
3260 } 3263 }
3261 3264
3262 DEFINE_TRACE(AXNodeObject) { 3265 DEFINE_TRACE(AXNodeObject) {
3263 visitor->Trace(node_); 3266 visitor->Trace(node_);
3264 AXObject::Trace(visitor); 3267 AXObject::Trace(visitor);
3265 } 3268 }
3266 3269
3267 } // namespace blink 3270 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698