| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/geometry/DoubleSize.h" | 5 #include "platform/geometry/DoubleSize.h" |
| 6 #include "platform/geometry/LayoutSize.h" | 6 #include "platform/geometry/LayoutSize.h" |
| 7 #include "wtf/text/WTFString.h" | 7 #include "wtf/text/WTFString.h" |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <math.h> | 10 #include <math.h> |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 DoubleSize::DoubleSize(const LayoutSize& size) | 14 DoubleSize::DoubleSize(const LayoutSize& size) |
| 15 : m_width(size.width().toDouble()) | 15 : m_width(size.width().toDouble()) |
| 16 , m_height(size.height().toDouble()) | 16 , m_height(size.height().toDouble()) |
| 17 { | 17 { |
| 18 } | 18 } |
| 19 | 19 |
| 20 bool DoubleSize::isZero() const | 20 bool DoubleSize::isZero() const |
| 21 { | 21 { |
| 22 return fabs(m_width) < std::numeric_limits<double>::epsilon() && fabs(m_heig
ht) < std::numeric_limits<double>::epsilon(); | 22 return fabs(m_width) < std::numeric_limits<double>::epsilon() && fabs(m_heig
ht) < std::numeric_limits<double>::epsilon(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 String DoubleSize::toString() const | 25 String DoubleSize::toString() const |
| 26 { | 26 { |
| 27 return String::format("%lgx%lg", width(), height()); | 27 return String::format("%lgx%lg", width(), height()); |
| 28 } | 28 } |
| 29 | 29 |
| 30 std::ostream& operator<<(std::ostream& ostream, const DoubleSize& size) |
| 31 { |
| 32 return ostream << size.toString(); |
| 33 } |
| 34 |
| 30 } // namespace blink | 35 } // namespace blink |
| OLD | NEW |