📄 mediaqueryevaluator.cpp
字号:
return colorMediaFeatureEval(value, style, frame, op);}static bool device_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op){ if (value) { FloatRect sg = screenRect(frame->page()->mainFrame()->view()); int h = 0; int v = 0; if (parseAspectRatio(value, h, v)) return v != 0 && compareValue(static_cast<int>(sg.width()) * v, static_cast<int>(sg.height()) * h, op); return false; } // ({,min-,max-}device-aspect-ratio) // assume if we have a device, its aspect ratio is non-zero return true;}static bool device_pixel_ratioMediaFeatureEval(CSSValue *value, RenderStyle*, Frame* frame, MediaFeaturePrefix op){ if (value) return value->isPrimitiveValue() && compareValue(frame->page()->chrome()->scaleFactor(), static_cast<CSSPrimitiveValue*>(value)->getFloatValue(), op); return frame->page()->chrome()->scaleFactor() != 0;}static bool gridMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op){ // if output device is bitmap, grid: 0 == true // assume we have bitmap device float number; if (value && numberValue(value, number)) return compareValue(static_cast<int>(number), 0, op); return false;}static bool device_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op){ if (value) { FloatRect sg = screenRect(frame->page()->mainFrame()->view()); return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.height()), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op); } // ({,min-,max-}device-height) // assume if we have a device, assume non-zero return true;}static bool device_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op){ if (value) { FloatRect sg = screenRect(frame->page()->mainFrame()->view()); return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.width()), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op); } // ({,min-,max-}device-width) // assume if we have a device, assume non-zero return true;}static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op){ FrameView* view = frame->view(); if (value) return value->isPrimitiveValue() && compareValue(view->layoutHeight(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op); return view->layoutHeight() != 0;}static bool widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op){ FrameView* view = frame->view(); if (value) return value->isPrimitiveValue() && compareValue(view->layoutWidth(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op); return view->layoutWidth() != 0;}// rest of the functions are trampolines which set the prefix according to the media feature expression usedstatic bool min_colorMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix){ return colorMediaFeatureEval(value, style, frame, MinPrefix);}static bool max_colorMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix){ return colorMediaFeatureEval(value, style, frame, MaxPrefix);}static bool min_monochromeMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix){ return monochromeMediaFeatureEval(value, style, frame, MinPrefix);}static bool max_monochromeMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix){ return monochromeMediaFeatureEval(value, style, frame, MaxPrefix);}static bool min_device_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix){ return device_aspect_ratioMediaFeatureEval(value, style, frame, MinPrefix);}static bool max_device_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix){ return device_aspect_ratioMediaFeatureEval(value, style, frame, MaxPrefix);}static bool min_device_pixel_ratioMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix){ return device_pixel_ratioMediaFeatureEval(value, style, frame, MinPrefix);}static bool max_device_pixel_ratioMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix){ return device_pixel_ratioMediaFeatureEval(value, style, frame, MaxPrefix);}static bool min_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix){ return heightMediaFeatureEval(value, style, frame, MinPrefix);}static bool max_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix){ return heightMediaFeatureEval(value, style, frame, MaxPrefix);}static bool min_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix){ return widthMediaFeatureEval(value, style, frame, MinPrefix);}static bool max_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix){ return widthMediaFeatureEval(value, style, frame, MaxPrefix);}static bool min_device_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix){ return device_heightMediaFeatureEval(value, style, frame, MinPrefix);}static bool max_device_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix){ return device_heightMediaFeatureEval(value, style, frame, MaxPrefix);}static bool min_device_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix){ return device_widthMediaFeatureEval(value, style, frame, MinPrefix);}static bool max_device_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix){ return device_widthMediaFeatureEval(value, style, frame, MaxPrefix);}static bool animationMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op){ if (value) { float number; return numberValue(value, number) && compareValue(1, static_cast<int>(number), op); } return true;}static bool transitionMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op){ if (value) { float number; return numberValue(value, number) && compareValue(1, static_cast<int>(number), op); } return true;}static bool transform_2dMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op){ if (value) { float number; return numberValue(value, number) && compareValue(1, static_cast<int>(number), op); } return true;}static bool transform_3dMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op){ if (value) { float number; return numberValue(value, number) && compareValue(0, static_cast<int>(number), op); } return false;}static void createFunctionMap(){ // Create the table. gFunctionMap = new FunctionMap;#define ADD_TO_FUNCTIONMAP(name, str) \ gFunctionMap->set(name##MediaFeature.impl(), name##MediaFeatureEval); CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP);#undef ADD_TO_FUNCTIONMAP}bool MediaQueryEvaluator::eval(const MediaQueryExp* expr) const{ if (!m_frame || !m_style) return m_expResult; if (!gFunctionMap) createFunctionMap(); // call the media feature evaluation function. Assume no prefix // and let trampoline functions override the prefix if prefix is // used EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); if (func) return func(expr->value(), m_style, m_frame, NoPrefix); return false;}} // namespace
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -