Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / platform / LengthBox.h
blob400a6b8cb3935bd0f668a81c00cbd65689787e14
1 /*
2 Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
4 Copyright (c) 2012, Google Inc. All rights reserved.
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
22 #ifndef LengthBox_h
23 #define LengthBox_h
25 #include "platform/Length.h"
26 #include "platform/PlatformExport.h"
27 #include "platform/text/TextDirection.h"
28 #include "platform/text/WritingMode.h"
30 namespace blink {
32 class PLATFORM_EXPORT LengthBox {
33 public:
34 LengthBox()
38 LengthBox(LengthType t)
39 : m_left(t)
40 , m_right(t)
41 , m_top(t)
42 , m_bottom(t)
46 LengthBox(int v)
47 : m_left(Length(v, Fixed))
48 , m_right(Length(v, Fixed))
49 , m_top(Length(v, Fixed))
50 , m_bottom(Length(v, Fixed))
54 LengthBox(const Length& t, const Length& r, const Length& b, const Length& l)
55 : m_left(l)
56 , m_right(r)
57 , m_top(t)
58 , m_bottom(b)
62 LengthBox(int t, int r, int b, int l)
63 : m_left(Length(l, Fixed))
64 , m_right(Length(r, Fixed))
65 , m_top(Length(t, Fixed))
66 , m_bottom(Length(b, Fixed))
70 const Length& left() const { return m_left; }
71 const Length& right() const { return m_right; }
72 const Length& top() const { return m_top; }
73 const Length& bottom() const { return m_bottom; }
75 const Length& logicalLeft(WritingMode) const;
76 const Length& logicalRight(WritingMode) const;
78 const Length& before(WritingMode) const;
79 const Length& after(WritingMode) const;
80 const Length& start(WritingMode, TextDirection) const;
81 const Length& end(WritingMode, TextDirection) const;
83 bool operator==(const LengthBox& o) const
85 return m_left == o.m_left && m_right == o.m_right && m_top == o.m_top && m_bottom == o.m_bottom;
88 bool operator!=(const LengthBox& o) const
90 return !(*this == o);
93 bool nonZero() const
95 return !(m_left.isZero() && m_right.isZero() && m_top.isZero() && m_bottom.isZero());
98 // Must be public for SET_VAR in ComputedStyle.h
99 Length m_left;
100 Length m_right;
101 Length m_top;
102 Length m_bottom;
105 } // namespace blink
107 #endif // LengthBox_h