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

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

Issue 143323014: *** DO NOT LAND *** Attempt to understand Regions complexity Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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/parser/BisonCSSParser.h ('k') | Source/core/css/resolver/ScopedStyleResolver.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) 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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 return true; 668 return true;
669 break; 669 break;
670 case CSSPropertyWebkitBoxPack: 670 case CSSPropertyWebkitBoxPack:
671 if (valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSS ValueCenter || valueID == CSSValueJustify) 671 if (valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSS ValueCenter || valueID == CSSValueJustify)
672 return true; 672 return true;
673 break; 673 break;
674 case CSSPropertyInternalCallback: 674 case CSSPropertyInternalCallback:
675 // This property is only injected programmatically, not parsed from styl esheets. 675 // This property is only injected programmatically, not parsed from styl esheets.
676 return false; 676 return false;
677 case CSSPropertyColumnFill: 677 case CSSPropertyColumnFill:
678 if (RuntimeEnabledFeatures::regionBasedColumnsEnabled()) {
679 if (valueID == CSSValueAuto || valueID == CSSValueBalance)
680 return true;
681 }
682 break; 678 break;
683 case CSSPropertyAlignContent: 679 case CSSPropertyAlignContent:
684 // FIXME: Per CSS alignment, this property should accept an optional <ov erflow-position>. We should share this parsing code with 'justify-self'. 680 // FIXME: Per CSS alignment, this property should accept an optional <ov erflow-position>. We should share this parsing code with 'justify-self'.
685 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || value ID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSp aceAround || valueID == CSSValueStretch) 681 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || value ID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSp aceAround || valueID == CSSValueStretch)
686 return true; 682 return true;
687 break; 683 break;
688 case CSSPropertyAlignItems: 684 case CSSPropertyAlignItems:
689 // FIXME: Per CSS alignment, this property should accept the same argume nts as 'justify-self' so we should share its parsing code. 685 // FIXME: Per CSS alignment, this property should accept the same argume nts as 'justify-self' so we should share its parsing code.
690 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueI D == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch ) 686 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueI D == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch )
691 return true; 687 return true;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 return true; 741 return true;
746 break; 742 break;
747 case CSSPropertyInternalMarqueeStyle: 743 case CSSPropertyInternalMarqueeStyle:
748 if (valueID == CSSValueNone || valueID == CSSValueSlide || valueID == CS SValueScroll || valueID == CSSValueAlternate) 744 if (valueID == CSSValueNone || valueID == CSSValueSlide || valueID == CS SValueScroll || valueID == CSSValueAlternate)
749 return true; 745 return true;
750 break; 746 break;
751 case CSSPropertyWebkitPrintColorAdjust: 747 case CSSPropertyWebkitPrintColorAdjust:
752 if (valueID == CSSValueExact || valueID == CSSValueEconomy) 748 if (valueID == CSSValueExact || valueID == CSSValueEconomy)
753 return true; 749 return true;
754 break; 750 break;
755 case CSSPropertyWebkitRegionBreakAfter:
756 case CSSPropertyWebkitRegionBreakBefore:
757 if (RuntimeEnabledFeatures::cssRegionsEnabled() && (valueID == CSSValueA uto || valueID == CSSValueAlways || valueID == CSSValueAvoid || valueID == CSSVa lueLeft || valueID == CSSValueRight))
758 return true;
759 break;
760 case CSSPropertyWebkitRegionBreakInside:
761 if (RuntimeEnabledFeatures::cssRegionsEnabled() && (valueID == CSSValueA uto || valueID == CSSValueAvoid))
762 return true;
763 break;
764 case CSSPropertyWebkitRegionFragment:
765 if (RuntimeEnabledFeatures::cssRegionsEnabled() && (valueID == CSSValueA uto || valueID == CSSValueBreak))
766 return true;
767 break;
768 case CSSPropertyWebkitRtlOrdering: 751 case CSSPropertyWebkitRtlOrdering:
769 if (valueID == CSSValueLogical || valueID == CSSValueVisual) 752 if (valueID == CSSValueLogical || valueID == CSSValueVisual)
770 return true; 753 return true;
771 break; 754 break;
772 755
773 case CSSPropertyWebkitRubyPosition: 756 case CSSPropertyWebkitRubyPosition:
774 if (valueID == CSSValueBefore || valueID == CSSValueAfter) 757 if (valueID == CSSValueBefore || valueID == CSSValueAfter)
775 return true; 758 return true;
776 break; 759 break;
777 760
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 case CSSPropertyWebkitLineAlign: 894 case CSSPropertyWebkitLineAlign:
912 case CSSPropertyWebkitLineBreak: 895 case CSSPropertyWebkitLineBreak:
913 case CSSPropertyWebkitLineSnap: 896 case CSSPropertyWebkitLineSnap:
914 case CSSPropertyWebkitMarginAfterCollapse: 897 case CSSPropertyWebkitMarginAfterCollapse:
915 case CSSPropertyWebkitMarginBeforeCollapse: 898 case CSSPropertyWebkitMarginBeforeCollapse:
916 case CSSPropertyWebkitMarginBottomCollapse: 899 case CSSPropertyWebkitMarginBottomCollapse:
917 case CSSPropertyWebkitMarginTopCollapse: 900 case CSSPropertyWebkitMarginTopCollapse:
918 case CSSPropertyInternalMarqueeDirection: 901 case CSSPropertyInternalMarqueeDirection:
919 case CSSPropertyInternalMarqueeStyle: 902 case CSSPropertyInternalMarqueeStyle:
920 case CSSPropertyWebkitPrintColorAdjust: 903 case CSSPropertyWebkitPrintColorAdjust:
921 case CSSPropertyWebkitRegionBreakAfter:
922 case CSSPropertyWebkitRegionBreakBefore:
923 case CSSPropertyWebkitRegionBreakInside:
924 case CSSPropertyWebkitRegionFragment:
925 case CSSPropertyWebkitRtlOrdering: 904 case CSSPropertyWebkitRtlOrdering:
926 case CSSPropertyWebkitRubyPosition: 905 case CSSPropertyWebkitRubyPosition:
927 case CSSPropertyWebkitTextCombine: 906 case CSSPropertyWebkitTextCombine:
928 case CSSPropertyWebkitTextEmphasisPosition: 907 case CSSPropertyWebkitTextEmphasisPosition:
929 case CSSPropertyWebkitTextSecurity: 908 case CSSPropertyWebkitTextSecurity:
930 case CSSPropertyWebkitTransformStyle: 909 case CSSPropertyWebkitTransformStyle:
931 case CSSPropertyWebkitUserDrag: 910 case CSSPropertyWebkitUserDrag:
932 case CSSPropertyWebkitUserModify: 911 case CSSPropertyWebkitUserModify:
933 case CSSPropertyWebkitUserSelect: 912 case CSSPropertyWebkitUserSelect:
934 case CSSPropertyWebkitWrapFlow: 913 case CSSPropertyWebkitWrapFlow:
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 validPrimitive = true; 2308 validPrimitive = true;
2330 else 2309 else
2331 validPrimitive = validUnit(value, FInteger | FNonNeg); 2310 validPrimitive = validUnit(value, FInteger | FNonNeg);
2332 break; 2311 break;
2333 case CSSPropertyInternalMarqueeSpeed: 2312 case CSSPropertyInternalMarqueeSpeed:
2334 if (id == CSSValueNormal || id == CSSValueSlow || id == CSSValueFast) 2313 if (id == CSSValueNormal || id == CSSValueSlow || id == CSSValueFast)
2335 validPrimitive = true; 2314 validPrimitive = true;
2336 else 2315 else
2337 validPrimitive = validUnit(value, FTime | FInteger | FNonNeg); 2316 validPrimitive = validUnit(value, FTime | FInteger | FNonNeg);
2338 break; 2317 break;
2339 case CSSPropertyWebkitFlowInto:
2340 if (!RuntimeEnabledFeatures::cssRegionsEnabled())
2341 return false;
2342 return parseFlowThread(propId, important);
2343 case CSSPropertyWebkitFlowFrom:
2344 if (!RuntimeEnabledFeatures::cssRegionsEnabled())
2345 return false;
2346 return parseRegionThread(propId, important);
2347 case CSSPropertyWebkitTransform: 2318 case CSSPropertyWebkitTransform:
2348 if (id == CSSValueNone) 2319 if (id == CSSValueNone)
2349 validPrimitive = true; 2320 validPrimitive = true;
2350 else { 2321 else {
2351 RefPtr<CSSValue> transformValue = parseTransform(); 2322 RefPtr<CSSValue> transformValue = parseTransform();
2352 if (transformValue) { 2323 if (transformValue) {
2353 addProperty(propId, transformValue.release(), important); 2324 addProperty(propId, transformValue.release(), important);
2354 return true; 2325 return true;
2355 } 2326 }
2356 return false; 2327 return false;
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
2826 case CSSPropertyWebkitLineAlign: 2797 case CSSPropertyWebkitLineAlign:
2827 case CSSPropertyWebkitLineBreak: 2798 case CSSPropertyWebkitLineBreak:
2828 case CSSPropertyWebkitLineSnap: 2799 case CSSPropertyWebkitLineSnap:
2829 case CSSPropertyWebkitMarginAfterCollapse: 2800 case CSSPropertyWebkitMarginAfterCollapse:
2830 case CSSPropertyWebkitMarginBeforeCollapse: 2801 case CSSPropertyWebkitMarginBeforeCollapse:
2831 case CSSPropertyWebkitMarginBottomCollapse: 2802 case CSSPropertyWebkitMarginBottomCollapse:
2832 case CSSPropertyWebkitMarginTopCollapse: 2803 case CSSPropertyWebkitMarginTopCollapse:
2833 case CSSPropertyInternalMarqueeDirection: 2804 case CSSPropertyInternalMarqueeDirection:
2834 case CSSPropertyInternalMarqueeStyle: 2805 case CSSPropertyInternalMarqueeStyle:
2835 case CSSPropertyWebkitPrintColorAdjust: 2806 case CSSPropertyWebkitPrintColorAdjust:
2836 case CSSPropertyWebkitRegionBreakAfter:
2837 case CSSPropertyWebkitRegionBreakBefore:
2838 case CSSPropertyWebkitRegionBreakInside:
2839 case CSSPropertyWebkitRegionFragment:
2840 case CSSPropertyWebkitRtlOrdering: 2807 case CSSPropertyWebkitRtlOrdering:
2841 case CSSPropertyWebkitRubyPosition: 2808 case CSSPropertyWebkitRubyPosition:
2842 case CSSPropertyWebkitTextCombine: 2809 case CSSPropertyWebkitTextCombine:
2843 case CSSPropertyWebkitTextEmphasisPosition: 2810 case CSSPropertyWebkitTextEmphasisPosition:
2844 case CSSPropertyWebkitTextSecurity: 2811 case CSSPropertyWebkitTextSecurity:
2845 case CSSPropertyWebkitTransformStyle: 2812 case CSSPropertyWebkitTransformStyle:
2846 case CSSPropertyWebkitUserDrag: 2813 case CSSPropertyWebkitUserDrag:
2847 case CSSPropertyWebkitUserModify: 2814 case CSSPropertyWebkitUserModify:
2848 case CSSPropertyWebkitUserSelect: 2815 case CSSPropertyWebkitUserSelect:
2849 case CSSPropertyWebkitWrapFlow: 2816 case CSSPropertyWebkitWrapFlow:
(...skipping 5873 matching lines...) Expand 10 before | Expand all | Expand 10 after
8723 if (!filterValue) 8690 if (!filterValue)
8724 return 0; 8691 return 0;
8725 8692
8726 list->append(filterValue); 8693 list->append(filterValue);
8727 } 8694 }
8728 } 8695 }
8729 8696
8730 return list.release(); 8697 return list.release();
8731 } 8698 }
8732 8699
8733 static bool validFlowName(const String& flowName)
8734 {
8735 return !(equalIgnoringCase(flowName, "auto")
8736 || equalIgnoringCase(flowName, "default")
8737 || equalIgnoringCase(flowName, "inherit")
8738 || equalIgnoringCase(flowName, "initial")
8739 || equalIgnoringCase(flowName, "none"));
8740 }
8741
8742 // none | <ident>
8743 bool BisonCSSParser::parseFlowThread(CSSPropertyID propId, bool important)
8744 {
8745 ASSERT(propId == CSSPropertyWebkitFlowInto);
8746 ASSERT(RuntimeEnabledFeatures::cssRegionsEnabled());
8747
8748 if (m_valueList->size() != 1)
8749 return false;
8750
8751 CSSParserValue* value = m_valueList->current();
8752 if (!value)
8753 return false;
8754
8755 if (value->unit != CSSPrimitiveValue::CSS_IDENT)
8756 return false;
8757
8758 if (value->id == CSSValueNone) {
8759 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant);
8760 return true;
8761 }
8762
8763 String inputProperty = String(value->string);
8764 if (!inputProperty.isEmpty()) {
8765 if (!validFlowName(inputProperty))
8766 return false;
8767 addProperty(propId, cssValuePool().createValue(inputProperty, CSSPrimiti veValue::CSS_STRING), important);
8768 } else
8769 addProperty(propId, cssValuePool().createIdentifierValue(CSSValueNone), important);
8770
8771 return true;
8772 }
8773
8774 // -webkit-flow-from: none | <ident>
8775 bool BisonCSSParser::parseRegionThread(CSSPropertyID propId, bool important)
8776 {
8777 ASSERT(propId == CSSPropertyWebkitFlowFrom);
8778 ASSERT(RuntimeEnabledFeatures::cssRegionsEnabled());
8779
8780 if (m_valueList->size() != 1)
8781 return false;
8782
8783 CSSParserValue* value = m_valueList->current();
8784 if (!value)
8785 return false;
8786
8787 if (value->unit != CSSPrimitiveValue::CSS_IDENT)
8788 return false;
8789
8790 if (value->id == CSSValueNone)
8791 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant);
8792 else {
8793 String inputProperty = String(value->string);
8794 if (!inputProperty.isEmpty()) {
8795 if (!validFlowName(inputProperty))
8796 return false;
8797 addProperty(propId, cssValuePool().createValue(inputProperty, CSSPri mitiveValue::CSS_STRING), important);
8798 } else
8799 addProperty(propId, cssValuePool().createIdentifierValue(CSSValueNon e), important);
8800 }
8801
8802 return true;
8803 }
8804
8805 bool BisonCSSParser::parseTransformOrigin(CSSPropertyID propId, CSSPropertyID& p ropId1, CSSPropertyID& propId2, CSSPropertyID& propId3, RefPtr<CSSValue>& value, RefPtr<CSSValue>& value2, RefPtr<CSSValue>& value3) 8700 bool BisonCSSParser::parseTransformOrigin(CSSPropertyID propId, CSSPropertyID& p ropId1, CSSPropertyID& propId2, CSSPropertyID& propId3, RefPtr<CSSValue>& value, RefPtr<CSSValue>& value2, RefPtr<CSSValue>& value3)
8806 { 8701 {
8807 propId1 = propId; 8702 propId1 = propId;
8808 propId2 = propId; 8703 propId2 = propId;
8809 propId3 = propId; 8704 propId3 = propId;
8810 if (propId == CSSPropertyWebkitTransformOrigin) { 8705 if (propId == CSSPropertyWebkitTransformOrigin) {
8811 propId1 = CSSPropertyWebkitTransformOriginX; 8706 propId1 = CSSPropertyWebkitTransformOriginX;
8812 propId2 = CSSPropertyWebkitTransformOriginY; 8707 propId2 = CSSPropertyWebkitTransformOriginY;
8813 propId3 = CSSPropertyWebkitTransformOriginZ; 8708 propId3 = CSSPropertyWebkitTransformOriginZ;
8814 } 8709 }
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
9824 selectorVector.append(pageSelector); 9719 selectorVector.append(pageSelector);
9825 rule->parserAdoptSelectorVector(selectorVector); 9720 rule->parserAdoptSelectorVector(selectorVector);
9826 rule->setProperties(createStylePropertySet()); 9721 rule->setProperties(createStylePropertySet());
9827 pageRule = rule.get(); 9722 pageRule = rule.get();
9828 m_parsedRules.append(rule.release()); 9723 m_parsedRules.append(rule.release());
9829 } 9724 }
9830 clearProperties(); 9725 clearProperties();
9831 return pageRule; 9726 return pageRule;
9832 } 9727 }
9833 9728
9834 void BisonCSSParser::setReusableRegionSelectorVector(Vector<OwnPtr<CSSParserSele ctor> >* selectors)
9835 {
9836 if (selectors)
9837 m_reusableRegionSelectorVector.swap(*selectors);
9838 }
9839
9840 StyleRuleBase* BisonCSSParser::createRegionRule(Vector<OwnPtr<CSSParserSelector> >* regionSelector, RuleList* rules)
9841 {
9842 if (m_useCounter)
9843 m_useCounter->count(UseCounter::CSSWebkitRegionAtRule);
9844
9845 if (!RuntimeEnabledFeatures::cssRegionsEnabled() || !regionSelector || !rule s)
9846 return 0;
9847
9848 m_allowImportRules = m_allowNamespaceDeclarations = false;
9849
9850 RefPtr<StyleRuleRegion> regionRule = StyleRuleRegion::create(regionSelector, *rules);
9851
9852 StyleRuleRegion* result = regionRule.get();
9853 m_parsedRules.append(regionRule.release());
9854 if (m_observer)
9855 m_observer->startEndUnknownRule();
9856
9857 return result;
9858 }
9859
9860 StyleRuleBase* BisonCSSParser::createMarginAtRule(CSSSelector::MarginBoxType /* marginBox */) 9729 StyleRuleBase* BisonCSSParser::createMarginAtRule(CSSSelector::MarginBoxType /* marginBox */)
9861 { 9730 {
9862 // FIXME: Implement margin at-rule here, using: 9731 // FIXME: Implement margin at-rule here, using:
9863 // - marginBox: margin box 9732 // - marginBox: margin box
9864 // - m_parsedProperties: properties at [m_numParsedPropertiesBeforeMa rginBox, m_parsedProperties.size()] are for this at-rule. 9733 // - m_parsedProperties: properties at [m_numParsedPropertiesBeforeMa rginBox, m_parsedProperties.size()] are for this at-rule.
9865 // 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. 9734 // 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.
9866 9735
9867 endDeclarationsForMarginBox(); 9736 endDeclarationsForMarginBox();
9868 return 0; // until this method is implemented. 9737 return 0; // until this method is implemented.
9869 } 9738 }
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
10169 { 10038 {
10170 // The tokenizer checks for the construct of an+b. 10039 // The tokenizer checks for the construct of an+b.
10171 // However, since the {ident} rule precedes the {nth} rule, some of those 10040 // However, since the {ident} rule precedes the {nth} rule, some of those
10172 // tokens are identified as string literal. Furthermore we need to accept 10041 // tokens are identified as string literal. Furthermore we need to accept
10173 // "odd" and "even" which does not match to an+b. 10042 // "odd" and "even" which does not match to an+b.
10174 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 10043 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
10175 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 10044 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
10176 } 10045 }
10177 10046
10178 } 10047 }
OLDNEW
« no previous file with comments | « Source/core/css/parser/BisonCSSParser.h ('k') | Source/core/css/resolver/ScopedStyleResolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698