Modified: branches/safari-613.1.17.0-branch/Source/WebCore/ChangeLog (289661 => 289662)
--- branches/safari-613.1.17.0-branch/Source/WebCore/ChangeLog 2022-02-11 20:31:55 UTC (rev 289661)
+++ branches/safari-613.1.17.0-branch/Source/WebCore/ChangeLog 2022-02-11 20:35:06 UTC (rev 289662)
@@ -1,5 +1,46 @@
2022-02-11 Russell Epstein <[email protected]>
+ Cherry-pick r289493. rdar://problem/88321921
+
+ Register strings in CSSTokenizer created from preprocessing
+ https://bugs.webkit.org/show_bug.cgi?id=236309
+
+ Patch by Gabriel Nava Marino <[email protected]> on 2022-02-09
+ Reviewed by Michael Saboff.
+
+ Register strings in CSSTokenizer created from preprocessing. This will align with
+ what is currently done for strings with escapes in CSSTokenizer::consumeName().
+
+ * css/parser/CSSTokenizer.cpp:
+ (WebCore::CSSTokenizer::preprocessString):
+ (WebCore::CSSTokenizer::tryCreate):
+ (WebCore::CSSTokenizer::CSSTokenizer):
+ (WebCore::preprocessString): Deleted.
+ * css/parser/CSSTokenizer.h:
+ * css/parser/CSSTokenizerInputStream.h:
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289493 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2022-02-09 Gabriel Nava Marino <[email protected]>
+
+ Register strings in CSSTokenizer created from preprocessing
+ https://bugs.webkit.org/show_bug.cgi?id=236309
+
+ Reviewed by Michael Saboff.
+
+ Register strings in CSSTokenizer created from preprocessing. This will align with
+ what is currently done for strings with escapes in CSSTokenizer::consumeName().
+
+ * css/parser/CSSTokenizer.cpp:
+ (WebCore::CSSTokenizer::preprocessString):
+ (WebCore::CSSTokenizer::tryCreate):
+ (WebCore::CSSTokenizer::CSSTokenizer):
+ (WebCore::preprocessString): Deleted.
+ * css/parser/CSSTokenizer.h:
+ * css/parser/CSSTokenizerInputStream.h:
+
+2022-02-11 Russell Epstein <[email protected]>
+
Cherry-pick r289462. rdar://problem/88580935
Don't return an empty value from AbortController.signal.reason and make it harder to return empty values from JSValueInWrappedObject
Modified: branches/safari-613.1.17.0-branch/Source/WebCore/css/parser/CSSTokenizer.cpp (289661 => 289662)
--- branches/safari-613.1.17.0-branch/Source/WebCore/css/parser/CSSTokenizer.cpp 2022-02-11 20:31:55 UTC (rev 289661)
+++ branches/safari-613.1.17.0-branch/Source/WebCore/css/parser/CSSTokenizer.cpp 2022-02-11 20:35:06 UTC (rev 289662)
@@ -43,12 +43,16 @@
namespace WebCore {
// https://drafts.csswg.org/css-syntax/#input-preprocessing
-static String preprocessString(String string)
+String CSSTokenizer::preprocessString(String string)
{
// We don't replace '\r' and '\f' with '\n' as the specification suggests, instead
// we treat them all the same in the isNewLine function below.
+ StringImpl* oldImpl = string.impl();
string.replace('\0', replacementCharacter);
- return replaceUnpairedSurrogatesWithReplacementCharacter(WTFMove(string));
+ String replaced = replaceUnpairedSurrogatesWithReplacementCharacter(WTFMove(string));
+ if (replaced.impl() != oldImpl)
+ registerString(replaced);
+ return replaced;
}
std::unique_ptr<CSSTokenizer> CSSTokenizer::tryCreate(const String& string)
@@ -55,7 +59,7 @@
{
bool success = true;
// We can't use makeUnique here because it does not have access to this private constructor.
- auto tokenizer = std::unique_ptr<CSSTokenizer>(new CSSTokenizer(preprocessString(string), nullptr, &success));
+ auto tokenizer = std::unique_ptr<CSSTokenizer>(new CSSTokenizer(string, nullptr, &success));
if (UNLIKELY(!success))
return nullptr;
return tokenizer;
@@ -65,7 +69,7 @@
{
bool success = true;
// We can't use makeUnique here because it does not have access to this private constructor.
- auto tokenizer = std::unique_ptr<CSSTokenizer>(new CSSTokenizer(preprocessString(string), &wrapper, &success));
+ auto tokenizer = std::unique_ptr<CSSTokenizer>(new CSSTokenizer(string, &wrapper, &success));
if (UNLIKELY(!success))
return nullptr;
return tokenizer;
@@ -72,17 +76,17 @@
}
CSSTokenizer::CSSTokenizer(const String& string)
- : CSSTokenizer(preprocessString(string), nullptr, nullptr)
+ : CSSTokenizer(string, nullptr, nullptr)
{
}
CSSTokenizer::CSSTokenizer(const String& string, CSSParserObserverWrapper& wrapper)
- : CSSTokenizer(preprocessString(string), &wrapper, nullptr)
+ : CSSTokenizer(string, &wrapper, nullptr)
{
}
-CSSTokenizer::CSSTokenizer(String&& string, CSSParserObserverWrapper* wrapper, bool* constructionSuccessPtr)
- : m_input(string)
+CSSTokenizer::CSSTokenizer(const String& string, CSSParserObserverWrapper* wrapper, bool* constructionSuccessPtr)
+ : m_input(preprocessString(string))
{
if (constructionSuccessPtr)
*constructionSuccessPtr = true;
Modified: branches/safari-613.1.17.0-branch/Source/WebCore/css/parser/CSSTokenizer.h (289661 => 289662)
--- branches/safari-613.1.17.0-branch/Source/WebCore/css/parser/CSSTokenizer.h 2022-02-11 20:31:55 UTC (rev 289661)
+++ branches/safari-613.1.17.0-branch/Source/WebCore/css/parser/CSSTokenizer.h 2022-02-11 20:35:06 UTC (rev 289662)
@@ -57,7 +57,7 @@
Vector<String>&& escapedStringsForAdoption() { return WTFMove(m_stringPool); }
private:
- CSSTokenizer(String&&, CSSParserObserverWrapper*, bool* constructionSuccess);
+ CSSTokenizer(const String&, CSSParserObserverWrapper*, bool* constructionSuccess);
CSSParserToken nextToken();
@@ -64,6 +64,8 @@
UChar consume();
void reconsume(UChar);
+ String preprocessString(String);
+
CSSParserToken consumeNumericToken();
CSSParserToken consumeIdentLikeToken();
CSSParserToken consumeNumber();
@@ -122,11 +124,10 @@
static const CodePoint codePoints[];
Vector<CSSParserTokenType, 8> m_blockStack;
- CSSTokenizerInputStream m_input;
-
Vector<CSSParserToken, 32> m_tokens;
// We only allocate strings when escapes are used.
Vector<String> m_stringPool;
+ CSSTokenizerInputStream m_input;
};
} // namespace WebCore
Modified: branches/safari-613.1.17.0-branch/Source/WebCore/css/parser/CSSTokenizerInputStream.h (289661 => 289662)
--- branches/safari-613.1.17.0-branch/Source/WebCore/css/parser/CSSTokenizerInputStream.h 2022-02-11 20:31:55 UTC (rev 289661)
+++ branches/safari-613.1.17.0-branch/Source/WebCore/css/parser/CSSTokenizerInputStream.h 2022-02-11 20:35:06 UTC (rev 289662)
@@ -41,8 +41,7 @@
public:
explicit CSSTokenizerInputStream(const String& input);
- // Gets the char in the stream replacing NUL characters with a unicode
- // replacement character. Will return (NUL) kEndOfFileMarker when at the
+ // Gets the char in the stream. Will return (NUL) kEndOfFileMarker when at the
// end of the stream.
UChar nextInputChar() const
{