Modified: trunk/Source/WebCore/ChangeLog (276209 => 276210)
--- trunk/Source/WebCore/ChangeLog 2021-04-17 22:38:29 UTC (rev 276209)
+++ trunk/Source/WebCore/ChangeLog 2021-04-17 22:40:08 UTC (rev 276210)
@@ -1,3 +1,16 @@
+2021-04-17 Chris Lord <[email protected]>
+
+ Create local copy of CSSParserContext in CSSPropertyParserWorkerSafe
+ https://bugs.webkit.org/show_bug.cgi?id=224675
+
+ Reviewed by Darin Adler.
+
+ Make sure to hold a copy of the CSSParserContext in
+ CSSPropertyParserWorkerSafe functions as CSSParserImpl only takes a
+ reference.
+
+ * css/parser/CSSParserWorkerSafe.cpp:
+
2021-04-17 Tyler Wilcock <[email protected]>
Consider making CSSStyleSheet::rules() just an alias of CSSStyleSheet::cssRules().
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.cpp (276209 => 276210)
--- trunk/Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.cpp 2021-04-17 22:38:29 UTC (rev 276209)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.cpp 2021-04-17 22:40:08 UTC (rev 276210)
@@ -68,11 +68,9 @@
return CSSPropertyParserHelpers::consumeColorWorkerSafe(range, CSSParserContext(HTMLStandardMode));
}
-static CSSParserContext parserContext(ScriptExecutionContext& context)
+static CSSParserMode parserMode(ScriptExecutionContext& context)
{
- if (!is<Document>(context))
- return HTMLStandardMode;
- return downcast<Document>(context).inQuirksMode() ? HTMLQuirksMode : HTMLStandardMode;
+ return (is<Document>(context) && downcast<Document>(context).inQuirksMode()) ? HTMLQuirksMode : HTMLStandardMode;
}
RefPtr<CSSValueList> CSSPropertyParserWorkerSafe::parseFontFaceSrc(const String& string, const CSSParserContext& context)
@@ -91,7 +89,8 @@
RefPtr<CSSValue> CSSPropertyParserWorkerSafe::parseFontFaceStyle(const String& string, ScriptExecutionContext& context)
{
- CSSParserImpl parser(parserContext(context), string);
+ CSSParserContext parserContext(parserMode(context));
+ CSSParserImpl parser(parserContext, string);
CSSParserTokenRange range = parser.tokenizer()->tokenRange();
range.consumeWhitespace();
if (range.atEnd())
@@ -98,9 +97,9 @@
return nullptr;
auto parsedValue =
#if ENABLE(VARIATION_FONTS)
- CSSPropertyParserHelpersWorkerSafe::consumeFontStyleRange(range, parser.context().mode, context.cssValuePool());
+ CSSPropertyParserHelpersWorkerSafe::consumeFontStyleRange(range, parserContext.mode, context.cssValuePool());
#else
- CSSPropertyParserHelpersWorkerSafe::consumeFontStyle(range, parser.context().mode, context.cssValuePool());
+ CSSPropertyParserHelpersWorkerSafe::consumeFontStyle(range, parserContext.mode, context.cssValuePool());
#endif
if (!parsedValue || !range.atEnd())
return nullptr;
@@ -110,7 +109,8 @@
RefPtr<CSSValue> CSSPropertyParserWorkerSafe::parseFontFaceWeight(const String& string, ScriptExecutionContext& context)
{
- CSSParserImpl parser(parserContext(context), string);
+ CSSParserContext parserContext(parserMode(context));
+ CSSParserImpl parser(parserContext, string);
CSSParserTokenRange range = parser.tokenizer()->tokenRange();
range.consumeWhitespace();
if (range.atEnd())
@@ -129,7 +129,8 @@
RefPtr<CSSValue> CSSPropertyParserWorkerSafe::parseFontFaceStretch(const String& string, ScriptExecutionContext& context)
{
- CSSParserImpl parser(parserContext(context), string);
+ CSSParserContext parserContext(parserMode(context));
+ CSSParserImpl parser(parserContext, string);
CSSParserTokenRange range = parser.tokenizer()->tokenRange();
range.consumeWhitespace();
if (range.atEnd())
@@ -148,7 +149,8 @@
RefPtr<CSSValue> CSSPropertyParserWorkerSafe::parseFontFaceUnicodeRange(const String& string, ScriptExecutionContext& context)
{
- CSSParserImpl parser(parserContext(context), string);
+ CSSParserContext parserContext(parserMode(context));
+ CSSParserImpl parser(parserContext, string);
CSSParserTokenRange range = parser.tokenizer()->tokenRange();
range.consumeWhitespace();
if (range.atEnd())
@@ -162,7 +164,8 @@
RefPtr<CSSValue> CSSPropertyParserWorkerSafe::parseFontFaceFeatureSettings(const String& string, ScriptExecutionContext& context)
{
- CSSParserImpl parser(parserContext(context), string);
+ CSSParserContext parserContext(parserMode(context));
+ CSSParserImpl parser(parserContext, string);
CSSParserTokenRange range = parser.tokenizer()->tokenRange();
range.consumeWhitespace();
if (range.atEnd())
@@ -176,7 +179,8 @@
RefPtr<CSSValue> CSSPropertyParserWorkerSafe::parseFontFaceDisplay(const String& string, ScriptExecutionContext& context)
{
- CSSParserImpl parser(parserContext(context), string);
+ CSSParserContext parserContext(parserMode(context));
+ CSSParserImpl parser(parserContext, string);
CSSParserTokenRange range = parser.tokenizer()->tokenRange();
range.consumeWhitespace();
if (range.atEnd())