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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 CSSToLengthConversionData::ViewportSize::ViewportSize(const RenderView* renderVi
ew) | 70 CSSToLengthConversionData::ViewportSize::ViewportSize(const RenderView* renderVi
ew) |
71 : m_width(renderView ? renderView->layoutViewportWidth() : 0) | 71 : m_width(renderView ? renderView->layoutViewportWidth() : 0) |
72 , m_height(renderView ? renderView->layoutViewportHeight() : 0) | 72 , m_height(renderView ? renderView->layoutViewportHeight() : 0) |
73 { | 73 { |
74 } | 74 } |
75 | 75 |
76 CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle* style, c
onst FontSizes& fontSizes, const ViewportSize& viewportSize, float zoom) | 76 CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle* style, c
onst FontSizes& fontSizes, const ViewportSize& viewportSize, float zoom) |
77 : m_style(style) | 77 : m_style(style) |
78 , m_fontSizes(fontSizes) | 78 , m_fontSizes(fontSizes) |
79 , m_viewportSize(viewportSize) | 79 , m_viewportSize(viewportSize) |
80 , m_zoom(zoom) | 80 , m_zoom(clampTo<float>(zoom, std::numeric_limits<float>::denorm_min())) |
81 { | 81 { |
82 ASSERT(m_style); | 82 ASSERT(m_style); |
83 ASSERT(zoom > 0); | |
84 } | 83 } |
85 | 84 |
86 CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle* style, c
onst RenderStyle* rootStyle, const RenderView* renderView, float zoom) | 85 CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle* style, c
onst RenderStyle* rootStyle, const RenderView* renderView, float zoom) |
87 : CSSToLengthConversionData(style, FontSizes(style, rootStyle), ViewportSize
(renderView), zoom) | 86 : CSSToLengthConversionData(style, FontSizes(style, rootStyle), ViewportSize
(renderView), zoom) |
88 { | 87 { |
89 } | 88 } |
90 | 89 |
91 double CSSToLengthConversionData::viewportWidthPercent() const | 90 double CSSToLengthConversionData::viewportWidthPercent() const |
92 { | 91 { |
93 m_style->setHasViewportUnits(); | 92 m_style->setHasViewportUnits(); |
94 return m_viewportSize.width() / 100; | 93 return m_viewportSize.width() / 100; |
95 } | 94 } |
96 double CSSToLengthConversionData::viewportHeightPercent() const | 95 double CSSToLengthConversionData::viewportHeightPercent() const |
97 { | 96 { |
98 m_style->setHasViewportUnits(); | 97 m_style->setHasViewportUnits(); |
99 return m_viewportSize.height() / 100; | 98 return m_viewportSize.height() / 100; |
100 } | 99 } |
101 double CSSToLengthConversionData::viewportMinPercent() const | 100 double CSSToLengthConversionData::viewportMinPercent() const |
102 { | 101 { |
103 m_style->setHasViewportUnits(); | 102 m_style->setHasViewportUnits(); |
104 return std::min(m_viewportSize.width(), m_viewportSize.height()) / 100; | 103 return std::min(m_viewportSize.width(), m_viewportSize.height()) / 100; |
105 } | 104 } |
106 double CSSToLengthConversionData::viewportMaxPercent() const | 105 double CSSToLengthConversionData::viewportMaxPercent() const |
107 { | 106 { |
108 m_style->setHasViewportUnits(); | 107 m_style->setHasViewportUnits(); |
109 return std::max(m_viewportSize.width(), m_viewportSize.height()) / 100; | 108 return std::max(m_viewportSize.width(), m_viewportSize.height()) / 100; |
110 } | 109 } |
111 | 110 |
112 } // namespace blink | 111 } // namespace blink |
OLD | NEW |