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

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

Issue 1252933003: Shrink SVG paint-order to take less bits (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Align with review comments Created 5 years, 4 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
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 7853 matching lines...) Expand 10 before | Expand all | Expand 10 after
7864 7864
7865 // normal | [ fill || stroke || markers ] 7865 // normal | [ fill || stroke || markers ]
7866 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePaintOrder() const 7866 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePaintOrder() const
7867 { 7867 {
7868 if (m_valueList->size() > 3) 7868 if (m_valueList->size() > 3)
7869 return nullptr; 7869 return nullptr;
7870 7870
7871 CSSParserValue* value = m_valueList->current(); 7871 CSSParserValue* value = m_valueList->current();
7872 ASSERT(value); 7872 ASSERT(value);
7873 7873
7874 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep arated(); 7874 Vector<CSSValueID, 3> paintTypeList;
7875 7875 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr;
7876 // The default paint-order is: Fill, Stroke, Markers. 7876 RefPtrWillBeRawPtr<CSSPrimitiveValue> stroke = nullptr;
7877 bool seenFill = false, seenStroke = false, seenMarkers = false; 7877 RefPtrWillBeRawPtr<CSSPrimitiveValue> markers = nullptr;
7878 7878 while (value) {
7879 for (; value; value = m_valueList->next()) { 7879 if (value->id == CSSValueFill && !fill)
7880 switch (value->id) { 7880 fill = CSSPrimitiveValue::createIdentifier(value->id);
7881 case CSSValueNormal: 7881 else if (value->id == CSSValueStroke && !stroke)
7882 // normal inside [fill || stroke || markers] not valid 7882 stroke = CSSPrimitiveValue::createIdentifier(value->id);
7883 else if (value->id == CSSValueMarkers && !markers)
7884 markers = CSSPrimitiveValue::createIdentifier(value->id);
7885 else
7883 return nullptr; 7886 return nullptr;
7884 case CSSValueFill: 7887 paintTypeList.append(value->id);
7885 if (seenFill) 7888 value = m_valueList->next();
7886 return nullptr;
7887
7888 seenFill = true;
7889 break;
7890 case CSSValueStroke:
7891 if (seenStroke)
7892 return nullptr;
7893
7894 seenStroke = true;
7895 break;
7896 case CSSValueMarkers:
7897 if (seenMarkers)
7898 return nullptr;
7899
7900 seenMarkers = true;
7901 break;
7902 default:
7903 return nullptr;
7904 }
7905
7906 parsedValues->append(CSSPrimitiveValue::createIdentifier(value->id));
7907 } 7889 }
7908 7890
7909 // fill out the rest of the paint order 7891 // After parsing we serialize the paint-order list. Since it is not possible to
7910 if (!seenFill) 7892 // pop a last list items from CSSValueList without bigger cost, we create th e
7911 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); 7893 // list after parsing.
7912 if (!seenStroke) 7894 CSSValueID firstPaintOrderType = paintTypeList.at(0);
7913 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) ); 7895 RefPtrWillBeRawPtr<CSSValueList> paintOrderList = CSSValueList::createSpaceS eparated();
7914 if (!seenMarkers) 7896 switch (firstPaintOrderType) {
7915 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers )); 7897 case CSSValueFill:
7898 case CSSValueStroke:
7899 paintOrderList->append(firstPaintOrderType == CSSValueFill ? fill.releas e() : stroke.release());
7900 if (paintTypeList.size() > 1) {
7901 if (paintTypeList.at(1) == CSSValueMarkers)
7902 paintOrderList->append(markers.release());
7903 }
7904 break;
7905 case CSSValueMarkers:
7906 paintOrderList->append(markers.release());
7907 if (paintTypeList.size() > 1) {
7908 if (paintTypeList.at(1) == CSSValueStroke)
7909 paintOrderList->append(stroke.release());
7910 }
7911 break;
7912 default:
7913 ASSERT_NOT_REACHED();
7914 }
7916 7915
7917 return parsedValues.release(); 7916 return paintOrderList.release();
7918 } 7917 }
7919 7918
7920 class TransformOperationInfo { 7919 class TransformOperationInfo {
7921 public: 7920 public:
7922 TransformOperationInfo(CSSValueID id) 7921 TransformOperationInfo(CSSValueID id)
7923 : m_validID(true) 7922 : m_validID(true)
7924 , m_allowSingleArgument(false) 7923 , m_allowSingleArgument(false)
7925 , m_argCount(1) 7924 , m_argCount(1)
7926 , m_unit(CSSPropertyParser::FUnknown) 7925 , m_unit(CSSPropertyParser::FUnknown)
7927 { 7926 {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
8152 } 8151 }
8153 } 8152 }
8154 8153
8155 if (!list->length()) 8154 if (!list->length())
8156 return nullptr; 8155 return nullptr;
8157 8156
8158 return list.release(); 8157 return list.release();
8159 } 8158 }
8160 8159
8161 } // namespace blink 8160 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/ComputedStyleCSSValueMapping.cpp ('k') | Source/core/css/resolver/StyleBuilderConverter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698