Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: third_party/WebKit/Source/platform/geometry/DoubleSize.cpp

Issue 2195903002: Add Double{Size, Point, Rect} pretty printers for logging and testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@geometryPrettyPrinters2
Patch Set: Remove unnecessary String casts Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
8 #include "wtf/text/WTFString.h" 7 #include "wtf/text/WTFString.h"
9 8
10 #include <limits> 9 #include <limits>
11 #include <math.h> 10 #include <math.h>
12 11
13 namespace blink { 12 namespace blink {
14 13
15 DoubleSize::DoubleSize(const LayoutSize& size) 14 DoubleSize::DoubleSize(const LayoutSize& size)
16 : m_width(size.width().toDouble()) 15 : m_width(size.width().toDouble())
17 , m_height(size.height().toDouble()) 16 , m_height(size.height().toDouble())
18 { 17 {
19 } 18 }
20 19
21 bool DoubleSize::isZero() const 20 bool DoubleSize::isZero() const
22 { 21 {
23 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();
24 } 23 }
25 24
26 #ifndef NDEBUG
27 String DoubleSize::toString() const 25 String DoubleSize::toString() const
28 { 26 {
29 return String::format("%fx%f", width(), height()); 27 return String::format("%lgx%lg", width(), height());
30 } 28 }
31 #endif
32 29
33 } // namespace blink 30 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698