Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (139944 => 139945)
--- trunk/Source/WebCore/CMakeLists.txt 2013-01-17 02:05:33 UTC (rev 139944)
+++ trunk/Source/WebCore/CMakeLists.txt 2013-01-17 02:18:20 UTC (rev 139945)
@@ -1527,6 +1527,7 @@
html/canvas/WebGLVertexArrayObjectOES.cpp
html/parser/CSSPreloadScanner.cpp
+ html/parser/CompactHTMLToken.cpp
html/parser/HTMLConstructionSite.cpp
html/parser/HTMLDocumentParser.cpp
html/parser/HTMLElementStack.cpp
Modified: trunk/Source/WebCore/ChangeLog (139944 => 139945)
--- trunk/Source/WebCore/ChangeLog 2013-01-17 02:05:33 UTC (rev 139944)
+++ trunk/Source/WebCore/ChangeLog 2013-01-17 02:18:20 UTC (rev 139945)
@@ -1,3 +1,42 @@
+2013-01-16 Tony Gentilcore <to...@chromium.org>
+
+ Introduce a CompactHTMLToken for the threaded HTML parser
+ https://bugs.webkit.org/show_bug.cgi?id=107069
+
+ Reviewed by Adam Barth.
+
+ This class is used for transporting tokens from the parser thread to the main thread where they are fed to the tree builder.
+
+ No new tests because covered by existing fast/parser tests.
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * Target.pri:
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * html/parser/CompactHTMLToken.cpp: Added.
+ (WebCore):
+ (WebCore::CompactHTMLToken::CompactHTMLToken):
+ (WebCore::isStringSafeToSendToAnotherThread):
+ (WebCore::CompactHTMLToken::isSafeToSendToAnotherThread):
+ * html/parser/CompactHTMLToken.h: Added.
+ (WebCore):
+ (CompactAttribute):
+ (WebCore::CompactAttribute::CompactAttribute):
+ (WebCore::CompactAttribute::name):
+ (WebCore::CompactAttribute::value):
+ (CompactHTMLToken):
+ (WebCore::CompactHTMLToken::type):
+ (WebCore::CompactHTMLToken::data):
+ (WebCore::CompactHTMLToken::selfClosing):
+ (WebCore::CompactHTMLToken::attributes):
+ (WebCore::CompactHTMLToken::publicIdentifier):
+ (WebCore::CompactHTMLToken::systemIdentifier):
+ * xml/parser/MarkupTokenBase.h:
+ (WebCore::MarkupTokenBase::data):
+ (MarkupTokenBase):
+
2013-01-16 Adam Barth <aba...@webkit.org>
Introduce HTMLParserThread to be able to parse on a background thread
Modified: trunk/Source/WebCore/GNUmakefile.list.am (139944 => 139945)
--- trunk/Source/WebCore/GNUmakefile.list.am 2013-01-17 02:05:33 UTC (rev 139944)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2013-01-17 02:18:20 UTC (rev 139945)
@@ -3532,6 +3532,8 @@
Source/WebCore/html/NumberInputType.h \
Source/WebCore/html/parser/CSSPreloadScanner.cpp \
Source/WebCore/html/parser/CSSPreloadScanner.h \
+ Source/WebCore/html/parser/CompactHTMLToken.cpp \
+ Source/WebCore/html/parser/CompactHTMLToken.h \
Source/WebCore/html/parser/HTMLConstructionSite.cpp \
Source/WebCore/html/parser/HTMLConstructionSite.h \
Source/WebCore/html/parser/HTMLDocumentParser.cpp \
Modified: trunk/Source/WebCore/Target.pri (139944 => 139945)
--- trunk/Source/WebCore/Target.pri 2013-01-17 02:05:33 UTC (rev 139944)
+++ trunk/Source/WebCore/Target.pri 2013-01-17 02:18:20 UTC (rev 139945)
@@ -708,6 +708,7 @@
html/canvas/CanvasStyle.cpp \
html/canvas/DataView.cpp \
html/parser/CSSPreloadScanner.cpp \
+ html/parser/CompactHTMLToken.cpp \
html/parser/HTMLConstructionSite.cpp \
html/parser/HTMLDocumentParser.cpp \
html/parser/HTMLElementStack.cpp \
@@ -1882,6 +1883,7 @@
html/TypeAhead.h \
html/ValidityState.h \
html/parser/CSSPreloadScanner.h \
+ html/parser/CompactHTMLToken.h \
html/parser/HTMLConstructionSite.h \
html/parser/HTMLDocumentParser.h \
html/parser/HTMLElementStack.h \
Modified: trunk/Source/WebCore/WebCore.gypi (139944 => 139945)
--- trunk/Source/WebCore/WebCore.gypi 2013-01-17 02:05:33 UTC (rev 139944)
+++ trunk/Source/WebCore/WebCore.gypi 2013-01-17 02:18:20 UTC (rev 139945)
@@ -3335,6 +3335,8 @@
'html/canvas/WebGLVertexArrayObjectOES.h',
'html/parser/CSSPreloadScanner.cpp',
'html/parser/CSSPreloadScanner.h',
+ 'html/parser/CompactHTMLToken.cpp',
+ 'html/parser/CompactHTMLToken.h',
'html/parser/HTMLConstructionSite.cpp',
'html/parser/HTMLConstructionSite.h',
'html/parser/HTMLDocumentParser.cpp',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (139944 => 139945)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2013-01-17 02:05:33 UTC (rev 139944)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2013-01-17 02:18:20 UTC (rev 139945)
@@ -64545,6 +64545,14 @@
>
</File>
<File
+ RelativePath="..\html\parser\CompactHTMLToken.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\html\parser\CompactHTMLToken.h"
+ >
+ </File>
+ <File
RelativePath="..\html\parser\HTMLConstructionSite.cpp"
>
</File>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (139944 => 139945)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-01-17 02:05:33 UTC (rev 139944)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-01-17 02:18:20 UTC (rev 139945)
@@ -3624,6 +3624,8 @@
977B37261228721700B81FF8 /* HTMLTreeBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 977B37221228721700B81FF8 /* HTMLTreeBuilder.h */; };
977B3862122883E900B81FF8 /* CSSPreloadScanner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 977B3849122883E900B81FF8 /* CSSPreloadScanner.cpp */; };
977B3863122883E900B81FF8 /* CSSPreloadScanner.h in Headers */ = {isa = PBXBuildFile; fileRef = 977B384A122883E900B81FF8 /* CSSPreloadScanner.h */; };
+ 977B3862122883E900B81FF9 /* CompactHTMLToken.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 977B3849122883E900B81FF9 /* CompactHTMLToken.cpp */; };
+ 977B3863122883E900B81FF9 /* CompactHTMLToken.h in Headers */ = {isa = PBXBuildFile; fileRef = 977B384A122883E900B81FF9 /* CompactHTMLToken.h */; };
977B3864122883E900B81FF8 /* HTMLConstructionSite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 977B384B122883E900B81FF8 /* HTMLConstructionSite.cpp */; };
977B3865122883E900B81FF8 /* HTMLConstructionSite.h in Headers */ = {isa = PBXBuildFile; fileRef = 977B384C122883E900B81FF8 /* HTMLConstructionSite.h */; };
977B3866122883E900B81FF8 /* HTMLDocumentParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 977B384D122883E900B81FF8 /* HTMLDocumentParser.cpp */; };
@@ -11000,6 +11002,8 @@
977B37221228721700B81FF8 /* HTMLTreeBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLTreeBuilder.h; path = parser/HTMLTreeBuilder.h; sourceTree = "<group>"; };
977B3849122883E900B81FF8 /* CSSPreloadScanner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CSSPreloadScanner.cpp; path = parser/CSSPreloadScanner.cpp; sourceTree = "<group>"; };
977B384A122883E900B81FF8 /* CSSPreloadScanner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSPreloadScanner.h; path = parser/CSSPreloadScanner.h; sourceTree = "<group>"; };
+ 977B3849122883E900B81FF9 /* CompactHTMLToken.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompactHTMLToken.cpp; path = parser/CompactHTMLToken.cpp; sourceTree = "<group>"; };
+ 977B384A122883E900B81FF9 /* CompactHTMLToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompactHTMLToken.h; path = parser/CompactHTMLToken.h; sourceTree = "<group>"; };
977B384B122883E900B81FF8 /* HTMLConstructionSite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HTMLConstructionSite.cpp; path = parser/HTMLConstructionSite.cpp; sourceTree = "<group>"; };
977B384C122883E900B81FF8 /* HTMLConstructionSite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLConstructionSite.h; path = parser/HTMLConstructionSite.h; sourceTree = "<group>"; };
977B384D122883E900B81FF8 /* HTMLDocumentParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HTMLDocumentParser.cpp; path = parser/HTMLDocumentParser.cpp; sourceTree = "<group>"; };
Added: trunk/Source/WebCore/html/parser/CompactHTMLToken.cpp (0 => 139945)
--- trunk/Source/WebCore/html/parser/CompactHTMLToken.cpp (rev 0)
+++ trunk/Source/WebCore/html/parser/CompactHTMLToken.cpp 2013-01-17 02:18:20 UTC (rev 139945)
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2013 Google, 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 GOOGLE 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 GOOGLE 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"
+
+#if ENABLE(THREADED_HTML_PARSER)
+
+#include "CompactHTMLToken.h"
+
+#include "HTMLToken.h"
+
+namespace WebCore {
+
+CompactHTMLToken::CompactHTMLToken(const HTMLToken& token)
+ : m_type(token.type())
+{
+ switch (m_type) {
+ case HTMLTokenTypes::Uninitialized:
+ ASSERT_NOT_REACHED();
+ break;
+ case HTMLTokenTypes::DOCTYPE:
+ m_data = String(token.name().data(), token.name().size());
+ m_publicIdentifier = String(token.publicIdentifier().data(), token.publicIdentifier().size());
+ m_systemIdentifier = String(token.systemIdentifier().data(), token.systemIdentifier().size());
+ break;
+ case HTMLTokenTypes::EndOfFile:
+ break;
+ case HTMLTokenTypes::StartTag:
+ m_attributes.reserveInitialCapacity(token.attributes().size());
+ for (Vector<AttributeBase>::const_iterator it = token.attributes().begin(); it != token.attributes().end(); ++it)
+ m_attributes.append(CompactAttribute(String(it->m_name.data(), it->m_name.size()), String(it->m_value.data(), it->m_value.size())));
+ // Fall through!
+ case HTMLTokenTypes::EndTag:
+ m_selfClosing = token.selfClosing();
+ // Fall through!
+ case HTMLTokenTypes::Comment:
+ case HTMLTokenTypes::Character:
+ if (token.isAll8BitData())
+ m_data = String::make8BitFrom16BitSource(token.data().data(), token.data().size());
+ else
+ m_data = String(token.data().data(), token.data().size());
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+}
+
+static bool isStringSafeToSendToAnotherThread(const String& string)
+{
+ StringImpl* impl = string.impl();
+ if (!impl)
+ return true;
+ if (impl->hasOneRef())
+ return true;
+ if (string.isEmpty())
+ return true;
+ return false;
+}
+
+bool CompactHTMLToken::isSafeToSendToAnotherThread() const
+{
+ for (Vector<CompactAttribute>::const_iterator it = m_attributes.begin(); it != m_attributes.end(); ++it) {
+ if (!isStringSafeToSendToAnotherThread(it->name()))
+ return false;
+ if (!isStringSafeToSendToAnotherThread(it->value()))
+ return false;
+ }
+
+ return isStringSafeToSendToAnotherThread(m_data)
+ && isStringSafeToSendToAnotherThread(m_publicIdentifier)
+ && isStringSafeToSendToAnotherThread(m_systemIdentifier);
+}
+
+}
+
+#endif // ENABLE(THREADED_HTML_PARSER)
Added: trunk/Source/WebCore/html/parser/CompactHTMLToken.h (0 => 139945)
--- trunk/Source/WebCore/html/parser/CompactHTMLToken.h (rev 0)
+++ trunk/Source/WebCore/html/parser/CompactHTMLToken.h 2013-01-17 02:18:20 UTC (rev 139945)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2013 Google, 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 GOOGLE 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 GOOGLE 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.
+ */
+
+#ifndef CompactHTMLToken_h
+#define CompactHTMLToken_h
+
+#if ENABLE(THREADED_HTML_PARSER)
+
+#include "HTMLTokenTypes.h"
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class HTMLToken;
+
+class CompactAttribute {
+public:
+ CompactAttribute(const String& name, const String& value)
+ : m_name(name)
+ , m_value(value)
+ {
+ }
+
+ const String& name() const { return m_name; }
+ const String& value() const { return m_value; }
+
+private:
+ String m_name;
+ String m_value;
+};
+
+class CompactHTMLToken {
+public:
+ explicit CompactHTMLToken(const HTMLToken&);
+
+ bool isSafeToSendToAnotherThread() const;
+
+ HTMLTokenTypes::Type type() const { return m_type; }
+ const String& data() const { return m_data; }
+ bool selfClosing() const { return m_selfClosing; }
+ const Vector<CompactAttribute>& attributes() const { return m_attributes; }
+
+ const String& publicIdentifier() const { return m_publicIdentifier; }
+ const String& systemIdentifier() const { return m_systemIdentifier; }
+
+private:
+ HTMLTokenTypes::Type m_type;
+ String m_data; // "name", "characters", or "data" depending on m_type
+ bool m_selfClosing;
+ Vector<CompactAttribute> m_attributes;
+
+ // For doctype only.
+ String m_publicIdentifier;
+ String m_systemIdentifier;
+};
+
+}
+
+#endif // ENABLE(THREADED_HTML_PARSER)
+
+#endif
Modified: trunk/Source/WebCore/xml/parser/MarkupTokenBase.h (139944 => 139945)
--- trunk/Source/WebCore/xml/parser/MarkupTokenBase.h 2013-01-17 02:05:33 UTC (rev 139944)
+++ trunk/Source/WebCore/xml/parser/MarkupTokenBase.h 2013-01-17 02:18:20 UTC (rev 139945)
@@ -321,6 +321,12 @@
return m_data;
}
+ const DataVector& data() const
+ {
+ ASSERT(m_type == TypeSet::Character || m_type == TypeSet::Comment || m_type == TypeSet::StartTag || m_type == TypeSet::EndTag);
+ return m_data;
+ }
+
bool isAll8BitData() const
{
return (m_orAllData <= 0xff);