Skip to content

Commit

Permalink
Revert of Split out CSSParser public API (patchset #3 id:40001 of htt…
Browse files Browse the repository at this point in the history
…ps://codereview.chromium.org/566483002/)

Reason for revert:
Caused compiling errors.

Original issue's description:
> Split out CSSParser public API
> 
> This patch separates the public API of BisonCSSParser from the hundreds
> of public methods it exposes. The plan is to build a new parser based on
> the css-syntax specification, which will eventually complete replace the
> bison-based parser. The functions in this class will do the run-time
> switching between the bison parser and the new (unwritten) parser.
> 
> For the functions here which are only ever used with a newly instantiated
> BisonCSSParser, I've moved instantiation to inside the CSSParser so that
> the functions can be static.
> 
> This is an updated version of a patch by eseidel from 8 months ago:
> https://codereview.chromium.org/112933010/
> 
> BUG=330389
> 
> Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=181825

[email protected],[email protected],[email protected],[email protected]
NOTREECHECKS=true
NOTRY=true
BUG=330389

Review URL: https://codereview.chromium.org/566703002

git-svn-id: svn://svn.chromium.org/blink/trunk@181837 bbb929c8-8fbe-4397-9dbb-9b2b20218538
  • Loading branch information
jianli-chromium committed Sep 11, 2014
1 parent b611aea commit a85c412
Show file tree
Hide file tree
Showing 46 changed files with 91 additions and 231 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "core/css/CSSPropertyMetadata.h"
#include "core/css/CSSStyleDeclaration.h"
#include "core/css/CSSValue.h"
#include "core/css/parser/CSSParser.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/events/EventTarget.h"
#include "wtf/ASCIICType.h"
#include "wtf/PassRefPtr.h"
Expand Down
2 changes: 1 addition & 1 deletion Source/core/animation/AnimationHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef AnimationHelpers_h
#define AnimationHelpers_h

#include "core/css/parser/CSSParser.h"
#include "core/css/parser/BisonCSSParser.h"
#include "wtf/text/StringBuilder.h"

namespace blink {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSValueList.h"
#include "core/css/StylePropertySet.h"
#include "core/css/parser/CSSParser.h"
#include "core/css/parser/BisonCSSParser.h"

#include <gtest/gtest.h>

Expand All @@ -23,7 +23,7 @@ class AnimationDeferredLegacyStyleInterpolationTest : public ::testing::Test {
if (propertyID == CSSPropertyFloodColor)
parserMode = SVGAttributeMode;
RefPtrWillBeRawPtr<MutableStylePropertySet> dummyStyle = MutableStylePropertySet::create();
bool parseSuccess = CSSParser::parseValue(dummyStyle.get(), propertyID, string, false, parserMode, 0);
bool parseSuccess = BisonCSSParser::parseValue(dummyStyle.get(), propertyID, string, false, parserMode, 0);
ASSERT_UNUSED(parseSuccess, parseSuccess);
return DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(*dummyStyle->getPropertyCSSValue(propertyID));
}
Expand Down
4 changes: 2 additions & 2 deletions Source/core/animation/EffectInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "core/animation/AnimationHelpers.h"
#include "core/animation/KeyframeEffectModel.h"
#include "core/animation/StringKeyframe.h"
#include "core/css/parser/CSSParser.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/css/resolver/CSSToStyleMap.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/dom/Document.h"
Expand Down Expand Up @@ -92,7 +92,7 @@ PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c

String timingFunctionString;
if (DictionaryHelper::get(keyframeDictionaryVector[i], "easing", timingFunctionString)) {
if (RefPtrWillBeRawPtr<CSSValue> timingFunctionValue = CSSParser::parseAnimationTimingFunctionValue(timingFunctionString))
if (RefPtrWillBeRawPtr<CSSValue> timingFunctionValue = BisonCSSParser::parseAnimationTimingFunctionValue(timingFunctionString))
keyframe->setEasing(CSSToStyleMap::mapAnimationTimingFunction(timingFunctionValue.get(), true));
}

Expand Down
4 changes: 2 additions & 2 deletions Source/core/animation/TimingInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "core/animation/TimingInput.h"

#include "bindings/core/v8/Dictionary.h"
#include "core/css/parser/CSSParser.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/css/resolver/CSSToStyleMap.h"

namespace blink {
Expand Down Expand Up @@ -89,7 +89,7 @@ void TimingInput::setPlaybackDirection(Timing& timing, const String& direction)

void TimingInput::setTimingFunction(Timing& timing, const String& timingFunctionString)
{
if (RefPtrWillBeRawPtr<CSSValue> timingFunctionValue = CSSParser::parseAnimationTimingFunctionValue(timingFunctionString))
if (RefPtrWillBeRawPtr<CSSValue> timingFunctionValue = BisonCSSParser::parseAnimationTimingFunctionValue(timingFunctionString))
timing.timingFunction = CSSToStyleMap::mapAnimationTimingFunction(timingFunctionValue.get(), true);
else
timing.timingFunction = Timing::defaults().timingFunction;
Expand Down
2 changes: 0 additions & 2 deletions Source/core/core.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,6 @@
'css/invalidation/StyleSheetInvalidationAnalysis.cpp',
'css/invalidation/StyleSheetInvalidationAnalysis.h',
'css/parser/BisonCSSParser.h',
'css/parser/CSSParser.cpp',
'css/parser/CSSParser.h',
'css/parser/CSSParserMode.cpp',
'css/parser/CSSParserMode.h',
'css/parser/CSSParserValues.cpp',
Expand Down
2 changes: 1 addition & 1 deletion Source/core/css/CSSComputedStyleDeclaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "core/css/CSSGridLineNamesValue.h"
#include "core/css/CSSGridTemplateAreasValue.h"
#include "core/css/CSSLineBoxContainValue.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSPrimitiveValueMappings.h"
#include "core/css/CSSPropertyMetadata.h"
Expand All @@ -51,7 +52,6 @@
#include "core/css/Pair.h"
#include "core/css/Rect.h"
#include "core/css/StylePropertySet.h"
#include "core/css/parser/CSSParser.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
Expand Down
5 changes: 3 additions & 2 deletions Source/core/css/CSSGroupingRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
#include "core/css/CSSGroupingRule.h"

#include "bindings/core/v8/ExceptionState.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/css/CSSRuleList.h"
#include "core/css/CSSStyleSheet.h"
#include "core/css/parser/CSSParser.h"
#include "core/dom/ExceptionCode.h"
#include "core/frame/UseCounter.h"
#include "wtf/text/StringBuilder.h"
Expand Down Expand Up @@ -70,7 +70,8 @@ unsigned CSSGroupingRule::insertRule(const String& ruleString, unsigned index, E

CSSStyleSheet* styleSheet = parentStyleSheet();
CSSParserContext context(parserContext(), UseCounter::getFrom(styleSheet));
RefPtrWillBeRawPtr<StyleRuleBase> newRule = CSSParser::parseRule(context, styleSheet ? styleSheet->contents() : 0, ruleString);
BisonCSSParser parser(context);
RefPtrWillBeRawPtr<StyleRuleBase> newRule = parser.parseRule(styleSheet ? styleSheet->contents() : 0, ruleString);
if (!newRule) {
exceptionState.throwDOMException(SyntaxError, "the rule '" + ruleString + "' is invalid and cannot be parsed.");
return 0;
Expand Down
4 changes: 2 additions & 2 deletions Source/core/css/CSSKeyframeRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
#include "core/css/CSSKeyframeRule.h"

#include "core/css/CSSKeyframesRule.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/css/PropertySetCSSStyleDeclaration.h"
#include "core/css/StylePropertySet.h"
#include "core/css/parser/CSSParser.h"
#include "core/frame/UseCounter.h"
#include "wtf/text/StringBuilder.h"

Expand Down Expand Up @@ -77,7 +77,7 @@ const Vector<double>& StyleKeyframe::keys() const
// Keys can only be cleared by setting the key text from JavaScript
// and this can never be null.
ASSERT(!m_keyText.isNull());
m_keys = CSSParser::parseKeyframeKeyList(m_keyText);
m_keys = BisonCSSParser(strictCSSParserContext()).parseKeyframeKeyList(m_keyText);
}
// If an invalid key string was set, m_keys may be empty.
ASSERT(m_keys);
Expand Down
5 changes: 3 additions & 2 deletions Source/core/css/CSSKeyframesRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
#include "core/css/CSSKeyframesRule.h"

#include "core/css/CSSKeyframeRule.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/css/CSSRuleList.h"
#include "core/css/CSSStyleSheet.h"
#include "core/css/parser/CSSParser.h"
#include "core/frame/UseCounter.h"
#include "wtf/text/StringBuilder.h"

Expand Down Expand Up @@ -124,7 +124,8 @@ void CSSKeyframesRule::insertRule(const String& ruleText)

CSSStyleSheet* styleSheet = parentStyleSheet();
CSSParserContext context(parserContext(), UseCounter::getFrom(styleSheet));
RefPtrWillBeRawPtr<StyleKeyframe> keyframe = CSSParser::parseKeyframeRule(context, styleSheet ? styleSheet->contents() : 0, ruleText);
BisonCSSParser parser(context);
RefPtrWillBeRawPtr<StyleKeyframe> keyframe = parser.parseKeyframeRule(styleSheet ? styleSheet->contents() : 0, ruleText);
if (!keyframe)
return;

Expand Down
6 changes: 3 additions & 3 deletions Source/core/css/CSSMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#include "bindings/core/v8/ExceptionState.h"
#include "core/CSSPropertyNames.h"
#include "core/CSSValueKeywords.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/css/CSSToLengthConversionData.h"
#include "core/css/StylePropertySet.h"
#include "core/css/parser/CSSParser.h"
#include "core/css/resolver/TransformBuilder.h"
#include "core/dom/ExceptionCode.h"
#include "core/rendering/style/RenderStyle.h"
Expand All @@ -55,9 +55,9 @@ void CSSMatrix::setMatrixValue(const String& string, ExceptionState& exceptionSt
if (string.isEmpty())
return;

// FIXME: crbug.com/154772 - should this continue to use legacy style parsing?
// FIXME: crbug.com/154722 - should this continue to use legacy style parsing?
RefPtrWillBeRawPtr<MutableStylePropertySet> styleDeclaration = MutableStylePropertySet::create();
if (CSSParser::parseValue(styleDeclaration.get(), CSSPropertyWebkitTransform, string, true, HTMLStandardMode, 0)) {
if (BisonCSSParser::parseValue(styleDeclaration.get(), CSSPropertyWebkitTransform, string, true, HTMLStandardMode, 0)) {
// Convert to TransformOperations. This can fail if a property
// requires style (i.e., param uses 'ems' or 'exs')
RefPtrWillBeRawPtr<CSSValue> value = styleDeclaration->getPropertyCSSValue(CSSPropertyWebkitTransform);
Expand Down
4 changes: 2 additions & 2 deletions Source/core/css/CSSPageRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
#include "config.h"
#include "core/css/CSSPageRule.h"

#include "core/css/parser/BisonCSSParser.h"
#include "core/css/CSSSelector.h"
#include "core/css/CSSStyleSheet.h"
#include "core/css/PropertySetCSSStyleDeclaration.h"
#include "core/css/StylePropertySet.h"
#include "core/css/StyleRule.h"
#include "core/css/parser/CSSParser.h"
#include "wtf/text/StringBuilder.h"

namespace blink {
Expand Down Expand Up @@ -71,7 +71,7 @@ String CSSPageRule::selectorText() const
void CSSPageRule::setSelectorText(const String& selectorText)
{
CSSParserContext context(parserContext(), 0);
CSSParser parser(context);
BisonCSSParser parser(context);
CSSSelectorList selectorList;
parser.parseSelector(selectorText, selectorList);
if (!selectorList.isValid())
Expand Down
4 changes: 2 additions & 2 deletions Source/core/css/CSSStyleRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
#include "config.h"
#include "core/css/CSSStyleRule.h"

#include "core/css/parser/BisonCSSParser.h"
#include "core/css/CSSSelector.h"
#include "core/css/CSSStyleSheet.h"
#include "core/css/PropertySetCSSStyleDeclaration.h"
#include "core/css/StylePropertySet.h"
#include "core/css/StyleRule.h"
#include "core/css/parser/CSSParser.h"
#include "wtf/text/StringBuilder.h"

namespace blink {
Expand Down Expand Up @@ -93,7 +93,7 @@ String CSSStyleRule::selectorText() const
void CSSStyleRule::setSelectorText(const String& selectorText)
{
CSSParserContext context(parserContext(), 0);
CSSParser p(context);
BisonCSSParser p(context);
CSSSelectorList selectorList;
p.parseSelector(selectorText, selectorList);
if (!selectorList.isValid())
Expand Down
5 changes: 3 additions & 2 deletions Source/core/css/CSSStyleSheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
#include "core/SVGNames.h"
#include "core/css/CSSCharsetRule.h"
#include "core/css/CSSImportRule.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/css/CSSRuleList.h"
#include "core/css/MediaList.h"
#include "core/css/StyleRule.h"
#include "core/css/StyleSheetContents.h"
#include "core/css/parser/CSSParser.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/Node.h"
Expand Down Expand Up @@ -310,7 +310,8 @@ unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
return 0;
}
CSSParserContext context(m_contents->parserContext(), UseCounter::getFrom(this));
RefPtrWillBeRawPtr<StyleRuleBase> rule = CSSParser::parseRule(context, m_contents.get(), ruleString);
BisonCSSParser p(context);
RefPtrWillBeRawPtr<StyleRuleBase> rule = p.parseRule(m_contents.get(), ruleString);

if (!rule) {
exceptionState.throwDOMException(SyntaxError, "Failed to parse the rule '" + ruleString + "'.");
Expand Down
2 changes: 1 addition & 1 deletion Source/core/css/CSSValueList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "config.h"
#include "core/css/CSSValueList.h"

#include "core/css/CSSPrimitiveValue.h"
#include "core/css/parser/CSSParserValues.h"
#include "wtf/text/StringBuilder.h"

namespace blink {
Expand Down
4 changes: 2 additions & 2 deletions Source/core/css/CSSValuePool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include "config.h"
#include "core/css/CSSValuePool.h"

#include "core/css/parser/BisonCSSParser.h"
#include "core/css/CSSValueList.h"
#include "core/css/parser/CSSParser.h"
#include "core/rendering/style/RenderStyle.h"

namespace blink {
Expand Down Expand Up @@ -142,7 +142,7 @@ PassRefPtrWillBeRawPtr<CSSValueList> CSSValuePool::createFontFaceValue(const Ato

RefPtrWillBeMember<CSSValueList>& value = m_fontFaceValueCache.add(string, nullptr).storedValue->value;
if (!value)
value = CSSParser::parseFontFaceValue(string);
value = BisonCSSParser::parseFontFaceValue(string);
return value;
}

Expand Down
10 changes: 6 additions & 4 deletions Source/core/css/DOMWindowCSS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#include "core/css/CSSPropertyMetadata.h"
#include "core/css/StylePropertySet.h"
#include "core/css/parser/CSSParser.h"
#include "core/css/parser/BisonCSSParser.h"
#include "wtf/text/WTFString.h"

namespace blink {
Expand Down Expand Up @@ -63,7 +63,7 @@ bool DOMWindowCSS::supports(const String& property, const String& value) const
return false;
ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID));

// CSSParser::parseValue() won't work correctly if !important is present,
// BisonCSSParser::parseValue() won't work correctly if !important is present,
// so just get rid of it. It doesn't matter to supports() if it's actually
// there or not, provided how it's specified in the value is correct.
String normalizedValue = value.stripWhiteSpace().simplifyWhiteSpace();
Expand All @@ -73,12 +73,14 @@ bool DOMWindowCSS::supports(const String& property, const String& value) const
return false;

RefPtrWillBeRawPtr<MutableStylePropertySet> dummyStyle = MutableStylePropertySet::create();
return CSSParser::parseValue(dummyStyle.get(), propertyID, normalizedValue, false, HTMLStandardMode, 0);
return BisonCSSParser::parseValue(dummyStyle.get(), propertyID, normalizedValue, false, HTMLStandardMode, 0);
}

bool DOMWindowCSS::supports(const String& conditionText) const
{
return CSSParser::parseSupportsCondition(conditionText);
CSSParserContext context(HTMLStandardMode, 0);
BisonCSSParser parser(context);
return parser.parseSupportsCondition(conditionText);
}

}
6 changes: 2 additions & 4 deletions Source/core/css/FontFace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "core/css/RemoteFontFaceSource.h"
#include "core/css/StylePropertySet.h"
#include "core/css/StyleRule.h"
#include "core/css/parser/CSSParser.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/dom/DOMException.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
Expand All @@ -61,14 +61,12 @@

namespace blink {

// FIXME: This should probably live in CSSParser since the same logic is
// duplicated elsewhere in the codebase
static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document, const String& s, CSSPropertyID propertyID)
{
if (s.isEmpty())
return nullptr;
RefPtrWillBeRawPtr<MutableStylePropertySet> parsedStyle = MutableStylePropertySet::create();
CSSParser::parseValue(parsedStyle.get(), propertyID, s, true, *document);
BisonCSSParser::parseValue(parsedStyle.get(), propertyID, s, true, *document);
return parsedStyle->getPropertyCSSValue(propertyID);
}

Expand Down
4 changes: 2 additions & 2 deletions Source/core/css/FontFaceSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "core/css/FontFaceCache.h"
#include "core/css/FontFaceSetLoadEvent.h"
#include "core/css/StylePropertySet.h"
#include "core/css/parser/CSSParser.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/dom/Document.h"
#include "core/dom/StyleEngine.h"
Expand Down Expand Up @@ -496,7 +496,7 @@ bool FontFaceSet::resolveFontStyle(const String& fontString, Font& font)

// Interpret fontString in the same way as the 'font' attribute of CanvasRenderingContext2D.
RefPtrWillBeRawPtr<MutableStylePropertySet> parsedStyle = MutableStylePropertySet::create();
CSSParser::parseValue(parsedStyle.get(), CSSPropertyFont, fontString, true, HTMLStandardMode, 0);
BisonCSSParser::parseValue(parsedStyle.get(), CSSPropertyFont, fontString, true, HTMLStandardMode, 0);
if (parsedStyle->isEmpty())
return false;

Expand Down
1 change: 1 addition & 0 deletions Source/core/css/MediaList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "bindings/core/v8/ExceptionState.h"
#include "core/MediaFeatureNames.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/css/CSSStyleSheet.h"
#include "core/css/MediaQuery.h"
#include "core/css/MediaQueryExp.h"
Expand Down
2 changes: 1 addition & 1 deletion Source/core/css/PropertySetCSSStyleDeclaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

#include "bindings/core/v8/ExceptionState.h"
#include "core/HTMLNames.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/css/CSSStyleSheet.h"
#include "core/css/StylePropertySet.h"
#include "core/css/parser/CSSParser.h"
#include "core/dom/Element.h"
#include "core/dom/MutationObserverInterestGroup.h"
#include "core/dom/MutationRecord.h"
Expand Down
Loading

0 comments on commit a85c412

Please sign in to comment.