Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: Source/core/css/CSSToLengthConversionData.h

Issue 705783002: Decouple font unit conversion in computeLengthDouble from RenderStyle. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed timloh's issues. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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;
41 42
42 class CSSToLengthConversionData { 43 class CSSToLengthConversionData {
43 public: 44 public:
44 CSSToLengthConversionData(const RenderStyle* currStyle, const RenderStyle* r ootStyle, const RenderView*, float zoom, bool computingFontSize = false);
45 CSSToLengthConversionData(const RenderStyle* currStyle, const RenderStyle* r ootStyle, const RenderView*, bool computingFontSize = false);
46 CSSToLengthConversionData(const RenderStyle* currStyle, const RenderStyle* r ootStyle, float viewportWidth, float viewportHeight, float zoom, bool computingF ontSize = false);
47 45
48 const RenderStyle& style() const { return *m_style; } 46 class FontSizes {
49 const RenderStyle* rootStyle() const { return m_rootStyle; } 47 public:
50 float zoom() const; 48 FontSizes() : m_em(0), m_rem(0), m_font(nullptr) { }
51 bool computingFontSize() const { return m_computingFontSize; } 49 FontSizes(float em, float rem, const Font*);
50 FontSizes(const RenderStyle*, const RenderStyle* rootStyle);
51
52 float em() const { return m_em; }
53 float rem() const { return m_rem; }
54 float ex() const;
55 float ch() const;
56 private:
57 float m_em;
58 float m_rem;
59 const Font* m_font;
60 };
61
62 class ViewportSize {
63 public:
64 ViewportSize() : m_width(0), m_height(0) { }
65 ViewportSize(double width, double height) : m_width(width), m_height(hei ght) { }
66 explicit ViewportSize(const RenderView*);
67
68 double width() const { return m_width; }
69 double height() const { return m_height; }
70 private:
71 double m_width;
72 double m_height;
73 };
74
75 CSSToLengthConversionData() { }
76 CSSToLengthConversionData(const RenderStyle*, const FontSizes&, const Viewpo rtSize&, float zoom);
77 CSSToLengthConversionData(const RenderStyle* currStyle, const RenderStyle* r ootStyle, const RenderView*, float zoom);
78
79 float zoom() const { return m_zoom; }
80
81 float emFontSize() const { return m_fontSizes.em(); }
82 float remFontSize() const { return m_fontSizes.rem(); }
83 float exFontSize() const { return m_fontSizes.ex(); }
84 float chFontSize() const { return m_fontSizes.ch(); }
52 85
53 // Accessing these marks the style as having viewport units 86 // Accessing these marks the style as having viewport units
54 double viewportWidthPercent() const; 87 double viewportWidthPercent() const;
55 double viewportHeightPercent() const; 88 double viewportHeightPercent() const;
56 double viewportMinPercent() const; 89 double viewportMinPercent() const;
57 double viewportMaxPercent() const; 90 double viewportMaxPercent() const;
58 91
59 void setStyle(const RenderStyle* style) { m_style = style; } 92 void setFontSizes(const FontSizes& fontSizes) { m_fontSizes = fontSizes; }
60 void setRootStyle(const RenderStyle* rootStyle) { m_rootStyle = rootStyle; } 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 FontSizes m_fontSizes;
70 float m_viewportWidth; 103 ViewportSize m_viewportSize;
Timothy Loh 2014/11/07 17:59:37 const?
andersr 2014/11/10 08:56:09 I didn't do this, since the implicit assignment op
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698