| 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_CHROMIUM_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_CHROMIUM_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_CHROMIUM_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_CHROMIUM_H_ |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 | 9 |
| 10 namespace mojo { | 10 namespace mojo { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } | 48 } |
| 49 | 49 |
| 50 int height() const { return height_; } | 50 int height() const { return height_; } |
| 51 void set_height(int height) { | 51 void set_height(int height) { |
| 52 DCHECK_GE(height, 0); | 52 DCHECK_GE(height, 0); |
| 53 height_ = height; | 53 height_ = height; |
| 54 } | 54 } |
| 55 | 55 |
| 56 int GetArea() const { return width_ * height_; } | 56 int GetArea() const { return width_ * height_; } |
| 57 | 57 |
| 58 bool operator==(const RectChromium& other) const { |
| 59 return (x() == other.x() && y() == other.y() && width() == other.width() && |
| 60 height() == other.height()); |
| 61 } |
| 62 bool operator!=(const RectChromium& other) const { return !(*this == other); } |
| 63 |
| 58 private: | 64 private: |
| 59 int x_ = 0; | 65 int x_ = 0; |
| 60 int y_ = 0; | 66 int y_ = 0; |
| 61 int width_ = 0; | 67 int width_ = 0; |
| 62 int height_ = 0; | 68 int height_ = 0; |
| 63 }; | 69 }; |
| 64 | 70 |
| 65 } // namespace test | 71 } // namespace test |
| 66 } // namespace mojo | 72 } // namespace mojo |
| 67 | 73 |
| 74 namespace std { |
| 75 |
| 76 template <> |
| 77 struct hash<mojo::test::RectChromium> { |
| 78 size_t operator()(const mojo::test::RectChromium& value) { |
| 79 // Terrible hash function: |
| 80 return (std::hash<int>()(value.x()) ^ std::hash<int>()(value.y()) ^ |
| 81 std::hash<int>()(value.width()) ^ std::hash<int>()(value.height())); |
| 82 } |
| 83 }; |
| 84 |
| 85 } // namespace std |
| 86 |
| 68 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_CHROMIUM_H_ | 87 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_CHROMIUM_H_ |
| OLD | NEW |