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 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 case CSSPropertyLetterSpacing: | 1357 case CSSPropertyLetterSpacing: |
1362 case CSSPropertyWordSpacing: | 1358 case CSSPropertyWordSpacing: |
1363 case CSSPropertyTabSize: | 1359 case CSSPropertyTabSize: |
1364 case CSSPropertyFontSize: | 1360 case CSSPropertyFontSize: |
1365 case CSSPropertyLineHeight: | 1361 case CSSPropertyLineHeight: |
1366 case CSSPropertyRotate: | 1362 case CSSPropertyRotate: |
1367 case CSSPropertyFont: | 1363 case CSSPropertyFont: |
1368 case CSSPropertyWebkitBorderHorizontalSpacing: | 1364 case CSSPropertyWebkitBorderHorizontalSpacing: |
1369 case CSSPropertyWebkitBorderVerticalSpacing: | 1365 case CSSPropertyWebkitBorderVerticalSpacing: |
1370 case CSSPropertyBorderSpacing: | 1366 case CSSPropertyBorderSpacing: |
| 1367 case CSSPropertySize: |
1371 validPrimitive = false; | 1368 validPrimitive = false; |
1372 break; | 1369 break; |
1373 | 1370 |
1374 case CSSPropertyScrollSnapPointsX: | 1371 case CSSPropertyScrollSnapPointsX: |
1375 case CSSPropertyScrollSnapPointsY: | 1372 case CSSPropertyScrollSnapPointsY: |
1376 parsedValue = parseScrollSnapPoints(); | 1373 parsedValue = parseScrollSnapPoints(); |
1377 break; | 1374 break; |
1378 case CSSPropertyScrollSnapCoordinate: | 1375 case CSSPropertyScrollSnapCoordinate: |
1379 parsedValue = parseScrollSnapCoordinate(); | 1376 parsedValue = parseScrollSnapCoordinate(); |
1380 break; | 1377 break; |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate() | 1901 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate() |
1905 { | 1902 { |
1906 if (m_valueList->current()->id == CSSValueNone) { | 1903 if (m_valueList->current()->id == CSSValueNone) { |
1907 m_valueList->next(); | 1904 m_valueList->next(); |
1908 return cssValuePool().createIdentifierValue(CSSValueNone); | 1905 return cssValuePool().createIdentifierValue(CSSValueNone); |
1909 } | 1906 } |
1910 | 1907 |
1911 return parsePositionList(m_valueList); | 1908 return parsePositionList(m_valueList); |
1912 } | 1909 } |
1913 | 1910 |
1914 // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ] | |
1915 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseSize() | |
1916 { | |
1917 CSSParserValue* value = m_valueList->current(); | |
1918 ASSERT(value); | |
1919 | |
1920 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep
arated(); | |
1921 | |
1922 // First parameter. | |
1923 SizeParameterType paramType = parseSizeParameter(parsedValues.get(), value,
None); | |
1924 if (paramType == None) | |
1925 return nullptr; | |
1926 value = m_valueList->next(); | |
1927 | |
1928 // Second parameter, if any. | |
1929 if (value) { | |
1930 paramType = parseSizeParameter(parsedValues.get(), value, paramType); | |
1931 if (paramType == None) | |
1932 return nullptr; | |
1933 m_valueList->next(); | |
1934 } | |
1935 | |
1936 return parsedValues.release(); | |
1937 } | |
1938 | |
1939 CSSPropertyParser::SizeParameterType CSSPropertyParser::parseSizeParameter(CSSVa
lueList* parsedValues, CSSParserValue* value, SizeParameterType prevParamType) | |
1940 { | |
1941 switch (value->id) { | |
1942 case CSSValueAuto: | |
1943 if (prevParamType == None) { | |
1944 parsedValues->append(cssValuePool().createIdentifierValue(value->id)
); | |
1945 return Auto; | |
1946 } | |
1947 return None; | |
1948 case CSSValueLandscape: | |
1949 case CSSValuePortrait: | |
1950 if (prevParamType == None || prevParamType == PageSize) { | |
1951 parsedValues->append(cssValuePool().createIdentifierValue(value->id)
); | |
1952 return Orientation; | |
1953 } | |
1954 return None; | |
1955 case CSSValueA3: | |
1956 case CSSValueA4: | |
1957 case CSSValueA5: | |
1958 case CSSValueB4: | |
1959 case CSSValueB5: | |
1960 case CSSValueLedger: | |
1961 case CSSValueLegal: | |
1962 case CSSValueLetter: | |
1963 if (prevParamType == None || prevParamType == Orientation) { | |
1964 // Normalize to Page Size then Orientation order by prepending for s
impler StyleBuilder handling | |
1965 parsedValues->prepend(cssValuePool().createIdentifierValue(value->id
)); | |
1966 return PageSize; | |
1967 } | |
1968 return None; | |
1969 case 0: | |
1970 if (validUnit(value, FLength | FNonNeg) && (prevParamType == None || pre
vParamType == Length)) { | |
1971 parsedValues->append(createPrimitiveNumericValue(value)); | |
1972 return Length; | |
1973 } | |
1974 return None; | |
1975 default: | |
1976 return None; | |
1977 } | |
1978 } | |
1979 | |
1980 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open
-quote | no-close-quote ]+ | inherit | 1911 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open
-quote | no-close-quote ]+ | inherit |
1981 // in CSS 2.1 this got somewhat reduced: | 1912 // in CSS 2.1 this got somewhat reduced: |
1982 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit | 1913 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit |
1983 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent() | 1914 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent() |
1984 { | 1915 { |
1985 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); | 1916 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); |
1986 | 1917 |
1987 while (CSSParserValue* val = m_valueList->current()) { | 1918 while (CSSParserValue* val = m_valueList->current()) { |
1988 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 1919 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
1989 if (val->m_unit == CSSParserValue::URI) { | 1920 if (val->m_unit == CSSParserValue::URI) { |
(...skipping 5109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7099 } | 7030 } |
7100 } | 7031 } |
7101 | 7032 |
7102 if (!list->length()) | 7033 if (!list->length()) |
7103 return nullptr; | 7034 return nullptr; |
7104 | 7035 |
7105 return list.release(); | 7036 return list.release(); |
7106 } | 7037 } |
7107 | 7038 |
7108 } // namespace blink | 7039 } // namespace blink |
OLD | NEW |