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

Side by Side Diff: Source/core/css/parser/CSSPropertyParser.cpp

Issue 1311503006: Make parseColumnsShorthand not mark 'auto' initial value as implicit (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: V3 Created 5 years, 3 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
« no previous file with comments | « no previous file | no next file » | 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) 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 1887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 m_valueList->next(); 1898 m_valueList->next();
1899 return parsedValue; 1899 return parsedValue;
1900 } 1900 }
1901 return nullptr; 1901 return nullptr;
1902 } 1902 }
1903 1903
1904 bool CSSPropertyParser::parseColumnsShorthand(bool important) 1904 bool CSSPropertyParser::parseColumnsShorthand(bool important)
1905 { 1905 {
1906 RefPtrWillBeRawPtr<CSSValue> columnWidth = nullptr; 1906 RefPtrWillBeRawPtr<CSSValue> columnWidth = nullptr;
1907 RefPtrWillBeRawPtr<CSSValue> columnCount = nullptr; 1907 RefPtrWillBeRawPtr<CSSValue> columnCount = nullptr;
1908 bool hasPendingExplicitAuto = false;
1909 1908
1910 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur rent(); propertiesParsed++) { 1909 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur rent(); propertiesParsed++) {
1911 if (propertiesParsed >= 2) 1910 if (propertiesParsed >= 2)
1912 return false; // Too many values for this shorthand. Invalid declara tion. 1911 return false; // Too many values for this shorthand. Invalid declara tion.
1913 if (!propertiesParsed && value->id == CSSValueAuto) { 1912 if (value->id == CSSValueAuto) {
1914 // 'auto' is a valid value for any of the two longhands, and at this point we 1913 // Skip 'auto' as we will use it for initial value if no width/count was parsed.
1915 // don't know which one(s) it is meant for. We need to see if there are other
1916 // values first.
1917 m_valueList->next(); 1914 m_valueList->next();
1918 hasPendingExplicitAuto = true;
1919 } else { 1915 } else {
1920 if (!columnWidth) { 1916 if (!columnWidth) {
1921 if ((columnWidth = parseColumnWidth())) 1917 if ((columnWidth = parseColumnWidth()))
1922 continue; 1918 continue;
1923 } 1919 }
1924 if (!columnCount) { 1920 if (!columnCount) {
1925 if ((columnCount = parseColumnCount())) 1921 if ((columnCount = parseColumnCount()))
1926 continue; 1922 continue;
1927 } 1923 }
1928 // If we didn't find at least one match, this is an 1924 // If we didn't find at least one match, this is an
1929 // invalid shorthand and we have to ignore it. 1925 // invalid shorthand and we have to ignore it.
1930 return false; 1926 return false;
1931 } 1927 }
1932 } 1928 }
1933 if (hasPendingExplicitAuto) {
1934 // Time to assign the previously skipped 'auto' value to a property. If both properties are
1935 // unassigned at this point (i.e. 'columns:auto'), it doesn't matter tha t much which one we
1936 // set (although it does make a slight difference to web-inspector). The one we don't set
1937 // here will get an implicit 'auto' value further down.
1938 if (!columnWidth) {
1939 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto);
1940 } else {
1941 ASSERT(!columnCount);
1942 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto);
1943 }
1944 }
1945 ASSERT(columnCount || columnWidth);
1946 1929
1947 // Any unassigned property at this point will become implicit 'auto'. 1930 if (!columnWidth)
1948 if (columnWidth) 1931 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto);
1949 addProperty(CSSPropertyWebkitColumnWidth, columnWidth, important); 1932 addProperty(CSSPropertyWebkitColumnWidth, columnWidth, important);
1950 else 1933 if (!columnCount)
1951 addProperty(CSSPropertyWebkitColumnWidth, cssValuePool().createIdentifie rValue(CSSValueAuto), important, true /* implicit */); 1934 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto);
1952 if (columnCount) 1935 addProperty(CSSPropertyWebkitColumnCount, columnCount, important);
1953 addProperty(CSSPropertyWebkitColumnCount, columnCount, important);
1954 else
1955 addProperty(CSSPropertyWebkitColumnCount, cssValuePool().createIdentifie rValue(CSSValueAuto), important, true /* implicit */);
1956 return true; 1936 return true;
1957 } 1937 }
1958 1938
1959 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty Shorthand& shorthand, bool important) 1939 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty Shorthand& shorthand, bool important)
1960 { 1940 {
1961 // We try to match as many properties as possible 1941 // We try to match as many properties as possible
1962 // We set up an array of booleans to mark which property has been found, 1942 // We set up an array of booleans to mark which property has been found,
1963 // and we try to search for properties until it makes no longer any sense. 1943 // and we try to search for properties until it makes no longer any sense.
1964 ShorthandScope scope(this, propId); 1944 ShorthandScope scope(this, propId);
1965 1945
(...skipping 6126 matching lines...) Expand 10 before | Expand all | Expand 10 after
8092 } 8072 }
8093 } 8073 }
8094 8074
8095 if (!list->length()) 8075 if (!list->length())
8096 return nullptr; 8076 return nullptr;
8097 8077
8098 return list.release(); 8078 return list.release();
8099 } 8079 }
8100 8080
8101 } // namespace blink 8081 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698