OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/accessibility/ax_tree_data.h" |
| 6 |
| 7 #include <set> |
| 8 |
| 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" |
| 13 |
| 14 using base::DoubleToString; |
| 15 using base::IntToString; |
| 16 |
| 17 namespace ui { |
| 18 |
| 19 AXTreeData::AXTreeData() |
| 20 : tree_id(-1), |
| 21 parent_tree_id(-1), |
| 22 loaded(false), |
| 23 loading_progress(0.0), |
| 24 sel_anchor_object_id(-1), |
| 25 sel_anchor_offset(-1), |
| 26 sel_focus_object_id(-1), |
| 27 sel_focus_offset(-1) { |
| 28 } |
| 29 |
| 30 AXTreeData::~AXTreeData() { |
| 31 } |
| 32 |
| 33 // Note that this includes an initial space character if nonempty, but |
| 34 // that works fine because this is normally printed by AXTree::ToString. |
| 35 std::string AXTreeData::ToString() const { |
| 36 std::string result; |
| 37 |
| 38 if (tree_id != -1) |
| 39 result += " tree_id=" + IntToString(tree_id); |
| 40 if (parent_tree_id != -1) |
| 41 result += " parent_tree_id=" + IntToString(parent_tree_id); |
| 42 |
| 43 if (!url.empty()) |
| 44 result += " url=" + url; |
| 45 if (!title.empty()) |
| 46 result += " title=" + title; |
| 47 if (!mimetype.empty()) |
| 48 result += " mimetype=" + mimetype; |
| 49 if (!doctype.empty()) |
| 50 result += " doctype=" + doctype; |
| 51 |
| 52 if (loaded) |
| 53 result += " loaded=true"; |
| 54 if (loading_progress != 0.0) |
| 55 result += " loading_progress=" + DoubleToString(loading_progress); |
| 56 |
| 57 if (sel_anchor_object_id != -1) { |
| 58 result += " sel_anchor_object_id=" + IntToString(sel_anchor_object_id); |
| 59 result += " sel_anchor_offset=" + IntToString(sel_anchor_offset); |
| 60 } |
| 61 if (sel_focus_object_id != -1) { |
| 62 result += " sel_focus_object_id=" + IntToString(sel_focus_object_id); |
| 63 result += " sel_focus_offset=" + IntToString(sel_focus_offset); |
| 64 } |
| 65 |
| 66 return result; |
| 67 } |
| 68 |
| 69 bool operator==(const AXTreeData& lhs, const AXTreeData& rhs) { |
| 70 return (lhs.tree_id == rhs.tree_id && |
| 71 lhs.parent_tree_id == rhs.parent_tree_id && |
| 72 lhs.url == rhs.url && |
| 73 lhs.title == rhs.title && |
| 74 lhs.mimetype == rhs.mimetype && |
| 75 lhs.doctype == rhs.doctype && |
| 76 lhs.loaded == rhs.loaded && |
| 77 lhs.loading_progress == rhs.loading_progress && |
| 78 lhs.sel_anchor_object_id == rhs.sel_anchor_object_id && |
| 79 lhs.sel_anchor_offset == rhs.sel_anchor_offset && |
| 80 lhs.sel_focus_object_id == rhs.sel_focus_object_id && |
| 81 lhs.sel_focus_offset == rhs.sel_focus_offset); |
| 82 } |
| 83 |
| 84 bool operator!=(const AXTreeData& lhs, const AXTreeData& rhs) { |
| 85 return !(lhs == rhs); |
| 86 } |
| 87 |
| 88 } // namespace ui |
OLD | NEW |