Chromium Code Reviews| 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 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1488 // Properties below are validated inside parseViewportProperty, because we | 1488 // Properties below are validated inside parseViewportProperty, because we |
| 1489 // check for parser state. We need to invalidate if someone adds them outsid e | 1489 // check for parser state. We need to invalidate if someone adds them outsid e |
| 1490 // a @viewport rule. | 1490 // a @viewport rule. |
| 1491 case CSSPropertyMaxZoom: | 1491 case CSSPropertyMaxZoom: |
| 1492 case CSSPropertyMinZoom: | 1492 case CSSPropertyMinZoom: |
| 1493 case CSSPropertyOrientation: | 1493 case CSSPropertyOrientation: |
| 1494 case CSSPropertyUserZoom: | 1494 case CSSPropertyUserZoom: |
| 1495 validPrimitive = false; | 1495 validPrimitive = false; |
| 1496 break; | 1496 break; |
| 1497 | 1497 |
| 1498 case CSSPropertyScrollSnapPointsX: | |
| 1499 case CSSPropertyScrollSnapPointsY: | |
| 1500 parsedValue = parseScrollSnapPoints(); | |
| 1501 break; | |
| 1502 case CSSPropertyScrollSnapCoordinate: | |
| 1503 parsedValue = parseScrollSnapCoordinate(); | |
| 1504 break; | |
| 1505 case CSSPropertyScrollSnapDestination: | |
| 1506 parsedValue = parseScrollSnapDestination(); | |
| 1507 break; | |
| 1508 | |
| 1498 default: | 1509 default: |
| 1499 return parseSVGValue(propId, important); | 1510 return parseSVGValue(propId, important); |
| 1500 } | 1511 } |
| 1501 | 1512 |
| 1502 if (validPrimitive) { | 1513 if (validPrimitive) { |
| 1503 parsedValue = parseValidPrimitive(id, value); | 1514 parsedValue = parseValidPrimitive(id, value); |
| 1504 m_valueList->next(); | 1515 m_valueList->next(); |
| 1505 } | 1516 } |
| 1506 ASSERT(!m_parsedCalculation); | 1517 ASSERT(!m_parsedCalculation); |
| 1507 if (parsedValue) { | 1518 if (parsedValue) { |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2001 break; | 2012 break; |
| 2002 } | 2013 } |
| 2003 default: { | 2014 default: { |
| 2004 return false; | 2015 return false; |
| 2005 } | 2016 } |
| 2006 } | 2017 } |
| 2007 | 2018 |
| 2008 return true; | 2019 return true; |
| 2009 } | 2020 } |
| 2010 | 2021 |
| 2022 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapPoints() | |
| 2023 { | |
| 2024 CSSParserValue* value = m_valueList->current(); | |
| 2025 | |
| 2026 if (value->id == CSSValueNone) { | |
| 2027 m_valueList->next(); | |
| 2028 return cssValuePool().createIdentifierValue(CSSValueNone); | |
| 2029 } | |
| 2030 | |
| 2031 if (value->unit == CSSParserValue::Function && value->function->id == CSSVal ueRepeat) { | |
| 2032 // The spec defines the following grammar: repeat( <length>) | |
| 2033 CSSParserValueList* arguments = value->function->args.get(); | |
| 2034 if (!arguments || arguments->size() != 1) | |
| 2035 return nullptr; | |
| 2036 | |
| 2037 CSSParserValue* repeatValue = arguments->valueAt(0); | |
| 2038 if (!validUnit(repeatValue, FNonNeg | FLength | FPercent)) | |
| 2039 return nullptr; | |
| 2040 | |
| 2041 RefPtrWillBeRawPtr<CSSFunctionValue> result = CSSFunctionValue::create(C SSValueRepeat); | |
| 2042 result->append(createPrimitiveNumericValue(repeatValue)); | |
| 2043 m_valueList->next(); | |
| 2044 return result.release(); | |
| 2045 } | |
| 2046 | |
| 2047 return nullptr; | |
| 2048 } | |
| 2049 | |
| 2050 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapDestination() | |
| 2051 { | |
| 2052 return parseScrollSnapPosition(); | |
| 2053 } | |
| 2054 | |
| 2055 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate() | |
| 2056 { | |
| 2057 if (m_valueList->current()->id == CSSValueNone) { | |
| 2058 m_valueList->next(); | |
| 2059 return cssValuePool().createIdentifierValue(CSSValueNone); | |
| 2060 } | |
| 2061 | |
| 2062 RefPtrWillBeRawPtr<CSSValueList> positions = CSSValueList::createSpaceSepara ted(); | |
| 2063 // TODO(majidvp): parse comma separated position lists correctly | |
|
Timothy Loh
2015/05/28 07:09:26
Can we just do this properly in this patch? Should
majidvp
2015/06/01 20:06:37
Done. I added a parsePositionList which can be use
| |
| 2064 while (m_valueList->current()) { | |
| 2065 // parseScrollSnapPosition advances the value list | |
| 2066 RefPtrWillBeRawPtr<CSSValue> position = parseScrollSnapPosition(); | |
| 2067 if (!position) | |
| 2068 return nullptr; | |
| 2069 | |
| 2070 positions->append(position); | |
| 2071 } | |
| 2072 | |
| 2073 if (positions->length()) { | |
|
Timothy Loh
2015/05/28 07:09:27
Pretty sure this is unnecessary
majidvp
2015/06/01 20:06:37
Done.
| |
| 2074 return positions.release(); | |
| 2075 } | |
| 2076 return nullptr; | |
| 2077 } | |
| 2078 | |
| 2079 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapPosition() | |
| 2080 { | |
| 2081 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; | |
| 2082 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; | |
| 2083 parseFillPosition(m_valueList, xValue, yValue); | |
| 2084 if (!xValue || !yValue) | |
| 2085 return nullptr; | |
| 2086 | |
| 2087 return createPrimitiveValuePair(toCSSPrimitiveValue(xValue.get()), toCSSPrim itiveValue(yValue.get()), Pair::KeepIdenticalValues); | |
| 2088 } | |
| 2089 | |
| 2090 // auto | <identifier> | |
|
Timothy Loh
2015/05/28 07:09:27
I wouldn't bother with these sorts of comments (es
majidvp
2015/06/01 20:06:37
Done.
| |
| 2011 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parsePage() | 2091 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parsePage() |
| 2012 { | 2092 { |
| 2013 CSSParserValue* value = m_valueList->current(); | 2093 CSSParserValue* value = m_valueList->current(); |
| 2014 m_valueList->next(); | 2094 m_valueList->next(); |
| 2015 ASSERT(value); | 2095 ASSERT(value); |
| 2016 | 2096 |
| 2017 if (value->id == CSSValueAuto) | 2097 if (value->id == CSSValueAuto) |
| 2018 return cssValuePool().createIdentifierValue(value->id); | 2098 return cssValuePool().createIdentifierValue(value->id); |
| 2019 if (value->unit == CSSPrimitiveValue::CSS_IDENT) | 2099 if (value->unit == CSSPrimitiveValue::CSS_IDENT) |
| 2020 return createPrimitiveCustomIdentValue(value); | 2100 return createPrimitiveCustomIdentValue(value); |
| (...skipping 5127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7148 RefPtrWillBeRawPtr<CSSFunctionValue> filterValue = parseBuiltinFilte rArguments(args, filterType); | 7228 RefPtrWillBeRawPtr<CSSFunctionValue> filterValue = parseBuiltinFilte rArguments(args, filterType); |
| 7149 if (!filterValue) | 7229 if (!filterValue) |
| 7150 return nullptr; | 7230 return nullptr; |
| 7151 | 7231 |
| 7152 list->append(filterValue); | 7232 list->append(filterValue); |
| 7153 } | 7233 } |
| 7154 } | 7234 } |
| 7155 | 7235 |
| 7156 return list.release(); | 7236 return list.release(); |
| 7157 } | 7237 } |
| 7238 | |
| 7158 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransformOrigin() | 7239 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransformOrigin() |
| 7159 { | 7240 { |
| 7160 CSSParserValue* value = m_valueList->current(); | 7241 CSSParserValue* value = m_valueList->current(); |
| 7161 CSSValueID id = value->id; | 7242 CSSValueID id = value->id; |
| 7162 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; | 7243 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; |
| 7163 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; | 7244 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; |
| 7164 RefPtrWillBeRawPtr<CSSValue> zValue = nullptr; | 7245 RefPtrWillBeRawPtr<CSSValue> zValue = nullptr; |
| 7165 if (id == CSSValueLeft || id == CSSValueRight) { | 7246 if (id == CSSValueLeft || id == CSSValueRight) { |
| 7166 xValue = cssValuePool().createIdentifierValue(id); | 7247 xValue = cssValuePool().createIdentifierValue(id); |
| 7167 } else if (id == CSSValueTop || id == CSSValueBottom) { | 7248 } else if (id == CSSValueTop || id == CSSValueBottom) { |
| (...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8400 } | 8481 } |
| 8401 } | 8482 } |
| 8402 | 8483 |
| 8403 if (!list->length()) | 8484 if (!list->length()) |
| 8404 return nullptr; | 8485 return nullptr; |
| 8405 | 8486 |
| 8406 return list.release(); | 8487 return list.release(); |
| 8407 } | 8488 } |
| 8408 | 8489 |
| 8409 } // namespace blink | 8490 } // namespace blink |
| OLD | NEW |