| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
| 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
| 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
| 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
| 10 * | 10 * |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 #include "WebKitCSSSVGDocumentValue.h" | 103 #include "WebKitCSSSVGDocumentValue.h" |
| 104 #endif | 104 #endif |
| 105 #endif | 105 #endif |
| 106 | 106 |
| 107 #if ENABLE(CSS_SHADERS) | 107 #if ENABLE(CSS_SHADERS) |
| 108 #include "WebKitCSSArrayFunctionValue.h" | 108 #include "WebKitCSSArrayFunctionValue.h" |
| 109 #include "WebKitCSSMixFunctionValue.h" | 109 #include "WebKitCSSMixFunctionValue.h" |
| 110 #include "WebKitCSSShaderValue.h" | 110 #include "WebKitCSSShaderValue.h" |
| 111 #endif | 111 #endif |
| 112 | 112 |
| 113 #if ENABLE(DASHBOARD_SUPPORT) | |
| 114 #include "DashboardRegion.h" | |
| 115 #endif | |
| 116 | |
| 117 #define YYDEBUG 0 | 113 #define YYDEBUG 0 |
| 118 | 114 |
| 119 #if YYDEBUG > 0 | 115 #if YYDEBUG > 0 |
| 120 extern int cssyydebug; | 116 extern int cssyydebug; |
| 121 #endif | 117 #endif |
| 122 | 118 |
| 123 extern int cssyyparse(WebCore::CSSParser*); | 119 extern int cssyyparse(WebCore::CSSParser*); |
| 124 | 120 |
| 125 using namespace std; | 121 using namespace std; |
| 126 using namespace WTF; | 122 using namespace WTF; |
| (...skipping 2629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2756 addProperty(propId, cssValuePool().createValue(lineGridValue, CS
SPrimitiveValue::CSS_STRING), important); | 2752 addProperty(propId, cssValuePool().createValue(lineGridValue, CS
SPrimitiveValue::CSS_STRING), important); |
| 2757 return true; | 2753 return true; |
| 2758 } | 2754 } |
| 2759 } | 2755 } |
| 2760 break; | 2756 break; |
| 2761 case CSSPropertyWebkitLocale: | 2757 case CSSPropertyWebkitLocale: |
| 2762 if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_STRING) | 2758 if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_STRING) |
| 2763 validPrimitive = true; | 2759 validPrimitive = true; |
| 2764 break; | 2760 break; |
| 2765 | 2761 |
| 2766 #if ENABLE(DASHBOARD_SUPPORT) | |
| 2767 case CSSPropertyWebkitDashboardRegion: // <dashboard-region> | <dashboard-re
gion> | |
| 2768 if (value->unit == CSSParserValue::Function || id == CSSValueNone) | |
| 2769 return parseDashboardRegions(propId, important); | |
| 2770 break; | |
| 2771 #endif | |
| 2772 // End Apple-specific properties | 2762 // End Apple-specific properties |
| 2773 | 2763 |
| 2774 #if ENABLE(DRAGGABLE_REGION) | 2764 #if ENABLE(DRAGGABLE_REGION) |
| 2775 case CSSPropertyWebkitAppRegion: | 2765 case CSSPropertyWebkitAppRegion: |
| 2776 if (id >= CSSValueDrag && id <= CSSValueNoDrag) | 2766 if (id >= CSSValueDrag && id <= CSSValueNoDrag) |
| 2777 validPrimitive = true; | 2767 validPrimitive = true; |
| 2778 break; | 2768 break; |
| 2779 #endif | 2769 #endif |
| 2780 | 2770 |
| 2781 #if ENABLE(TOUCH_EVENTS) | 2771 #if ENABLE(TOUCH_EVENTS) |
| (...skipping 2025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4807 { | 4797 { |
| 4808 if (currentValue->id == CSSValueWebkitMinContent || currentValue->id == CSSV
alueWebkitMaxContent) | 4798 if (currentValue->id == CSSValueWebkitMinContent || currentValue->id == CSSV
alueWebkitMaxContent) |
| 4809 return cssValuePool().createIdentifierValue(currentValue->id); | 4799 return cssValuePool().createIdentifierValue(currentValue->id); |
| 4810 | 4800 |
| 4811 if (!validUnit(currentValue, FLength | FPercent)) | 4801 if (!validUnit(currentValue, FLength | FPercent)) |
| 4812 return 0; | 4802 return 0; |
| 4813 | 4803 |
| 4814 return createPrimitiveNumericValue(currentValue); | 4804 return createPrimitiveNumericValue(currentValue); |
| 4815 } | 4805 } |
| 4816 | 4806 |
| 4817 #if ENABLE(DASHBOARD_SUPPORT) | |
| 4818 | |
| 4819 #define DASHBOARD_REGION_NUM_PARAMETERS 6 | |
| 4820 #define DASHBOARD_REGION_SHORT_NUM_PARAMETERS 2 | |
| 4821 | |
| 4822 static CSSParserValue* skipCommaInDashboardRegion(CSSParserValueList *args) | |
| 4823 { | |
| 4824 if (args->size() == (DASHBOARD_REGION_NUM_PARAMETERS*2-1) || | |
| 4825 args->size() == (DASHBOARD_REGION_SHORT_NUM_PARAMETERS*2-1)) { | |
| 4826 CSSParserValue* current = args->current(); | |
| 4827 if (current->unit == CSSParserValue::Operator && current->iValue == ',') | |
| 4828 return args->next(); | |
| 4829 } | |
| 4830 return args->current(); | |
| 4831 } | |
| 4832 | |
| 4833 bool CSSParser::parseDashboardRegions(CSSPropertyID propId, bool important) | |
| 4834 { | |
| 4835 bool valid = true; | |
| 4836 | |
| 4837 CSSParserValue* value = m_valueList->current(); | |
| 4838 | |
| 4839 if (value->id == CSSValueNone) { | |
| 4840 if (m_valueList->next()) | |
| 4841 return false; | |
| 4842 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp
ortant); | |
| 4843 return valid; | |
| 4844 } | |
| 4845 | |
| 4846 RefPtr<DashboardRegion> firstRegion = DashboardRegion::create(); | |
| 4847 DashboardRegion* region = 0; | |
| 4848 | |
| 4849 while (value) { | |
| 4850 if (region == 0) { | |
| 4851 region = firstRegion.get(); | |
| 4852 } else { | |
| 4853 RefPtr<DashboardRegion> nextRegion = DashboardRegion::create(); | |
| 4854 region->m_next = nextRegion; | |
| 4855 region = nextRegion.get(); | |
| 4856 } | |
| 4857 | |
| 4858 if (value->unit != CSSParserValue::Function) { | |
| 4859 valid = false; | |
| 4860 break; | |
| 4861 } | |
| 4862 | |
| 4863 // Commas count as values, so allow (function name is dashboard-region f
or DASHBOARD_SUPPORT feature): | |
| 4864 // dashboard-region(label, type, t, r, b, l) or dashboard-region(label t
ype t r b l) | |
| 4865 // dashboard-region(label, type, t, r, b, l) or dashboard-region(label t
ype t r b l) | |
| 4866 // also allow | |
| 4867 // dashboard-region(label, type) or dashboard-region(label type) | |
| 4868 // dashboard-region(label, type) or dashboard-region(label type) | |
| 4869 CSSParserValueList* args = value->function->args.get(); | |
| 4870 if (!equalIgnoringCase(value->function->name, "dashboard-region(") || !a
rgs) { | |
| 4871 valid = false; | |
| 4872 break; | |
| 4873 } | |
| 4874 | |
| 4875 int numArgs = args->size(); | |
| 4876 if ((numArgs != DASHBOARD_REGION_NUM_PARAMETERS && numArgs != (DASHBOARD
_REGION_NUM_PARAMETERS*2-1)) && | |
| 4877 (numArgs != DASHBOARD_REGION_SHORT_NUM_PARAMETERS && numArgs != (DAS
HBOARD_REGION_SHORT_NUM_PARAMETERS*2-1))) { | |
| 4878 valid = false; | |
| 4879 break; | |
| 4880 } | |
| 4881 | |
| 4882 // First arg is a label. | |
| 4883 CSSParserValue* arg = args->current(); | |
| 4884 if (arg->unit != CSSPrimitiveValue::CSS_IDENT) { | |
| 4885 valid = false; | |
| 4886 break; | |
| 4887 } | |
| 4888 | |
| 4889 region->m_label = arg->string; | |
| 4890 | |
| 4891 // Second arg is a type. | |
| 4892 arg = args->next(); | |
| 4893 arg = skipCommaInDashboardRegion(args); | |
| 4894 if (arg->unit != CSSPrimitiveValue::CSS_IDENT) { | |
| 4895 valid = false; | |
| 4896 break; | |
| 4897 } | |
| 4898 | |
| 4899 if (equalIgnoringCase(arg, "circle")) | |
| 4900 region->m_isCircle = true; | |
| 4901 else if (equalIgnoringCase(arg, "rectangle")) | |
| 4902 region->m_isRectangle = true; | |
| 4903 else { | |
| 4904 valid = false; | |
| 4905 break; | |
| 4906 } | |
| 4907 | |
| 4908 region->m_geometryType = arg->string; | |
| 4909 | |
| 4910 if (numArgs == DASHBOARD_REGION_SHORT_NUM_PARAMETERS || numArgs == (DASH
BOARD_REGION_SHORT_NUM_PARAMETERS*2-1)) { | |
| 4911 // This originally used CSSValueInvalid by accident. It might be mor
e logical to use something else. | |
| 4912 RefPtr<CSSPrimitiveValue> amount = cssValuePool().createIdentifierVa
lue(CSSValueInvalid); | |
| 4913 | |
| 4914 region->setTop(amount); | |
| 4915 region->setRight(amount); | |
| 4916 region->setBottom(amount); | |
| 4917 region->setLeft(amount); | |
| 4918 } else { | |
| 4919 // Next four arguments must be offset numbers | |
| 4920 int i; | |
| 4921 for (i = 0; i < 4; i++) { | |
| 4922 arg = args->next(); | |
| 4923 arg = skipCommaInDashboardRegion(args); | |
| 4924 | |
| 4925 valid = arg->id == CSSValueAuto || validUnit(arg, FLength); | |
| 4926 if (!valid) | |
| 4927 break; | |
| 4928 | |
| 4929 RefPtr<CSSPrimitiveValue> amount = arg->id == CSSValueAuto ? | |
| 4930 cssValuePool().createIdentifierValue(CSSValueAuto) : | |
| 4931 createPrimitiveNumericValue(arg); | |
| 4932 | |
| 4933 if (i == 0) | |
| 4934 region->setTop(amount); | |
| 4935 else if (i == 1) | |
| 4936 region->setRight(amount); | |
| 4937 else if (i == 2) | |
| 4938 region->setBottom(amount); | |
| 4939 else | |
| 4940 region->setLeft(amount); | |
| 4941 } | |
| 4942 } | |
| 4943 | |
| 4944 if (args->next()) | |
| 4945 return false; | |
| 4946 | |
| 4947 value = m_valueList->next(); | |
| 4948 } | |
| 4949 | |
| 4950 if (valid) | |
| 4951 addProperty(propId, cssValuePool().createValue(firstRegion.release()), i
mportant); | |
| 4952 | |
| 4953 return valid; | |
| 4954 } | |
| 4955 | |
| 4956 #endif /* ENABLE(DASHBOARD_SUPPORT) */ | |
| 4957 | |
| 4958 PassRefPtr<CSSValue> CSSParser::parseCounterContent(CSSParserValueList* args, bo
ol counters) | 4807 PassRefPtr<CSSValue> CSSParser::parseCounterContent(CSSParserValueList* args, bo
ol counters) |
| 4959 { | 4808 { |
| 4960 unsigned numArgs = args->size(); | 4809 unsigned numArgs = args->size(); |
| 4961 if (counters && numArgs != 3 && numArgs != 5) | 4810 if (counters && numArgs != 3 && numArgs != 5) |
| 4962 return 0; | 4811 return 0; |
| 4963 if (!counters && numArgs != 1 && numArgs != 3) | 4812 if (!counters && numArgs != 1 && numArgs != 3) |
| 4964 return 0; | 4813 return 0; |
| 4965 | 4814 |
| 4966 CSSParserValue* i = args->current(); | 4815 CSSParserValue* i = args->current(); |
| 4967 if (i->unit != CSSPrimitiveValue::CSS_IDENT) | 4816 if (i->unit != CSSPrimitiveValue::CSS_IDENT) |
| (...skipping 7226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12194 { | 12043 { |
| 12195 // The tokenizer checks for the construct of an+b. | 12044 // The tokenizer checks for the construct of an+b. |
| 12196 // However, since the {ident} rule precedes the {nth} rule, some of those | 12045 // However, since the {ident} rule precedes the {nth} rule, some of those |
| 12197 // tokens are identified as string literal. Furthermore we need to accept | 12046 // tokens are identified as string literal. Furthermore we need to accept |
| 12198 // "odd" and "even" which does not match to an+b. | 12047 // "odd" and "even" which does not match to an+b. |
| 12199 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 12048 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
| 12200 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 12049 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
| 12201 } | 12050 } |
| 12202 | 12051 |
| 12203 } | 12052 } |
| OLD | NEW |