Chromium Code Reviews| 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/Noncopyable.h" | 35 #include "wtf/Noncopyable.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 class RenderStyle; | 39 class RenderStyle; |
| 40 class RenderView; | 40 class RenderView; |
| 41 class Font; | |
| 42 | |
| 43 class CSSToLengthFontSizes { | |
|
Timothy Loh
2014/11/06 16:24:00
We don't usually put multiple classes in the same
andersr
2014/11/07 10:43:11
Done. Inner classes look OK to me.
| |
| 44 public: | |
| 45 CSSToLengthFontSizes() : m_em(0), m_rem(0), m_font(nullptr) { } | |
| 46 CSSToLengthFontSizes(float em, float rem, const Font*); | |
| 47 CSSToLengthFontSizes(const RenderStyle*, const RenderStyle* rootStyle); | |
| 48 | |
| 49 float em() const { return m_em; } | |
| 50 float rem() const { return m_rem; } | |
| 51 float ex() const; | |
| 52 float ch() const; | |
| 53 private: | |
| 54 float m_em; | |
| 55 float m_rem; | |
| 56 const Font* m_font; | |
| 57 }; | |
| 58 | |
| 59 class CSSToLengthViewportSize { | |
| 60 public: | |
| 61 CSSToLengthViewportSize() : m_width(0), m_height(0) { } | |
| 62 CSSToLengthViewportSize(double width, double height) : m_width(width), m_hei ght(height) { } | |
| 63 explicit CSSToLengthViewportSize(const RenderView*); | |
| 64 | |
| 65 double width() const { return m_width; } | |
| 66 double height() const { return m_height; } | |
| 67 private: | |
| 68 double m_width; | |
| 69 double m_height; | |
| 70 }; | |
| 41 | 71 |
| 42 class CSSToLengthConversionData { | 72 class CSSToLengthConversionData { |
| 43 public: | 73 public: |
| 44 CSSToLengthConversionData(const RenderStyle* currStyle, const RenderStyle* r ootStyle, const RenderView*, float zoom, bool computingFontSize = false); | 74 CSSToLengthConversionData() { } |
| 45 CSSToLengthConversionData(const RenderStyle* currStyle, const RenderStyle* r ootStyle, const RenderView*, bool computingFontSize = false); | 75 CSSToLengthConversionData(const RenderStyle*, const CSSToLengthFontSizes&, c onst CSSToLengthViewportSize&, float zoom); |
| 46 CSSToLengthConversionData(const RenderStyle* currStyle, const RenderStyle* r ootStyle, float viewportWidth, float viewportHeight, float zoom, bool computingF ontSize = false); | 76 CSSToLengthConversionData(const RenderStyle* currStyle, const RenderStyle* r ootStyle, const RenderView*, float zoom); |
| 47 | 77 |
| 48 const RenderStyle& style() const { return *m_style; } | 78 float zoom() const { return m_zoom; } |
| 49 const RenderStyle* rootStyle() const { return m_rootStyle; } | 79 |
| 50 float zoom() const; | 80 float emFontSize() const { return m_fontSizes.em(); } |
| 51 bool computingFontSize() const { return m_computingFontSize; } | 81 float remFontSize() const { return m_fontSizes.rem(); } |
| 82 float exFontSize() const { return m_fontSizes.ex(); } | |
| 83 float chFontSize() const { return m_fontSizes.ch(); } | |
| 52 | 84 |
| 53 // Accessing these marks the style as having viewport units | 85 // Accessing these marks the style as having viewport units |
| 54 double viewportWidthPercent() const; | 86 double viewportWidthPercent() const; |
| 55 double viewportHeightPercent() const; | 87 double viewportHeightPercent() const; |
| 56 double viewportMinPercent() const; | 88 double viewportMinPercent() const; |
| 57 double viewportMaxPercent() const; | 89 double viewportMaxPercent() const; |
| 58 | 90 |
| 59 void setStyle(const RenderStyle* style) { m_style = style; } | 91 void setStyle(const RenderStyle* style) { m_style = style; } |
| 60 void setRootStyle(const RenderStyle* rootStyle) { m_rootStyle = rootStyle; } | 92 void setFontSizes(const CSSToLengthFontSizes& fontSizes) { m_fontSizes = fon tSizes; } |
| 93 void setZoom(float zoom) { m_zoom = zoom; } | |
| 61 | 94 |
| 62 CSSToLengthConversionData copyWithAdjustedZoom(float newZoom) const | 95 CSSToLengthConversionData copyWithAdjustedZoom(float newZoom) const |
| 63 { | 96 { |
| 64 return CSSToLengthConversionData(m_style, m_rootStyle, m_viewportWidth, m_viewportHeight, newZoom, m_computingFontSize); | 97 return CSSToLengthConversionData(m_style, m_fontSizes, m_viewportSize, n ewZoom); |
| 65 } | 98 } |
| 66 | 99 |
| 67 private: | 100 private: |
| 68 const RenderStyle* m_style; | 101 const RenderStyle* m_style; |
| 69 const RenderStyle* m_rootStyle; | 102 CSSToLengthFontSizes m_fontSizes; |
| 70 float m_viewportWidth; | 103 CSSToLengthViewportSize m_viewportSize; |
| 71 float m_viewportHeight; | |
| 72 float m_zoom; | 104 float m_zoom; |
| 73 bool m_useEffectiveZoom; | |
| 74 bool m_computingFontSize; | |
| 75 }; | 105 }; |
| 76 | 106 |
| 77 } // namespace blink | 107 } // namespace blink |
| 78 | 108 |
| 79 #endif | 109 #endif |
| OLD | NEW |