Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1683)

Side by Side Diff: Source/core/css/CSSGrammar.y.in

Issue 16339006: Make sure to use CSSValueID and CSSPropertyID rather than integers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSComputedStyleDeclaration.cpp ('k') | Source/core/css/CSSParser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2002-2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2002-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 App le Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 App le Inc. All rights reserved.
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
6 * Copyright (C) 2012 Intel Corporation. All rights reserved. 6 * Copyright (C) 2012 Intel Corporation. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after
1663 valid_expr: 1663 valid_expr:
1664 term { 1664 term {
1665 $$ = parser->createFloatingValueList(); 1665 $$ = parser->createFloatingValueList();
1666 $$->addValue(parser->sinkFloatingValue($1)); 1666 $$->addValue(parser->sinkFloatingValue($1));
1667 } 1667 }
1668 | valid_expr operator term { 1668 | valid_expr operator term {
1669 $$ = $1; 1669 $$ = $1;
1670 if ($$) { 1670 if ($$) {
1671 if ($2) { 1671 if ($2) {
1672 CSSParserValue v; 1672 CSSParserValue v;
1673 v.id = 0; 1673 v.id = CSSValueInvalid;
1674 v.unit = CSSParserValue::Operator; 1674 v.unit = CSSParserValue::Operator;
1675 v.iValue = $2; 1675 v.iValue = $2;
1676 $$->addValue(v); 1676 $$->addValue(v);
1677 } 1677 }
1678 $$->addValue(parser->sinkFloatingValue($3)); 1678 $$->addValue(parser->sinkFloatingValue($3));
1679 } 1679 }
1680 } 1680 }
1681 ; 1681 ;
1682 1682
1683 expr_recovery: 1683 expr_recovery:
(...skipping 10 matching lines...) Expand all
1694 $$ = ','; 1694 $$ = ',';
1695 } 1695 }
1696 | /* empty */ { 1696 | /* empty */ {
1697 $$ = 0; 1697 $$ = 0;
1698 } 1698 }
1699 ; 1699 ;
1700 1700
1701 term: 1701 term:
1702 unary_term maybe_space { $$ = $1; } 1702 unary_term maybe_space { $$ = $1; }
1703 | unary_operator unary_term maybe_space { $$ = $2; $$.fValue *= $1; } 1703 | unary_operator unary_term maybe_space { $$ = $2; $$.fValue *= $1; }
1704 | STRING maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue: :CSS_STRING; } 1704 | STRING maybe_space { $$.id = CSSValueInvalid; $$.string = $1; $$.unit = CSSP rimitiveValue::CSS_STRING; }
1705 | IDENT maybe_space { 1705 | IDENT maybe_space {
1706 $$.id = cssValueKeywordID($1); 1706 $$.id = cssValueKeywordID($1);
1707 $$.unit = CSSPrimitiveValue::CSS_IDENT; 1707 $$.unit = CSSPrimitiveValue::CSS_IDENT;
1708 $$.string = $1; 1708 $$.string = $1;
1709 } 1709 }
1710 /* We might need to actually parse the number from a dimension, but we can't j ust put something that uses $$.string into unary_term. */ 1710 /* We might need to actually parse the number from a dimension, but we can't j ust put something that uses $$.string into unary_term. */
1711 | DIMEN maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue:: CSS_DIMENSION; } 1711 | DIMEN maybe_space { $$.id = CSSValueInvalid; $$.string = $1; $$.unit = CSSPr imitiveValue::CSS_DIMENSION; }
1712 | unary_operator DIMEN maybe_space { $$.id = 0; $$.string = $2; $$.unit = CSSP rimitiveValue::CSS_DIMENSION; } 1712 | unary_operator DIMEN maybe_space { $$.id = CSSValueInvalid; $$.string = $2; $$.unit = CSSPrimitiveValue::CSS_DIMENSION; }
1713 | URI maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CS S_URI; } 1713 | URI maybe_space { $$.id = CSSValueInvalid; $$.string = $1; $$.unit = CSSPrim itiveValue::CSS_URI; }
1714 | UNICODERANGE maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitive Value::CSS_UNICODE_RANGE; } 1714 | UNICODERANGE maybe_space { $$.id = CSSValueInvalid; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_UNICODE_RANGE; }
1715 | HEX maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CS S_PARSER_HEXCOLOR; } 1715 | HEX maybe_space { $$.id = CSSValueInvalid; $$.string = $1; $$.unit = CSSPrim itiveValue::CSS_PARSER_HEXCOLOR; }
1716 | '#' maybe_space { $$.id = 0; $$.string = CSSParserString(); $$.unit = CSSPri mitiveValue::CSS_PARSER_HEXCOLOR; } /* Handle error case: "color: #;" */ 1716 | '#' maybe_space { $$.id = CSSValueInvalid; $$.string = CSSParserString(); $$ .unit = CSSPrimitiveValue::CSS_PARSER_HEXCOLOR; } /* Handle error case: "color: #;" */
1717 | VARFUNCTION maybe_space IDENT closing_parenthesis maybe_space { 1717 | VARFUNCTION maybe_space IDENT closing_parenthesis maybe_space {
1718 $$.id = 0; 1718 $$.id = CSSValueInvalid;
1719 $$.string = $3; 1719 $$.string = $3;
1720 $$.unit = CSSPrimitiveValue::CSS_VARIABLE_NAME; 1720 $$.unit = CSSPrimitiveValue::CSS_VARIABLE_NAME;
1721 } 1721 }
1722 /* FIXME: according to the specs a function can have a unary_operator in front . I know no case where this makes sense */ 1722 /* FIXME: according to the specs a function can have a unary_operator in front . I know no case where this makes sense */
1723 | function maybe_space { 1723 | function maybe_space {
1724 $$ = $1; 1724 $$ = $1;
1725 } 1725 }
1726 | calc_function maybe_space { 1726 | calc_function maybe_space {
1727 $$ = $1; 1727 $$ = $1;
1728 } 1728 }
1729 | min_or_max_function maybe_space { 1729 | min_or_max_function maybe_space {
1730 $$ = $1; 1730 $$ = $1;
1731 } 1731 }
1732 | '%' maybe_space { /* Handle width: %; */ 1732 | '%' maybe_space { /* Handle width: %; */
1733 $$.id = 0; $$.unit = 0; 1733 $$.id = CSSValueInvalid; $$.unit = 0;
1734 } 1734 }
1735 ; 1735 ;
1736 1736
1737 unary_term: 1737 unary_term:
1738 INTEGER { $$.setFromNumber($1); $$.isInt = true; } 1738 INTEGER { $$.setFromNumber($1); $$.isInt = true; }
1739 | FLOATTOKEN { $$.setFromNumber($1); } 1739 | FLOATTOKEN { $$.setFromNumber($1); }
1740 | PERCENTAGE { $$.setFromNumber($1, CSSPrimitiveValue::CSS_PERCENTAGE); } 1740 | PERCENTAGE { $$.setFromNumber($1, CSSPrimitiveValue::CSS_PERCENTAGE); }
1741 | PXS { $$.setFromNumber($1, CSSPrimitiveValue::CSS_PX); } 1741 | PXS { $$.setFromNumber($1, CSSPrimitiveValue::CSS_PX); }
1742 | CMS { $$.setFromNumber($1, CSSPrimitiveValue::CSS_CM); } 1742 | CMS { $$.setFromNumber($1, CSSPrimitiveValue::CSS_CM); }
1743 | MMS { $$.setFromNumber($1, CSSPrimitiveValue::CSS_MM); } 1743 | MMS { $$.setFromNumber($1, CSSPrimitiveValue::CSS_MM); }
(...skipping 26 matching lines...) Expand all
1770 | DPCM { $$.setFromNumber($1, CSSPrimitiveValue::CSS_DPCM); } 1770 | DPCM { $$.setFromNumber($1, CSSPrimitiveValue::CSS_DPCM); }
1771 | FR { $$.setFromNumber($1, CSSPrimitiveValue::CSS_FR); } 1771 | FR { $$.setFromNumber($1, CSSPrimitiveValue::CSS_FR); }
1772 ; 1772 ;
1773 1773
1774 function: 1774 function:
1775 FUNCTION maybe_space expr closing_parenthesis { 1775 FUNCTION maybe_space expr closing_parenthesis {
1776 if ($3) { 1776 if ($3) {
1777 CSSParserFunction* f = parser->createFloatingFunction(); 1777 CSSParserFunction* f = parser->createFloatingFunction();
1778 f->name = $1; 1778 f->name = $1;
1779 f->args = parser->sinkFloatingValueList($3); 1779 f->args = parser->sinkFloatingValueList($3);
1780 $$.id = 0; 1780 $$.id = CSSValueInvalid;
1781 $$.unit = CSSParserValue::Function; 1781 $$.unit = CSSParserValue::Function;
1782 $$.function = f; 1782 $$.function = f;
1783 } else 1783 } else
1784 YYERROR; 1784 YYERROR;
1785 } | 1785 } |
1786 FUNCTION maybe_space closing_parenthesis { 1786 FUNCTION maybe_space closing_parenthesis {
1787 CSSParserFunction* f = parser->createFloatingFunction(); 1787 CSSParserFunction* f = parser->createFloatingFunction();
1788 f->name = $1; 1788 f->name = $1;
1789 CSSParserValueList* valueList = parser->createFloatingValueList(); 1789 CSSParserValueList* valueList = parser->createFloatingValueList();
1790 f->args = parser->sinkFloatingValueList(valueList); 1790 f->args = parser->sinkFloatingValueList(valueList);
1791 $$.id = 0; 1791 $$.id = CSSValueInvalid;
1792 $$.unit = CSSParserValue::Function; 1792 $$.unit = CSSParserValue::Function;
1793 $$.function = f; 1793 $$.function = f;
1794 } | 1794 } |
1795 FUNCTION maybe_space expr_recovery closing_parenthesis { 1795 FUNCTION maybe_space expr_recovery closing_parenthesis {
1796 YYERROR; 1796 YYERROR;
1797 } 1797 }
1798 ; 1798 ;
1799 1799
1800 calc_func_term: 1800 calc_func_term:
1801 unary_term { $$ = $1; } 1801 unary_term { $$ = $1; }
1802 | VARFUNCTION maybe_space IDENT closing_parenthesis { 1802 | VARFUNCTION maybe_space IDENT closing_parenthesis {
1803 $$.id = 0; 1803 $$.id = CSSValueInvalid;
1804 $$.string = $3; 1804 $$.string = $3;
1805 $$.unit = CSSPrimitiveValue::CSS_VARIABLE_NAME; 1805 $$.unit = CSSPrimitiveValue::CSS_VARIABLE_NAME;
1806 } 1806 }
1807 | unary_operator unary_term { $$ = $2; $$.fValue *= $1; } 1807 | unary_operator unary_term { $$ = $2; $$.fValue *= $1; }
1808 ; 1808 ;
1809 1809
1810 calc_func_operator: 1810 calc_func_operator:
1811 WHITESPACE '+' WHITESPACE { 1811 WHITESPACE '+' WHITESPACE {
1812 $$ = '+'; 1812 $$ = '+';
1813 } 1813 }
(...skipping 11 matching lines...) Expand all
1825 calc_maybe_space: 1825 calc_maybe_space:
1826 /* empty */ 1826 /* empty */
1827 | WHITESPACE 1827 | WHITESPACE
1828 ; 1828 ;
1829 1829
1830 calc_func_paren_expr: 1830 calc_func_paren_expr:
1831 '(' maybe_space calc_func_expr calc_maybe_space closing_parenthesis { 1831 '(' maybe_space calc_func_expr calc_maybe_space closing_parenthesis {
1832 if ($3) { 1832 if ($3) {
1833 $$ = $3; 1833 $$ = $3;
1834 CSSParserValue v; 1834 CSSParserValue v;
1835 v.id = 0; 1835 v.id = CSSValueInvalid;
1836 v.unit = CSSParserValue::Operator; 1836 v.unit = CSSParserValue::Operator;
1837 v.iValue = '('; 1837 v.iValue = '(';
1838 $$->insertValueAt(0, v); 1838 $$->insertValueAt(0, v);
1839 v.iValue = ')'; 1839 v.iValue = ')';
1840 $$->addValue(v); 1840 $$->addValue(v);
1841 } else 1841 } else
1842 YYERROR; 1842 YYERROR;
1843 } 1843 }
1844 | '(' maybe_space expr_recovery closing_parenthesis { 1844 | '(' maybe_space expr_recovery closing_parenthesis {
1845 YYERROR; 1845 YYERROR;
1846 } 1846 }
1847 ; 1847 ;
1848 1848
1849 calc_func_expr: 1849 calc_func_expr:
1850 valid_calc_func_expr 1850 valid_calc_func_expr
1851 | valid_calc_func_expr expr_recovery { $$ = 0; } 1851 | valid_calc_func_expr expr_recovery { $$ = 0; }
1852 ; 1852 ;
1853 1853
1854 valid_calc_func_expr: 1854 valid_calc_func_expr:
1855 calc_func_term { 1855 calc_func_term {
1856 $$ = parser->createFloatingValueList(); 1856 $$ = parser->createFloatingValueList();
1857 $$->addValue(parser->sinkFloatingValue($1)); 1857 $$->addValue(parser->sinkFloatingValue($1));
1858 } 1858 }
1859 | calc_func_expr calc_func_operator calc_func_term { 1859 | calc_func_expr calc_func_operator calc_func_term {
1860 if ($1 && $2) { 1860 if ($1 && $2) {
1861 $$ = $1; 1861 $$ = $1;
1862 CSSParserValue v; 1862 CSSParserValue v;
1863 v.id = 0; 1863 v.id = CSSValueInvalid;
1864 v.unit = CSSParserValue::Operator; 1864 v.unit = CSSParserValue::Operator;
1865 v.iValue = $2; 1865 v.iValue = $2;
1866 $$->addValue(v); 1866 $$->addValue(v);
1867 $$->addValue(parser->sinkFloatingValue($3)); 1867 $$->addValue(parser->sinkFloatingValue($3));
1868 } else 1868 } else
1869 YYERROR; 1869 YYERROR;
1870 1870
1871 } 1871 }
1872 | calc_func_expr calc_func_operator calc_func_paren_expr { 1872 | calc_func_expr calc_func_operator calc_func_paren_expr {
1873 if ($1 && $2 && $3) { 1873 if ($1 && $2 && $3) {
1874 $$ = $1; 1874 $$ = $1;
1875 CSSParserValue v; 1875 CSSParserValue v;
1876 v.id = 0; 1876 v.id = CSSValueInvalid;
1877 v.unit = CSSParserValue::Operator; 1877 v.unit = CSSParserValue::Operator;
1878 v.iValue = $2; 1878 v.iValue = $2;
1879 $$->addValue(v); 1879 $$->addValue(v);
1880 $$->extend(*($3)); 1880 $$->extend(*($3));
1881 } else 1881 } else
1882 YYERROR; 1882 YYERROR;
1883 } 1883 }
1884 | calc_func_paren_expr 1884 | calc_func_paren_expr
1885 ; 1885 ;
1886 1886
1887 calc_func_expr_list: 1887 calc_func_expr_list:
1888 calc_func_expr calc_maybe_space { 1888 calc_func_expr calc_maybe_space {
1889 $$ = $1; 1889 $$ = $1;
1890 } 1890 }
1891 | calc_func_expr_list ',' maybe_space calc_func_expr calc_maybe_space { 1891 | calc_func_expr_list ',' maybe_space calc_func_expr calc_maybe_space {
1892 if ($1 && $4) { 1892 if ($1 && $4) {
1893 $$ = $1; 1893 $$ = $1;
1894 CSSParserValue v; 1894 CSSParserValue v;
1895 v.id = 0; 1895 v.id = CSSValueInvalid;
1896 v.unit = CSSParserValue::Operator; 1896 v.unit = CSSParserValue::Operator;
1897 v.iValue = ','; 1897 v.iValue = ',';
1898 $$->addValue(v); 1898 $$->addValue(v);
1899 $$->extend(*($4)); 1899 $$->extend(*($4));
1900 } else 1900 } else
1901 YYERROR; 1901 YYERROR;
1902 } 1902 }
1903 ; 1903 ;
1904 1904
1905 calc_function: 1905 calc_function:
1906 CALCFUNCTION maybe_space calc_func_expr calc_maybe_space closing_parenthesis { 1906 CALCFUNCTION maybe_space calc_func_expr calc_maybe_space closing_parenthesis {
1907 CSSParserFunction* f = parser->createFloatingFunction(); 1907 CSSParserFunction* f = parser->createFloatingFunction();
1908 f->name = $1; 1908 f->name = $1;
1909 f->args = parser->sinkFloatingValueList($3); 1909 f->args = parser->sinkFloatingValueList($3);
1910 $$.id = 0; 1910 $$.id = CSSValueInvalid;
1911 $$.unit = CSSParserValue::Function; 1911 $$.unit = CSSParserValue::Function;
1912 $$.function = f; 1912 $$.function = f;
1913 } 1913 }
1914 | CALCFUNCTION maybe_space expr_recovery closing_parenthesis { 1914 | CALCFUNCTION maybe_space expr_recovery closing_parenthesis {
1915 YYERROR; 1915 YYERROR;
1916 } 1916 }
1917 ; 1917 ;
1918 1918
1919 1919
1920 min_or_max: 1920 min_or_max:
1921 MINFUNCTION { 1921 MINFUNCTION {
1922 $$ = $1; 1922 $$ = $1;
1923 } 1923 }
1924 | MAXFUNCTION { 1924 | MAXFUNCTION {
1925 $$ = $1; 1925 $$ = $1;
1926 } 1926 }
1927 ; 1927 ;
1928 1928
1929 min_or_max_function: 1929 min_or_max_function:
1930 min_or_max maybe_space calc_func_expr_list closing_parenthesis { 1930 min_or_max maybe_space calc_func_expr_list closing_parenthesis {
1931 CSSParserFunction* f = parser->createFloatingFunction(); 1931 CSSParserFunction* f = parser->createFloatingFunction();
1932 f->name = $1; 1932 f->name = $1;
1933 f->args = parser->sinkFloatingValueList($3); 1933 f->args = parser->sinkFloatingValueList($3);
1934 $$.id = 0; 1934 $$.id = CSSValueInvalid;
1935 $$.unit = CSSParserValue::Function; 1935 $$.unit = CSSParserValue::Function;
1936 $$.function = f; 1936 $$.function = f;
1937 } 1937 }
1938 | min_or_max maybe_space expr_recovery closing_parenthesis { 1938 | min_or_max maybe_space expr_recovery closing_parenthesis {
1939 YYERROR; 1939 YYERROR;
1940 } 1940 }
1941 ; 1941 ;
1942 1942
1943 invalid_at: 1943 invalid_at:
1944 ATKEYWORD at_rule_recovery { 1944 ATKEYWORD at_rule_recovery {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 2002
2003 rule_error_recovery: 2003 rule_error_recovery:
2004 /* empty */ 2004 /* empty */
2005 | rule_error_recovery error 2005 | rule_error_recovery error
2006 | rule_error_recovery invalid_square_brackets_block 2006 | rule_error_recovery invalid_square_brackets_block
2007 | rule_error_recovery invalid_parentheses_block 2007 | rule_error_recovery invalid_parentheses_block
2008 ; 2008 ;
2009 2009
2010 %% 2010 %%
2011 2011
OLDNEW
« no previous file with comments | « Source/core/css/CSSComputedStyleDeclaration.cpp ('k') | Source/core/css/CSSParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698