| 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 23 matching lines...) Expand all Loading... |
| 34 #include "core/layout/api/LayoutViewItem.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, | 39 CSSToLengthConversionData::FontSizes::FontSizes(float em, |
| 40 float rem, | 40 float rem, |
| 41 const Font* font) | 41 const Font* font) |
| 42 : m_em(em), m_rem(rem), m_font(font) { | 42 : m_em(em), m_rem(rem), m_font(font) { |
| 43 // FIXME: Improve RAII of StyleResolverState to use const Font&. | 43 // FIXME: Improve RAII of StyleResolverState to use const Font&. |
| 44 ASSERT(m_font); | 44 DCHECK(m_font); |
| 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 DCHECK(m_font); |
| 55 const SimpleFontData* fontData = m_font->primaryFont(); | 55 const SimpleFontData* fontData = m_font->primaryFont(); |
| 56 DCHECK(fontData); | 56 DCHECK(fontData); |
| 57 | 57 |
| 58 // 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 |
| 59 // 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 |
| 60 // specifiedSize and not use our actual constructed layoutObject font. | 60 // specifiedSize and not use our actual constructed layoutObject font. |
| 61 if (!fontData || !fontData->getFontMetrics().hasXHeight()) | 61 if (!fontData || !fontData->getFontMetrics().hasXHeight()) |
| 62 return m_em / 2.0f; | 62 return m_em / 2.0f; |
| 63 return fontData->getFontMetrics().xHeight(); | 63 return fontData->getFontMetrics().xHeight(); |
| 64 } | 64 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 case CSSPrimitiveValue::UnitType::Exs: | 169 case CSSPrimitiveValue::UnitType::Exs: |
| 170 return value * exFontSize(); | 170 return value * exFontSize(); |
| 171 | 171 |
| 172 case CSSPrimitiveValue::UnitType::Rems: | 172 case CSSPrimitiveValue::UnitType::Rems: |
| 173 return value * remFontSize(); | 173 return value * remFontSize(); |
| 174 | 174 |
| 175 case CSSPrimitiveValue::UnitType::Chs: | 175 case CSSPrimitiveValue::UnitType::Chs: |
| 176 return value * chFontSize(); | 176 return value * chFontSize(); |
| 177 | 177 |
| 178 default: | 178 default: |
| 179 ASSERT_NOT_REACHED(); | 179 NOTREACHED(); |
| 180 return 0; | 180 return 0; |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace blink | 184 } // namespace blink |
| OLD | NEW |