| 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 "core/css/CSSToLengthConversionData.h" | 31 #include "core/css/CSSToLengthConversionData.h" |
| 32 | 32 |
| 33 #include "core/css/CSSHelper.h" | 33 #include "core/css/CSSHelper.h" |
| 34 #include "core/layout/LayoutView.h" | 34 #include "core/layout/api/LayoutViewItem.h" |
| 35 #include "core/style/ComputedStyle.h" | 35 #include "core/style/ComputedStyle.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 CSSToLengthConversionData::FontSizes::FontSizes(float em, float rem, const Font*
font) | 39 CSSToLengthConversionData::FontSizes::FontSizes(float em, float rem, const Font*
font) |
| 40 : m_em(em) | 40 : m_em(em) |
| 41 , m_rem(rem) | 41 , m_rem(rem) |
| 42 , m_font(font) | 42 , m_font(font) |
| 43 { | 43 { |
| 44 // FIXME: Improve RAII of StyleResolverState to use const Font&. | 44 // FIXME: Improve RAII of StyleResolverState to use const Font&. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 60 return m_em / 2.0f; | 60 return m_em / 2.0f; |
| 61 return m_font->getFontMetrics().xHeight(); | 61 return m_font->getFontMetrics().xHeight(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 float CSSToLengthConversionData::FontSizes::ch() const | 64 float CSSToLengthConversionData::FontSizes::ch() const |
| 65 { | 65 { |
| 66 ASSERT(m_font); | 66 ASSERT(m_font); |
| 67 return m_font->getFontMetrics().zeroWidth(); | 67 return m_font->getFontMetrics().zeroWidth(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 CSSToLengthConversionData::ViewportSize::ViewportSize(const LayoutView* layoutVi
ew) | 70 CSSToLengthConversionData::ViewportSize::ViewportSize(const LayoutViewItem& layo
utViewItem) |
| 71 : m_size(layoutView ? layoutView->viewportSizeForViewportUnits() : DoubleSiz
e()) | 71 : m_size(!layoutViewItem.isNull() ? layoutViewItem.viewportSizeForViewportUn
its() : DoubleSize()) |
| 72 { | 72 { |
| 73 } | 73 } |
| 74 | 74 |
| 75 CSSToLengthConversionData::CSSToLengthConversionData(const ComputedStyle* style,
const FontSizes& fontSizes, const ViewportSize& viewportSize, float zoom) | 75 CSSToLengthConversionData::CSSToLengthConversionData(const ComputedStyle* style,
const FontSizes& fontSizes, const ViewportSize& viewportSize, float zoom) |
| 76 : m_style(style) | 76 : m_style(style) |
| 77 , m_fontSizes(fontSizes) | 77 , m_fontSizes(fontSizes) |
| 78 , m_viewportSize(viewportSize) | 78 , m_viewportSize(viewportSize) |
| 79 , m_zoom(clampTo<float>(zoom, std::numeric_limits<float>::denorm_min())) | 79 , m_zoom(clampTo<float>(zoom, std::numeric_limits<float>::denorm_min())) |
| 80 { | 80 { |
| 81 ASSERT(m_style); | 81 ASSERT(m_style); |
| 82 } | 82 } |
| 83 | 83 |
| 84 CSSToLengthConversionData::CSSToLengthConversionData(const ComputedStyle* style,
const ComputedStyle* rootStyle, const LayoutView* layoutView, float zoom) | 84 CSSToLengthConversionData::CSSToLengthConversionData(const ComputedStyle* style,
const ComputedStyle* rootStyle, const LayoutViewItem& layoutViewItem, float zoo
m) |
| 85 : CSSToLengthConversionData(style, FontSizes(style, rootStyle), ViewportSize
(layoutView), zoom) | 85 : CSSToLengthConversionData(style, FontSizes(style, rootStyle), ViewportSize
(layoutViewItem), zoom) |
| 86 { | 86 { |
| 87 } | 87 } |
| 88 | 88 |
| 89 double CSSToLengthConversionData::viewportWidthPercent() const | 89 double CSSToLengthConversionData::viewportWidthPercent() const |
| 90 { | 90 { |
| 91 m_style->setHasViewportUnits(); | 91 m_style->setHasViewportUnits(); |
| 92 return m_viewportSize.width() / 100; | 92 return m_viewportSize.width() / 100; |
| 93 } | 93 } |
| 94 double CSSToLengthConversionData::viewportHeightPercent() const | 94 double CSSToLengthConversionData::viewportHeightPercent() const |
| 95 { | 95 { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 case CSSPrimitiveValue::UnitType::Chs: | 166 case CSSPrimitiveValue::UnitType::Chs: |
| 167 return value * chFontSize(); | 167 return value * chFontSize(); |
| 168 | 168 |
| 169 default: | 169 default: |
| 170 ASSERT_NOT_REACHED(); | 170 ASSERT_NOT_REACHED(); |
| 171 return 0; | 171 return 0; |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 } // namespace blink | 175 } // namespace blink |
| OLD | NEW |