Diff
Modified: trunk/Source/WebCore/ChangeLog (289355 => 289356)
--- trunk/Source/WebCore/ChangeLog 2022-02-08 03:31:51 UTC (rev 289355)
+++ trunk/Source/WebCore/ChangeLog 2022-02-08 04:24:37 UTC (rev 289356)
@@ -1,3 +1,29 @@
+2022-02-07 Cameron McCormack <[email protected]>
+
+ Remove HTMLSourceTracker
+ https://bugs.webkit.org/show_bug.cgi?id=236259
+
+ Reviewed by Geoffrey Garen.
+
+ Since the removal of the XSS Auditor in bug 230499, the tracking of
+ attribute locations that HTMLSourceTracker does is unused.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * html/parser/HTMLDocumentParser.cpp:
+ (WebCore::HTMLDocumentParser::pumpTokenizerLoop):
+ * html/parser/HTMLDocumentParser.h:
+ * html/parser/HTMLSourceTracker.cpp: Removed.
+ * html/parser/HTMLSourceTracker.h: Removed.
+ * html/parser/HTMLToken.h:
+ (WebCore::HTMLToken::beginAttribute):
+ (WebCore::HTMLToken::endAttribute):
+ (WebCore::HTMLToken::setAttributeBaseOffset): Deleted.
+ * html/parser/HTMLTokenizer.cpp:
+ (WebCore::HTMLTokenizer::processToken):
+ * html/parser/HTMLTokenizer.h:
+ (WebCore::HTMLTokenizer::setTokenAttributeBaseOffset): Deleted.
+
2022-02-07 Andres Gonzalez <[email protected]>
Prevent removal of isolated objects from a different parent than the current parent.
Modified: trunk/Source/WebCore/Sources.txt (289355 => 289356)
--- trunk/Source/WebCore/Sources.txt 2022-02-08 03:31:51 UTC (rev 289355)
+++ trunk/Source/WebCore/Sources.txt 2022-02-08 04:24:37 UTC (rev 289356)
@@ -1421,7 +1421,6 @@
html/parser/HTMLPreloadScanner.cpp
html/parser/HTMLResourcePreloader.cpp
html/parser/HTMLScriptRunner.cpp
-html/parser/HTMLSourceTracker.cpp
html/parser/HTMLSrcsetParser.cpp
html/parser/HTMLTokenizer.cpp
html/parser/HTMLTreeBuilder.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (289355 => 289356)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-02-08 03:31:51 UTC (rev 289355)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-02-08 04:24:37 UTC (rev 289356)
@@ -3184,7 +3184,6 @@
977B3875122883E900B81FF8 /* HTMLScriptRunner.h in Headers */ = {isa = PBXBuildFile; fileRef = 977B385C122883E900B81FF8 /* HTMLScriptRunner.h */; };
977B3876122883E900B81FF8 /* HTMLScriptRunnerHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 977B385D122883E900B81FF8 /* HTMLScriptRunnerHost.h */; };
977B3878122883E900B81FF8 /* HTMLTokenizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 977B385F122883E900B81FF8 /* HTMLTokenizer.h */; };
- 977E2DCE12F0E28300C13379 /* HTMLSourceTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 977E2DCC12F0E28300C13379 /* HTMLSourceTracker.h */; };
978AD67514130A8D00C7CAE3 /* HTMLSpanElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 978AD67214130A8D00C7CAE3 /* HTMLSpanElement.h */; };
979F43D41075E44A0000F83B /* NavigationScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 979F43D21075E44A0000F83B /* NavigationScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
97AA3CA5145237CC003E1DA6 /* EventTargetHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AA3CA3145237CC003E1DA6 /* EventTargetHeaders.h */; };
@@ -13192,8 +13191,6 @@
977B385D122883E900B81FF8 /* HTMLScriptRunnerHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLScriptRunnerHost.h; sourceTree = "<group>"; };
977B385E122883E900B81FF8 /* HTMLTokenizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLTokenizer.cpp; sourceTree = "<group>"; };
977B385F122883E900B81FF8 /* HTMLTokenizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLTokenizer.h; sourceTree = "<group>"; };
- 977E2DCB12F0E28300C13379 /* HTMLSourceTracker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLSourceTracker.cpp; sourceTree = "<group>"; };
- 977E2DCC12F0E28300C13379 /* HTMLSourceTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLSourceTracker.h; sourceTree = "<group>"; };
978AD67114130A8D00C7CAE3 /* HTMLSpanElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLSpanElement.cpp; sourceTree = "<group>"; };
978AD67214130A8D00C7CAE3 /* HTMLSpanElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLSpanElement.h; sourceTree = "<group>"; };
978AD67314130A8D00C7CAE3 /* HTMLSpanElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLSpanElement.idl; sourceTree = "<group>"; };
@@ -26396,8 +26393,6 @@
977B385B122883E900B81FF8 /* HTMLScriptRunner.cpp */,
977B385C122883E900B81FF8 /* HTMLScriptRunner.h */,
977B385D122883E900B81FF8 /* HTMLScriptRunnerHost.h */,
- 977E2DCB12F0E28300C13379 /* HTMLSourceTracker.cpp */,
- 977E2DCC12F0E28300C13379 /* HTMLSourceTracker.h */,
536D5A1E193E18D000CE4CAB /* HTMLSrcsetParser.cpp */,
536D5A1F193E18E900CE4CAB /* HTMLSrcsetParser.h */,
97C1F552122855CB00EDE615 /* HTMLStackItem.h */,
@@ -34822,7 +34817,6 @@
A81369D8097374F600D74463 /* HTMLSelectElement.h in Headers */,
9B69D3B51B98FFE900E3512B /* HTMLSlotElement.h in Headers */,
E44613A80CD6331000FADA75 /* HTMLSourceElement.h in Headers */,
- 977E2DCE12F0E28300C13379 /* HTMLSourceTracker.h in Headers */,
978AD67514130A8D00C7CAE3 /* HTMLSpanElement.h in Headers */,
536D5A20193E18E900CE4CAB /* HTMLSrcsetParser.h in Headers */,
A871DC230A15205700B12A68 /* HTMLStyleElement.h in Headers */,
Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp (289355 => 289356)
--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp 2022-02-08 03:31:51 UTC (rev 289355)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp 2022-02-08 04:24:37 UTC (rev 289356)
@@ -274,16 +274,10 @@
if (UNLIKELY(mode == AllowYield && m_parserScheduler->shouldYieldBeforeToken(session)))
return true;
- if (!parsingFragment)
- m_sourceTracker.startToken(m_input.current(), m_tokenizer);
-
auto token = m_tokenizer.nextToken(m_input.current());
if (!token)
return false;
- if (!parsingFragment)
- m_sourceTracker.endToken(m_input.current(), m_tokenizer);
-
constructTreeFromHTMLToken(token);
} while (!isStopped());
Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.h (289355 => 289356)
--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.h 2022-02-08 03:31:51 UTC (rev 289355)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.h 2022-02-08 04:24:37 UTC (rev 289356)
@@ -28,7 +28,6 @@
#include "HTMLInputStream.h"
#include "HTMLScriptRunnerHost.h"
-#include "HTMLSourceTracker.h"
#include "HTMLTokenizer.h"
#include "PendingScriptClient.h"
#include "ScriptableDocumentParser.h"
@@ -135,7 +134,6 @@
std::unique_ptr<HTMLPreloadScanner> m_preloadScanner;
std::unique_ptr<HTMLPreloadScanner> m_insertionPreloadScanner;
std::unique_ptr<HTMLParserScheduler> m_parserScheduler;
- HTMLSourceTracker m_sourceTracker;
TextPosition m_textPosition;
std::unique_ptr<HTMLResourcePreloader> m_preloader;
Deleted: trunk/Source/WebCore/html/parser/HTMLSourceTracker.cpp (289355 => 289356)
--- trunk/Source/WebCore/html/parser/HTMLSourceTracker.cpp 2022-02-08 03:31:51 UTC (rev 289355)
+++ trunk/Source/WebCore/html/parser/HTMLSourceTracker.cpp 2022-02-08 04:24:37 UTC (rev 289356)
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2010 Adam Barth. All Rights Reserved.
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "HTMLSourceTracker.h"
-
-#include "HTMLTokenizer.h"
-#include <wtf/text/StringBuilder.h>
-
-namespace WebCore {
-
-void HTMLSourceTracker::startToken(SegmentedString& currentInput, HTMLTokenizer& tokenizer)
-{
- if (!m_started) {
- if (tokenizer.numberOfBufferedCharacters())
- m_previousSource = tokenizer.bufferedCharacters();
- else
- m_previousSource.clear();
- m_started = true;
- } else
- m_previousSource.append(m_currentSource);
-
- m_currentSource = currentInput;
- m_tokenStart = m_currentSource.numberOfCharactersConsumed() - m_previousSource.length();
- tokenizer.setTokenAttributeBaseOffset(m_tokenStart);
-}
-
-void HTMLSourceTracker::endToken(SegmentedString& currentInput, HTMLTokenizer& tokenizer)
-{
- ASSERT(m_started);
- m_started = false;
-
- m_tokenEnd = currentInput.numberOfCharactersConsumed() - tokenizer.numberOfBufferedCharacters();
- m_cachedSourceForToken = String();
-}
-
-String HTMLSourceTracker::source(const HTMLToken& token)
-{
- ASSERT(!m_started);
-
- if (token.type() == HTMLToken::EndOfFile)
- return String(); // Hides the null character we use to mark the end of file.
-
- if (!m_cachedSourceForToken.isEmpty())
- return m_cachedSourceForToken;
-
- unsigned length = m_tokenEnd - m_tokenStart;
-
- StringBuilder source;
- source.reserveCapacity(length);
-
- unsigned i = 0;
- for ( ; i < length && !m_previousSource.isEmpty(); ++i) {
- source.append(m_previousSource.currentCharacter());
- m_previousSource.advance();
- }
- for ( ; i < length; ++i) {
- ASSERT(!m_currentSource.isEmpty());
- source.append(m_currentSource.currentCharacter());
- m_currentSource.advance();
- }
-
- m_cachedSourceForToken = source.toString();
- return m_cachedSourceForToken;
-}
-
-String HTMLSourceTracker::source(const HTMLToken& token, unsigned attributeStart, unsigned attributeEnd)
-{
- return source(token).substring(attributeStart, attributeEnd - attributeStart);
-}
-
-}
Deleted: trunk/Source/WebCore/html/parser/HTMLSourceTracker.h (289355 => 289356)
--- trunk/Source/WebCore/html/parser/HTMLSourceTracker.h 2022-02-08 03:31:51 UTC (rev 289355)
+++ trunk/Source/WebCore/html/parser/HTMLSourceTracker.h 2022-02-08 04:24:37 UTC (rev 289356)
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2010 Adam Barth. All Rights Reserved.
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include "SegmentedString.h"
-
-namespace WebCore {
-
-class HTMLToken;
-class HTMLTokenizer;
-
-class HTMLSourceTracker {
- WTF_MAKE_NONCOPYABLE(HTMLSourceTracker);
-public:
- HTMLSourceTracker() = default;
-
- void startToken(SegmentedString&, HTMLTokenizer&);
- void endToken(SegmentedString&, HTMLTokenizer&);
-
- String source(const HTMLToken&);
- String source(const HTMLToken&, unsigned attributeStart, unsigned attributeEnd);
-
-private:
- bool m_started { false };
-
- unsigned m_tokenStart;
- unsigned m_tokenEnd;
-
- SegmentedString m_previousSource;
- SegmentedString m_currentSource;
-
- String m_cachedSourceForToken;
-};
-
-} // namespace WebCore
Modified: trunk/Source/WebCore/html/parser/HTMLToken.h (289355 => 289356)
--- trunk/Source/WebCore/html/parser/HTMLToken.h 2022-02-08 03:31:51 UTC (rev 289355)
+++ trunk/Source/WebCore/html/parser/HTMLToken.h 2022-02-08 04:24:37 UTC (rev 289356)
@@ -56,10 +56,6 @@
struct Attribute {
Vector<UChar, 32> name;
Vector<UChar, 64> value;
-
- // Used by HTMLSourceTracker.
- unsigned startOffset;
- unsigned endOffset;
};
typedef Vector<Attribute, 10> AttributeList;
@@ -106,19 +102,14 @@
void beginEndTag(LChar);
void beginEndTag(const Vector<LChar, 32>&);
- void beginAttribute(unsigned offset);
+ void beginAttribute();
void appendToAttributeName(UChar);
void appendToAttributeValue(UChar);
- void endAttribute(unsigned offset);
+ void appendToAttributeValue(unsigned index, StringView value);
+ void endAttribute();
void setSelfClosing();
- // Used by HTMLTokenizer on behalf of HTMLSourceTracker.
- void setAttributeBaseOffset(unsigned attributeBaseOffset) { m_attributeBaseOffset = attributeBaseOffset; }
-
-public:
- void appendToAttributeValue(unsigned index, StringView value);
-
// Character.
// Starting a character token works slightly differently than starting
@@ -153,8 +144,6 @@
// For DOCTYPE
std::unique_ptr<DoctypeData> m_doctypeData;
-
- unsigned m_attributeBaseOffset { 0 }; // Changes across document.write() boundaries.
};
const HTMLToken::Attribute* findAttribute(const Vector<HTMLToken::Attribute>&, StringView name);
@@ -309,22 +298,16 @@
m_data.appendVector(characters);
}
-inline void HTMLToken::beginAttribute(unsigned offset)
+inline void HTMLToken::beginAttribute()
{
ASSERT(m_type == StartTag || m_type == EndTag);
- ASSERT(offset);
-
m_attributes.grow(m_attributes.size() + 1);
m_currentAttribute = &m_attributes.last();
-
- m_currentAttribute->startOffset = offset - m_attributeBaseOffset;
}
-inline void HTMLToken::endAttribute(unsigned offset)
+inline void HTMLToken::endAttribute()
{
- ASSERT(offset);
ASSERT(m_currentAttribute);
- m_currentAttribute->endOffset = offset - m_attributeBaseOffset;
#if ASSERT_ENABLED
m_currentAttribute = nullptr;
#endif
Modified: trunk/Source/WebCore/html/parser/HTMLTokenizer.cpp (289355 => 289356)
--- trunk/Source/WebCore/html/parser/HTMLTokenizer.cpp 2022-02-08 03:31:51 UTC (rev 289355)
+++ trunk/Source/WebCore/html/parser/HTMLTokenizer.cpp 2022-02-08 04:24:37 UTC (rev 289356)
@@ -721,7 +721,7 @@
}
if (character == '"' || character == '\'' || character == '<' || character == '=')
parseError();
- m_token.beginAttribute(source.numberOfCharactersConsumed());
+ m_token.beginAttribute();
m_token.appendToAttributeName(toASCIILower(character));
ADVANCE_PAST_NON_NEWLINE_TO(AttributeNameState);
END_STATE()
@@ -764,7 +764,7 @@
}
if (character == '"' || character == '\'' || character == '<')
parseError();
- m_token.beginAttribute(source.numberOfCharactersConsumed());
+ m_token.beginAttribute();
m_token.appendToAttributeName(toASCIILower(character));
ADVANCE_PAST_NON_NEWLINE_TO(AttributeNameState);
END_STATE()
@@ -794,7 +794,7 @@
BEGIN_STATE(AttributeValueDoubleQuotedState)
if (character == '"') {
- m_token.endAttribute(source.numberOfCharactersConsumed());
+ m_token.endAttribute();
ADVANCE_PAST_NON_NEWLINE_TO(AfterAttributeValueQuotedState);
}
if (character == '&') {
@@ -803,7 +803,7 @@
}
if (character == kEndOfFileMarker) {
parseError();
- m_token.endAttribute(source.numberOfCharactersConsumed());
+ m_token.endAttribute();
RECONSUME_IN(DataState);
}
m_token.appendToAttributeValue(character);
@@ -812,7 +812,7 @@
BEGIN_STATE(AttributeValueSingleQuotedState)
if (character == '\'') {
- m_token.endAttribute(source.numberOfCharactersConsumed());
+ m_token.endAttribute();
ADVANCE_PAST_NON_NEWLINE_TO(AfterAttributeValueQuotedState);
}
if (character == '&') {
@@ -821,7 +821,7 @@
}
if (character == kEndOfFileMarker) {
parseError();
- m_token.endAttribute(source.numberOfCharactersConsumed());
+ m_token.endAttribute();
RECONSUME_IN(DataState);
}
m_token.appendToAttributeValue(character);
@@ -830,7 +830,7 @@
BEGIN_STATE(AttributeValueUnquotedState)
if (isTokenizerWhitespace(character)) {
- m_token.endAttribute(source.numberOfCharactersConsumed());
+ m_token.endAttribute();
ADVANCE_TO(BeforeAttributeNameState);
}
if (character == '&') {
@@ -838,12 +838,12 @@
ADVANCE_PAST_NON_NEWLINE_TO(CharacterReferenceInAttributeValueState);
}
if (character == '>') {
- m_token.endAttribute(source.numberOfCharactersConsumed());
+ m_token.endAttribute();
return emitAndResumeInDataState(source);
}
if (character == kEndOfFileMarker) {
parseError();
- m_token.endAttribute(source.numberOfCharactersConsumed());
+ m_token.endAttribute();
RECONSUME_IN(DataState);
}
if (character == '"' || character == '\'' || character == '<' || character == '=' || character == '`')
Modified: trunk/Source/WebCore/html/parser/HTMLTokenizer.h (289355 => 289356)
--- trunk/Source/WebCore/html/parser/HTMLTokenizer.h 2022-02-08 03:31:51 UTC (rev 289355)
+++ trunk/Source/WebCore/html/parser/HTMLTokenizer.h 2022-02-08 04:24:37 UTC (rev 289356)
@@ -42,9 +42,6 @@
class TokenPtr;
TokenPtr nextToken(SegmentedString&);
- // Used by HTMLSourceTracker.
- void setTokenAttributeBaseOffset(unsigned);
-
// Returns a copy of any characters buffered internally by the tokenizer.
// The tokenizer buffers characters when searching for the </script> token that terminates a script element.
String bufferedCharacters() const;
@@ -284,11 +281,6 @@
return TokenPtr(processToken(source) ? &m_token : nullptr);
}
-inline void HTMLTokenizer::setTokenAttributeBaseOffset(unsigned offset)
-{
- m_token.setAttributeBaseOffset(offset);
-}
-
inline size_t HTMLTokenizer::numberOfBufferedCharacters() const
{
// Notice that we add 2 to the length of the m_temporaryBuffer to