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

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

Issue 2393123002: Implement caching asynchronous accessibility hit testing. (Closed)
Patch Set: Made test more robust Created 4 years, 2 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
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 child_start += child_len; 709 child_start += child_len;
710 if (start >= child_len) 710 if (start >= child_len)
711 start -= child_len; 711 start -= child_len;
712 else 712 else
713 start = -1; 713 start = -1;
714 } 714 }
715 return word_start; 715 return word_start;
716 } 716 }
717 } 717 }
718 718
719 BrowserAccessibility* BrowserAccessibility::BrowserAccessibilityForPoint( 719 BrowserAccessibility* BrowserAccessibility::ApproximateHitTest(
720 const gfx::Point& point) { 720 const gfx::Point& point) {
721 // The best result found that's a child of this object. 721 // The best result found that's a child of this object.
722 BrowserAccessibility* child_result = NULL; 722 BrowserAccessibility* child_result = NULL;
723 // The best result that's an indirect descendant like grandchild, etc. 723 // The best result that's an indirect descendant like grandchild, etc.
724 BrowserAccessibility* descendant_result = NULL; 724 BrowserAccessibility* descendant_result = NULL;
725 725
726 // Walk the children recursively looking for the BrowserAccessibility that 726 // Walk the children recursively looking for the BrowserAccessibility that
727 // most tightly encloses the specified point. Walk backwards so that in 727 // most tightly encloses the specified point. Walk backwards so that in
728 // the absence of any other information, we assume the object that occurs 728 // the absence of any other information, we assume the object that occurs
729 // later in the tree is on top of one that comes before it. 729 // later in the tree is on top of one that comes before it.
730 for (int i = static_cast<int>(PlatformChildCount()) - 1; i >= 0; --i) { 730 for (int i = static_cast<int>(PlatformChildCount()) - 1; i >= 0; --i) {
731 BrowserAccessibility* child = PlatformGetChild(i); 731 BrowserAccessibility* child = PlatformGetChild(i);
732 732
733 // Skip table columns because cells are only contained in rows, 733 // Skip table columns because cells are only contained in rows,
734 // not columns. 734 // not columns.
735 if (child->GetRole() == ui::AX_ROLE_COLUMN) 735 if (child->GetRole() == ui::AX_ROLE_COLUMN)
736 continue; 736 continue;
737 737
738 if (child->GetScreenBoundsRect().Contains(point)) { 738 if (child->GetScreenBoundsRect().Contains(point)) {
739 BrowserAccessibility* result = child->BrowserAccessibilityForPoint(point); 739 BrowserAccessibility* result = child->ApproximateHitTest(point);
740 if (result == child && !child_result) 740 if (result == child && !child_result)
741 child_result = result; 741 child_result = result;
742 if (result != child && !descendant_result) 742 if (result != child && !descendant_result)
743 descendant_result = result; 743 descendant_result = result;
744 } 744 }
745 745
746 if (child_result && descendant_result) 746 if (child_result && descendant_result)
747 break; 747 break;
748 } 748 }
749 749
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 } 1216 }
1217 } 1217 }
1218 1218
1219 node = container; 1219 node = container;
1220 } 1220 }
1221 1221
1222 return gfx::ToEnclosingRect(bounds); 1222 return gfx::ToEnclosingRect(bounds);
1223 } 1223 }
1224 1224
1225 } // namespace content 1225 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698