| OLD | NEW |
| 1 /* | 1 /* |
| 2 * CSS Media Query Evaluator | 2 * CSS Media Query Evaluator |
| 3 * | 3 * |
| 4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. | 4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. |
| 5 * Copyright (C) 2013 Apple Inc. All rights reserved. | 5 * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 6 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "core/dom/NodeComputedStyle.h" | 44 #include "core/dom/NodeComputedStyle.h" |
| 45 #include "core/frame/FrameHost.h" | 45 #include "core/frame/FrameHost.h" |
| 46 #include "core/frame/FrameView.h" | 46 #include "core/frame/FrameView.h" |
| 47 #include "core/frame/LocalFrame.h" | 47 #include "core/frame/LocalFrame.h" |
| 48 #include "core/frame/Settings.h" | 48 #include "core/frame/Settings.h" |
| 49 #include "core/frame/UseCounter.h" | 49 #include "core/frame/UseCounter.h" |
| 50 #include "core/inspector/InspectorInstrumentation.h" | 50 #include "core/inspector/InspectorInstrumentation.h" |
| 51 #include "core/style/ComputedStyle.h" | 51 #include "core/style/ComputedStyle.h" |
| 52 #include "platform/RuntimeEnabledFeatures.h" | 52 #include "platform/RuntimeEnabledFeatures.h" |
| 53 #include "platform/geometry/FloatRect.h" | 53 #include "platform/geometry/FloatRect.h" |
| 54 #include "platform/graphics/ColorSpace.h" |
| 54 #include "public/platform/PointerProperties.h" | 55 #include "public/platform/PointerProperties.h" |
| 55 #include "public/platform/ShapeProperties.h" | 56 #include "public/platform/ShapeProperties.h" |
| 56 #include "public/platform/WebDisplayMode.h" | 57 #include "public/platform/WebDisplayMode.h" |
| 57 #include "wtf/HashMap.h" | 58 #include "wtf/HashMap.h" |
| 58 | 59 |
| 59 namespace blink { | 60 namespace blink { |
| 60 | 61 |
| 61 using namespace MediaFeatureNames; | 62 using namespace MediaFeatureNames; |
| 62 | 63 |
| 63 enum MediaFeaturePrefix { MinPrefix, MaxPrefix, NoPrefix }; | 64 enum MediaFeaturePrefix { MinPrefix, MaxPrefix, NoPrefix }; |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 | 747 |
| 747 if (!value.isID) | 748 if (!value.isID) |
| 748 return false; | 749 return false; |
| 749 | 750 |
| 750 // If a platform interface supplies progressive/interlace info for TVs in the | 751 // If a platform interface supplies progressive/interlace info for TVs in the |
| 751 // future, it needs to be handled here. For now, assume a modern TV with | 752 // future, it needs to be handled here. For now, assume a modern TV with |
| 752 // progressive display. | 753 // progressive display. |
| 753 return (value.id == CSSValueProgressive); | 754 return (value.id == CSSValueProgressive); |
| 754 } | 755 } |
| 755 | 756 |
| 757 static bool colorGamutMediaFeatureEval(const MediaQueryExpValue& value, |
| 758 MediaFeaturePrefix, |
| 759 const MediaValues& mediaValues) { |
| 760 // isValid() is false if there is no parameter. Without parameter we should |
| 761 // return true to indicate that colorGamutMediaFeature is enabled in the |
| 762 // browser. |
| 763 if (!value.isValid()) |
| 764 return true; |
| 765 |
| 766 if (!value.isID) |
| 767 return false; |
| 768 |
| 769 DCHECK(value.id == CSSValueSRGB || value.id == CSSValueP3 || |
| 770 value.id == CSSValueRec2020); |
| 771 |
| 772 ColorSpaceGamut gamut = mediaValues.colorGamut(); |
| 773 switch (gamut) { |
| 774 case ColorSpaceGamut::Unknown: |
| 775 case ColorSpaceGamut::LessThanNTSC: |
| 776 case ColorSpaceGamut::NTSC: |
| 777 case ColorSpaceGamut::SRGB: |
| 778 return value.id == CSSValueSRGB; |
| 779 case ColorSpaceGamut::AlmostP3: |
| 780 case ColorSpaceGamut::P3: |
| 781 case ColorSpaceGamut::AdobeRGB: |
| 782 case ColorSpaceGamut::Wide: |
| 783 return value.id == CSSValueSRGB || value.id == CSSValueP3; |
| 784 case ColorSpaceGamut::BT2020: |
| 785 case ColorSpaceGamut::ProPhoto: |
| 786 case ColorSpaceGamut::UltraWide: |
| 787 return value.id == CSSValueSRGB || value.id == CSSValueP3 || |
| 788 value.id == CSSValueRec2020; |
| 789 case ColorSpaceGamut::End: |
| 790 NOTREACHED(); |
| 791 return false; |
| 792 } |
| 793 |
| 794 // This is for some compilers that do not understand that it can't be reached. |
| 795 NOTREACHED(); |
| 796 return false; |
| 797 } |
| 798 |
| 756 void MediaQueryEvaluator::init() { | 799 void MediaQueryEvaluator::init() { |
| 757 // Create the table. | 800 // Create the table. |
| 758 gFunctionMap = new FunctionMap; | 801 gFunctionMap = new FunctionMap; |
| 759 #define ADD_TO_FUNCTIONMAP(name) \ | 802 #define ADD_TO_FUNCTIONMAP(name) \ |
| 760 gFunctionMap->set(name##MediaFeature.impl(), name##MediaFeatureEval); | 803 gFunctionMap->set(name##MediaFeature.impl(), name##MediaFeatureEval); |
| 761 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP); | 804 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP); |
| 762 #undef ADD_TO_FUNCTIONMAP | 805 #undef ADD_TO_FUNCTIONMAP |
| 763 } | 806 } |
| 764 | 807 |
| 765 bool MediaQueryEvaluator::eval(const MediaQueryExp* expr) const { | 808 bool MediaQueryEvaluator::eval(const MediaQueryExp* expr) const { |
| 766 if (!m_mediaValues || !m_mediaValues->hasValues()) | 809 if (!m_mediaValues || !m_mediaValues->hasValues()) |
| 767 return true; | 810 return true; |
| 768 | 811 |
| 769 DCHECK(gFunctionMap); | 812 DCHECK(gFunctionMap); |
| 770 | 813 |
| 771 // Call the media feature evaluation function. Assume no prefix and let | 814 // Call the media feature evaluation function. Assume no prefix and let |
| 772 // trampoline functions override the prefix if prefix is used. | 815 // trampoline functions override the prefix if prefix is used. |
| 773 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); | 816 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); |
| 774 if (func) | 817 if (func) |
| 775 return func(expr->expValue(), NoPrefix, *m_mediaValues); | 818 return func(expr->expValue(), NoPrefix, *m_mediaValues); |
| 776 | 819 |
| 777 return false; | 820 return false; |
| 778 } | 821 } |
| 779 | 822 |
| 780 } // namespace blink | 823 } // namespace blink |
| OLD | NEW |