| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012, Google Inc. All rights reserved. | 2 * Copyright (c) 2012, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 LayoutSize fitToAspectRatio(const LayoutSize& aspectRatio, AspectRatioFit fi
t) const | 120 LayoutSize fitToAspectRatio(const LayoutSize& aspectRatio, AspectRatioFit fi
t) const |
| 121 { | 121 { |
| 122 float heightScale = height().toFloat() / aspectRatio.height().toFloat(); | 122 float heightScale = height().toFloat() / aspectRatio.height().toFloat(); |
| 123 float widthScale = width().toFloat() / aspectRatio.width().toFloat(); | 123 float widthScale = width().toFloat() / aspectRatio.width().toFloat(); |
| 124 if ((widthScale > heightScale) != (fit == AspectRatioFitGrow)) | 124 if ((widthScale > heightScale) != (fit == AspectRatioFitGrow)) |
| 125 return LayoutSize(height() * aspectRatio.width() / aspectRatio.heigh
t(), height()); | 125 return LayoutSize(height() * aspectRatio.width() / aspectRatio.heigh
t(), height()); |
| 126 return LayoutSize(width(), width() * aspectRatio.height() / aspectRatio.
width()); | 126 return LayoutSize(width(), width() * aspectRatio.height() / aspectRatio.
width()); |
| 127 } | 127 } |
| 128 | 128 |
| 129 LayoutSize fraction() const |
| 130 { |
| 131 return LayoutSize(m_width.fraction(), m_height.fraction()); |
| 132 } |
| 133 |
| 129 private: | 134 private: |
| 130 LayoutUnit m_width, m_height; | 135 LayoutUnit m_width, m_height; |
| 131 }; | 136 }; |
| 132 | 137 |
| 133 inline LayoutSize& operator+=(LayoutSize& a, const LayoutSize& b) | 138 inline LayoutSize& operator+=(LayoutSize& a, const LayoutSize& b) |
| 134 { | 139 { |
| 135 a.setWidth(a.width() + b.width()); | 140 a.setWidth(a.width() + b.width()); |
| 136 a.setHeight(a.height() + b.height()); | 141 a.setHeight(a.height() + b.height()); |
| 137 return a; | 142 return a; |
| 138 } | 143 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 185 } |
| 181 | 186 |
| 182 inline LayoutSize roundedLayoutSize(const FloatSize& s) | 187 inline LayoutSize roundedLayoutSize(const FloatSize& s) |
| 183 { | 188 { |
| 184 return LayoutSize(s); | 189 return LayoutSize(s); |
| 185 } | 190 } |
| 186 | 191 |
| 187 } // namespace WebCore | 192 } // namespace WebCore |
| 188 | 193 |
| 189 #endif // LayoutSize_h | 194 #endif // LayoutSize_h |
| OLD | NEW |