Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / platform / text / TabSize.h
blob2503183b722cdd86a75b830fd9984782c15f536a
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.
5 #ifndef TabSize_h
6 #define TabSize_h
8 namespace blink {
10 struct TabSize {
11 TabSize(float pixels)
12 : m_floatValue(pixels)
13 , m_isSpaces(0)
17 TabSize(int spaces)
18 : m_floatValue(spaces)
19 , m_isSpaces(1)
23 bool isSpaces() const
25 return m_isSpaces;
28 float getPixelSize(float spaceWidth) const
30 return m_isSpaces ? m_floatValue * spaceWidth : m_floatValue;
33 float m_floatValue;
34 unsigned m_isSpaces : 1;
37 inline bool operator==(const TabSize& a, const TabSize& b)
39 return (a.m_floatValue == b.m_floatValue) && (a.m_isSpaces == b.m_isSpaces);
42 inline bool operator!=(const TabSize& a, const TabSize& b)
44 return !(a == b);
47 } // namespace blink
49 #endif // TabSize_h