| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/css/CSSToLengthConversionData.h" | 32 #include "core/css/CSSToLengthConversionData.h" |
| 33 | 33 |
| 34 #include "core/css/MediaValues.h" |
| 34 #include "core/rendering/RenderView.h" | 35 #include "core/rendering/RenderView.h" |
| 35 #include "core/rendering/style/RenderStyle.h" | 36 #include "core/rendering/style/RenderStyle.h" |
| 36 | 37 |
| 37 namespace WebCore { | 38 namespace WebCore { |
| 38 | 39 |
| 39 CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle* style, c
onst RenderStyle* rootStyle, const RenderView* renderView, float zoom, bool comp
utingFontSize) | 40 CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle* style, c
onst RenderStyle* rootStyle, const RenderView* renderView, float zoom, bool comp
utingFontSize) |
| 40 : m_style(style) | 41 : m_style(style) |
| 41 , m_rootStyle(rootStyle) | 42 , m_rootStyle(rootStyle) |
| 42 , m_viewportWidth(renderView ? renderView->layoutViewportWidth() : 0) | 43 , m_viewportWidth(renderView ? renderView->layoutViewportWidth() : 0) |
| 43 , m_viewportHeight(renderView ? renderView->layoutViewportHeight() : 0) | 44 , m_viewportHeight(renderView ? renderView->layoutViewportHeight() : 0) |
| 44 , m_zoom(zoom) | 45 , m_zoom(zoom) |
| 45 , m_useEffectiveZoom(false) | 46 , m_useEffectiveZoom(false) |
| 46 , m_computingFontSize(computingFontSize) | 47 , m_computingFontSize(computingFontSize) |
| 47 { | 48 { |
| 48 ASSERT(zoom > 0); | 49 ASSERT(zoom > 0); |
| 50 ASSERT(style && rootStyle); |
| 49 } | 51 } |
| 50 | 52 |
| 51 CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle* style, c
onst RenderStyle* rootStyle, const RenderView* renderView, bool computingFontSiz
e) | 53 CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle* style, c
onst RenderStyle* rootStyle, const RenderView* renderView, bool computingFontSiz
e) |
| 52 : m_style(style) | 54 : m_style(style) |
| 53 , m_rootStyle(rootStyle) | 55 , m_rootStyle(rootStyle) |
| 54 , m_viewportWidth(renderView ? renderView->layoutViewportWidth() : 0) | 56 , m_viewportWidth(renderView ? renderView->layoutViewportWidth() : 0) |
| 55 , m_viewportHeight(renderView ? renderView->layoutViewportHeight() : 0) | 57 , m_viewportHeight(renderView ? renderView->layoutViewportHeight() : 0) |
| 56 , m_useEffectiveZoom(true) | 58 , m_useEffectiveZoom(true) |
| 57 , m_computingFontSize(computingFontSize) | 59 , m_computingFontSize(computingFontSize) |
| 58 { | 60 { |
| 61 ASSERT(style && rootStyle); |
| 59 } | 62 } |
| 60 | 63 |
| 61 CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle* style, c
onst RenderStyle* rootStyle, float viewportWidth, float viewportHeight, float zo
om, bool computingFontSize) | 64 CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle* style, c
onst RenderStyle* rootStyle, float viewportWidth, float viewportHeight, float zo
om, bool computingFontSize) |
| 62 : m_style(style) | 65 : m_style(style) |
| 63 , m_rootStyle(rootStyle) | 66 , m_rootStyle(rootStyle) |
| 64 , m_viewportWidth(viewportWidth) | 67 , m_viewportWidth(viewportWidth) |
| 65 , m_viewportHeight(viewportHeight) | 68 , m_viewportHeight(viewportHeight) |
| 66 , m_zoom(zoom) | 69 , m_zoom(zoom) |
| 67 , m_useEffectiveZoom(false) | 70 , m_useEffectiveZoom(false) |
| 68 , m_computingFontSize(computingFontSize) | 71 , m_computingFontSize(computingFontSize) |
| 69 { | 72 { |
| 70 ASSERT(zoom > 0); | 73 ASSERT(zoom > 0); |
| 74 ASSERT(style && rootStyle); |
| 71 } | 75 } |
| 72 | 76 |
| 73 float CSSToLengthConversionData::zoom() const | 77 float CSSToLengthConversionData::zoom() const |
| 74 { | 78 { |
| 75 if (m_useEffectiveZoom) | 79 if (m_useEffectiveZoom) |
| 76 return m_style ? m_style->effectiveZoom() : 1; | 80 return m_style ? m_style->effectiveZoom() : 1; |
| 77 return m_zoom; | 81 return m_zoom; |
| 78 } | 82 } |
| 79 | 83 |
| 80 double CSSToLengthConversionData::viewportWidthPercent() const | 84 double CSSToLengthConversionData::viewportWidthPercent() const |
| (...skipping 10 matching lines...) Expand all Loading... |
| 91 { | 95 { |
| 92 m_style->setHasViewportUnits(); | 96 m_style->setHasViewportUnits(); |
| 93 return std::min(m_viewportWidth, m_viewportHeight) / 100; | 97 return std::min(m_viewportWidth, m_viewportHeight) / 100; |
| 94 } | 98 } |
| 95 double CSSToLengthConversionData::viewportMaxPercent() const | 99 double CSSToLengthConversionData::viewportMaxPercent() const |
| 96 { | 100 { |
| 97 m_style->setHasViewportUnits(); | 101 m_style->setHasViewportUnits(); |
| 98 return std::max(m_viewportWidth, m_viewportHeight) / 100; | 102 return std::max(m_viewportWidth, m_viewportHeight) / 100; |
| 99 } | 103 } |
| 100 | 104 |
| 105 bool CSSToLengthConversionData::computingFontSize() const |
| 106 { |
| 107 return m_computingFontSize; |
| 108 } |
| 109 |
| 110 double CSSToLengthConversionData::fontSpecifiedSize() const |
| 111 { |
| 112 return m_style->fontDescription().specifiedSize(); |
| 113 } |
| 114 |
| 115 double CSSToLengthConversionData::fontComputedSize() const |
| 116 { |
| 117 return m_style->fontDescription().computedSize(); |
| 118 } |
| 119 |
| 120 double CSSToLengthConversionData::rootFontSpecifiedSize() const |
| 121 { |
| 122 return m_rootStyle->fontDescription().specifiedSize(); |
| 123 } |
| 124 |
| 125 double CSSToLengthConversionData::rootFontComputedSize() const |
| 126 { |
| 127 return m_rootStyle->fontDescription().computedSize(); |
| 128 } |
| 129 |
| 130 bool CSSToLengthConversionData::hasXHeight() const |
| 131 { |
| 132 return m_style->fontMetrics().hasXHeight(); |
| 133 } |
| 134 |
| 135 double CSSToLengthConversionData::xHeight() const |
| 136 { |
| 137 return m_style->fontMetrics().xHeight(); |
| 138 } |
| 139 |
| 140 double CSSToLengthConversionData::zeroWidth() const |
| 141 { |
| 142 return m_style->fontMetrics().zeroWidth(); |
| 143 } |
| 144 |
| 101 } // namespace WebCore | 145 } // namespace WebCore |
| OLD | NEW |