| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "sky/engine/core/css/MediaList.h" | 42 #include "sky/engine/core/css/MediaList.h" |
| 43 #include "sky/engine/core/css/MediaQuery.h" | 43 #include "sky/engine/core/css/MediaQuery.h" |
| 44 #include "sky/engine/core/css/MediaQueryExp.h" | 44 #include "sky/engine/core/css/MediaQueryExp.h" |
| 45 #include "sky/engine/core/css/MediaValuesDynamic.h" | 45 #include "sky/engine/core/css/MediaValuesDynamic.h" |
| 46 #include "sky/engine/core/css/PointerProperties.h" | 46 #include "sky/engine/core/css/PointerProperties.h" |
| 47 #include "sky/engine/core/dom/NodeRenderStyle.h" | 47 #include "sky/engine/core/dom/NodeRenderStyle.h" |
| 48 #include "sky/engine/core/frame/FrameHost.h" | 48 #include "sky/engine/core/frame/FrameHost.h" |
| 49 #include "sky/engine/core/frame/FrameView.h" | 49 #include "sky/engine/core/frame/FrameView.h" |
| 50 #include "sky/engine/core/frame/LocalFrame.h" | 50 #include "sky/engine/core/frame/LocalFrame.h" |
| 51 #include "sky/engine/core/frame/Settings.h" | 51 #include "sky/engine/core/frame/Settings.h" |
| 52 #include "sky/engine/core/frame/UseCounter.h" | |
| 53 #include "sky/engine/core/rendering/RenderView.h" | 52 #include "sky/engine/core/rendering/RenderView.h" |
| 54 #include "sky/engine/core/rendering/style/RenderStyle.h" | 53 #include "sky/engine/core/rendering/style/RenderStyle.h" |
| 55 #include "sky/engine/platform/PlatformScreen.h" | 54 #include "sky/engine/platform/PlatformScreen.h" |
| 56 #include "sky/engine/platform/geometry/FloatRect.h" | 55 #include "sky/engine/platform/geometry/FloatRect.h" |
| 57 #include "sky/engine/wtf/HashMap.h" | 56 #include "sky/engine/wtf/HashMap.h" |
| 58 | 57 |
| 59 namespace blink { | 58 namespace blink { |
| 60 | 59 |
| 61 using namespace MediaFeatureNames; | 60 using namespace MediaFeatureNames; |
| 62 | 61 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 return compareValue( | 293 return compareValue( |
| 295 floorf(0.5 + 100 * actualResolution) / 100, | 294 floorf(0.5 + 100 * actualResolution) / 100, |
| 296 floorf(0.5 + 100 * valueInDppx) / 100, op); | 295 floorf(0.5 + 100 * valueInDppx) / 100, op); |
| 297 } | 296 } |
| 298 | 297 |
| 299 return compareValue(actualResolution, valueInDppx, op); | 298 return compareValue(actualResolution, valueInDppx, op); |
| 300 } | 299 } |
| 301 | 300 |
| 302 static bool devicePixelRatioMediaFeatureEval(const MediaQueryExpValue& value, Me
diaFeaturePrefix op, const MediaValues& mediaValues) | 301 static bool devicePixelRatioMediaFeatureEval(const MediaQueryExpValue& value, Me
diaFeaturePrefix op, const MediaValues& mediaValues) |
| 303 { | 302 { |
| 304 UseCounter::count(mediaValues.document(), UseCounter::PrefixedDevicePixelRat
ioMediaFeature); | |
| 305 | |
| 306 return (!value.isValid() || value.unit == CSSPrimitiveValue::CSS_NUMBER) &&
evalResolution(value, op, mediaValues); | 303 return (!value.isValid() || value.unit == CSSPrimitiveValue::CSS_NUMBER) &&
evalResolution(value, op, mediaValues); |
| 307 } | 304 } |
| 308 | 305 |
| 309 static bool resolutionMediaFeatureEval(const MediaQueryExpValue& value, MediaFea
turePrefix op, const MediaValues& MediaValues) | 306 static bool resolutionMediaFeatureEval(const MediaQueryExpValue& value, MediaFea
turePrefix op, const MediaValues& MediaValues) |
| 310 { | 307 { |
| 311 return (!value.isValid() || CSSPrimitiveValue::isResolution(value.unit)) &&
evalResolution(value, op, MediaValues); | 308 return (!value.isValid() || CSSPrimitiveValue::isResolution(value.unit)) &&
evalResolution(value, op, MediaValues); |
| 312 } | 309 } |
| 313 | 310 |
| 314 static bool computeLength(const MediaQueryExpValue& value, const MediaValues& me
diaValues, int& result) | 311 static bool computeLength(const MediaQueryExpValue& value, const MediaValues& me
diaValues, int& result) |
| 315 { | 312 { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 return deviceAspectRatioMediaFeatureEval(value, MinPrefix, mediaValues); | 414 return deviceAspectRatioMediaFeatureEval(value, MinPrefix, mediaValues); |
| 418 } | 415 } |
| 419 | 416 |
| 420 static bool maxDeviceAspectRatioMediaFeatureEval(const MediaQueryExpValue& value
, MediaFeaturePrefix, const MediaValues& mediaValues) | 417 static bool maxDeviceAspectRatioMediaFeatureEval(const MediaQueryExpValue& value
, MediaFeaturePrefix, const MediaValues& mediaValues) |
| 421 { | 418 { |
| 422 return deviceAspectRatioMediaFeatureEval(value, MaxPrefix, mediaValues); | 419 return deviceAspectRatioMediaFeatureEval(value, MaxPrefix, mediaValues); |
| 423 } | 420 } |
| 424 | 421 |
| 425 static bool minDevicePixelRatioMediaFeatureEval(const MediaQueryExpValue& value,
MediaFeaturePrefix, const MediaValues& mediaValues) | 422 static bool minDevicePixelRatioMediaFeatureEval(const MediaQueryExpValue& value,
MediaFeaturePrefix, const MediaValues& mediaValues) |
| 426 { | 423 { |
| 427 UseCounter::count(mediaValues.document(), UseCounter::PrefixedMinDevicePixel
RatioMediaFeature); | |
| 428 | |
| 429 return devicePixelRatioMediaFeatureEval(value, MinPrefix, mediaValues); | 424 return devicePixelRatioMediaFeatureEval(value, MinPrefix, mediaValues); |
| 430 } | 425 } |
| 431 | 426 |
| 432 static bool maxDevicePixelRatioMediaFeatureEval(const MediaQueryExpValue& value,
MediaFeaturePrefix, const MediaValues& mediaValues) | 427 static bool maxDevicePixelRatioMediaFeatureEval(const MediaQueryExpValue& value,
MediaFeaturePrefix, const MediaValues& mediaValues) |
| 433 { | 428 { |
| 434 UseCounter::count(mediaValues.document(), UseCounter::PrefixedMaxDevicePixel
RatioMediaFeature); | |
| 435 | |
| 436 return devicePixelRatioMediaFeatureEval(value, MaxPrefix, mediaValues); | 429 return devicePixelRatioMediaFeatureEval(value, MaxPrefix, mediaValues); |
| 437 } | 430 } |
| 438 | 431 |
| 439 static bool minHeightMediaFeatureEval(const MediaQueryExpValue& value, MediaFeat
urePrefix, const MediaValues& mediaValues) | 432 static bool minHeightMediaFeatureEval(const MediaQueryExpValue& value, MediaFeat
urePrefix, const MediaValues& mediaValues) |
| 440 { | 433 { |
| 441 return heightMediaFeatureEval(value, MinPrefix, mediaValues); | 434 return heightMediaFeatureEval(value, MinPrefix, mediaValues); |
| 442 } | 435 } |
| 443 | 436 |
| 444 static bool maxHeightMediaFeatureEval(const MediaQueryExpValue& value, MediaFeat
urePrefix, const MediaValues& mediaValues) | 437 static bool maxHeightMediaFeatureEval(const MediaQueryExpValue& value, MediaFeat
urePrefix, const MediaValues& mediaValues) |
| 445 { | 438 { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 return resolutionMediaFeatureEval(value, MinPrefix, mediaValues); | 474 return resolutionMediaFeatureEval(value, MinPrefix, mediaValues); |
| 482 } | 475 } |
| 483 | 476 |
| 484 static bool maxResolutionMediaFeatureEval(const MediaQueryExpValue& value, Media
FeaturePrefix, const MediaValues& mediaValues) | 477 static bool maxResolutionMediaFeatureEval(const MediaQueryExpValue& value, Media
FeaturePrefix, const MediaValues& mediaValues) |
| 485 { | 478 { |
| 486 return resolutionMediaFeatureEval(value, MaxPrefix, mediaValues); | 479 return resolutionMediaFeatureEval(value, MaxPrefix, mediaValues); |
| 487 } | 480 } |
| 488 | 481 |
| 489 static bool transform3dMediaFeatureEval(const MediaQueryExpValue& value, MediaFe
aturePrefix op, const MediaValues& mediaValues) | 482 static bool transform3dMediaFeatureEval(const MediaQueryExpValue& value, MediaFe
aturePrefix op, const MediaValues& mediaValues) |
| 490 { | 483 { |
| 491 UseCounter::count(mediaValues.document(), UseCounter::PrefixedTransform3dMed
iaFeature); | |
| 492 | |
| 493 bool returnValueIfNoParameter; | 484 bool returnValueIfNoParameter; |
| 494 int have3dRendering; | 485 int have3dRendering; |
| 495 | 486 |
| 496 bool threeDEnabled = mediaValues.threeDEnabled(); | 487 bool threeDEnabled = mediaValues.threeDEnabled(); |
| 497 | 488 |
| 498 returnValueIfNoParameter = threeDEnabled; | 489 returnValueIfNoParameter = threeDEnabled; |
| 499 have3dRendering = threeDEnabled ? 1 : 0; | 490 have3dRendering = threeDEnabled ? 1 : 0; |
| 500 | 491 |
| 501 if (value.isValid()) { | 492 if (value.isValid()) { |
| 502 float number; | 493 float number; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 // Call the media feature evaluation function. Assume no prefix and let | 629 // Call the media feature evaluation function. Assume no prefix and let |
| 639 // trampoline functions override the prefix if prefix is used. | 630 // trampoline functions override the prefix if prefix is used. |
| 640 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); | 631 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); |
| 641 if (func) | 632 if (func) |
| 642 return func(expr->expValue(), NoPrefix, *m_mediaValues); | 633 return func(expr->expValue(), NoPrefix, *m_mediaValues); |
| 643 | 634 |
| 644 return false; | 635 return false; |
| 645 } | 636 } |
| 646 | 637 |
| 647 } // namespace | 638 } // namespace |
| OLD | NEW |