| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 m_constraintsDirty = true; | 60 m_constraintsDirty = true; |
| 61 } | 61 } |
| 62 | 62 |
| 63 void PageScaleConstraintsSet::setUserAgentConstraints(const PageScaleConstraints
& userAgentConstraints) | 63 void PageScaleConstraintsSet::setUserAgentConstraints(const PageScaleConstraints
& userAgentConstraints) |
| 64 { | 64 { |
| 65 m_userAgentConstraints = userAgentConstraints; | 65 m_userAgentConstraints = userAgentConstraints; |
| 66 m_constraintsDirty = true; | 66 m_constraintsDirty = true; |
| 67 } | 67 } |
| 68 | 68 |
| 69 PageScaleConstraints PageScaleConstraintsSet::computeConstraintsStack() const |
| 70 { |
| 71 PageScaleConstraints constraints = defaultConstraints(); |
| 72 constraints.overrideWith(m_pageDefinedConstraints); |
| 73 constraints.overrideWith(m_userAgentConstraints); |
| 74 return constraints; |
| 75 } |
| 76 |
| 69 void PageScaleConstraintsSet::computeFinalConstraints() | 77 void PageScaleConstraintsSet::computeFinalConstraints() |
| 70 { | 78 { |
| 71 m_finalConstraints = defaultConstraints(); | 79 m_finalConstraints = computeConstraintsStack(); |
| 72 m_finalConstraints.overrideWith(m_pageDefinedConstraints); | |
| 73 m_finalConstraints.overrideWith(m_userAgentConstraints); | |
| 74 | 80 |
| 75 m_constraintsDirty = false; | 81 m_constraintsDirty = false; |
| 76 } | 82 } |
| 77 | 83 |
| 78 void PageScaleConstraintsSet::adjustFinalConstraintsToContentsSize(IntSize viewS
ize, IntSize contentsSize, int nonOverlayScrollbarWidth) | 84 void PageScaleConstraintsSet::adjustFinalConstraintsToContentsSize(IntSize viewS
ize, IntSize contentsSize, int nonOverlayScrollbarWidth) |
| 79 { | 85 { |
| 80 m_finalConstraints.fitToContentsWidth(contentsSize.width(), viewSize.width()
- nonOverlayScrollbarWidth); | 86 m_finalConstraints.fitToContentsWidth(contentsSize.width(), viewSize.width()
- nonOverlayScrollbarWidth); |
| 81 } | 87 } |
| 82 | 88 |
| 83 void PageScaleConstraintsSet::setNeedsReset(bool needsReset) | 89 void PageScaleConstraintsSet::setNeedsReset(bool needsReset) |
| 84 { | 90 { |
| 85 m_needsReset = needsReset; | 91 m_needsReset = needsReset; |
| 86 if (needsReset) | 92 if (needsReset) |
| 87 m_constraintsDirty = true; | 93 m_constraintsDirty = true; |
| 88 } | 94 } |
| 89 | 95 |
| 90 void PageScaleConstraintsSet::didChangeContentsSize(IntSize contentsSize, float
pageScaleFactor) | 96 void PageScaleConstraintsSet::didChangeContentsSize(IntSize contentsSize, float
pageScaleFactor) |
| 91 { | 97 { |
| 92 // If a large fixed-width element expanded the size of the document | 98 // If a large fixed-width element expanded the size of the document late in |
| 93 // late in loading and our initial scale is not constrained, reset the | 99 // loading and our initial scale is not set (or set to be less than the last |
| 94 // page scale factor to the new minimum scale. | 100 // minimum scale), reset the page scale factor to the new initial scale. |
| 95 if (contentsSize.width() > m_lastContentsWidth | 101 if (contentsSize.width() > m_lastContentsWidth |
| 96 && pageScaleFactor == finalConstraints().minimumScale | 102 && pageScaleFactor == finalConstraints().minimumScale |
| 97 && userAgentConstraints().initialScale == -1 && pageDefinedConstraints()
.initialScale == -1) | 103 && computeConstraintsStack().initialScale < finalConstraints().minimumSc
ale) |
| 98 setNeedsReset(true); | 104 setNeedsReset(true); |
| 99 | 105 |
| 100 m_constraintsDirty = true; | 106 m_constraintsDirty = true; |
| 101 m_lastContentsWidth = contentsSize.width(); | 107 m_lastContentsWidth = contentsSize.width(); |
| 102 } | 108 } |
| 103 | 109 |
| 104 static float computeDeprecatedTargetDensityDPIFactor(const ViewportDescription&
description, float deviceScaleFactor) | 110 static float computeDeprecatedTargetDensityDPIFactor(const ViewportDescription&
description, float deviceScaleFactor) |
| 105 { | 111 { |
| 106 if (description.deprecatedTargetDensityDPI == ViewportDescription::ValueDevi
ceDPI) | 112 if (description.deprecatedTargetDensityDPI == ViewportDescription::ValueDevi
ceDPI) |
| 107 return 1.0f / deviceScaleFactor; | 113 return 1.0f / deviceScaleFactor; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 const float nonWideScale = description.zoom < 1 && !description.maxW
idth.isViewportPercentage() ? -1 : oldInitialScale; | 167 const float nonWideScale = description.zoom < 1 && !description.maxW
idth.isViewportPercentage() ? -1 : oldInitialScale; |
| 162 adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(viewSize,
nonWideScale) / targetDensityDPIFactor; | 168 adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(viewSize,
nonWideScale) / targetDensityDPIFactor; |
| 163 if (description.zoom < 1) { | 169 if (description.zoom < 1) { |
| 164 m_pageDefinedConstraints.initialScale = targetDensityDPIFactor; | 170 m_pageDefinedConstraints.initialScale = targetDensityDPIFactor; |
| 165 m_pageDefinedConstraints.minimumScale = std::min<float>(m_pageDe
finedConstraints.minimumScale, m_pageDefinedConstraints.initialScale); | 171 m_pageDefinedConstraints.minimumScale = std::min<float>(m_pageDe
finedConstraints.minimumScale, m_pageDefinedConstraints.initialScale); |
| 166 m_pageDefinedConstraints.maximumScale = std::max<float>(m_pageDe
finedConstraints.maximumScale, m_pageDefinedConstraints.initialScale); | 172 m_pageDefinedConstraints.maximumScale = std::max<float>(m_pageDe
finedConstraints.maximumScale, m_pageDefinedConstraints.initialScale); |
| 167 } | 173 } |
| 168 } | 174 } |
| 169 } | 175 } |
| 170 | 176 |
| 171 if (oldInitialScale != m_pageDefinedConstraints.initialScale && m_pageDefine
dConstraints.initialScale != -1) | |
| 172 setNeedsReset(true); | |
| 173 | |
| 174 if (adjustedLayoutSizeWidth != m_pageDefinedConstraints.layoutSize.width())
{ | 177 if (adjustedLayoutSizeWidth != m_pageDefinedConstraints.layoutSize.width())
{ |
| 175 ASSERT(m_pageDefinedConstraints.layoutSize.width() > 0); | 178 ASSERT(m_pageDefinedConstraints.layoutSize.width() > 0); |
| 176 float adjustedLayoutSizeHeight = (adjustedLayoutSizeWidth * m_pageDefine
dConstraints.layoutSize.height()) / m_pageDefinedConstraints.layoutSize.width(); | 179 float adjustedLayoutSizeHeight = (adjustedLayoutSizeWidth * m_pageDefine
dConstraints.layoutSize.height()) / m_pageDefinedConstraints.layoutSize.width(); |
| 177 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth); | 180 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth); |
| 178 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight); | 181 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight); |
| 179 } | 182 } |
| 180 } | 183 } |
| 181 | 184 |
| 182 } // namespace WebCore | 185 } // namespace WebCore |
| OLD | NEW |