| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 UI_ACCESSIBILITY_AX_RELATIVE_BOUNDS_H_ | 5 #ifndef UI_ACCESSIBILITY_AX_RELATIVE_BOUNDS_H_ |
| 6 #define UI_ACCESSIBILITY_AX_RELATIVE_BOUNDS_H_ | 6 #define UI_ACCESSIBILITY_AX_RELATIVE_BOUNDS_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ui/accessibility/ax_export.h" | 10 #include "ui/accessibility/ax_export.h" |
| 11 #include "ui/gfx/geometry/rect_f.h" | 11 #include "ui/gfx/geometry/rect_f.h" |
| 12 | 12 |
| 13 namespace gfx { | 13 namespace gfx { |
| 14 class Transform; | 14 class Transform; |
| 15 }; | 15 }; |
| 16 | 16 |
| 17 namespace ui { | 17 namespace ui { |
| 18 | 18 |
| 19 // The relative bounding box of an AXNode. | 19 // The relative bounding box of an AXNode. |
| 20 // | 20 // |
| 21 // This is an efficient, compact, serializable representation of a node's | 21 // This is an efficient, compact, serializable representation of a node's |
| 22 // bounding box that requires minimal changes to the tree when layers are | 22 // bounding box that requires minimal changes to the tree when layers are |
| 23 // moved or scrolled. Computing the absolute bounding box of a node requires | 23 // moved or scrolled. Computing the absolute bounding box of a node requires |
| 24 // walking up the tree and applying node offsets and transforms until reaching | 24 // walking up the tree and applying node offsets, scroll positions, and |
| 25 // the top. | 25 // transforms until reaching the top. |
| 26 // | 26 // |
| 27 // If the offset container id is valid, the bounds are relative | 27 // If the offset container id is valid, the bounds are relative |
| 28 // to the node with that offset container id. | 28 // to the node with that offset container id. |
| 29 // | 29 // |
| 30 // Otherwise, for a node other than the root, the bounds are relative to | 30 // Otherwise, for a node other than the root, the bounds are relative to |
| 31 // the root of the tree, and for the root of a tree, the bounds are relative | 31 // the root of the tree, and for the root of a tree, the bounds are relative |
| 32 // to its immediate containing node. | 32 // to its immediate containing node. |
| 33 // |
| 34 // If |is_fixed_positioned| is true, the scroll offsets of the container |
| 35 // node should be ignored. |
| 36 // |
| 37 // The canonical implementation of converting a node's bounding box |
| 38 // from local coordinates to tree coordinates is AXTree::GetTreeBounds(). |
| 39 // Always try to use that rather than reimplementing it. |
| 33 struct AX_EXPORT AXRelativeBounds { | 40 struct AX_EXPORT AXRelativeBounds { |
| 34 AXRelativeBounds(); | 41 AXRelativeBounds(); |
| 35 virtual ~AXRelativeBounds(); | 42 virtual ~AXRelativeBounds(); |
| 36 | 43 |
| 37 AXRelativeBounds(const AXRelativeBounds& other); | 44 AXRelativeBounds(const AXRelativeBounds& other); |
| 38 AXRelativeBounds& operator=(AXRelativeBounds other); | 45 AXRelativeBounds& operator=(AXRelativeBounds other); |
| 39 bool operator!=(const AXRelativeBounds& other); | 46 bool operator!=(const AXRelativeBounds& other); |
| 40 bool operator==(const AXRelativeBounds& other); | 47 bool operator==(const AXRelativeBounds& other); |
| 41 | 48 |
| 42 std::string ToString() const; | 49 std::string ToString() const; |
| 43 | 50 |
| 44 // The id of an ancestor node in the same AXTree that this object's | 51 // The id of an ancestor node in the same AXTree that this object's |
| 45 // bounding box is relative to, or -1 if there's no offset container. | 52 // bounding box is relative to, or -1 if there's no offset container. |
| 46 int offset_container_id; | 53 int offset_container_id; |
| 47 | 54 |
| 48 // The relative bounding box of this node. | 55 // The relative bounding box of this node. |
| 49 gfx::RectF bounds; | 56 gfx::RectF bounds; |
| 50 | 57 |
| 51 // An additional transform to apply to position this object and its subtree. | 58 // An additional transform to apply to position this object and its subtree. |
| 52 // NOTE: this member is a std::unique_ptr because it's rare and gfx::Transform | 59 // NOTE: this member is a std::unique_ptr because it's rare and gfx::Transform |
| 53 // takes up a fair amount of space. The assignment operator and copy | 60 // takes up a fair amount of space. The assignment operator and copy |
| 54 // constructor both make a duplicate of the owned pointer, so it acts more | 61 // constructor both make a duplicate of the owned pointer, so it acts more |
| 55 // like a member than a pointer. | 62 // like a member than a pointer. |
| 56 std::unique_ptr<gfx::Transform> transform; | 63 std::unique_ptr<gfx::Transform> transform; |
| 64 |
| 65 // If true, the container's scroll position should be ignored. |
| 66 bool is_fixed_positioned; |
| 57 }; | 67 }; |
| 58 | 68 |
| 59 } // namespace ui | 69 } // namespace ui |
| 60 | 70 |
| 61 #endif // UI_ACCESSIBILITY_AX_NODE_DATA_H_ | 71 #endif // UI_ACCESSIBILITY_AX_NODE_DATA_H_ |
| OLD | NEW |