| 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 20 matching lines...) Expand all Loading... |
| 31 #ifndef CSSToLengthConversionData_h | 31 #ifndef CSSToLengthConversionData_h |
| 32 #define CSSToLengthConversionData_h | 32 #define CSSToLengthConversionData_h |
| 33 | 33 |
| 34 #include "wtf/Assertions.h" | 34 #include "wtf/Assertions.h" |
| 35 #include "wtf/MathExtras.h" | 35 #include "wtf/MathExtras.h" |
| 36 #include "wtf/Noncopyable.h" | 36 #include "wtf/Noncopyable.h" |
| 37 #include <limits> | 37 #include <limits> |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 class LayoutStyle; | 41 class ComputedStyle; |
| 42 class LayoutView; | 42 class LayoutView; |
| 43 class Font; | 43 class Font; |
| 44 | 44 |
| 45 class CSSToLengthConversionData { | 45 class CSSToLengthConversionData { |
| 46 public: | 46 public: |
| 47 | 47 |
| 48 class FontSizes { | 48 class FontSizes { |
| 49 public: | 49 public: |
| 50 FontSizes() : m_em(0), m_rem(0), m_font(nullptr) { } | 50 FontSizes() : m_em(0), m_rem(0), m_font(nullptr) { } |
| 51 FontSizes(float em, float rem, const Font*); | 51 FontSizes(float em, float rem, const Font*); |
| 52 FontSizes(const LayoutStyle*, const LayoutStyle* rootStyle); | 52 FontSizes(const ComputedStyle*, const ComputedStyle* rootStyle); |
| 53 | 53 |
| 54 float em() const { return m_em; } | 54 float em() const { return m_em; } |
| 55 float rem() const { return m_rem; } | 55 float rem() const { return m_rem; } |
| 56 float ex() const; | 56 float ex() const; |
| 57 float ch() const; | 57 float ch() const; |
| 58 private: | 58 private: |
| 59 float m_em; | 59 float m_em; |
| 60 float m_rem; | 60 float m_rem; |
| 61 const Font* m_font; | 61 const Font* m_font; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 class ViewportSize { | 64 class ViewportSize { |
| 65 public: | 65 public: |
| 66 ViewportSize() : m_width(0), m_height(0) { } | 66 ViewportSize() : m_width(0), m_height(0) { } |
| 67 ViewportSize(double width, double height) : m_width(width), m_height(hei
ght) { } | 67 ViewportSize(double width, double height) : m_width(width), m_height(hei
ght) { } |
| 68 explicit ViewportSize(const LayoutView*); | 68 explicit ViewportSize(const LayoutView*); |
| 69 | 69 |
| 70 double width() const { return m_width; } | 70 double width() const { return m_width; } |
| 71 double height() const { return m_height; } | 71 double height() const { return m_height; } |
| 72 private: | 72 private: |
| 73 double m_width; | 73 double m_width; |
| 74 double m_height; | 74 double m_height; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 CSSToLengthConversionData() { } | 77 CSSToLengthConversionData() { } |
| 78 CSSToLengthConversionData(const LayoutStyle*, const FontSizes&, const Viewpo
rtSize&, float zoom); | 78 CSSToLengthConversionData(const ComputedStyle*, const FontSizes&, const View
portSize&, float zoom); |
| 79 CSSToLengthConversionData(const LayoutStyle* currStyle, const LayoutStyle* r
ootStyle, const LayoutView*, float zoom); | 79 CSSToLengthConversionData(const ComputedStyle* currStyle, const ComputedStyl
e* rootStyle, const LayoutView*, float zoom); |
| 80 | 80 |
| 81 float zoom() const { return m_zoom; } | 81 float zoom() const { return m_zoom; } |
| 82 | 82 |
| 83 float emFontSize() const { return m_fontSizes.em(); } | 83 float emFontSize() const { return m_fontSizes.em(); } |
| 84 float remFontSize() const { return m_fontSizes.rem(); } | 84 float remFontSize() const { return m_fontSizes.rem(); } |
| 85 float exFontSize() const { return m_fontSizes.ex(); } | 85 float exFontSize() const { return m_fontSizes.ex(); } |
| 86 float chFontSize() const { return m_fontSizes.ch(); } | 86 float chFontSize() const { return m_fontSizes.ch(); } |
| 87 | 87 |
| 88 // Accessing these marks the style as having viewport units | 88 // Accessing these marks the style as having viewport units |
| 89 double viewportWidthPercent() const; | 89 double viewportWidthPercent() const; |
| 90 double viewportHeightPercent() const; | 90 double viewportHeightPercent() const; |
| 91 double viewportMinPercent() const; | 91 double viewportMinPercent() const; |
| 92 double viewportMaxPercent() const; | 92 double viewportMaxPercent() const; |
| 93 | 93 |
| 94 void setFontSizes(const FontSizes& fontSizes) { m_fontSizes = fontSizes; } | 94 void setFontSizes(const FontSizes& fontSizes) { m_fontSizes = fontSizes; } |
| 95 void setZoom(float zoom) { m_zoom = clampTo<float>(zoom, std::numeric_limits
<float>::denorm_min()); } | 95 void setZoom(float zoom) { m_zoom = clampTo<float>(zoom, std::numeric_limits
<float>::denorm_min()); } |
| 96 | 96 |
| 97 CSSToLengthConversionData copyWithAdjustedZoom(float newZoom) const | 97 CSSToLengthConversionData copyWithAdjustedZoom(float newZoom) const |
| 98 { | 98 { |
| 99 return CSSToLengthConversionData(m_style, m_fontSizes, m_viewportSize, n
ewZoom); | 99 return CSSToLengthConversionData(m_style, m_fontSizes, m_viewportSize, n
ewZoom); |
| 100 } | 100 } |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 const LayoutStyle* m_style; | 103 const ComputedStyle* m_style; |
| 104 FontSizes m_fontSizes; | 104 FontSizes m_fontSizes; |
| 105 ViewportSize m_viewportSize; | 105 ViewportSize m_viewportSize; |
| 106 float m_zoom; | 106 float m_zoom; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 } // namespace blink | 109 } // namespace blink |
| 110 | 110 |
| 111 #endif | 111 #endif |
| OLD | NEW |