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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 addProperty(propId, parsedValue.release(), important); | 424 addProperty(propId, parsedValue.release(), important); |
425 return true; | 425 return true; |
426 } | 426 } |
427 if (parseShorthand(propId, important)) | 427 if (parseShorthand(propId, important)) |
428 return true; | 428 return true; |
429 | 429 |
430 bool validPrimitive = false; | 430 bool validPrimitive = false; |
431 Units unitless = FUnknown; | 431 Units unitless = FUnknown; |
432 | 432 |
433 switch (propId) { | 433 switch (propId) { |
434 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait
| landscape] ] | |
435 parsedValue = parseSize(); | |
436 break; | |
437 | |
438 case CSSPropertyContent: // [ <string> | <uri> | <counter> | at
tr(X) | open-quote | | 434 case CSSPropertyContent: // [ <string> | <uri> | <counter> | at
tr(X) | open-quote | |
439 // close-quote | no-open-quote | no-close-quote ]+ | inherit | 435 // close-quote | no-open-quote | no-close-quote ]+ | inherit |
440 parsedValue = parseContent(); | 436 parsedValue = parseContent(); |
441 break; | 437 break; |
442 case CSSPropertyClip: // <shape> | auto | inherit | 438 case CSSPropertyClip: // <shape> | auto | inherit |
443 if (id == CSSValueAuto) | 439 if (id == CSSValueAuto) |
444 validPrimitive = true; | 440 validPrimitive = true; |
445 else if (value->m_unit == CSSParserValue::Function) | 441 else if (value->m_unit == CSSParserValue::Function) |
446 parsedValue = parseClipShape(); | 442 parsedValue = parseClipShape(); |
447 break; | 443 break; |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1350 case CSSPropertyTabSize: | 1346 case CSSPropertyTabSize: |
1351 case CSSPropertyFontSize: | 1347 case CSSPropertyFontSize: |
1352 case CSSPropertyLineHeight: | 1348 case CSSPropertyLineHeight: |
1353 case CSSPropertyRotate: | 1349 case CSSPropertyRotate: |
1354 case CSSPropertyFont: | 1350 case CSSPropertyFont: |
1355 case CSSPropertyWebkitBorderHorizontalSpacing: | 1351 case CSSPropertyWebkitBorderHorizontalSpacing: |
1356 case CSSPropertyWebkitBorderVerticalSpacing: | 1352 case CSSPropertyWebkitBorderVerticalSpacing: |
1357 case CSSPropertyBorderSpacing: | 1353 case CSSPropertyBorderSpacing: |
1358 case CSSPropertyCounterIncrement: | 1354 case CSSPropertyCounterIncrement: |
1359 case CSSPropertyCounterReset: | 1355 case CSSPropertyCounterReset: |
| 1356 case CSSPropertySize: |
1360 validPrimitive = false; | 1357 validPrimitive = false; |
1361 break; | 1358 break; |
1362 | 1359 |
1363 case CSSPropertyScrollSnapPointsX: | 1360 case CSSPropertyScrollSnapPointsX: |
1364 case CSSPropertyScrollSnapPointsY: | 1361 case CSSPropertyScrollSnapPointsY: |
1365 parsedValue = parseScrollSnapPoints(); | 1362 parsedValue = parseScrollSnapPoints(); |
1366 break; | 1363 break; |
1367 case CSSPropertyScrollSnapCoordinate: | 1364 case CSSPropertyScrollSnapCoordinate: |
1368 parsedValue = parseScrollSnapCoordinate(); | 1365 parsedValue = parseScrollSnapCoordinate(); |
1369 break; | 1366 break; |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1893 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate() | 1890 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate() |
1894 { | 1891 { |
1895 if (m_valueList->current()->id == CSSValueNone) { | 1892 if (m_valueList->current()->id == CSSValueNone) { |
1896 m_valueList->next(); | 1893 m_valueList->next(); |
1897 return cssValuePool().createIdentifierValue(CSSValueNone); | 1894 return cssValuePool().createIdentifierValue(CSSValueNone); |
1898 } | 1895 } |
1899 | 1896 |
1900 return parsePositionList(m_valueList); | 1897 return parsePositionList(m_valueList); |
1901 } | 1898 } |
1902 | 1899 |
1903 // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ] | |
1904 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseSize() | |
1905 { | |
1906 CSSParserValue* value = m_valueList->current(); | |
1907 ASSERT(value); | |
1908 | |
1909 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep
arated(); | |
1910 | |
1911 // First parameter. | |
1912 SizeParameterType paramType = parseSizeParameter(parsedValues.get(), value,
None); | |
1913 if (paramType == None) | |
1914 return nullptr; | |
1915 value = m_valueList->next(); | |
1916 | |
1917 // Second parameter, if any. | |
1918 if (value) { | |
1919 paramType = parseSizeParameter(parsedValues.get(), value, paramType); | |
1920 if (paramType == None) | |
1921 return nullptr; | |
1922 m_valueList->next(); | |
1923 } | |
1924 | |
1925 return parsedValues.release(); | |
1926 } | |
1927 | |
1928 CSSPropertyParser::SizeParameterType CSSPropertyParser::parseSizeParameter(CSSVa
lueList* parsedValues, CSSParserValue* value, SizeParameterType prevParamType) | |
1929 { | |
1930 switch (value->id) { | |
1931 case CSSValueAuto: | |
1932 if (prevParamType == None) { | |
1933 parsedValues->append(cssValuePool().createIdentifierValue(value->id)
); | |
1934 return Auto; | |
1935 } | |
1936 return None; | |
1937 case CSSValueLandscape: | |
1938 case CSSValuePortrait: | |
1939 if (prevParamType == None || prevParamType == PageSize) { | |
1940 parsedValues->append(cssValuePool().createIdentifierValue(value->id)
); | |
1941 return Orientation; | |
1942 } | |
1943 return None; | |
1944 case CSSValueA3: | |
1945 case CSSValueA4: | |
1946 case CSSValueA5: | |
1947 case CSSValueB4: | |
1948 case CSSValueB5: | |
1949 case CSSValueLedger: | |
1950 case CSSValueLegal: | |
1951 case CSSValueLetter: | |
1952 if (prevParamType == None || prevParamType == Orientation) { | |
1953 // Normalize to Page Size then Orientation order by prepending for s
impler StyleBuilder handling | |
1954 parsedValues->prepend(cssValuePool().createIdentifierValue(value->id
)); | |
1955 return PageSize; | |
1956 } | |
1957 return None; | |
1958 case 0: | |
1959 if (validUnit(value, FLength | FNonNeg) && (prevParamType == None || pre
vParamType == Length)) { | |
1960 parsedValues->append(createPrimitiveNumericValue(value)); | |
1961 return Length; | |
1962 } | |
1963 return None; | |
1964 default: | |
1965 return None; | |
1966 } | |
1967 } | |
1968 | |
1969 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open
-quote | no-close-quote ]+ | inherit | 1900 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open
-quote | no-close-quote ]+ | inherit |
1970 // in CSS 2.1 this got somewhat reduced: | 1901 // in CSS 2.1 this got somewhat reduced: |
1971 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit | 1902 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit |
1972 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent() | 1903 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent() |
1973 { | 1904 { |
1974 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); | 1905 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); |
1975 | 1906 |
1976 while (CSSParserValue* val = m_valueList->current()) { | 1907 while (CSSParserValue* val = m_valueList->current()) { |
1977 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 1908 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
1978 if (val->m_unit == CSSParserValue::URI) { | 1909 if (val->m_unit == CSSParserValue::URI) { |
(...skipping 5081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7060 } | 6991 } |
7061 } | 6992 } |
7062 | 6993 |
7063 if (!list->length()) | 6994 if (!list->length()) |
7064 return nullptr; | 6995 return nullptr; |
7065 | 6996 |
7066 return list.release(); | 6997 return list.release(); |
7067 } | 6998 } |
7068 | 6999 |
7069 } // namespace blink | 7000 } // namespace blink |
OLD | NEW |