Chromium Code Reviews| 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 |