OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ | 5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ |
6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ | 6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // top-left corner of the overall web area. | 101 // top-left corner of the overall web area. |
102 gfx::Rect GetLocalBoundsRect(); | 102 gfx::Rect GetLocalBoundsRect(); |
103 | 103 |
104 // Returns the bounds of this object in screen coordinates. | 104 // Returns the bounds of this object in screen coordinates. |
105 gfx::Rect GetGlobalBoundsRect(); | 105 gfx::Rect GetGlobalBoundsRect(); |
106 | 106 |
107 // Returns the deepest descendant that contains the specified point | 107 // Returns the deepest descendant that contains the specified point |
108 // (in global screen coordinates). | 108 // (in global screen coordinates). |
109 BrowserAccessibility* BrowserAccessibilityForPoint(const gfx::Point& point); | 109 BrowserAccessibility* BrowserAccessibilityForPoint(const gfx::Point& point); |
110 | 110 |
| 111 // Scrolls this element so that the |focus| rect (in local coordinates |
| 112 // relative to this element) is scrolled to fit within the given |
| 113 // |viewport| (which is clipped to the actual bounds of this |
| 114 // object if you specify something larger). If the whole focus area |
| 115 // doesn't fit, you can specify |subfocus|, which will prioritize |
| 116 // a smaller area within |focus|. |
| 117 // |
| 118 // Note that "focus" doesn't necessarily mean the rectangle must correspond |
| 119 // to a focused element on the page; assistive technology might request |
| 120 // that any object be made visible. |
| 121 void ScrollToMakeVisible(const gfx::Rect& subfocus, |
| 122 const gfx::Rect& focus, |
| 123 const gfx::Rect& viewport); |
| 124 |
| 125 // This is a 1-dimensional scroll offset helper function that's applied |
| 126 // separately in the horizontal and vertical directions, because the |
| 127 // logic is the same. The goal is to compute the best scroll offset |
| 128 // in order to make a focused item visible within a viewport. |
| 129 // |
| 130 // In case the whole focused item cannot fit, you can specify a |
| 131 // subfocus - a smaller region within the focus that should |
| 132 // be prioritized. If the whole focused item can fit, the subfocus is |
| 133 // ignored. |
| 134 // |
| 135 // Example: the viewport is scrolled to the right just enough |
| 136 // that the focus is in view. |
| 137 // Before: |
| 138 // +----------Viewport---------+ |
| 139 // +----Focus---+ |
| 140 // +--SubFocus--+ |
| 141 // |
| 142 // After: |
| 143 // +----------Viewport---------+ |
| 144 // +----Focus---+ |
| 145 // +--SubFocus--+ |
| 146 // |
| 147 // When constraints cannot be fully satisfied, the min |
| 148 // (left/top) position takes precedence over the max (right/bottom). |
| 149 // |
| 150 // Note that the return value represents the ideal new scroll offset. |
| 151 // This may be out of range - the calling function should clip this |
| 152 // to the available range. |
| 153 static int ComputeBestScrollOffset(int current_scroll_offset, |
| 154 int subfocus_min, int subfocus_max, |
| 155 int focus_min, int focus_max, |
| 156 int viewport_min, int viewport_max); |
| 157 |
111 // | 158 // |
112 // Reference counting | 159 // Reference counting |
113 // | 160 // |
114 // Each object has an internal reference count and many platform | 161 // Each object has an internal reference count and many platform |
115 // implementations may also use native reference counting. | 162 // implementations may also use native reference counting. |
116 // | 163 // |
117 // The internal reference counting is used because sometimes | 164 // The internal reference counting is used because sometimes |
118 // multiple references to the same object exist temporarily during | 165 // multiple references to the same object exist temporarily during |
119 // an update. When the internal reference count reaches zero, | 166 // an update. When the internal reference count reaches zero, |
120 // NativeReleaseReference is called. | 167 // NativeReleaseReference is called. |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 // tree, a client may still be holding onto a pointer to this object, so | 322 // tree, a client may still be holding onto a pointer to this object, so |
276 // we mark it as inactive so that calls to any of this object's methods | 323 // we mark it as inactive so that calls to any of this object's methods |
277 // immediately return failure. | 324 // immediately return failure. |
278 bool instance_active_; | 325 bool instance_active_; |
279 | 326 |
280 private: | 327 private: |
281 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); | 328 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); |
282 }; | 329 }; |
283 | 330 |
284 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ | 331 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ |
OLD | NEW |