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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_H_ 7 8 #include "base/logging.h" 9 10 namespace mojo { 11 namespace test { 12 13 // An implementation of a hypothetical Rect type specifically for consumers in 14 // in Blink. Unlike the Chromium variant (see rect_chromium.h) this does not 15 // support negative origin coordinates and is not copyable. 16 class RectBlink { 17 public: RectBlink()18 RectBlink() {} RectBlink(int x,int y,int width,int height)19 RectBlink(int x, int y, int width, int height) : 20 x_(x), y_(y), width_(width), height_(height) { 21 DCHECK_GE(x_, 0); 22 DCHECK_GE(y_, 0); 23 DCHECK_GE(width_, 0); 24 DCHECK_GE(height_, 0); 25 } ~RectBlink()26 ~RectBlink() {} 27 x()28 int x() const { return x_; } setX(int x)29 void setX(int x) { 30 DCHECK_GE(x, 0); 31 x_ = x; 32 } 33 y()34 int y() const { return y_; } setY(int y)35 void setY(int y) { 36 DCHECK_GE(y, 0); 37 y_ = y; 38 } 39 width()40 int width() const { return width_; } setWidth(int width)41 void setWidth(int width) { 42 DCHECK_GE(width, 0); 43 width_ = width; 44 } 45 height()46 int height() const { return height_; } setHeight(int height)47 void setHeight(int height) { 48 DCHECK_GE(height, 0); 49 height_ = height; 50 } 51 computeArea()52 int computeArea() const { return width_ * height_; } 53 54 private: 55 int x_ = 0; 56 int y_ = 0; 57 int width_ = 0; 58 int height_ = 0; 59 }; 60 61 } // namespace test 62 } // namespace mojo 63 64 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_H_ 65