| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 CSSToLengthConversionData::FontSizes::FontSizes(const ComputedStyle* style, | 47 CSSToLengthConversionData::FontSizes::FontSizes(const ComputedStyle* style, |
| 48 const ComputedStyle* rootStyle) | 48 const ComputedStyle* rootStyle) |
| 49 : FontSizes(style->computedFontSize(), | 49 : FontSizes(style->computedFontSize(), |
| 50 rootStyle ? rootStyle->computedFontSize() : 1.0f, | 50 rootStyle ? rootStyle->computedFontSize() : 1.0f, |
| 51 &style->font()) {} | 51 &style->font()) {} |
| 52 | 52 |
| 53 float CSSToLengthConversionData::FontSizes::ex() const { | 53 float CSSToLengthConversionData::FontSizes::ex() const { |
| 54 ASSERT(m_font); | 54 ASSERT(m_font); |
| 55 const SimpleFontData* fontData = m_font->primaryFont(); |
| 56 DCHECK(fontData); |
| 57 |
| 55 // FIXME: We have a bug right now where the zoom will be applied twice to EX | 58 // FIXME: We have a bug right now where the zoom will be applied twice to EX |
| 56 // units. We really need to compute EX using fontMetrics for the original | 59 // units. We really need to compute EX using fontMetrics for the original |
| 57 // specifiedSize and not use our actual constructed layoutObject font. | 60 // specifiedSize and not use our actual constructed layoutObject font. |
| 58 if (!m_font->getFontMetrics().hasXHeight()) | 61 if (!fontData || !fontData->getFontMetrics().hasXHeight()) |
| 59 return m_em / 2.0f; | 62 return m_em / 2.0f; |
| 60 return m_font->getFontMetrics().xHeight(); | 63 return fontData->getFontMetrics().xHeight(); |
| 61 } | 64 } |
| 62 | 65 |
| 63 float CSSToLengthConversionData::FontSizes::ch() const { | 66 float CSSToLengthConversionData::FontSizes::ch() const { |
| 64 ASSERT(m_font); | 67 DCHECK(m_font); |
| 65 return m_font->getFontMetrics().zeroWidth(); | 68 const SimpleFontData* fontData = m_font->primaryFont(); |
| 69 DCHECK(fontData); |
| 70 return fontData ? fontData->getFontMetrics().zeroWidth() : 0; |
| 66 } | 71 } |
| 67 | 72 |
| 68 CSSToLengthConversionData::ViewportSize::ViewportSize( | 73 CSSToLengthConversionData::ViewportSize::ViewportSize( |
| 69 const LayoutViewItem& layoutViewItem) | 74 const LayoutViewItem& layoutViewItem) |
| 70 : m_size(!layoutViewItem.isNull() | 75 : m_size(!layoutViewItem.isNull() |
| 71 ? layoutViewItem.viewportSizeForViewportUnits() | 76 ? layoutViewItem.viewportSizeForViewportUnits() |
| 72 : DoubleSize()) {} | 77 : DoubleSize()) {} |
| 73 | 78 |
| 74 CSSToLengthConversionData::CSSToLengthConversionData( | 79 CSSToLengthConversionData::CSSToLengthConversionData( |
| 75 const ComputedStyle* style, | 80 const ComputedStyle* style, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 case CSSPrimitiveValue::UnitType::Chs: | 176 case CSSPrimitiveValue::UnitType::Chs: |
| 172 return value * chFontSize(); | 177 return value * chFontSize(); |
| 173 | 178 |
| 174 default: | 179 default: |
| 175 ASSERT_NOT_REACHED(); | 180 ASSERT_NOT_REACHED(); |
| 176 return 0; | 181 return 0; |
| 177 } | 182 } |
| 178 } | 183 } |
| 179 | 184 |
| 180 } // namespace blink | 185 } // namespace blink |
| OLD | NEW |