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

Side by Side Diff: third_party/WebKit/Source/platform/LengthFunctions.cpp

Issue 2849903002: Replace ASSERT_NOT_REACHED with NOTREACHED in platform/ (Closed)
Patch Set: rebase Created 3 years, 7 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 /* 1 /*
2 Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 Copyright (C) 2006, 2008 Apple Inc. All rights reserved. 3 Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
4 Copyright (C) 2011 Rik Cabanier (cabanier@adobe.com) 4 Copyright (C) 2011 Rik Cabanier (cabanier@adobe.com)
5 Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 5 Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
6 Copyright (C) 2012 Motorola Mobility, Inc. All rights reserved. 6 Copyright (C) 2012 Motorola Mobility, Inc. All rights reserved.
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 return static_cast<float>(maximum_value); 44 return static_cast<float>(maximum_value);
45 case kCalculated: 45 case kCalculated:
46 return length.NonNanCalculatedValue(LayoutUnit(maximum_value)); 46 return length.NonNanCalculatedValue(LayoutUnit(maximum_value));
47 case kMinContent: 47 case kMinContent:
48 case kMaxContent: 48 case kMaxContent:
49 case kFitContent: 49 case kFitContent:
50 case kExtendToZoom: 50 case kExtendToZoom:
51 case kDeviceWidth: 51 case kDeviceWidth:
52 case kDeviceHeight: 52 case kDeviceHeight:
53 case kMaxSizeNone: 53 case kMaxSizeNone:
54 ASSERT_NOT_REACHED(); 54 NOTREACHED();
55 return 0; 55 return 0;
56 } 56 }
57 ASSERT_NOT_REACHED(); 57 NOTREACHED();
58 return 0; 58 return 0;
59 } 59 }
60 60
61 LayoutUnit MinimumValueForLength(const Length& length, 61 LayoutUnit MinimumValueForLength(const Length& length,
62 LayoutUnit maximum_value) { 62 LayoutUnit maximum_value) {
63 switch (length.GetType()) { 63 switch (length.GetType()) {
64 case kFixed: 64 case kFixed:
65 return LayoutUnit(length.Value()); 65 return LayoutUnit(length.Value());
66 case kPercent: 66 case kPercent:
67 // Don't remove the extra cast to float. It is needed for rounding on 67 // Don't remove the extra cast to float. It is needed for rounding on
68 // 32-bit Intel machines that use the FPU stack. 68 // 32-bit Intel machines that use the FPU stack.
69 return LayoutUnit( 69 return LayoutUnit(
70 static_cast<float>(maximum_value * length.Percent() / 100.0f)); 70 static_cast<float>(maximum_value * length.Percent() / 100.0f));
71 case kCalculated: 71 case kCalculated:
72 return LayoutUnit(length.NonNanCalculatedValue(maximum_value)); 72 return LayoutUnit(length.NonNanCalculatedValue(maximum_value));
73 case kFillAvailable: 73 case kFillAvailable:
74 case kAuto: 74 case kAuto:
75 return LayoutUnit(); 75 return LayoutUnit();
76 case kMinContent: 76 case kMinContent:
77 case kMaxContent: 77 case kMaxContent:
78 case kFitContent: 78 case kFitContent:
79 case kExtendToZoom: 79 case kExtendToZoom:
80 case kDeviceWidth: 80 case kDeviceWidth:
81 case kDeviceHeight: 81 case kDeviceHeight:
82 case kMaxSizeNone: 82 case kMaxSizeNone:
83 ASSERT_NOT_REACHED(); 83 NOTREACHED();
84 return LayoutUnit(); 84 return LayoutUnit();
85 } 85 }
86 ASSERT_NOT_REACHED(); 86 NOTREACHED();
87 return LayoutUnit(); 87 return LayoutUnit();
88 } 88 }
89 89
90 LayoutUnit RoundedMinimumValueForLength(const Length& length, 90 LayoutUnit RoundedMinimumValueForLength(const Length& length,
91 LayoutUnit maximum_value) { 91 LayoutUnit maximum_value) {
92 if (length.GetType() == kPercent) 92 if (length.GetType() == kPercent)
93 return static_cast<LayoutUnit>( 93 return static_cast<LayoutUnit>(
94 round(maximum_value * length.Percent() / 100.0f)); 94 round(maximum_value * length.Percent() / 100.0f));
95 return MinimumValueForLength(length, maximum_value); 95 return MinimumValueForLength(length, maximum_value);
96 } 96 }
97 97
98 LayoutUnit ValueForLength(const Length& length, LayoutUnit maximum_value) { 98 LayoutUnit ValueForLength(const Length& length, LayoutUnit maximum_value) {
99 switch (length.GetType()) { 99 switch (length.GetType()) {
100 case kFixed: 100 case kFixed:
101 case kPercent: 101 case kPercent:
102 case kCalculated: 102 case kCalculated:
103 return MinimumValueForLength(length, maximum_value); 103 return MinimumValueForLength(length, maximum_value);
104 case kFillAvailable: 104 case kFillAvailable:
105 case kAuto: 105 case kAuto:
106 return maximum_value; 106 return maximum_value;
107 case kMinContent: 107 case kMinContent:
108 case kMaxContent: 108 case kMaxContent:
109 case kFitContent: 109 case kFitContent:
110 case kExtendToZoom: 110 case kExtendToZoom:
111 case kDeviceWidth: 111 case kDeviceWidth:
112 case kDeviceHeight: 112 case kDeviceHeight:
113 case kMaxSizeNone: 113 case kMaxSizeNone:
114 ASSERT_NOT_REACHED(); 114 NOTREACHED();
115 return LayoutUnit(); 115 return LayoutUnit();
116 } 116 }
117 ASSERT_NOT_REACHED(); 117 NOTREACHED();
118 return LayoutUnit(); 118 return LayoutUnit();
119 } 119 }
120 120
121 FloatSize FloatSizeForLengthSize(const LengthSize& length_size, 121 FloatSize FloatSizeForLengthSize(const LengthSize& length_size,
122 const FloatSize& box_size) { 122 const FloatSize& box_size) {
123 return FloatSize( 123 return FloatSize(
124 FloatValueForLength(length_size.Width(), box_size.Width()), 124 FloatValueForLength(length_size.Width(), box_size.Width()),
125 FloatValueForLength(length_size.Height(), box_size.Height())); 125 FloatValueForLength(length_size.Height(), box_size.Height()));
126 } 126 }
127 127
128 FloatPoint FloatPointForLengthPoint(const LengthPoint& length_point, 128 FloatPoint FloatPointForLengthPoint(const LengthPoint& length_point,
129 const FloatSize& box_size) { 129 const FloatSize& box_size) {
130 return FloatPoint(FloatValueForLength(length_point.X(), box_size.Width()), 130 return FloatPoint(FloatValueForLength(length_point.X(), box_size.Width()),
131 FloatValueForLength(length_point.Y(), box_size.Height())); 131 FloatValueForLength(length_point.Y(), box_size.Height()));
132 } 132 }
133 133
134 } // namespace blink 134 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/Length.cpp ('k') | third_party/WebKit/Source/platform/SharedBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698