Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSLazyPropertyParserImpl.h

Issue 2315923002: Lazy Parse CSS (Closed)
Patch Set: Remove the closure and refactor logic into a separate file Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/parser/CSSLazyPropertyParserImpl.h
diff --git a/third_party/WebKit/Source/core/css/parser/CSSLazyPropertyParserImpl.h b/third_party/WebKit/Source/core/css/parser/CSSLazyPropertyParserImpl.h
new file mode 100644
index 0000000000000000000000000000000000000000..00c04d7d6b8a8a098da164771681b6157883a910
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/parser/CSSLazyPropertyParserImpl.h
@@ -0,0 +1,63 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CSSLazyPropertyParserImpl_h
+#define CSSLazyPropertyParserImpl_h
+
+#include "core/css/CSSSelectorList.h"
+#include "core/css/StylePropertySet.h"
+#include "core/css/parser/CSSParser.h"
+#include "core/css/parser/CSSParserMode.h"
+#include "core/css/parser/CSSParserTokenRange.h"
+#include "core/css/parser/CSSTokenizer.h"
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
+
+namespace blink {
+
+// This class helps lazy parsing by retaining necessary state. It should not
+// outlive the StyleSheetContents that initiated the parse, as it retains a raw
+// reference to the UseCounter associated with the style sheet.
+class CSSLazyParsingState
+ : public GarbageCollectedFinalized<CSSLazyParsingState> {
+ public:
+ CSSLazyParsingState(const CSSParserContext&,
+ std::unique_ptr<Vector<String>> escapedStrings,
esprehn 2016/10/24 21:20:21 There's no reason to pass around a unique_ptr to V
Charlie Harrison 2016/10/25 15:56:55 timloh had wanted to me only lazily initiate the V
Timothy Loh 2016/10/25 23:47:31 I think it was already a unique_ptr at that point,
+ const String& sheetText);
+
+ // This should be a copy of the context used in CSSParser::parseSheet.
+ const CSSParserContext& context() { return m_context; }
+
+ bool shouldLazilyParseProperties(const CSSSelectorList&);
+
+ DEFINE_INLINE_TRACE() {}
+
+ private:
+ CSSParserContext m_context;
+ std::unique_ptr<Vector<String>> m_escapedStrings;
+ // Also referenced on the css resource.
+ String m_sheetText;
+};
+
+// This class is responsible for lazily parsing a single CSS declaration list.
+class CSSLazyPropertyParserImpl : public CSSLazyPropertyParser {
+ public:
+ CSSLazyPropertyParserImpl(CSSParserTokenRange block, CSSLazyParsingState*);
+
+ // CSSLazyPropertyParser:
+ StylePropertySet* parseProperties() override;
+
+ DEFINE_INLINE_TRACE() {
+ visitor->trace(m_lazyState);
+ CSSLazyPropertyParser::trace(visitor);
+ }
+
+ private:
+ Vector<CSSParserToken, 0u> m_tokens;
esprehn 2016/10/24 21:20:21 remove 0, the default is zero, no need to specify
Charlie Harrison 2016/10/25 15:56:55 Done.
+ Member<CSSLazyParsingState> m_lazyState;
+};
+
+} // namespace blink
+
+#endif // CSSLazyPropertyParserImpl_h

Powered by Google App Engine
This is Rietveld 408576698