| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 { | 229 { |
| 230 return view->layoutSize(ScrollableArea::IncludeScrollbars); | 230 return view->layoutSize(ScrollableArea::IncludeScrollbars); |
| 231 } | 231 } |
| 232 | 232 |
| 233 static bool orientationMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* fr
ame, MediaFeaturePrefix) | 233 static bool orientationMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* fr
ame, MediaFeaturePrefix) |
| 234 { | 234 { |
| 235 FrameView* view = frame->view(); | 235 FrameView* view = frame->view(); |
| 236 int width = viewportSize(view).width(); | 236 int width = viewportSize(view).width(); |
| 237 int height = viewportSize(view).height(); | 237 int height = viewportSize(view).height(); |
| 238 if (value && value->isPrimitiveValue()) { | 238 if (value && value->isPrimitiveValue()) { |
| 239 const int id = toCSSPrimitiveValue(value)->getIdent(); | 239 const CSSValueID id = toCSSPrimitiveValue(value)->getValueID(); |
| 240 if (width > height) // Square viewport is portrait. | 240 if (width > height) // Square viewport is portrait. |
| 241 return CSSValueLandscape == id; | 241 return CSSValueLandscape == id; |
| 242 return CSSValuePortrait == id; | 242 return CSSValuePortrait == id; |
| 243 } | 243 } |
| 244 | 244 |
| 245 // Expression (orientation) evaluates to true if width and height >= 0. | 245 // Expression (orientation) evaluates to true if width and height >= 0. |
| 246 return height >= 0 && width >= 0; | 246 return height >= 0 && width >= 0; |
| 247 } | 247 } |
| 248 | 248 |
| 249 static bool aspectRatioMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* fr
ame, MediaFeaturePrefix op) | 249 static bool aspectRatioMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* fr
ame, MediaFeaturePrefix op) |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 } | 578 } |
| 579 return returnValueIfNoParameter; | 579 return returnValueIfNoParameter; |
| 580 } | 580 } |
| 581 | 581 |
| 582 static bool viewModeMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame
, MediaFeaturePrefix op) | 582 static bool viewModeMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame
, MediaFeaturePrefix op) |
| 583 { | 583 { |
| 584 UNUSED_PARAM(op); | 584 UNUSED_PARAM(op); |
| 585 if (!value) | 585 if (!value) |
| 586 return true; | 586 return true; |
| 587 | 587 |
| 588 return toCSSPrimitiveValue(value)->getIdent() == CSSValueWindowed; | 588 return toCSSPrimitiveValue(value)->getValueID() == CSSValueWindowed; |
| 589 } | 589 } |
| 590 | 590 |
| 591 enum PointerDeviceType { TouchPointer, MousePointer, NoPointer, UnknownPointer }
; | 591 enum PointerDeviceType { TouchPointer, MousePointer, NoPointer, UnknownPointer }
; |
| 592 | 592 |
| 593 static PointerDeviceType leastCapablePrimaryPointerDeviceType(Frame* frame) | 593 static PointerDeviceType leastCapablePrimaryPointerDeviceType(Frame* frame) |
| 594 { | 594 { |
| 595 if (frame->settings()->deviceSupportsTouch()) | 595 if (frame->settings()->deviceSupportsTouch()) |
| 596 return TouchPointer; | 596 return TouchPointer; |
| 597 | 597 |
| 598 // FIXME: We should also try to determine if we know we have a mouse. | 598 // FIXME: We should also try to determine if we know we have a mouse. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 // as if this feature feature isn't supported. | 635 // as if this feature feature isn't supported. |
| 636 if (pointer == UnknownPointer) | 636 if (pointer == UnknownPointer) |
| 637 return false; | 637 return false; |
| 638 | 638 |
| 639 if (!value) | 639 if (!value) |
| 640 return pointer != NoPointer; | 640 return pointer != NoPointer; |
| 641 | 641 |
| 642 if (!value->isPrimitiveValue()) | 642 if (!value->isPrimitiveValue()) |
| 643 return false; | 643 return false; |
| 644 | 644 |
| 645 const int id = toCSSPrimitiveValue(value)->getIdent(); | 645 const CSSValueID id = toCSSPrimitiveValue(value)->getValueID(); |
| 646 return (pointer == NoPointer && id == CSSValueNone) | 646 return (pointer == NoPointer && id == CSSValueNone) |
| 647 || (pointer == TouchPointer && id == CSSValueCoarse) | 647 || (pointer == TouchPointer && id == CSSValueCoarse) |
| 648 || (pointer == MousePointer && id == CSSValueFine); | 648 || (pointer == MousePointer && id == CSSValueFine); |
| 649 } | 649 } |
| 650 | 650 |
| 651 static bool scanMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, Me
diaFeaturePrefix) | 651 static bool scanMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, Me
diaFeaturePrefix) |
| 652 { | 652 { |
| 653 // Scan only applies to tv media. | 653 // Scan only applies to tv media. |
| 654 if (!equalIgnoringCase(frame->view()->mediaType(), "tv")) | 654 if (!equalIgnoringCase(frame->view()->mediaType(), "tv")) |
| 655 return false; | 655 return false; |
| 656 | 656 |
| 657 if (!value) | 657 if (!value) |
| 658 return true; | 658 return true; |
| 659 | 659 |
| 660 if (!value->isPrimitiveValue()) | 660 if (!value->isPrimitiveValue()) |
| 661 return false; | 661 return false; |
| 662 | 662 |
| 663 // If a platform interface supplies progressive/interlace info for TVs in th
e | 663 // If a platform interface supplies progressive/interlace info for TVs in th
e |
| 664 // future, it needs to be handled here. For now, assume a modern TV with | 664 // future, it needs to be handled here. For now, assume a modern TV with |
| 665 // progressive display. | 665 // progressive display. |
| 666 const int id = toCSSPrimitiveValue(value)->getIdent(); | 666 return toCSSPrimitiveValue(value)->getValueID() == CSSValueProgressive; |
| 667 return id == CSSValueProgressive; | |
| 668 } | 667 } |
| 669 | 668 |
| 670 static void createFunctionMap() | 669 static void createFunctionMap() |
| 671 { | 670 { |
| 672 // Create the table. | 671 // Create the table. |
| 673 gFunctionMap = new FunctionMap; | 672 gFunctionMap = new FunctionMap; |
| 674 #define ADD_TO_FUNCTIONMAP(name, str) \ | 673 #define ADD_TO_FUNCTIONMAP(name, str) \ |
| 675 gFunctionMap->set(name##MediaFeature.impl(), name##MediaFeatureEval); | 674 gFunctionMap->set(name##MediaFeature.impl(), name##MediaFeatureEval); |
| 676 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP); | 675 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP); |
| 677 #undef ADD_TO_FUNCTIONMAP | 676 #undef ADD_TO_FUNCTIONMAP |
| (...skipping 14 matching lines...) Expand all Loading... |
| 692 // and let trampoline functions override the prefix if prefix is | 691 // and let trampoline functions override the prefix if prefix is |
| 693 // used | 692 // used |
| 694 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); | 693 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); |
| 695 if (func) | 694 if (func) |
| 696 return func(expr->value(), m_style.get(), m_frame, NoPrefix); | 695 return func(expr->value(), m_style.get(), m_frame, NoPrefix); |
| 697 | 696 |
| 698 return false; | 697 return false; |
| 699 } | 698 } |
| 700 | 699 |
| 701 } // namespace | 700 } // namespace |
| OLD | NEW |