| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/accessibility/ax_tree_data.h" | 5 #include "ui/accessibility/ax_tree_data.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 | 13 |
| 14 using base::DoubleToString; | 14 using base::DoubleToString; |
| 15 using base::IntToString; | 15 using base::IntToString; |
| 16 | 16 |
| 17 namespace ui { | 17 namespace ui { |
| 18 | 18 |
| 19 AXTreeData::AXTreeData() | 19 AXTreeData::AXTreeData() |
| 20 : tree_id(-1), | 20 : tree_id(-1), |
| 21 parent_tree_id(-1), | 21 parent_tree_id(-1), |
| 22 focused_tree_id(-1), |
| 22 loaded(false), | 23 loaded(false), |
| 23 loading_progress(0.0), | 24 loading_progress(0.0), |
| 24 focus_id(-1), | 25 focus_id(-1), |
| 25 sel_anchor_object_id(-1), | 26 sel_anchor_object_id(-1), |
| 26 sel_anchor_offset(-1), | 27 sel_anchor_offset(-1), |
| 27 sel_focus_object_id(-1), | 28 sel_focus_object_id(-1), |
| 28 sel_focus_offset(-1) { | 29 sel_focus_offset(-1) { |
| 29 } | 30 } |
| 30 | 31 |
| 31 AXTreeData::AXTreeData(const AXTreeData& other) = default; | 32 AXTreeData::AXTreeData(const AXTreeData& other) = default; |
| 32 | 33 |
| 33 AXTreeData::~AXTreeData() { | 34 AXTreeData::~AXTreeData() { |
| 34 } | 35 } |
| 35 | 36 |
| 36 // Note that this includes an initial space character if nonempty, but | 37 // Note that this includes an initial space character if nonempty, but |
| 37 // that works fine because this is normally printed by AXTree::ToString. | 38 // that works fine because this is normally printed by AXTree::ToString. |
| 38 std::string AXTreeData::ToString() const { | 39 std::string AXTreeData::ToString() const { |
| 39 std::string result; | 40 std::string result; |
| 40 | 41 |
| 41 if (tree_id != -1) | 42 if (tree_id != -1) |
| 42 result += " tree_id=" + IntToString(tree_id); | 43 result += " tree_id=" + IntToString(tree_id); |
| 43 if (parent_tree_id != -1) | 44 if (parent_tree_id != -1) |
| 44 result += " parent_tree_id=" + IntToString(parent_tree_id); | 45 result += " parent_tree_id=" + IntToString(parent_tree_id); |
| 46 if (focused_tree_id != -1) |
| 47 result += " focused_tree_id=" + IntToString(focused_tree_id); |
| 45 | 48 |
| 46 if (!url.empty()) | 49 if (!url.empty()) |
| 47 result += " url=" + url; | 50 result += " url=" + url; |
| 48 if (!title.empty()) | 51 if (!title.empty()) |
| 49 result += " title=" + title; | 52 result += " title=" + title; |
| 50 if (!mimetype.empty()) | 53 if (!mimetype.empty()) |
| 51 result += " mimetype=" + mimetype; | 54 result += " mimetype=" + mimetype; |
| 52 if (!doctype.empty()) | 55 if (!doctype.empty()) |
| 53 result += " doctype=" + doctype; | 56 result += " doctype=" + doctype; |
| 54 | 57 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 68 result += " sel_focus_object_id=" + IntToString(sel_focus_object_id); | 71 result += " sel_focus_object_id=" + IntToString(sel_focus_object_id); |
| 69 result += " sel_focus_offset=" + IntToString(sel_focus_offset); | 72 result += " sel_focus_offset=" + IntToString(sel_focus_offset); |
| 70 } | 73 } |
| 71 | 74 |
| 72 return result; | 75 return result; |
| 73 } | 76 } |
| 74 | 77 |
| 75 bool operator==(const AXTreeData& lhs, const AXTreeData& rhs) { | 78 bool operator==(const AXTreeData& lhs, const AXTreeData& rhs) { |
| 76 return (lhs.tree_id == rhs.tree_id && | 79 return (lhs.tree_id == rhs.tree_id && |
| 77 lhs.parent_tree_id == rhs.parent_tree_id && | 80 lhs.parent_tree_id == rhs.parent_tree_id && |
| 81 lhs.focused_tree_id == rhs.focused_tree_id && |
| 78 lhs.url == rhs.url && | 82 lhs.url == rhs.url && |
| 79 lhs.title == rhs.title && | 83 lhs.title == rhs.title && |
| 80 lhs.mimetype == rhs.mimetype && | 84 lhs.mimetype == rhs.mimetype && |
| 81 lhs.doctype == rhs.doctype && | 85 lhs.doctype == rhs.doctype && |
| 82 lhs.loaded == rhs.loaded && | 86 lhs.loaded == rhs.loaded && |
| 83 lhs.loading_progress == rhs.loading_progress && | 87 lhs.loading_progress == rhs.loading_progress && |
| 84 lhs.focus_id == rhs.focus_id && | 88 lhs.focus_id == rhs.focus_id && |
| 85 lhs.sel_anchor_object_id == rhs.sel_anchor_object_id && | 89 lhs.sel_anchor_object_id == rhs.sel_anchor_object_id && |
| 86 lhs.sel_anchor_offset == rhs.sel_anchor_offset && | 90 lhs.sel_anchor_offset == rhs.sel_anchor_offset && |
| 87 lhs.sel_focus_object_id == rhs.sel_focus_object_id && | 91 lhs.sel_focus_object_id == rhs.sel_focus_object_id && |
| 88 lhs.sel_focus_offset == rhs.sel_focus_offset); | 92 lhs.sel_focus_offset == rhs.sel_focus_offset); |
| 89 } | 93 } |
| 90 | 94 |
| 91 bool operator!=(const AXTreeData& lhs, const AXTreeData& rhs) { | 95 bool operator!=(const AXTreeData& lhs, const AXTreeData& rhs) { |
| 92 return !(lhs == rhs); | 96 return !(lhs == rhs); |
| 93 } | 97 } |
| 94 | 98 |
| 95 } // namespace ui | 99 } // namespace ui |
| OLD | NEW |