Index: Source/core/css/MediaValues.cpp |
diff --git a/Source/core/css/MediaValues.cpp b/Source/core/css/MediaValues.cpp |
index 533562476a437a2e3061d531d862e209ba970495..0732f946b42adad31ecfc4ed35a83d12a3499758 100644 |
--- a/Source/core/css/MediaValues.cpp |
+++ b/Source/core/css/MediaValues.cpp |
@@ -85,6 +85,26 @@ static int calculateDefaultFontSize(RenderStyle* style) |
return style->fontDescription().specifiedSize(); |
} |
+static int calculateComputedFontSize(RenderStyle* style) |
+{ |
+ return style->fontDescription().computedSize(); |
+} |
+ |
+static bool calculateHasXHeight(RenderStyle* style) |
+{ |
+ return style->fontMetrics().hasXHeight(); |
+} |
+ |
+static double calculateXHeight(RenderStyle* style) |
+{ |
+ return style->fontMetrics().xHeight(); |
+} |
+ |
+static double calculateZeroWidth(RenderStyle* style) |
+{ |
+ return style->fontMetrics().zeroWidth(); |
+} |
+ |
static bool calculateScanMediaType(LocalFrame* frame) |
{ |
ASSERT(frame && frame->view()); |
@@ -113,6 +133,12 @@ static bool calculateThreeDEnabled(LocalFrame* frame) |
return threeDEnabled; |
} |
+static float calculateEffectiveZoom(RenderStyle* style) |
+{ |
+ ASSERT(style); |
+ return style->effectiveZoom(); |
+} |
+ |
static MediaValues::PointerDeviceType calculateLeastCapablePrimaryPointerDeviceType(LocalFrame* frame) |
{ |
ASSERT(frame && frame->settings()); |
@@ -139,11 +165,16 @@ PassRefPtr<MediaValues> MediaValues::create(MediaValuesMode mode, |
int monochromeBitsPerComponent, |
PointerDeviceType pointer, |
int defaultFontSize, |
+ int computedFontSize, |
+ bool hasXHeight, |
+ double xHeight, |
+ double zeroWidth, |
bool threeDEnabled, |
bool scanMediaType, |
bool screenMediaType, |
bool printMediaType, |
- bool strictMode) |
+ bool strictMode, |
+ float effectiveZoom) |
{ |
ASSERT(mode == CachingMode); |
RefPtr<MediaValues> mediaValues = adoptRef(new MediaValues(0, nullptr, mode)); |
@@ -156,11 +187,16 @@ PassRefPtr<MediaValues> MediaValues::create(MediaValuesMode mode, |
mediaValues->m_monochromeBitsPerComponent = monochromeBitsPerComponent; |
mediaValues->m_pointer = pointer; |
mediaValues->m_defaultFontSize = defaultFontSize; |
+ mediaValues->m_computedFontSize = computedFontSize; |
+ mediaValues->m_hasXHeight = hasXHeight; |
+ mediaValues->m_xHeight = xHeight; |
+ mediaValues->m_zeroWidth = zeroWidth; |
mediaValues->m_threeDEnabled = threeDEnabled; |
mediaValues->m_scanMediaType = scanMediaType; |
mediaValues->m_screenMediaType = screenMediaType; |
mediaValues->m_printMediaType = printMediaType; |
mediaValues->m_strictMode = strictMode; |
+ mediaValues->m_effectiveZoom = effectiveZoom; |
return mediaValues; |
} |
@@ -172,19 +208,24 @@ PassRefPtr<MediaValues> MediaValues::create(LocalFrame* frame, RenderStyle* styl |
mediaValues = adoptRef(new MediaValues(frame, style, mode)); |
if (mode == CachingMode) { |
mediaValues->m_viewportWidth = calculateViewportWidth(frame, style); |
- mediaValues->m_viewportHeight = calculateViewportHeight(frame, style), |
- mediaValues->m_deviceWidth = calculateDeviceWidth(frame), |
- mediaValues->m_deviceHeight = calculateDeviceHeight(frame), |
- mediaValues->m_devicePixelRatio = calculateDevicePixelRatio(frame), |
- mediaValues->m_colorBitsPerComponent = calculateColorBitsPerComponent(frame), |
- mediaValues->m_monochromeBitsPerComponent = calculateMonochromeBitsPerComponent(frame), |
- mediaValues->m_pointer = calculateLeastCapablePrimaryPointerDeviceType(frame), |
- mediaValues->m_defaultFontSize = calculateDefaultFontSize(style), |
- mediaValues->m_threeDEnabled = calculateThreeDEnabled(frame), |
- mediaValues->m_scanMediaType = calculateScanMediaType(frame), |
- mediaValues->m_screenMediaType = calculateScreenMediaType(frame), |
- mediaValues->m_printMediaType = calculatePrintMediaType(frame), |
+ mediaValues->m_viewportHeight = calculateViewportHeight(frame, style); |
+ mediaValues->m_deviceWidth = calculateDeviceWidth(frame); |
+ mediaValues->m_deviceHeight = calculateDeviceHeight(frame); |
+ mediaValues->m_devicePixelRatio = calculateDevicePixelRatio(frame); |
+ mediaValues->m_colorBitsPerComponent = calculateColorBitsPerComponent(frame); |
+ mediaValues->m_monochromeBitsPerComponent = calculateMonochromeBitsPerComponent(frame); |
+ mediaValues->m_pointer = calculateLeastCapablePrimaryPointerDeviceType(frame); |
+ mediaValues->m_defaultFontSize = calculateDefaultFontSize(style); |
+ mediaValues->m_computedFontSize = calculateComputedFontSize(style); |
+ mediaValues->m_hasXHeight = calculateHasXHeight(style); |
+ mediaValues->m_xHeight = calculateXHeight(style); |
+ mediaValues->m_zeroWidth = calculateZeroWidth(style); |
+ mediaValues->m_threeDEnabled = calculateThreeDEnabled(frame); |
+ mediaValues->m_scanMediaType = calculateScanMediaType(frame); |
+ mediaValues->m_screenMediaType = calculateScreenMediaType(frame); |
+ mediaValues->m_printMediaType = calculatePrintMediaType(frame); |
mediaValues->m_strictMode = calculateStrictMode(frame); |
+ mediaValues->m_effectiveZoom = calculateEffectiveZoom(style); |
mediaValues->m_style.clear(); |
mediaValues->m_frame = 0; |
@@ -193,10 +234,9 @@ PassRefPtr<MediaValues> MediaValues::create(LocalFrame* frame, RenderStyle* styl |
return mediaValues; |
} |
-PassRefPtr<MediaValues> MediaValues::create(Document* document, MediaValuesMode mode) |
+PassRefPtr<MediaValues> MediaValues::create(const Document& document, MediaValuesMode mode) |
{ |
- ASSERT(document); |
- Document* executingDocument = document->import() ? document->import()->master() : document; |
+ const Document* executingDocument = document.import() ? document.import()->master() : &document; |
ASSERT(executingDocument->frame()); |
ASSERT(executingDocument->renderer()); |
ASSERT(executingDocument->renderer()->style()); |
@@ -219,11 +259,16 @@ PassRefPtr<MediaValues> MediaValues::copy() const |
mediaValues->m_monochromeBitsPerComponent = m_monochromeBitsPerComponent; |
mediaValues->m_pointer = m_pointer; |
mediaValues->m_defaultFontSize = m_defaultFontSize; |
+ mediaValues->m_computedFontSize = m_computedFontSize; |
+ mediaValues->m_hasXHeight = m_hasXHeight; |
+ mediaValues->m_xHeight = m_xHeight; |
+ mediaValues->m_zeroWidth = m_zeroWidth; |
mediaValues->m_threeDEnabled = m_threeDEnabled; |
mediaValues->m_scanMediaType = m_scanMediaType; |
mediaValues->m_screenMediaType = m_screenMediaType; |
mediaValues->m_printMediaType = m_printMediaType; |
mediaValues->m_strictMode = m_strictMode; |
+ mediaValues->m_effectiveZoom = m_effectiveZoom; |
return mediaValues; |
} |
@@ -296,6 +341,13 @@ int MediaValues::defaultFontSize() const |
return m_defaultFontSize; |
} |
+int MediaValues::computedFontSize() const |
+{ |
+ if (m_mode == DynamicMode) |
+ return calculateComputedFontSize(m_style.get()); |
+ return m_computedFontSize; |
+} |
+ |
bool MediaValues::threeDEnabled() const |
{ |
if (m_mode == DynamicMode) |
@@ -331,6 +383,13 @@ bool MediaValues::strictMode() const |
return m_strictMode; |
} |
+float MediaValues::effectiveZoom() const |
+{ |
+ if (m_mode == DynamicMode) |
+ return calculateEffectiveZoom(m_style.get()); |
+ return m_effectiveZoom; |
+} |
+ |
Document* MediaValues::document() const |
{ |
if (!m_frame) |
@@ -338,4 +397,79 @@ Document* MediaValues::document() const |
return m_frame->document(); |
} |
+float MediaValues::zoom() const |
+{ |
+ return m_effectiveZoom; |
+} |
+ |
+bool MediaValues::computingFontSize() const |
+{ |
+ // MediaValues is used to computeLength from the MediaQueryEvaluator with the assumption that fonts are computed |
+ return true; |
+} |
+ |
+double MediaValues::fontSpecifiedSize() const |
+{ |
+ return m_defaultFontSize; |
+} |
+ |
+double MediaValues::fontComputedSize() const |
+{ |
+ return m_computedFontSize; |
+ |
+} |
+ |
+double MediaValues::rootFontSpecifiedSize() const |
+{ |
+ return m_defaultFontSize; |
+} |
+ |
+double MediaValues::rootFontComputedSize() const |
+{ |
+ return m_computedFontSize; |
+} |
+ |
+bool MediaValues::hasXHeight() const |
+{ |
+ return m_hasXHeight; |
+} |
+ |
+double MediaValues::xHeight() const |
+{ |
+ return m_xHeight; |
+} |
+ |
+double MediaValues::zeroWidth() const |
+{ |
+ return m_zeroWidth; |
+} |
+ |
+bool MediaValues::hasRoot() const |
+{ |
+ // MediaValues is used to computeLength from the MediaQueryEvaluator with the assumption |
+ // that root is present (and equal to the initial style) |
+ return true; |
+} |
+ |
+ |
+double MediaValues::viewportWidthPercent() const |
+{ |
+ return (double)m_viewportWidth / 100.0; |
+} |
+ |
+double MediaValues::viewportHeightPercent() const |
+{ |
+ return (double)m_viewportHeight / 100.0; |
+} |
+ |
+double MediaValues::viewportMinPercent() const |
+{ |
+ return (double)(std::min(m_viewportWidth, m_viewportHeight)) / 100.0; |
+} |
+ |
+double MediaValues::viewportMaxPercent() const |
+{ |
+ return (double)(std::max(m_viewportWidth, m_viewportHeight)) / 100.0; |
+} |
+ |
} // namespace |