| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 143 } |
| 144 | 144 |
| 145 IntSize PageScaleConstraintsSet::mainFrameSize(int contentWidthIncludingScrollba
r) const | 145 IntSize PageScaleConstraintsSet::mainFrameSize(int contentWidthIncludingScrollba
r) const |
| 146 { | 146 { |
| 147 // If there's no explicit minimum scale factor set, size the frame so that i
ts width == content width | 147 // If there's no explicit minimum scale factor set, size the frame so that i
ts width == content width |
| 148 // so there's no horizontal scrolling at the minimum scale. | 148 // so there's no horizontal scrolling at the minimum scale. |
| 149 if (m_pageDefinedConstraints.minimumScale < finalConstraints().minimumScale | 149 if (m_pageDefinedConstraints.minimumScale < finalConstraints().minimumScale |
| 150 && m_userAgentConstraints.minimumScale < finalConstraints().minimumScale | 150 && m_userAgentConstraints.minimumScale < finalConstraints().minimumScale |
| 151 && contentWidthIncludingScrollbar | 151 && contentWidthIncludingScrollbar |
| 152 && m_viewSize.width()) { | 152 && m_viewSize.width()) { |
| 153 |
| 154 // Special case where the contents are exactly as wide as the viewport t
o prevent an off-by-one due |
| 155 // to floating point imprecision in the aspect ratio height calculation. |
| 156 if (contentWidthIncludingScrollbar == m_viewSize.width()) |
| 157 return m_viewSize; |
| 158 |
| 153 return expandedIntSize(FloatSize( | 159 return expandedIntSize(FloatSize( |
| 154 contentWidthIncludingScrollbar, | 160 contentWidthIncludingScrollbar, |
| 155 computeHeightByAspectRatio(contentWidthIncludingScrollbar, m_viewSiz
e))); | 161 computeHeightByAspectRatio(contentWidthIncludingScrollbar, m_viewSiz
e))); |
| 156 } | 162 } |
| 157 | 163 |
| 158 // If there is a minimum scale (or there's no content size yet), the frame s
ize should match the viewport | 164 // If there is a minimum scale (or there's no content size yet), the frame s
ize should match the viewport |
| 159 // size at minimum scale, since the viewport must always be contained by the
frame. | 165 // size at minimum scale, since the viewport must always be contained by the
frame. |
| 160 FloatSize frameSize(m_viewSize); | 166 FloatSize frameSize(m_viewSize); |
| 161 frameSize.scale(1 / finalConstraints().minimumScale); | 167 frameSize.scale(1 / finalConstraints().minimumScale); |
| 162 return expandedIntSize(frameSize); | 168 return expandedIntSize(frameSize); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 adjustedLayoutSizeWidth = m_viewSize.width() / targetDensityDPIFacto
r; | 235 adjustedLayoutSizeWidth = m_viewSize.width() / targetDensityDPIFacto
r; |
| 230 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout
SizeWidth, m_viewSize); | 236 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout
SizeWidth, m_viewSize); |
| 231 } | 237 } |
| 232 } | 238 } |
| 233 | 239 |
| 234 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth); | 240 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth); |
| 235 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight); | 241 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight); |
| 236 } | 242 } |
| 237 | 243 |
| 238 } // namespace blink | 244 } // namespace blink |
| OLD | NEW |