Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/accessibility/ax_relative_bounds.h" | |
| 6 | |
| 7 #include "base/strings/string_number_conversions.h" | |
| 8 #include "ui/gfx/transform.h" | |
| 9 | |
| 10 using base::IntToString; | |
| 11 | |
| 12 namespace ui { | |
| 13 | |
| 14 AXRelativeBounds::AXRelativeBounds() | |
| 15 : offset_container_id(-1) { | |
| 16 } | |
| 17 | |
| 18 AXRelativeBounds::~AXRelativeBounds() { | |
| 19 } | |
| 20 | |
| 21 AXRelativeBounds::AXRelativeBounds(const AXRelativeBounds& other) { | |
| 22 offset_container_id = other.offset_container_id; | |
| 23 bounds = other.bounds; | |
| 24 if (other.transform) | |
| 25 transform.reset(new gfx::Transform(*other.transform)); | |
| 26 } | |
| 27 | |
| 28 AXRelativeBounds& AXRelativeBounds::operator=(AXRelativeBounds other) { | |
| 29 offset_container_id = other.offset_container_id; | |
| 30 bounds = other.bounds; | |
| 31 if (other.transform) | |
| 32 transform.reset(new gfx::Transform(*other.transform)); | |
| 33 return *this; | |
| 34 } | |
| 35 | |
| 36 bool AXRelativeBounds::operator==(const AXRelativeBounds& other) { | |
| 37 if (offset_container_id != other.offset_container_id) | |
| 38 return false; | |
| 39 if (bounds != other.bounds) | |
| 40 return false; | |
| 41 if (!transform && !other.transform) | |
| 42 return true; | |
| 43 if ((transform && !other.transform) || (!transform && other.transform)) | |
| 44 return false; | |
| 45 return *transform == *other.transform; | |
| 46 } | |
| 47 | |
| 48 bool AXRelativeBounds::operator!=(const AXRelativeBounds& other) { | |
|
aboxhall
2016/08/12 16:05:10
Why can't this delegate to operator==?
dmazzoni
2016/08/15 05:31:11
Much better idea. Done.
| |
| 49 if (offset_container_id != other.offset_container_id) | |
| 50 return true; | |
| 51 if (bounds != other.bounds) | |
| 52 return true; | |
| 53 if (!transform && !other.transform) | |
| 54 return false; | |
| 55 if ((transform && !other.transform) || (!transform && other.transform)) | |
| 56 return true; | |
| 57 return *transform != *other.transform; | |
| 58 } | |
| 59 | |
| 60 std::string AXRelativeBounds::ToString() const { | |
| 61 std::string result; | |
| 62 | |
| 63 if (offset_container_id != -1) | |
| 64 result += "offset_container_id=" + IntToString(offset_container_id) + " "; | |
| 65 | |
| 66 result += "(" + IntToString(bounds.x()) + ", " + | |
| 67 IntToString(bounds.y()) + ")-(" + | |
| 68 IntToString(bounds.width()) + ", " + | |
| 69 IntToString(bounds.height()) + ")"; | |
| 70 | |
| 71 if (transform && !transform->IsIdentity()) | |
| 72 result += " transform=" + transform->ToString(); | |
| 73 | |
| 74 return result; | |
| 75 } | |
| 76 | |
| 77 } // namespace ui | |
| OLD | NEW |