blob: b28b2bfa25be5345a0f529a478be0a05b2f97c75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_DOUBLE_SIZE_H_
#define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_DOUBLE_SIZE_H_
#include "third_party/blink/public/platform/web_common.h"
#if INSIDE_BLINK
#include "third_party/blink/renderer/platform/geometry/double_size.h"
#else
#include <ui/gfx/geometry/size_f.h>
#include <ui/gfx/geometry/vector2d_f.h>
#endif
namespace blink {
class WebDoubleSize {
public:
bool IsEmpty() const { return width_ <= 0 || height_ <= 0; }
WebDoubleSize() : width_(0), height_(0) {}
WebDoubleSize(double width, double height) : width_(width), height_(height) {}
#if INSIDE_BLINK
WebDoubleSize(const DoubleSize& size)
: width_(size.Width()), height_(size.Height()) {}
WebDoubleSize& operator=(const DoubleSize& size) {
width_ = size.Width();
height_ = size.Height();
return *this;
}
operator DoubleSize() const { return DoubleSize(width_, height_); }
#else
WebDoubleSize(const gfx::SizeF& size)
: width_(size.width()), height_(size.height()) {}
WebDoubleSize(const gfx::Vector2dF& vector)
: width_(vector.x()), height_(vector.y()) {}
WebDoubleSize& operator=(const gfx::SizeF& size) {
width_ = size.width();
height_ = size.height();
return *this;
}
WebDoubleSize& operator=(const gfx::Vector2dF& vector) {
width_ = vector.x();
height_ = vector.y();
return *this;
}
#endif
double Width() const { return width_; }
double Height() const { return height_; }
private:
double width_;
double height_;
};
inline bool operator==(const WebDoubleSize& a, const WebDoubleSize& b) {
return a.Width() == b.Width() && a.Height() == b.Height();
}
inline bool operator!=(const WebDoubleSize& a, const WebDoubleSize& b) {
return !(a == b);
}
} // namespace blink
#endif
|