| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "core/frame/FrameHost.h" | 46 #include "core/frame/FrameHost.h" |
| 47 #include "core/frame/FrameView.h" | 47 #include "core/frame/FrameView.h" |
| 48 #include "core/frame/LocalFrame.h" | 48 #include "core/frame/LocalFrame.h" |
| 49 #include "core/frame/Settings.h" | 49 #include "core/frame/Settings.h" |
| 50 #include "core/frame/UseCounter.h" | 50 #include "core/frame/UseCounter.h" |
| 51 #include "core/inspector/InspectorInstrumentation.h" | 51 #include "core/inspector/InspectorInstrumentation.h" |
| 52 #include "core/rendering/RenderView.h" | 52 #include "core/rendering/RenderView.h" |
| 53 #include "core/rendering/compositing/RenderLayerCompositor.h" | 53 #include "core/rendering/compositing/RenderLayerCompositor.h" |
| 54 #include "core/rendering/style/RenderStyle.h" | 54 #include "core/rendering/style/RenderStyle.h" |
| 55 #include "platform/PlatformScreen.h" | 55 #include "platform/PlatformScreen.h" |
| 56 #include "platform/RuntimeEnabledFeatures.h" |
| 56 #include "platform/geometry/FloatRect.h" | 57 #include "platform/geometry/FloatRect.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 }; |
| 64 | 65 |
| 65 typedef bool (*EvalFunc)(const MediaQueryExpValue&, MediaFeaturePrefix, const Me
diaValues&); | 66 typedef bool (*EvalFunc)(const MediaQueryExpValue&, MediaFeaturePrefix, const Me
diaValues&); |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 static bool hoverMediaFeatureEval(const MediaQueryExpValue& value, MediaFeatureP
refix, const MediaValues& mediaValues) | 530 static bool hoverMediaFeatureEval(const MediaQueryExpValue& value, MediaFeatureP
refix, const MediaValues& mediaValues) |
| 530 { | 531 { |
| 531 MediaValues::PointerDeviceType pointer = mediaValues.pointer(); | 532 MediaValues::PointerDeviceType pointer = mediaValues.pointer(); |
| 532 | 533 |
| 533 // If we're on a port that hasn't explicitly opted into providing pointer de
vice information | 534 // If we're on a port that hasn't explicitly opted into providing pointer de
vice information |
| 534 // (or otherwise can't be confident in the pointer hardware available), then
behave exactly | 535 // (or otherwise can't be confident in the pointer hardware available), then
behave exactly |
| 535 // as if this feature feature isn't supported. | 536 // as if this feature feature isn't supported. |
| 536 if (pointer == MediaValues::UnknownPointer) | 537 if (pointer == MediaValues::UnknownPointer) |
| 537 return false; | 538 return false; |
| 538 | 539 |
| 539 float number = 1; | 540 // FIXME: Remove the old code once we're sure this doesn't break anything si
gnificant. |
| 540 if (value.isValid()) { | 541 if (RuntimeEnabledFeatures::hoverMediaQueryKeywordsEnabled()) { |
| 541 if (!numberValue(value, number)) | 542 if (!value.isValid()) |
| 543 return pointer != MediaValues::NoPointer; |
| 544 |
| 545 if (!value.isID) |
| 542 return false; | 546 return false; |
| 547 |
| 548 return (pointer == MediaValues::NoPointer && value.id == CSSValueNone) |
| 549 || (pointer == MediaValues::TouchPointer && value.id == CSSValueOnDe
mand) |
| 550 || (pointer == MediaValues::MousePointer && value.id == CSSValueHove
r); |
| 551 } else { |
| 552 float number = 1; |
| 553 if (value.isValid()) { |
| 554 if (!numberValue(value, number)) |
| 555 return false; |
| 556 } |
| 557 |
| 558 return (pointer == MediaValues::NoPointer && !number) |
| 559 || (pointer == MediaValues::TouchPointer && !number) |
| 560 || (pointer == MediaValues::MousePointer && number == 1); |
| 543 } | 561 } |
| 544 | |
| 545 return (pointer == MediaValues::NoPointer && !number) | |
| 546 || (pointer == MediaValues::TouchPointer && !number) | |
| 547 || (pointer == MediaValues::MousePointer && number == 1); | |
| 548 } | 562 } |
| 549 | 563 |
| 550 static bool pointerMediaFeatureEval(const MediaQueryExpValue& value, MediaFeatur
ePrefix, const MediaValues& mediaValues) | 564 static bool pointerMediaFeatureEval(const MediaQueryExpValue& value, MediaFeatur
ePrefix, const MediaValues& mediaValues) |
| 551 { | 565 { |
| 552 MediaValues::PointerDeviceType pointer = mediaValues.pointer(); | 566 MediaValues::PointerDeviceType pointer = mediaValues.pointer(); |
| 553 | 567 |
| 554 // If we're on a port that hasn't explicitly opted into providing pointer de
vice information | 568 // If we're on a port that hasn't explicitly opted into providing pointer de
vice information |
| 555 // (or otherwise can't be confident in the pointer hardware available), then
behave exactly | 569 // (or otherwise can't be confident in the pointer hardware available), then
behave exactly |
| 556 // as if this feature feature isn't supported. | 570 // as if this feature feature isn't supported. |
| 557 if (pointer == MediaValues::UnknownPointer) | 571 if (pointer == MediaValues::UnknownPointer) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 // Call the media feature evaluation function. Assume no prefix and let | 621 // Call the media feature evaluation function. Assume no prefix and let |
| 608 // trampoline functions override the prefix if prefix is used. | 622 // trampoline functions override the prefix if prefix is used. |
| 609 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); | 623 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); |
| 610 if (func) | 624 if (func) |
| 611 return func(expr->expValue(), NoPrefix, *m_mediaValues); | 625 return func(expr->expValue(), NoPrefix, *m_mediaValues); |
| 612 | 626 |
| 613 return false; | 627 return false; |
| 614 } | 628 } |
| 615 | 629 |
| 616 } // namespace | 630 } // namespace |
| OLD | NEW |