XSSAuditor performance regression in M26

The refactoring we did for the threaded parser introduced a performance
regression in innerHTML because we'd boot up the XSSAuditor for fragment
parsing. This CL returns to our earlier behavior of not booting up the
XSSAuditor when parsing fragments.

BUG=230504
TBR=eseidel

Review URL: https://codereview.chromium.org/14327009

git-svn-id: svn://svn.chromium.org/blink/trunk@148792 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/Source/core/html/parser/HTMLDocumentParser.cpp b/Source/core/html/parser/HTMLDocumentParser.cpp
index 0f8e97f..1ad5f1f 100644
--- a/Source/core/html/parser/HTMLDocumentParser.cpp
+++ b/Source/core/html/parser/HTMLDocumentParser.cpp
@@ -114,6 +114,7 @@
     ASSERT(!shouldUseThreading());
     bool reportErrors = false; // For now document fragment parsing never reports errors.
     m_tokenizer->setState(tokenizerStateForContextElement(contextElement, reportErrors, m_options));
+    m_xssAuditor.initForFragment();
 }
 
 HTMLDocumentParser::~HTMLDocumentParser()
diff --git a/Source/core/html/parser/XSSAuditor.cpp b/Source/core/html/parser/XSSAuditor.cpp
index e9d1b64..57e7e48 100644
--- a/Source/core/html/parser/XSSAuditor.cpp
+++ b/Source/core/html/parser/XSSAuditor.cpp
@@ -227,6 +227,16 @@
     // we want to reference might not all have been constructed yet.
 }
 
+void XSSAuditor::initForFragment()
+{
+    ASSERT(isMainThread());
+    ASSERT(m_state == Uninitialized);
+    m_state = Initialized;
+    // When parsing a fragment, we don't enable the XSS auditor because it's
+    // too much overhead.
+    ASSERT(!m_isEnabled);
+}
+
 void XSSAuditor::init(Document* document, XSSAuditorDelegate* auditorDelegate)
 {
     const size_t miniumLengthForSuffixTree = 512; // FIXME: Tune this parameter.
diff --git a/Source/core/html/parser/XSSAuditor.h b/Source/core/html/parser/XSSAuditor.h
index 82be346..07e8465 100644
--- a/Source/core/html/parser/XSSAuditor.h
+++ b/Source/core/html/parser/XSSAuditor.h
@@ -59,6 +59,8 @@
     XSSAuditor();
 
     void init(Document*, XSSAuditorDelegate*);
+    void initForFragment();
+
     PassOwnPtr<XSSInfo> filterToken(const FilterTokenRequest&);
     bool isSafeToSendToAnotherThread() const;