Remove WebKitTestRunner::setClientWindowRect.
[chromium-blink-merge.git] / ui / gfx / insets_base.h
blobda7aca103e549bce791d8fdff22a3c5894f5da53
1 // Copyright 2012 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.
5 #ifndef UI_GFX_INSETS_BASE_H_
6 #define UI_GFX_INSETS_BASE_H_
8 #include "ui/gfx/gfx_export.h"
10 namespace gfx {
12 // An insets represents the borders of a container (the space the container must
13 // leave at each of its edges).
14 template<typename Class, typename Type>
15 class GFX_EXPORT InsetsBase {
16 public:
17 Type top() const { return top_; }
18 Type left() const { return left_; }
19 Type bottom() const { return bottom_; }
20 Type right() const { return right_; }
22 // Returns the total width taken up by the insets, which is the sum of the
23 // left and right insets.
24 Type width() const { return left_ + right_; }
26 // Returns the total height taken up by the insets, which is the sum of the
27 // top and bottom insets.
28 Type height() const { return top_ + bottom_; }
30 // Returns true if the insets are empty.
31 bool empty() const { return width() == 0 && height() == 0; }
33 void Set(Type top, Type left, Type bottom, Type right) {
34 top_ = top;
35 left_ = left;
36 bottom_ = bottom;
37 right_ = right;
40 bool operator==(const Class& insets) const {
41 return top_ == insets.top_ && left_ == insets.left_ &&
42 bottom_ == insets.bottom_ && right_ == insets.right_;
45 bool operator!=(const Class& insets) const {
46 return !(*this == insets);
49 void operator+=(const Class& insets) {
50 top_ += insets.top_;
51 left_ += insets.left_;
52 bottom_ += insets.bottom_;
53 right_ += insets.right_;
56 Class operator-() const {
57 return Class(-top_, -left_, -bottom_, -right_);
60 protected:
61 InsetsBase(Type top, Type left, Type bottom, Type right)
62 : top_(top),
63 left_(left),
64 bottom_(bottom),
65 right_(right) {}
67 // Destructor is intentionally made non virtual and protected.
68 // Do not make this public.
69 ~InsetsBase() {}
71 private:
72 Type top_;
73 Type left_;
74 Type bottom_;
75 Type right_;
78 } // namespace gfx
80 #endif // UI_GFX_INSETS_BASE_H_