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

Side by Side Diff: ui/gfx/rect_f.cc

Issue 24883002: Uses and returns the fractional width in text eliding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win bots Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/gfx/rect_f.h" 5 #include "ui/gfx/rect_f.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "ui/gfx/insets_f.h" 11 #include "ui/gfx/insets_f.h"
12 #include "ui/gfx/rect_base_impl.h" 12 #include "ui/gfx/rect_base_impl.h"
13 #include "ui/gfx/safe_integer_conversions.h" 13 #include "ui/gfx/safe_integer_conversions.h"
14 14
15 namespace gfx { 15 namespace gfx {
16 16
17 template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>; 17 template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>;
18 18
19 typedef class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, 19 typedef class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF,
20 float> RectBaseT; 20 float> RectBaseT;
21 21
22 #if defined(OS_MACOSX)
23 CGRect RectF::ToCGRect() const {
24 return CGRectMake(x(), y(), width(), height());
25 }
26 #endif
27
22 bool RectF::IsExpressibleAsRect() const { 28 bool RectF::IsExpressibleAsRect() const {
23 return IsExpressibleAsInt(x()) && IsExpressibleAsInt(y()) && 29 return IsExpressibleAsInt(x()) && IsExpressibleAsInt(y()) &&
24 IsExpressibleAsInt(width()) && IsExpressibleAsInt(height()) && 30 IsExpressibleAsInt(width()) && IsExpressibleAsInt(height()) &&
25 IsExpressibleAsInt(right()) && IsExpressibleAsInt(bottom()); 31 IsExpressibleAsInt(right()) && IsExpressibleAsInt(bottom());
26 } 32 }
27 33
28 std::string RectF::ToString() const { 34 std::string RectF::ToString() const {
29 return base::StringPrintf("%s %s", 35 return base::StringPrintf("%s %s",
30 origin().ToString().c_str(), 36 origin().ToString().c_str(),
31 size().ToString().c_str()); 37 size().ToString().c_str());
(...skipping 19 matching lines...) Expand all
51 57
52 RectF BoundingRect(const PointF& p1, const PointF& p2) { 58 RectF BoundingRect(const PointF& p1, const PointF& p2) {
53 float rx = std::min(p1.x(), p2.x()); 59 float rx = std::min(p1.x(), p2.x());
54 float ry = std::min(p1.y(), p2.y()); 60 float ry = std::min(p1.y(), p2.y());
55 float rr = std::max(p1.x(), p2.x()); 61 float rr = std::max(p1.x(), p2.x());
56 float rb = std::max(p1.y(), p2.y()); 62 float rb = std::max(p1.y(), p2.y());
57 return RectF(rx, ry, rr - rx, rb - ry); 63 return RectF(rx, ry, rr - rx, rb - ry);
58 } 64 }
59 65
60 } // namespace gfx 66 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698