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

Side by Side Diff: Source/core/css/parser/BisonCSSParser-in.cpp

Issue 134473008: Remove CSS regions support, keeping a bare minimum to support "region-based" multicol. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 return true; 746 return true;
747 break; 747 break;
748 case CSSPropertyInternalMarqueeStyle: 748 case CSSPropertyInternalMarqueeStyle:
749 if (valueID == CSSValueNone || valueID == CSSValueSlide || valueID == CS SValueScroll || valueID == CSSValueAlternate) 749 if (valueID == CSSValueNone || valueID == CSSValueSlide || valueID == CS SValueScroll || valueID == CSSValueAlternate)
750 return true; 750 return true;
751 break; 751 break;
752 case CSSPropertyWebkitPrintColorAdjust: 752 case CSSPropertyWebkitPrintColorAdjust:
753 if (valueID == CSSValueExact || valueID == CSSValueEconomy) 753 if (valueID == CSSValueExact || valueID == CSSValueEconomy)
754 return true; 754 return true;
755 break; 755 break;
756 case CSSPropertyWebkitRegionBreakAfter:
757 case CSSPropertyWebkitRegionBreakBefore:
758 if (RuntimeEnabledFeatures::cssRegionsEnabled() && (valueID == CSSValueA uto || valueID == CSSValueAlways || valueID == CSSValueAvoid || valueID == CSSVa lueLeft || valueID == CSSValueRight))
759 return true;
760 break;
761 case CSSPropertyWebkitRegionBreakInside:
762 if (RuntimeEnabledFeatures::cssRegionsEnabled() && (valueID == CSSValueA uto || valueID == CSSValueAvoid))
763 return true;
764 break;
765 case CSSPropertyWebkitRegionFragment:
766 if (RuntimeEnabledFeatures::cssRegionsEnabled() && (valueID == CSSValueA uto || valueID == CSSValueBreak))
767 return true;
768 break;
769 case CSSPropertyWebkitRtlOrdering: 756 case CSSPropertyWebkitRtlOrdering:
770 if (valueID == CSSValueLogical || valueID == CSSValueVisual) 757 if (valueID == CSSValueLogical || valueID == CSSValueVisual)
771 return true; 758 return true;
772 break; 759 break;
773 760
774 case CSSPropertyWebkitRubyPosition: 761 case CSSPropertyWebkitRubyPosition:
775 if (valueID == CSSValueBefore || valueID == CSSValueAfter) 762 if (valueID == CSSValueBefore || valueID == CSSValueAfter)
776 return true; 763 return true;
777 break; 764 break;
778 765
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 case CSSPropertyWebkitLineAlign: 900 case CSSPropertyWebkitLineAlign:
914 case CSSPropertyWebkitLineBreak: 901 case CSSPropertyWebkitLineBreak:
915 case CSSPropertyWebkitLineSnap: 902 case CSSPropertyWebkitLineSnap:
916 case CSSPropertyWebkitMarginAfterCollapse: 903 case CSSPropertyWebkitMarginAfterCollapse:
917 case CSSPropertyWebkitMarginBeforeCollapse: 904 case CSSPropertyWebkitMarginBeforeCollapse:
918 case CSSPropertyWebkitMarginBottomCollapse: 905 case CSSPropertyWebkitMarginBottomCollapse:
919 case CSSPropertyWebkitMarginTopCollapse: 906 case CSSPropertyWebkitMarginTopCollapse:
920 case CSSPropertyInternalMarqueeDirection: 907 case CSSPropertyInternalMarqueeDirection:
921 case CSSPropertyInternalMarqueeStyle: 908 case CSSPropertyInternalMarqueeStyle:
922 case CSSPropertyWebkitPrintColorAdjust: 909 case CSSPropertyWebkitPrintColorAdjust:
923 case CSSPropertyWebkitRegionBreakAfter:
924 case CSSPropertyWebkitRegionBreakBefore:
925 case CSSPropertyWebkitRegionBreakInside:
926 case CSSPropertyWebkitRegionFragment:
927 case CSSPropertyWebkitRtlOrdering: 910 case CSSPropertyWebkitRtlOrdering:
928 case CSSPropertyWebkitRubyPosition: 911 case CSSPropertyWebkitRubyPosition:
929 case CSSPropertyWebkitTextCombine: 912 case CSSPropertyWebkitTextCombine:
930 case CSSPropertyWebkitTextEmphasisPosition: 913 case CSSPropertyWebkitTextEmphasisPosition:
931 case CSSPropertyWebkitTextSecurity: 914 case CSSPropertyWebkitTextSecurity:
932 case CSSPropertyWebkitTransformStyle: 915 case CSSPropertyWebkitTransformStyle:
933 case CSSPropertyWebkitUserDrag: 916 case CSSPropertyWebkitUserDrag:
934 case CSSPropertyWebkitUserModify: 917 case CSSPropertyWebkitUserModify:
935 case CSSPropertyWebkitUserSelect: 918 case CSSPropertyWebkitUserSelect:
936 case CSSPropertyWebkitWrapFlow: 919 case CSSPropertyWebkitWrapFlow:
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2294 validPrimitive = true; 2277 validPrimitive = true;
2295 else 2278 else
2296 validPrimitive = validUnit(value, FInteger | FNonNeg); 2279 validPrimitive = validUnit(value, FInteger | FNonNeg);
2297 break; 2280 break;
2298 case CSSPropertyInternalMarqueeSpeed: 2281 case CSSPropertyInternalMarqueeSpeed:
2299 if (id == CSSValueNormal || id == CSSValueSlow || id == CSSValueFast) 2282 if (id == CSSValueNormal || id == CSSValueSlow || id == CSSValueFast)
2300 validPrimitive = true; 2283 validPrimitive = true;
2301 else 2284 else
2302 validPrimitive = validUnit(value, FTime | FInteger | FNonNeg); 2285 validPrimitive = validUnit(value, FTime | FInteger | FNonNeg);
2303 break; 2286 break;
2304 case CSSPropertyWebkitFlowInto:
2305 if (!RuntimeEnabledFeatures::cssRegionsEnabled())
2306 return false;
2307 return parseFlowThread(propId, important);
2308 case CSSPropertyWebkitFlowFrom:
2309 if (!RuntimeEnabledFeatures::cssRegionsEnabled())
2310 return false;
2311 return parseRegionThread(propId, important);
2312 case CSSPropertyWebkitTransform: 2287 case CSSPropertyWebkitTransform:
2313 if (id == CSSValueNone) 2288 if (id == CSSValueNone)
2314 validPrimitive = true; 2289 validPrimitive = true;
2315 else { 2290 else {
2316 RefPtr<CSSValue> transformValue = parseTransform(); 2291 RefPtr<CSSValue> transformValue = parseTransform();
2317 if (transformValue) { 2292 if (transformValue) {
2318 addProperty(propId, transformValue.release(), important); 2293 addProperty(propId, transformValue.release(), important);
2319 return true; 2294 return true;
2320 } 2295 }
2321 return false; 2296 return false;
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
2790 case CSSPropertyWebkitLineAlign: 2765 case CSSPropertyWebkitLineAlign:
2791 case CSSPropertyWebkitLineBreak: 2766 case CSSPropertyWebkitLineBreak:
2792 case CSSPropertyWebkitLineSnap: 2767 case CSSPropertyWebkitLineSnap:
2793 case CSSPropertyWebkitMarginAfterCollapse: 2768 case CSSPropertyWebkitMarginAfterCollapse:
2794 case CSSPropertyWebkitMarginBeforeCollapse: 2769 case CSSPropertyWebkitMarginBeforeCollapse:
2795 case CSSPropertyWebkitMarginBottomCollapse: 2770 case CSSPropertyWebkitMarginBottomCollapse:
2796 case CSSPropertyWebkitMarginTopCollapse: 2771 case CSSPropertyWebkitMarginTopCollapse:
2797 case CSSPropertyInternalMarqueeDirection: 2772 case CSSPropertyInternalMarqueeDirection:
2798 case CSSPropertyInternalMarqueeStyle: 2773 case CSSPropertyInternalMarqueeStyle:
2799 case CSSPropertyWebkitPrintColorAdjust: 2774 case CSSPropertyWebkitPrintColorAdjust:
2800 case CSSPropertyWebkitRegionBreakAfter:
2801 case CSSPropertyWebkitRegionBreakBefore:
2802 case CSSPropertyWebkitRegionBreakInside:
2803 case CSSPropertyWebkitRegionFragment:
2804 case CSSPropertyWebkitRtlOrdering: 2775 case CSSPropertyWebkitRtlOrdering:
2805 case CSSPropertyWebkitRubyPosition: 2776 case CSSPropertyWebkitRubyPosition:
2806 case CSSPropertyWebkitTextCombine: 2777 case CSSPropertyWebkitTextCombine:
2807 case CSSPropertyWebkitTextEmphasisPosition: 2778 case CSSPropertyWebkitTextEmphasisPosition:
2808 case CSSPropertyWebkitTextSecurity: 2779 case CSSPropertyWebkitTextSecurity:
2809 case CSSPropertyWebkitTransformStyle: 2780 case CSSPropertyWebkitTransformStyle:
2810 case CSSPropertyWebkitUserDrag: 2781 case CSSPropertyWebkitUserDrag:
2811 case CSSPropertyWebkitUserModify: 2782 case CSSPropertyWebkitUserModify:
2812 case CSSPropertyWebkitUserSelect: 2783 case CSSPropertyWebkitUserSelect:
2813 case CSSPropertyWebkitWrapFlow: 2784 case CSSPropertyWebkitWrapFlow:
(...skipping 5985 matching lines...) Expand 10 before | Expand all | Expand 10 after
8799 if (!filterValue) 8770 if (!filterValue)
8800 return 0; 8771 return 0;
8801 8772
8802 list->append(filterValue); 8773 list->append(filterValue);
8803 } 8774 }
8804 } 8775 }
8805 8776
8806 return list.release(); 8777 return list.release();
8807 } 8778 }
8808 8779
8809 static bool validFlowName(const String& flowName)
8810 {
8811 return !(equalIgnoringCase(flowName, "auto")
8812 || equalIgnoringCase(flowName, "default")
8813 || equalIgnoringCase(flowName, "inherit")
8814 || equalIgnoringCase(flowName, "initial")
8815 || equalIgnoringCase(flowName, "none"));
8816 }
8817
8818 // none | <ident>
8819 bool BisonCSSParser::parseFlowThread(CSSPropertyID propId, bool important)
8820 {
8821 ASSERT(propId == CSSPropertyWebkitFlowInto);
8822 ASSERT(RuntimeEnabledFeatures::cssRegionsEnabled());
8823
8824 if (m_valueList->size() != 1)
8825 return false;
8826
8827 CSSParserValue* value = m_valueList->current();
8828 if (!value)
8829 return false;
8830
8831 if (value->unit != CSSPrimitiveValue::CSS_IDENT)
8832 return false;
8833
8834 if (value->id == CSSValueNone) {
8835 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant);
8836 return true;
8837 }
8838
8839 String inputProperty = String(value->string);
8840 if (!inputProperty.isEmpty()) {
8841 if (!validFlowName(inputProperty))
8842 return false;
8843 addProperty(propId, cssValuePool().createValue(inputProperty, CSSPrimiti veValue::CSS_STRING), important);
8844 } else
8845 addProperty(propId, cssValuePool().createIdentifierValue(CSSValueNone), important);
8846
8847 return true;
8848 }
8849
8850 // -webkit-flow-from: none | <ident>
8851 bool BisonCSSParser::parseRegionThread(CSSPropertyID propId, bool important)
8852 {
8853 ASSERT(propId == CSSPropertyWebkitFlowFrom);
8854 ASSERT(RuntimeEnabledFeatures::cssRegionsEnabled());
8855
8856 if (m_valueList->size() != 1)
8857 return false;
8858
8859 CSSParserValue* value = m_valueList->current();
8860 if (!value)
8861 return false;
8862
8863 if (value->unit != CSSPrimitiveValue::CSS_IDENT)
8864 return false;
8865
8866 if (value->id == CSSValueNone)
8867 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant);
8868 else {
8869 String inputProperty = String(value->string);
8870 if (!inputProperty.isEmpty()) {
8871 if (!validFlowName(inputProperty))
8872 return false;
8873 addProperty(propId, cssValuePool().createValue(inputProperty, CSSPri mitiveValue::CSS_STRING), important);
8874 } else
8875 addProperty(propId, cssValuePool().createIdentifierValue(CSSValueNon e), important);
8876 }
8877
8878 return true;
8879 }
8880
8881 bool BisonCSSParser::parseTransformOrigin(CSSPropertyID propId, CSSPropertyID& p ropId1, CSSPropertyID& propId2, CSSPropertyID& propId3, RefPtr<CSSValue>& value, RefPtr<CSSValue>& value2, RefPtr<CSSValue>& value3) 8780 bool BisonCSSParser::parseTransformOrigin(CSSPropertyID propId, CSSPropertyID& p ropId1, CSSPropertyID& propId2, CSSPropertyID& propId3, RefPtr<CSSValue>& value, RefPtr<CSSValue>& value2, RefPtr<CSSValue>& value3)
8882 { 8781 {
8883 propId1 = propId; 8782 propId1 = propId;
8884 propId2 = propId; 8783 propId2 = propId;
8885 propId3 = propId; 8784 propId3 = propId;
8886 if (propId == CSSPropertyWebkitTransformOrigin) { 8785 if (propId == CSSPropertyWebkitTransformOrigin) {
8887 propId1 = CSSPropertyWebkitTransformOriginX; 8786 propId1 = CSSPropertyWebkitTransformOriginX;
8888 propId2 = CSSPropertyWebkitTransformOriginY; 8787 propId2 = CSSPropertyWebkitTransformOriginY;
8889 propId3 = CSSPropertyWebkitTransformOriginZ; 8788 propId3 = CSSPropertyWebkitTransformOriginZ;
8890 } 8789 }
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
9900 selectorVector.append(pageSelector); 9799 selectorVector.append(pageSelector);
9901 rule->parserAdoptSelectorVector(selectorVector); 9800 rule->parserAdoptSelectorVector(selectorVector);
9902 rule->setProperties(createStylePropertySet()); 9801 rule->setProperties(createStylePropertySet());
9903 pageRule = rule.get(); 9802 pageRule = rule.get();
9904 m_parsedRules.append(rule.release()); 9803 m_parsedRules.append(rule.release());
9905 } 9804 }
9906 clearProperties(); 9805 clearProperties();
9907 return pageRule; 9806 return pageRule;
9908 } 9807 }
9909 9808
9910 void BisonCSSParser::setReusableRegionSelectorVector(Vector<OwnPtr<CSSParserSele ctor> >* selectors)
9911 {
9912 if (selectors)
9913 m_reusableRegionSelectorVector.swap(*selectors);
9914 }
9915
9916 StyleRuleBase* BisonCSSParser::createRegionRule(Vector<OwnPtr<CSSParserSelector> >* regionSelector, RuleList* rules)
9917 {
9918 if (m_context.useCounter())
9919 m_context.useCounter()->count(UseCounter::CSSWebkitRegionAtRule);
9920
9921 if (!RuntimeEnabledFeatures::cssRegionsEnabled() || !regionSelector || !rule s)
9922 return 0;
9923
9924 m_allowImportRules = m_allowNamespaceDeclarations = false;
9925
9926 RefPtr<StyleRuleRegion> regionRule = StyleRuleRegion::create(regionSelector, *rules);
9927
9928 StyleRuleRegion* result = regionRule.get();
9929 m_parsedRules.append(regionRule.release());
9930 if (m_observer)
9931 m_observer->startEndUnknownRule();
9932
9933 return result;
9934 }
9935
9936 StyleRuleBase* BisonCSSParser::createMarginAtRule(CSSSelector::MarginBoxType /* marginBox */) 9809 StyleRuleBase* BisonCSSParser::createMarginAtRule(CSSSelector::MarginBoxType /* marginBox */)
9937 { 9810 {
9938 // FIXME: Implement margin at-rule here, using: 9811 // FIXME: Implement margin at-rule here, using:
9939 // - marginBox: margin box 9812 // - marginBox: margin box
9940 // - m_parsedProperties: properties at [m_numParsedPropertiesBeforeMa rginBox, m_parsedProperties.size()] are for this at-rule. 9813 // - m_parsedProperties: properties at [m_numParsedPropertiesBeforeMa rginBox, m_parsedProperties.size()] are for this at-rule.
9941 // Don't forget to also update the action for page symbol in CSSGrammar.y su ch that margin at-rule data is cleared if page_selector is invalid. 9814 // Don't forget to also update the action for page symbol in CSSGrammar.y su ch that margin at-rule data is cleared if page_selector is invalid.
9942 9815
9943 endDeclarationsForMarginBox(); 9816 endDeclarationsForMarginBox();
9944 return 0; // until this method is implemented. 9817 return 0; // until this method is implemented.
9945 } 9818 }
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
10245 { 10118 {
10246 // The tokenizer checks for the construct of an+b. 10119 // The tokenizer checks for the construct of an+b.
10247 // However, since the {ident} rule precedes the {nth} rule, some of those 10120 // However, since the {ident} rule precedes the {nth} rule, some of those
10248 // tokens are identified as string literal. Furthermore we need to accept 10121 // tokens are identified as string literal. Furthermore we need to accept
10249 // "odd" and "even" which does not match to an+b. 10122 // "odd" and "even" which does not match to an+b.
10250 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 10123 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
10251 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 10124 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
10252 } 10125 }
10253 10126
10254 } 10127 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698