PassRefPtr<MediaValues> MediaValues::create(LocalFrame* frame, RenderStyle* style, MediaValuesMode mode) { ASSERT(frame && style); RefPtr<MediaValues> mediaValues; 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_strictMode = calculateStrictMode(frame); mediaValues->m_style.clear(); mediaValues->m_frame = 0; } return mediaValues; }
MediaValuesCached::MediaValuesCached(LocalFrame* frame) { ASSERT(isMainThread()); ASSERT(frame); // In case that frame is missing (e.g. for images that their document does not have a frame) // We simply leave the MediaValues object with the default MediaValuesCachedData values. m_data.viewportWidth = calculateViewportWidth(frame); m_data.viewportHeight = calculateViewportHeight(frame); m_data.deviceWidth = calculateDeviceWidth(frame); m_data.deviceHeight = calculateDeviceHeight(frame); m_data.devicePixelRatio = calculateDevicePixelRatio(frame); m_data.colorBitsPerComponent = calculateColorBitsPerComponent(frame); m_data.monochromeBitsPerComponent = calculateMonochromeBitsPerComponent(frame); m_data.pointer = calculateLeastCapablePrimaryPointerDeviceType(frame); m_data.defaultFontSize = calculateDefaultFontSize(frame); m_data.threeDEnabled = calculateThreeDEnabled(frame); m_data.scanMediaType = calculateScanMediaType(frame); m_data.screenMediaType = calculateScreenMediaType(frame); m_data.printMediaType = calculatePrintMediaType(frame); m_data.strictMode = calculateStrictMode(frame); }
bool MediaValues::screenMediaType() const { if (m_mode == DynamicMode) return calculateScreenMediaType(m_frame); return m_screenMediaType; }