| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 return media_type_; | 95 return media_type_; |
| 96 // Otherwise, we get one from mediaValues (which may be dynamic or cached). | 96 // Otherwise, we get one from mediaValues (which may be dynamic or cached). |
| 97 if (media_values_) | 97 if (media_values_) |
| 98 return media_values_->MediaType(); | 98 return media_values_->MediaType(); |
| 99 return g_null_atom; | 99 return g_null_atom; |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool MediaQueryEvaluator::MediaTypeMatch( | 102 bool MediaQueryEvaluator::MediaTypeMatch( |
| 103 const String& media_type_to_match) const { | 103 const String& media_type_to_match) const { |
| 104 return media_type_to_match.IsEmpty() || | 104 return media_type_to_match.IsEmpty() || |
| 105 EqualIgnoringCase(media_type_to_match, MediaTypeNames::all) || | 105 DeprecatedEqualIgnoringCase(media_type_to_match, |
| 106 EqualIgnoringCase(media_type_to_match, MediaType()); | 106 MediaTypeNames::all) || |
| 107 DeprecatedEqualIgnoringCase(media_type_to_match, MediaType()); |
| 107 } | 108 } |
| 108 | 109 |
| 109 static bool ApplyRestrictor(MediaQuery::RestrictorType r, bool value) { | 110 static bool ApplyRestrictor(MediaQuery::RestrictorType r, bool value) { |
| 110 return r == MediaQuery::kNot ? !value : value; | 111 return r == MediaQuery::kNot ? !value : value; |
| 111 } | 112 } |
| 112 | 113 |
| 113 bool MediaQueryEvaluator::Eval( | 114 bool MediaQueryEvaluator::Eval( |
| 114 const MediaQuery* query, | 115 const MediaQuery* query, |
| 115 MediaQueryResultList* viewport_dependent_media_query_results, | 116 MediaQueryResultList* viewport_dependent_media_query_results, |
| 116 MediaQueryResultList* device_dependent_media_query_results) const { | 117 MediaQueryResultList* device_dependent_media_query_results) const { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 const MediaValues& media_values) { | 324 const MediaValues& media_values) { |
| 324 // According to MQ4, only 'screen', 'print' and 'speech' may match. | 325 // According to MQ4, only 'screen', 'print' and 'speech' may match. |
| 325 // FIXME: What should speech match? | 326 // FIXME: What should speech match? |
| 326 // https://www.w3.org/Style/CSS/Tracker/issues/348 | 327 // https://www.w3.org/Style/CSS/Tracker/issues/348 |
| 327 float actual_resolution = 0; | 328 float actual_resolution = 0; |
| 328 | 329 |
| 329 // This checks the actual media type applied to the document, and we know | 330 // This checks the actual media type applied to the document, and we know |
| 330 // this method only got called if this media type matches the one defined | 331 // this method only got called if this media type matches the one defined |
| 331 // in the query. Thus, if if the document's media type is "print", the | 332 // in the query. Thus, if if the document's media type is "print", the |
| 332 // media type of the query will either be "print" or "all". | 333 // media type of the query will either be "print" or "all". |
| 333 if (EqualIgnoringCase(media_values.MediaType(), MediaTypeNames::screen)) { | 334 if (DeprecatedEqualIgnoringCase(media_values.MediaType(), |
| 335 MediaTypeNames::screen)) { |
| 334 actual_resolution = clampTo<float>(media_values.DevicePixelRatio()); | 336 actual_resolution = clampTo<float>(media_values.DevicePixelRatio()); |
| 335 } else if (EqualIgnoringCase(media_values.MediaType(), | 337 } else if (DeprecatedEqualIgnoringCase(media_values.MediaType(), |
| 336 MediaTypeNames::print)) { | 338 MediaTypeNames::print)) { |
| 337 // The resolution of images while printing should not depend on the DPI | 339 // The resolution of images while printing should not depend on the DPI |
| 338 // of the screen. Until we support proper ways of querying this info | 340 // of the screen. Until we support proper ways of querying this info |
| 339 // we use 300px which is considered minimum for current printers. | 341 // we use 300px which is considered minimum for current printers. |
| 340 actual_resolution = 300 / kCssPixelsPerInch; | 342 actual_resolution = 300 / kCssPixelsPerInch; |
| 341 } | 343 } |
| 342 | 344 |
| 343 if (!value.IsValid()) | 345 if (!value.IsValid()) |
| 344 return !!actual_resolution; | 346 return !!actual_resolution; |
| 345 | 347 |
| 346 if (!value.is_value) | 348 if (!value.is_value) |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 default: | 734 default: |
| 733 NOTREACHED(); | 735 NOTREACHED(); |
| 734 return false; | 736 return false; |
| 735 } | 737 } |
| 736 } | 738 } |
| 737 | 739 |
| 738 static bool ScanMediaFeatureEval(const MediaQueryExpValue& value, | 740 static bool ScanMediaFeatureEval(const MediaQueryExpValue& value, |
| 739 MediaFeaturePrefix, | 741 MediaFeaturePrefix, |
| 740 const MediaValues& media_values) { | 742 const MediaValues& media_values) { |
| 741 // Scan only applies to 'tv' media. | 743 // Scan only applies to 'tv' media. |
| 742 if (!EqualIgnoringCase(media_values.MediaType(), MediaTypeNames::tv)) | 744 if (!DeprecatedEqualIgnoringCase(media_values.MediaType(), |
| 745 MediaTypeNames::tv)) |
| 743 return false; | 746 return false; |
| 744 | 747 |
| 745 if (!value.IsValid()) | 748 if (!value.IsValid()) |
| 746 return true; | 749 return true; |
| 747 | 750 |
| 748 if (!value.is_id) | 751 if (!value.is_id) |
| 749 return false; | 752 return false; |
| 750 | 753 |
| 751 // If a platform interface supplies progressive/interlace info for TVs in the | 754 // If a platform interface supplies progressive/interlace info for TVs in the |
| 752 // future, it needs to be handled here. For now, assume a modern TV with | 755 // future, it needs to be handled here. For now, assume a modern TV with |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 // Call the media feature evaluation function. Assume no prefix and let | 818 // Call the media feature evaluation function. Assume no prefix and let |
| 816 // trampoline functions override the prefix if prefix is used. | 819 // trampoline functions override the prefix if prefix is used. |
| 817 EvalFunc func = g_function_map->at(expr->MediaFeature().Impl()); | 820 EvalFunc func = g_function_map->at(expr->MediaFeature().Impl()); |
| 818 if (func) | 821 if (func) |
| 819 return func(expr->ExpValue(), kNoPrefix, *media_values_); | 822 return func(expr->ExpValue(), kNoPrefix, *media_values_); |
| 820 | 823 |
| 821 return false; | 824 return false; |
| 822 } | 825 } |
| 823 | 826 |
| 824 } // namespace blink | 827 } // namespace blink |
| OLD | NEW |