| 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 13 matching lines...) Expand all Loading... |
| 24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "core/css/MediaQueryEvaluator.h" | 31 #include "core/css/MediaQueryEvaluator.h" |
| 32 | 32 |
| 33 #include "CSSValueKeywords.h" | 33 #include "CSSValueKeywords.h" |
| 34 #include "MediaFeatureNames.h" |
| 35 #include "MediaFeatures.h" |
| 34 #include "core/css/CSSAspectRatioValue.h" | 36 #include "core/css/CSSAspectRatioValue.h" |
| 35 #include "core/css/CSSHelper.h" | 37 #include "core/css/CSSHelper.h" |
| 36 #include "core/css/CSSPrimitiveValue.h" | 38 #include "core/css/CSSPrimitiveValue.h" |
| 37 #include "core/css/CSSToLengthConversionData.h" | 39 #include "core/css/CSSToLengthConversionData.h" |
| 38 #include "core/css/MediaFeatureNames.h" | |
| 39 #include "core/css/MediaList.h" | 40 #include "core/css/MediaList.h" |
| 40 #include "core/css/MediaQuery.h" | 41 #include "core/css/MediaQuery.h" |
| 41 #include "core/css/resolver/MediaQueryResult.h" | 42 #include "core/css/resolver/MediaQueryResult.h" |
| 42 #include "core/dom/NodeRenderStyle.h" | 43 #include "core/dom/NodeRenderStyle.h" |
| 43 #include "core/frame/FrameHost.h" | 44 #include "core/frame/FrameHost.h" |
| 44 #include "core/frame/FrameView.h" | 45 #include "core/frame/FrameView.h" |
| 45 #include "core/frame/LocalFrame.h" | 46 #include "core/frame/LocalFrame.h" |
| 46 #include "core/frame/Settings.h" | 47 #include "core/frame/Settings.h" |
| 47 #include "core/inspector/InspectorInstrumentation.h" | 48 #include "core/inspector/InspectorInstrumentation.h" |
| 48 #include "core/rendering/RenderView.h" | 49 #include "core/rendering/RenderView.h" |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 // If a platform interface supplies progressive/interlace info for TVs in th
e | 667 // If a platform interface supplies progressive/interlace info for TVs in th
e |
| 667 // future, it needs to be handled here. For now, assume a modern TV with | 668 // future, it needs to be handled here. For now, assume a modern TV with |
| 668 // progressive display. | 669 // progressive display. |
| 669 return toCSSPrimitiveValue(value)->getValueID() == CSSValueProgressive; | 670 return toCSSPrimitiveValue(value)->getValueID() == CSSValueProgressive; |
| 670 } | 671 } |
| 671 | 672 |
| 672 static void createFunctionMap() | 673 static void createFunctionMap() |
| 673 { | 674 { |
| 674 // Create the table. | 675 // Create the table. |
| 675 gFunctionMap = new FunctionMap; | 676 gFunctionMap = new FunctionMap; |
| 676 #define ADD_TO_FUNCTIONMAP(name, str) \ | 677 #define ADD_TO_FUNCTIONMAP(name) \ |
| 677 gFunctionMap->set(name##MediaFeature.impl(), name##MediaFeatureEval); | 678 gFunctionMap->set(name##MediaFeature.impl(), name##MediaFeatureEval); |
| 678 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP); | 679 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP); |
| 679 #undef ADD_TO_FUNCTIONMAP | 680 #undef ADD_TO_FUNCTIONMAP |
| 680 } | 681 } |
| 681 | 682 |
| 682 bool MediaQueryEvaluator::eval(const MediaQueryExp* expr) const | 683 bool MediaQueryEvaluator::eval(const MediaQueryExp* expr) const |
| 683 { | 684 { |
| 684 if (!m_frame || !m_style) | 685 if (!m_frame || !m_style) |
| 685 return m_expResult; | 686 return m_expResult; |
| 686 | 687 |
| 687 if (!gFunctionMap) | 688 if (!gFunctionMap) |
| 688 createFunctionMap(); | 689 createFunctionMap(); |
| 689 | 690 |
| 690 // Call the media feature evaluation function. Assume no prefix and let | 691 // Call the media feature evaluation function. Assume no prefix and let |
| 691 // trampoline functions override the prefix if prefix is used. | 692 // trampoline functions override the prefix if prefix is used. |
| 692 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); | 693 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); |
| 693 if (func) | 694 if (func) |
| 694 return func(expr->value(), m_style.get(), m_frame, NoPrefix); | 695 return func(expr->value(), m_style.get(), m_frame, NoPrefix); |
| 695 | 696 |
| 696 return false; | 697 return false; |
| 697 } | 698 } |
| 698 | 699 |
| 699 } // namespace | 700 } // namespace |
| OLD | NEW |