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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/css/CSSToLengthConversionData.h
diff --git a/Source/core/css/CSSToLengthConversionData.h b/Source/core/css/CSSToLengthConversionData.h
index e9595dea95e20eb2f705e28638713fd05d90536f..c12e4ef814ebb3df134c2f7c88365a211241c8a0 100644
--- a/Source/core/css/CSSToLengthConversionData.h
+++ b/Source/core/css/CSSToLengthConversionData.h
@@ -38,17 +38,49 @@ namespace blink {
class RenderStyle;
class RenderView;
+class Font;
+
+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.
+public:
+ CSSToLengthFontSizes() : m_em(0), m_rem(0), m_font(nullptr) { }
+ CSSToLengthFontSizes(float em, float rem, const Font*);
+ CSSToLengthFontSizes(const RenderStyle*, const RenderStyle* rootStyle);
+
+ float em() const { return m_em; }
+ float rem() const { return m_rem; }
+ float ex() const;
+ float ch() const;
+private:
+ float m_em;
+ float m_rem;
+ const Font* m_font;
+};
+
+class CSSToLengthViewportSize {
+public:
+ CSSToLengthViewportSize() : m_width(0), m_height(0) { }
+ CSSToLengthViewportSize(double width, double height) : m_width(width), m_height(height) { }
+ explicit CSSToLengthViewportSize(const RenderView*);
+
+ double width() const { return m_width; }
+ double height() const { return m_height; }
+private:
+ double m_width;
+ double m_height;
+};
class CSSToLengthConversionData {
public:
- CSSToLengthConversionData(const RenderStyle* currStyle, const RenderStyle* rootStyle, const RenderView*, float zoom, bool computingFontSize = false);
- CSSToLengthConversionData(const RenderStyle* currStyle, const RenderStyle* rootStyle, const RenderView*, bool computingFontSize = false);
- CSSToLengthConversionData(const RenderStyle* currStyle, const RenderStyle* rootStyle, float viewportWidth, float viewportHeight, float zoom, bool computingFontSize = false);
+ CSSToLengthConversionData() { }
+ CSSToLengthConversionData(const RenderStyle*, const CSSToLengthFontSizes&, const CSSToLengthViewportSize&, float zoom);
+ CSSToLengthConversionData(const RenderStyle* currStyle, const RenderStyle* rootStyle, const RenderView*, float zoom);
+
+ float zoom() const { return m_zoom; }
- const RenderStyle& style() const { return *m_style; }
- const RenderStyle* rootStyle() const { return m_rootStyle; }
- float zoom() const;
- bool computingFontSize() const { return m_computingFontSize; }
+ float emFontSize() const { return m_fontSizes.em(); }
+ float remFontSize() const { return m_fontSizes.rem(); }
+ float exFontSize() const { return m_fontSizes.ex(); }
+ float chFontSize() const { return m_fontSizes.ch(); }
// Accessing these marks the style as having viewport units
double viewportWidthPercent() const;
@@ -57,21 +89,19 @@ public:
double viewportMaxPercent() const;
void setStyle(const RenderStyle* style) { m_style = style; }
- void setRootStyle(const RenderStyle* rootStyle) { m_rootStyle = rootStyle; }
+ void setFontSizes(const CSSToLengthFontSizes& fontSizes) { m_fontSizes = fontSizes; }
+ void setZoom(float zoom) { m_zoom = zoom; }
CSSToLengthConversionData copyWithAdjustedZoom(float newZoom) const
{
- return CSSToLengthConversionData(m_style, m_rootStyle, m_viewportWidth, m_viewportHeight, newZoom, m_computingFontSize);
+ return CSSToLengthConversionData(m_style, m_fontSizes, m_viewportSize, newZoom);
}
private:
const RenderStyle* m_style;
- const RenderStyle* m_rootStyle;
- float m_viewportWidth;
- float m_viewportHeight;
+ CSSToLengthFontSizes m_fontSizes;
+ CSSToLengthViewportSize m_viewportSize;
float m_zoom;
- bool m_useEffectiveZoom;
- bool m_computingFontSize;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698