https://bugs.webkit.org/show_bug.cgi?id=82335
Source/WebCore:
Reviewed by Ryosuke Niwa.
Introduce the new CSSParserMode enum to more classes. SVG classes make use of SVGAttributeMode for CSS parsing already.
But SVGAttributeMode does not differ from CSSQuirksMode at the moment. This will change with a followup patch on bug 46112.
No new tests. No change of functionality. Everything gets covered by existing tests.
* css/CSSImportRule.cpp:
(WebCore::CSSImportRule::setCSSStyleSheet):
* css/CSSMediaRule.cpp:
(WebCore::CSSMediaRule::insertRule):
* css/CSSParser.cpp: Move private functions away from strict boolean and make use of CSSParserMode instead.
(WebCore):
(WebCore::parseColorValue):
(WebCore::parseSimpleLengthValue):
(WebCore::CSSParser::parseFontFaceValue):
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseColor):
(WebCore::CSSParser::createStyleRule):
(WebCore::CSSParser::createFontFaceRule):
(WebCore::CSSParser::createPageRule):
(WebCore::CSSParser::createKeyframeRule):
* css/CSSParser.h: Removed constructor with boolean argument. We just use the CSSParserMode enum now.
(CSSParser):
* css/CSSParserMode.h:
(strictToCSSParserMode): New helper function to convert boolean to CSSParserMode.
(isStrictParserMode): Helper function that returns true if argument is CSSStrictMode.
* css/CSSRule.h:
(WebCore::CSSRule::cssParserMode): Renamed useStrictParsing to cssParserMode since it returns CSSParserMode instead of a boolean now.
* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::CSSStyleSheet):
(WebCore::CSSStyleSheet::insertRule):
(WebCore::CSSStyleSheet::parseString):
(WebCore::CSSStyleSheet::parseStringAtLine):
* css/CSSStyleSheet.h:
(CSSStyleSheet):
(WebCore::CSSStyleSheet::setCSSParserMode): Renamed setStrictParsing to setCSSParserMode since we set an enum now.
(WebCore::CSSStyleSheet::cssParserMode): Renamed useStrictParsing to cssParserMode since it returns CSSParserMode instead of a boolean now.
* css/MediaList.cpp:
(WebCore::MediaQuerySet::parse):
(WebCore::MediaQuerySet::add):
(WebCore::MediaQuerySet::remove):
* css/StylePropertySet.cpp:
(WebCore::StylePropertySet::StylePropertySet):
(WebCore::StylePropertySet::setProperty):
(WebCore::StylePropertySet::parseDeclaration):
* css/StylePropertySet.h: Use unsigned member variables to store the parser mode.
(WebCore::StylePropertySet::create):
(WebCore::StylePropertySet::setCSSParserMode): Renamed setStrictParsing to setCSSParserMode since we get an enum now. This gets converted to unsigned internally.
(WebCore::StylePropertySet::cssParserMode): Renamed useStrictParsing to cssParserMode since it returns CSSParserMode instead of a boolean now.
(StylePropertySet):
* css/StyleSheet.h:
(StyleSheet):
* css/WebKitCSSKeyframesRule.cpp:
(WebCore::WebKitCSSKeyframesRule::insertRule):
* css/WebKitCSSMatrix.cpp:
(WebCore::WebKitCSSMatrix::setMatrixValue):
* dom/Document.cpp:
(WebCore::Document::webkitGetFlowByName):
(WebCore::Document::pageUserSheet):
(WebCore::Document::pageGroupUserSheets):
* dom/Element.cpp:
(WebCore::Element::webkitMatchesSelector):
* dom/ElementAttributeData.cpp:
(WebCore::ElementAttributeData::ensureInlineStyle):
(WebCore::ElementAttributeData::ensureMutableInlineStyle):
(WebCore::ElementAttributeData::updateInlineStyleAvoidingMutation):
* dom/Node.cpp:
(WebCore::Node::querySelector):
(WebCore::Node::querySelectorAll):
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::parseStyleSheet):
* dom/StyleElement.cpp:
(WebCore::StyleElement::createSheet):
* html/HTMLElement.cpp:
(WebCore::StyledElement::copyNonAttributeProperties):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::setCSSStyleSheet):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::setFont):
* html/shadow/ContentSelectorQuery.cpp:
(WebCore::ContentSelectorQuery::ContentSelectorQuery):
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::reparseStyleSheet):
* svg/SVGElementRareData.h:
(WebCore::SVGElementRareData::ensureAnimatedSMILStyleProperties):
* svg/SVGFontFaceElement.cpp:
(WebCore::SVGFontFaceElement::SVGFontFaceElement):
* svg/SVGStyledElement.cpp:
(WebCore::SVGStyledElement::getPresentationAttribute):
* xml/XSLStyleSheet.h:
(XSLStyleSheet):
* xml/XSLStyleSheetLibxslt.cpp:
(WebCore::XSLStyleSheet::parseString):
* xml/XSLStyleSheetQt.cpp:
(WebCore::XSLStyleSheet::parseString):
Source/WebKit/chromium:
Use CSSParserMode for setting the parsing mode on parseValue.
* src/WebDocument.cpp:
(WebKit::WebDocument::insertUserStyleSheet):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@112537
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-03-28 Dirk Schulze <krit@webkit.org>
+
+ Introduce CSSParserMode in all classes
+ https://bugs.webkit.org/show_bug.cgi?id=82335
+
+ Reviewed by Ryosuke Niwa.
+
+ Introduce the new CSSParserMode enum to more classes. SVG classes make use of SVGAttributeMode for CSS parsing already.
+ But SVGAttributeMode does not differ from CSSQuirksMode at the moment. This will change with a followup patch on bug 46112.
+
+ No new tests. No change of functionality. Everything gets covered by existing tests.
+
+ * css/CSSImportRule.cpp:
+ (WebCore::CSSImportRule::setCSSStyleSheet):
+ * css/CSSMediaRule.cpp:
+ (WebCore::CSSMediaRule::insertRule):
+ * css/CSSParser.cpp: Move private functions away from strict boolean and make use of CSSParserMode instead.
+ (WebCore):
+ (WebCore::parseColorValue):
+ (WebCore::parseSimpleLengthValue):
+ (WebCore::CSSParser::parseFontFaceValue):
+ (WebCore::CSSParser::parseValue):
+ (WebCore::CSSParser::parseColor):
+ (WebCore::CSSParser::createStyleRule):
+ (WebCore::CSSParser::createFontFaceRule):
+ (WebCore::CSSParser::createPageRule):
+ (WebCore::CSSParser::createKeyframeRule):
+ * css/CSSParser.h: Removed constructor with boolean argument. We just use the CSSParserMode enum now.
+ (CSSParser):
+ * css/CSSParserMode.h:
+ (strictToCSSParserMode): New helper function to convert boolean to CSSParserMode.
+ (isStrictParserMode): Helper function that returns true if argument is CSSStrictMode.
+ * css/CSSRule.h:
+ (WebCore::CSSRule::cssParserMode): Renamed useStrictParsing to cssParserMode since it returns CSSParserMode instead of a boolean now.
+ * css/CSSStyleSheet.cpp:
+ (WebCore::CSSStyleSheet::CSSStyleSheet):
+ (WebCore::CSSStyleSheet::insertRule):
+ (WebCore::CSSStyleSheet::parseString):
+ (WebCore::CSSStyleSheet::parseStringAtLine):
+ * css/CSSStyleSheet.h:
+ (CSSStyleSheet):
+ (WebCore::CSSStyleSheet::setCSSParserMode): Renamed setStrictParsing to setCSSParserMode since we set an enum now.
+ (WebCore::CSSStyleSheet::cssParserMode): Renamed useStrictParsing to cssParserMode since it returns CSSParserMode instead of a boolean now.
+ * css/MediaList.cpp:
+ (WebCore::MediaQuerySet::parse):
+ (WebCore::MediaQuerySet::add):
+ (WebCore::MediaQuerySet::remove):
+ * css/StylePropertySet.cpp:
+ (WebCore::StylePropertySet::StylePropertySet):
+ (WebCore::StylePropertySet::setProperty):
+ (WebCore::StylePropertySet::parseDeclaration):
+ * css/StylePropertySet.h: Use unsigned member variables to store the parser mode.
+ (WebCore::StylePropertySet::create):
+ (WebCore::StylePropertySet::setCSSParserMode): Renamed setStrictParsing to setCSSParserMode since we get an enum now. This gets converted to unsigned internally.
+ (WebCore::StylePropertySet::cssParserMode): Renamed useStrictParsing to cssParserMode since it returns CSSParserMode instead of a boolean now.
+ (StylePropertySet):
+ * css/StyleSheet.h:
+ (StyleSheet):
+ * css/WebKitCSSKeyframesRule.cpp:
+ (WebCore::WebKitCSSKeyframesRule::insertRule):
+ * css/WebKitCSSMatrix.cpp:
+ (WebCore::WebKitCSSMatrix::setMatrixValue):
+ * dom/Document.cpp:
+ (WebCore::Document::webkitGetFlowByName):
+ (WebCore::Document::pageUserSheet):
+ (WebCore::Document::pageGroupUserSheets):
+ * dom/Element.cpp:
+ (WebCore::Element::webkitMatchesSelector):
+ * dom/ElementAttributeData.cpp:
+ (WebCore::ElementAttributeData::ensureInlineStyle):
+ (WebCore::ElementAttributeData::ensureMutableInlineStyle):
+ (WebCore::ElementAttributeData::updateInlineStyleAvoidingMutation):
+ * dom/Node.cpp:
+ (WebCore::Node::querySelector):
+ (WebCore::Node::querySelectorAll):
+ * dom/ProcessingInstruction.cpp:
+ (WebCore::ProcessingInstruction::parseStyleSheet):
+ * dom/StyleElement.cpp:
+ (WebCore::StyleElement::createSheet):
+ * html/HTMLElement.cpp:
+ (WebCore::StyledElement::copyNonAttributeProperties):
+ * html/HTMLLinkElement.cpp:
+ (WebCore::HTMLLinkElement::setCSSStyleSheet):
+ * html/canvas/CanvasRenderingContext2D.cpp:
+ (WebCore::CanvasRenderingContext2D::setFont):
+ * html/shadow/ContentSelectorQuery.cpp:
+ (WebCore::ContentSelectorQuery::ContentSelectorQuery):
+ * inspector/InspectorStyleSheet.cpp:
+ (WebCore::InspectorStyleSheet::reparseStyleSheet):
+ * svg/SVGElementRareData.h:
+ (WebCore::SVGElementRareData::ensureAnimatedSMILStyleProperties):
+ * svg/SVGFontFaceElement.cpp:
+ (WebCore::SVGFontFaceElement::SVGFontFaceElement):
+ * svg/SVGStyledElement.cpp:
+ (WebCore::SVGStyledElement::getPresentationAttribute):
+ * xml/XSLStyleSheet.h:
+ (XSLStyleSheet):
+ * xml/XSLStyleSheetLibxslt.cpp:
+ (WebCore::XSLStyleSheet::parseString):
+ * xml/XSLStyleSheetQt.cpp:
+ (WebCore::XSLStyleSheet::parseString):
+
2012-03-29 Sanghyun Park <sh919.park@samsung.com>
Fix the error type in JSAudioBufferSourceNodeCustom to pass layout test.
bool crossOriginCSS = false;
bool validMIMEType = false;
CSSStyleSheet* parent = parentStyleSheet();
- bool strict = !parent || parent->useStrictParsing();
- bool enforceMIMEType = strict;
+ CSSParserMode cssParserMode = parent ? parent->cssParserMode() : CSSStrictMode;
+ bool enforceMIMEType = isStrictParserMode(cssParserMode);
Document* document = parent ? parent->findDocument() : 0;
bool needsSiteSpecificQuirks = document && document->settings() && document->settings()->needsSiteSpecificQuirks();
#endif
String sheetText = sheet->sheetText(enforceMIMEType, &validMIMEType);
- m_styleSheet->parseString(sheetText, strict);
+ m_styleSheet->parseString(sheetText, cssParserMode);
if (!document || !document->securityOrigin()->canRequest(baseURL))
crossOriginCSS = true;
if (crossOriginCSS && !validMIMEType && !m_styleSheet->hasSyntacticallyValidCSSHeader())
m_styleSheet = CSSStyleSheet::create(this, href, baseURL, charset);
- if (strict && needsSiteSpecificQuirks) {
+ if (isStrictParserMode(cssParserMode) && needsSiteSpecificQuirks) {
// Work around <https://bugs.webkit.org/show_bug.cgi?id=28350>.
DEFINE_STATIC_LOCAL(const String, slashKHTMLFixesDotCss, ("/KHTMLFixes.css"));
DEFINE_STATIC_LOCAL(const String, mediaWikiKHTMLFixesStyleSheet, ("/* KHTML fix stylesheet */\n/* work around the horizontal scrollbars */\n#column-content { margin-left: 0; }\n\n"));
return 0;
}
- CSSParser p(useStrictParsing());
+ CSSParser p(cssParserMode());
RefPtr<CSSRule> newRule = p.parseRule(parentStyleSheet(), rule);
if (!newRule) {
// SYNTAX_ERR: Raised if the specified rule has a syntax error and is unparsable.
m_cssValuePool = CSSValuePool::create();
}
-CSSParser::CSSParser(bool strictParsing)
- : m_cssParserMode(strictParsing ? CSSStrictMode : CSSQuirksMode)
- , m_important(false)
- , m_id(0)
- , m_styleSheet(0)
- , m_inParseShorthand(0)
- , m_currentShorthand(0)
- , m_implicitShorthand(false)
- , m_hasFontFaceOnlyValues(false)
- , m_hadSyntacticallyValidCSSRule(false)
- , m_defaultNamespace(starAtom)
- , m_inStyleRuleOrDeclaration(false)
- , m_selectorListRange(0, 0)
- , m_ruleBodyRange(0, 0)
- , m_propertyRange(UINT_MAX, UINT_MAX)
- , m_ruleRangeMap(0)
- , m_currentRuleData(0)
- , m_parsingMode(NormalMode)
- , m_currentCharacter(0)
- , m_token(0)
- , m_lineNumber(0)
- , m_lastSelectorLineNumber(0)
- , m_allowImportRules(true)
- , m_allowNamespaceDeclarations(true)
-{
-#if YYDEBUG > 0
- cssyydebug = 1;
-#endif
- CSSPropertySourceData::init();
-}
-
-
CSSParser::CSSParser(CSSParserMode cssParserMode)
: m_cssParserMode(cssParserMode)
, m_important(false)
}
}
-static bool parseColorValue(StylePropertySet* declaration, int propertyId, const String& string, bool important, bool strict, CSSStyleSheet* contextStyleSheet)
+static bool parseColorValue(StylePropertySet* declaration, int propertyId, const String& string, bool important, CSSParserMode cssParserMode, CSSStyleSheet* contextStyleSheet)
{
+ bool strict = isStrictParserMode(cssParserMode);
if (!string.length())
return false;
if (!isColorPropertyID(propertyId))
}
}
-static bool parseSimpleLengthValue(StylePropertySet* declaration, int propertyId, const String& string, bool important, bool strict, CSSStyleSheet* contextStyleSheet)
+static bool parseSimpleLengthValue(StylePropertySet* declaration, int propertyId, const String& string, bool important, CSSParserMode cssParserMode, CSSStyleSheet* contextStyleSheet)
{
bool acceptsNegativeNumbers;
+ bool strict = isStrictParserMode(cssParserMode);
unsigned length = string.length();
if (!length)
PassRefPtr<CSSValueList> CSSParser::parseFontFaceValue(const AtomicString& string, CSSStyleSheet* contextStyleSheet)
{
RefPtr<StylePropertySet> dummyStyle = StylePropertySet::create();
- if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, false, contextStyleSheet))
+ if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, CSSQuirksMode, contextStyleSheet))
return 0;
return static_pointer_cast<CSSValueList>(dummyStyle->getPropertyCSSValue(CSSPropertyFontFamily));
}
-bool CSSParser::parseValue(StylePropertySet* declaration, int propertyId, const String& string, bool important, bool strict, CSSStyleSheet* contextStyleSheet)
+bool CSSParser::parseValue(StylePropertySet* declaration, int propertyId, const String& string, bool important, CSSParserMode cssParserMode, CSSStyleSheet* contextStyleSheet)
{
- if (parseSimpleLengthValue(declaration, propertyId, string, important, strict, contextStyleSheet))
+ if (parseSimpleLengthValue(declaration, propertyId, string, important, cssParserMode, contextStyleSheet))
return true;
- if (parseColorValue(declaration, propertyId, string, important, strict, contextStyleSheet))
+ if (parseColorValue(declaration, propertyId, string, important, cssParserMode, contextStyleSheet))
return true;
if (parseKeywordValue(declaration, propertyId, string, important, contextStyleSheet))
return true;
- CSSParser parser(strict);
+ CSSParser parser(cssParserMode);
return parser.parseValue(declaration, propertyId, string, important, contextStyleSheet);
}
if (fastParseColor(color, string, strict))
return true;
- CSSParser parser(true);
+ CSSParser parser(CSSStrictMode);
// In case the fast-path parser didn't understand the color, try the full parser.
if (!parser.parseColor(string))
rule->styleRule()->adoptSelectorVector(*selectors);
if (m_hasFontFaceOnlyValues)
deleteFontFaceOnlyValues();
- rule->styleRule()->setProperties(StylePropertySet::create(m_parsedProperties.data(), m_parsedProperties.size(), inStrictMode()));
+ rule->styleRule()->setProperties(StylePropertySet::create(m_parsedProperties.data(), m_parsedProperties.size(), m_cssParserMode));
result = rule.get();
m_parsedRules.append(rule.release());
if (m_ruleRangeMap) {
}
}
RefPtr<CSSFontFaceRule> rule = CSSFontFaceRule::create(m_styleSheet);
- rule->setDeclaration(StylePropertySet::create(m_parsedProperties.data(), m_parsedProperties.size(), inStrictMode()));
+ rule->setDeclaration(StylePropertySet::create(m_parsedProperties.data(), m_parsedProperties.size(), m_cssParserMode));
clearProperties();
CSSFontFaceRule* result = rule.get();
m_parsedRules.append(rule.release());
Vector<OwnPtr<CSSParserSelector> > selectorVector;
selectorVector.append(pageSelector);
rule->adoptSelectorVector(selectorVector);
- rule->setDeclaration(StylePropertySet::create(m_parsedProperties.data(), m_parsedProperties.size(), inStrictMode()));
+ rule->setDeclaration(StylePropertySet::create(m_parsedProperties.data(), m_parsedProperties.size(), m_cssParserMode));
pageRule = rule.get();
m_parsedRules.append(rule.release());
}
RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create();
keyframe->setKeyText(keyString);
- keyframe->setProperties(StylePropertySet::create(m_parsedProperties.data(), m_parsedProperties.size(), inStrictMode()));
+ keyframe->setProperties(StylePropertySet::create(m_parsedProperties.data(), m_parsedProperties.size(), m_cssParserMode));
clearProperties();
class CSSParser {
public:
-
- // FIXME: Remove the boolean constructor once moved to CSSParserMode completely.
- CSSParser(bool strictParsing);
CSSParser(CSSParserMode = CSSStrictMode);
~CSSParser();
void parseSheet(CSSStyleSheet*, const String&, int startLineNumber = 0, StyleRuleRangeMap* ruleRangeMap = 0);
PassRefPtr<CSSRule> parseRule(CSSStyleSheet*, const String&);
PassRefPtr<StyleKeyframe> parseKeyframeRule(CSSStyleSheet*, const String&);
- static bool parseValue(StylePropertySet*, int propId, const String&, bool important, bool strict, CSSStyleSheet* contextStyleSheet);
+ static bool parseValue(StylePropertySet*, int propId, const String&, bool important, CSSParserMode, CSSStyleSheet* contextStyleSheet);
static bool parseColor(RGBA32& color, const String&, bool strict = false);
static bool parseSystemColor(RGBA32& color, const String&, Document*);
static PassRefPtr<CSSValueList> parseFontFaceValue(const AtomicString&, CSSStyleSheet* contextStyleSheet);
SVGAttributeMode
};
+inline CSSParserMode strictToCSSParserMode(bool inStrictMode)
+{
+ return inStrictMode ? CSSStrictMode : CSSQuirksMode;
+}
+
+inline bool isStrictParserMode(CSSParserMode cssParserMode)
+{
+ // FIXME: SVG presnetation attribute values should be parsed in strict mode as well.
+ return cssParserMode == CSSStrictMode;
+}
+
#endif // CSSParserMode_h
bool isRegionRule() const { return type() == WEBKIT_REGION_RULE; }
bool isImportRule() const { return type() == IMPORT_RULE; }
- bool useStrictParsing() const
+ CSSParserMode cssParserMode() const
{
if (parentRule())
- return parentRule()->useStrictParsing();
+ return parentRule()->cssParserMode();
if (parentStyleSheet())
- return parentStyleSheet()->useStrictParsing();
- return true;
+ return parentStyleSheet()->cssParserMode();
+ return CSSStrictMode;
}
void setParentStyleSheet(CSSStyleSheet* styleSheet)
: StyleSheet(parentNode, href, baseURL)
, m_charset(charset)
, m_loadCompleted(false)
- , m_strictParsing(false)
+ , m_cssParserMode(CSSQuirksMode)
, m_isUserStyleSheet(false)
, m_hasSyntacticallyValidCSSHeader(true)
, m_didLoadErrorOccur(false)
: StyleSheet(ownerRule, href, baseURL)
, m_charset(charset)
, m_loadCompleted(false)
- , m_strictParsing(!ownerRule || ownerRule->useStrictParsing())
+ , m_cssParserMode(ownerRule ? ownerRule->cssParserMode() : CSSStrictMode)
, m_hasSyntacticallyValidCSSHeader(true)
, m_didLoadErrorOccur(false)
{
ec = INDEX_SIZE_ERR;
return 0;
}
- CSSParser p(useStrictParsing());
+ CSSParser p(cssParserMode());
RefPtr<CSSRule> rule = p.parseRule(this, ruleString);
if (!rule) {
return nullAtom; // Assume we won't match any namespaces.
}
-bool CSSStyleSheet::parseString(const String &string, bool strict)
+bool CSSStyleSheet::parseString(const String &string, CSSParserMode cssParserMode)
{
- return parseStringAtLine(string, strict, 0);
+ return parseStringAtLine(string, cssParserMode, 0);
}
-bool CSSStyleSheet::parseStringAtLine(const String& string, bool strict, int startLineNumber)
+bool CSSStyleSheet::parseStringAtLine(const String& string, CSSParserMode cssParserMode, int startLineNumber)
{
- setStrictParsing(strict);
- CSSParser p(strict);
+ setCSSParserMode(cssParserMode);
+ CSSParser p(cssParserMode);
p.parseSheet(this, string, startLineNumber);
return true;
}
#ifndef CSSStyleSheet_h
#define CSSStyleSheet_h
+#include "CSSParserMode.h"
#include "StyleSheet.h"
namespace WebCore {
void styleSheetChanged();
- virtual bool parseString(const String&, bool strict = true);
+ virtual bool parseString(const String&, CSSParserMode = CSSStrictMode);
- bool parseStringAtLine(const String&, bool strict, int startLineNumber);
+ bool parseStringAtLine(const String&, CSSParserMode, int startLineNumber);
virtual bool isLoading();
KURL completeURL(const String& url) const;
void addSubresourceStyleURLs(ListHashSet<KURL>&);
- void setStrictParsing(bool b) { m_strictParsing = b; }
- bool useStrictParsing() const { return m_strictParsing; }
+ void setCSSParserMode(CSSParserMode cssParserMode) { m_cssParserMode = cssParserMode; }
+ CSSParserMode cssParserMode() const { return m_cssParserMode; }
void setIsUserStyleSheet(bool b) { m_isUserStyleSheet = b; }
bool isUserStyleSheet() const { return m_isUserStyleSheet; }
RefPtr<MediaQuerySet> m_mediaQueries;
bool m_loadCompleted : 1;
- bool m_strictParsing : 1;
+ CSSParserMode m_cssParserMode;
bool m_isUserStyleSheet : 1;
bool m_hasSyntacticallyValidCSSHeader : 1;
bool m_didLoadErrorOccur : 1;
bool MediaQuerySet::parse(const String& mediaString)
{
- CSSParser parser(true);
+ CSSParser parser(CSSStrictMode);
Vector<OwnPtr<MediaQuery> > result;
Vector<String> list;
bool MediaQuerySet::add(const String& queryString)
{
- CSSParser parser(true);
+ CSSParser parser(CSSStrictMode);
OwnPtr<MediaQuery> parsedQuery = parser.parseMediaQuery(queryString);
if (!parsedQuery && m_fallbackToDescriptor) {
bool MediaQuerySet::remove(const String& queryStringToRemove)
{
- CSSParser parser(true);
+ CSSParser parser(CSSStrictMode);
OwnPtr<MediaQuery> parsedQuery = parser.parseMediaQuery(queryStringToRemove);
if (!parsedQuery && m_fallbackToDescriptor) {
return propertySetCSSOMWrapperMapInstance;
}
-StylePropertySet::StylePropertySet()
- : m_strictParsing(false)
+StylePropertySet::StylePropertySet(CSSParserMode cssParserMode)
+ : m_cssParserMode(cssParserMode)
, m_hasCSSOMWrapper(false)
{
}
StylePropertySet::StylePropertySet(const Vector<CSSProperty>& properties)
: m_properties(properties)
- , m_strictParsing(true)
+ , m_cssParserMode(CSSStrictMode)
, m_hasCSSOMWrapper(false)
{
m_properties.shrinkToFit();
}
-StylePropertySet::StylePropertySet(const CSSProperty* properties, int numProperties, bool useStrictParsing)
- : m_strictParsing(useStrictParsing)
+StylePropertySet::StylePropertySet(const CSSProperty* properties, int numProperties, CSSParserMode cssParserMode)
+ : m_cssParserMode(cssParserMode)
, m_hasCSSOMWrapper(false)
{
// FIXME: This logic belongs in CSSParser.
// When replacing an existing property value, this moves the property to the end of the list.
// Firefox preserves the position, and MSIE moves the property to the beginning.
- return CSSParser::parseValue(this, propertyID, value, important, useStrictParsing(), contextStyleSheet);
+ return CSSParser::parseValue(this, propertyID, value, important, cssParserMode(), contextStyleSheet);
}
void StylePropertySet::setProperty(int propertyID, PassRefPtr<CSSValue> prpValue, bool important)
void StylePropertySet::parseDeclaration(const String& styleDeclaration, CSSStyleSheet* contextStyleSheet)
{
m_properties.clear();
- CSSParser parser(useStrictParsing());
+ CSSParser parser(cssParserMode());
parser.parseDeclaration(this, styleDeclaration, 0, contextStyleSheet);
}
#ifndef StylePropertySet_h
#define StylePropertySet_h
+#include "CSSParserMode.h"
#include "CSSPrimitiveValue.h"
#include "CSSProperty.h"
#include <wtf/ListHashSet.h>
public:
~StylePropertySet();
- static PassRefPtr<StylePropertySet> create()
+ static PassRefPtr<StylePropertySet> create(CSSParserMode cssParserMode = CSSQuirksMode)
{
- return adoptRef(new StylePropertySet);
+ return adoptRef(new StylePropertySet(cssParserMode));
}
- static PassRefPtr<StylePropertySet> create(const CSSProperty* properties, int numProperties, bool useStrictParsing)
+ static PassRefPtr<StylePropertySet> create(const CSSProperty* properties, int numProperties, CSSParserMode cssParserMode)
{
- return adoptRef(new StylePropertySet(properties, numProperties, useStrictParsing));
+ return adoptRef(new StylePropertySet(properties, numProperties, cssParserMode));
}
static PassRefPtr<StylePropertySet> create(const Vector<CSSProperty>& properties)
{
void merge(const StylePropertySet*, bool argOverridesOnConflict = true);
- void setStrictParsing(bool b) { m_strictParsing = b; }
- bool useStrictParsing() const { return m_strictParsing; }
+ void setCSSParserMode(CSSParserMode cssParserMode) { m_cssParserMode = cssParserMode; }
+ CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); }
void addSubresourceStyleURLs(ListHashSet<KURL>&, CSSStyleSheet* contextStyleSheet);
bool hasCSSOMWrapper() const { return m_hasCSSOMWrapper; }
private:
- StylePropertySet();
+ StylePropertySet(CSSParserMode);
StylePropertySet(const Vector<CSSProperty>&);
- StylePropertySet(const CSSProperty*, int numProperties, bool useStrictParsing);
+ StylePropertySet(const CSSProperty*, int numProperties, CSSParserMode);
void setNeedsStyleRecalc();
Vector<CSSProperty, 4> m_properties;
- bool m_strictParsing : 1;
- mutable bool m_hasCSSOMWrapper : 1;
+ unsigned m_cssParserMode : 2;
+ mutable unsigned m_hasCSSOMWrapper : 1;
friend class PropertySetCSSStyleDeclaration;
};
#ifndef StyleSheet_h
#define StyleSheet_h
+#include "CSSParserMode.h"
#include "KURLHash.h"
#include "PlatformString.h"
#include <wtf/ListHashSet.h>
virtual String type() const = 0;
virtual bool isLoading() = 0;
- virtual bool parseString(const String&, bool strict = true) = 0;
+ virtual bool parseString(const String&, CSSParserMode = CSSStrictMode) = 0;
virtual bool isCSSStyleSheet() const { return false; }
virtual bool isXSLStyleSheet() const { return false; }
void WebKitCSSKeyframesRule::insertRule(const String& ruleText)
{
- CSSParser p(useStrictParsing());
+ CSSParser p(cssParserMode());
RefPtr<StyleKeyframe> keyframe = p.parseKeyframeRule(parentStyleSheet(), ruleText);
if (!keyframe)
return;
void WebKitCSSMatrix::setMatrixValue(const String& string, ExceptionCode& ec)
{
RefPtr<StylePropertySet> styleDeclaration = StylePropertySet::create();
- if (CSSParser::parseValue(styleDeclaration.get(), CSSPropertyWebkitTransform, string, true, true, 0)) {
+ if (CSSParser::parseValue(styleDeclaration.get(), CSSPropertyWebkitTransform, string, true, CSSStrictMode, 0)) {
// Convert to TransformOperations. This can fail if a property
// requires style (i.e., param uses 'ems' or 'exs')
RefPtr<CSSValue> value = styleDeclaration->getPropertyCSSValue(CSSPropertyWebkitTransform);
return 0;
// Make a slower check for invalid flow name
- CSSParser p(true);
- if (!p.parseFlowThread(flowName, this))
+ CSSParser parser(CSSStrictMode);
+ if (!parser.parseFlowThread(flowName, this))
return 0;
if (RenderView* view = renderer()->view())
// Parse the sheet and cache it.
m_pageUserSheet = CSSStyleSheet::createInline(this, settings()->userStyleSheetLocation());
m_pageUserSheet->setIsUserStyleSheet(true);
- m_pageUserSheet->parseString(userSheetText, !inQuirksMode());
+ m_pageUserSheet->parseString(userSheetText, strictToCSSParserMode(!inQuirksMode()));
return m_pageUserSheet.get();
}
continue;
RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::createInline(const_cast<Document*>(this), sheet->url());
parsedSheet->setIsUserStyleSheet(sheet->level() == UserStyleUserLevel);
- parsedSheet->parseString(sheet->source(), !inQuirksMode());
+ parsedSheet->parseString(sheet->source(), strictToCSSParserMode(!inQuirksMode()));
if (!m_pageGroupUserSheets)
m_pageGroupUserSheets = adoptPtr(new Vector<RefPtr<CSSStyleSheet> >);
m_pageGroupUserSheets->append(parsedSheet.release());
}
bool strictParsing = !document()->inQuirksMode();
- CSSParser p(strictParsing);
+ CSSParser p(strictToCSSParserMode(strictParsing));
CSSSelectorList selectorList;
p.parseSelector(selector, document(), selectorList);
if (!m_inlineStyleDecl) {
ASSERT(element->isStyledElement());
m_inlineStyleDecl = StylePropertySet::create();
- m_inlineStyleDecl->setStrictParsing(element->isHTMLElement() && !element->document()->inQuirksMode());
+ m_inlineStyleDecl->setCSSParserMode(strictToCSSParserMode(element->isHTMLElement() && !element->document()->inQuirksMode()));
}
return m_inlineStyleDecl.get();
}
{
if (m_inlineStyleDecl && !m_inlineStyleDecl->hasCSSOMWrapper()) {
m_inlineStyleDecl = m_inlineStyleDecl->copy();
- m_inlineStyleDecl->setStrictParsing(element->isHTMLElement() && !element->document()->inQuirksMode());
+ m_inlineStyleDecl->setCSSParserMode(strictToCSSParserMode(element->isHTMLElement() && !element->document()->inQuirksMode()));
return m_inlineStyleDecl.get();
}
return ensureInlineStyle(element);
m_inlineStyleDecl.clear();
if (!m_inlineStyleDecl) {
m_inlineStyleDecl = StylePropertySet::create();
- m_inlineStyleDecl->setStrictParsing(element->isHTMLElement() && !element->document()->inQuirksMode());
+ m_inlineStyleDecl->setCSSParserMode(strictToCSSParserMode(element->isHTMLElement() && !element->document()->inQuirksMode()));
}
m_inlineStyleDecl->parseDeclaration(text, element->document()->elementSheet());
}
return 0;
}
bool strictParsing = !document()->inQuirksMode();
- CSSParser p(strictParsing);
+ CSSParser p(strictToCSSParserMode(strictParsing));
CSSSelectorList querySelectorList;
p.parseSelector(selectors, document(), querySelectorList);
return 0;
}
bool strictParsing = !document()->inQuirksMode();
- CSSParser p(strictParsing);
+ CSSParser p(strictToCSSParserMode(strictParsing));
CSSSelectorList querySelectorList;
p.parseSelector(selectors, document(), querySelectorList);
void ProcessingInstruction::parseStyleSheet(const String& sheet)
{
- m_sheet->parseString(sheet, true);
+ m_sheet->parseString(sheet, CSSStrictMode);
if (m_cachedSheet)
m_cachedSheet->removeClient(this);
m_cachedSheet = 0;
document->addPendingSheet();
m_loading = true;
m_sheet = CSSStyleSheet::create(e, String(), KURL(), document->inputEncoding());
- m_sheet->parseStringAtLine(text, !document->inQuirksMode(), startLineNumber);
+ m_sheet->parseStringAtLine(text, strictToCSSParserMode(!document->inQuirksMode()), startLineNumber);
m_sheet->setMediaQueries(mediaQueries.release());
m_sheet->setTitle(e->title());
m_loading = false;
StylePropertySet* inlineStyle = ensureAttributeData()->ensureMutableInlineStyle(this);
inlineStyle->copyPropertiesFrom(*source->inlineStyle());
- inlineStyle->setStrictParsing(source->inlineStyle()->useStrictParsing());
+ inlineStyle->setCSSParserMode(source->inlineStyle()->cssParserMode());
setIsStyleAttributeValid(source->isStyleAttributeValid());
#include "HTMLLinkElement.h"
#include "Attribute.h"
+#include "CSSStyleSelector.h"
#include "CachedCSSStyleSheet.h"
#include "CachedResource.h"
#include "CachedResourceLoader.h"
-#include "CSSStyleSelector.h"
#include "Document.h"
#include "EventSender.h"
#include "Frame.h"
#endif
String sheetText = sheet->sheetText(enforceMIMEType, &validMIMEType);
- m_sheet->parseString(sheetText, strictParsing);
+ m_sheet->parseString(sheetText, strictToCSSParserMode(strictParsing));
// If we're loading a stylesheet cross-origin, and the MIME type is not
// standard, require the CSS to at least start with a syntactically
void CanvasRenderingContext2D::setFont(const String& newFont)
{
RefPtr<StylePropertySet> tempDecl = StylePropertySet::create();
- CSSParser parser(!m_usesCSSCompatibilityParseMode);
+ CSSParser parser(strictToCSSParserMode(!m_usesCSSCompatibilityParseMode));
String declarationText("font: ");
declarationText += newFont;
return;
}
- CSSParser parser(true);
+ CSSParser parser(CSSStrictMode);
parser.parseSelector(insertionPoint->select(), insertionPoint->document(), m_selectorList);
m_isValidSelector = ContentSelectorQuery::validateSelectorList();
void InspectorStyleSheet::reparseStyleSheet(const String& text)
{
m_pageStyleSheet->clearRules();
- m_pageStyleSheet->parseString(text, m_pageStyleSheet->useStrictParsing());
+ m_pageStyleSheet->parseString(text, m_pageStyleSheet->cssParserMode());
m_pageStyleSheet->styleSheetChanged();
m_inspectorStyles.clear();
fireStyleSheetChanged();
#ifndef SVGElementRareData_h
#define SVGElementRareData_h
+#include "CSSParserMode.h"
#include <wtf/HashSet.h>
#include <wtf/Noncopyable.h>
#include <wtf/StdLibExtras.h>
{
if (!m_animatedSMILStyleProperties) {
m_animatedSMILStyleProperties = StylePropertySet::create();
- m_animatedSMILStyleProperties->setStrictParsing(false);
+ m_animatedSMILStyleProperties->setCSSParserMode(SVGAttributeMode);
}
return m_animatedSMILStyleProperties.get();
}
{
ASSERT(hasTagName(font_faceTag));
RefPtr<StylePropertySet> styleDeclaration = StylePropertySet::create();
- styleDeclaration->setStrictParsing(true);
+ styleDeclaration->setCSSParserMode(CSSStrictMode);
m_fontFaceRule->setDeclaration(styleDeclaration.release());
}
return 0;
RefPtr<StylePropertySet> style = StylePropertySet::create();
- style->setStrictParsing(false);
+ style->setCSSParserMode(SVGAttributeMode);
int propertyID = SVGStyledElement::cssPropertyIdForSVGAttributeName(attr->name());
style->setProperty(propertyID, attr->value());
return style->getPropertyCSSValue(propertyID);
virtual String type() const { return "text/xml"; }
- virtual bool parseString(const String &string, bool strict = true);
+ virtual bool parseString(const String&, CSSParserMode cssParseMode = CSSStrictMode);
virtual bool isLoading();
void checkLoaded();
return document->cachedResourceLoader();
}
-bool XSLStyleSheet::parseString(const String& string, bool)
+bool XSLStyleSheet::parseString(const String& string, CSSParserMode)
{
// Parse in a single chunk into an xmlDocPtr
const UChar BOM = 0xFEFF;
return document->cachedResourceLoader();
}
-bool XSLStyleSheet::parseString(const String& string, bool)
+bool XSLStyleSheet::parseString(const String& string, CSSParserMode)
{
// FIXME: Fix QXmlQuery so that it allows compiling the stylesheet before setting the document
// to be transformed. This way we could not only check if the stylesheet is correct before using it
+2012-03-28 Dirk Schulze <krit@webkit.org>
+
+ Introduce CSSParserMode in all classes
+ https://bugs.webkit.org/show_bug.cgi?id=82335
+
+ Use CSSParserMode for setting the parsing mode on parseValue.
+
+ * src/WebDocument.cpp:
+ (WebKit::WebDocument::insertUserStyleSheet):
+
2012-03-29 Tommy Widenflycht <tommyw@google.com>
MediaStream API: Adding better comments for the WebRTC methods in WebKitPlatformSupport.h
#include "WebDocument.h"
#include "AXObjectCache.h"
+#include "CSSParserMode.h"
#include "CSSStyleSheet.h"
#include "Document.h"
#include "DocumentLoader.h"
RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::create(document.get());
parsedSheet->setIsUserStyleSheet(level == UserStyleUserLevel);
- parsedSheet->parseString(sourceCode, !document->inQuirksMode());
+ parsedSheet->parseString(sourceCode, toCSSParserMode(!document->inQuirksMode()));
document->addUserSheet(parsedSheet.release());
}