OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/css/parser/CSSLazyPropertyParserImpl.h" | 5 #include "core/css/parser/CSSLazyPropertyParserImpl.h" |
6 | 6 |
7 #include "core/css/parser/CSSLazyParsingState.h" | 7 #include "core/css/parser/CSSLazyParsingState.h" |
8 #include "core/css/parser/CSSParserImpl.h" | 8 #include "core/css/parser/CSSParserImpl.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 CSSLazyPropertyParserImpl::CSSLazyPropertyParserImpl(CSSParserTokenRange block, | 12 CSSLazyPropertyParserImpl::CSSLazyPropertyParserImpl(size_t startOffset, |
13 CSSLazyParsingState* state) | 13 CSSLazyParsingState* state) |
14 : CSSLazyPropertyParser(), m_lazyState(state) { | 14 : CSSLazyPropertyParser(), m_startOffset(startOffset), m_lazyState(state) {} |
15 // Reserve capacity to minimize heap bloat. | |
16 size_t length = block.end() - block.begin(); | |
17 m_tokens.reserveCapacity(length); | |
18 m_tokens.append(block.begin(), length); | |
19 } | |
20 | 15 |
21 StylePropertySet* CSSLazyPropertyParserImpl::parseProperties() { | 16 StylePropertySet* CSSLazyPropertyParserImpl::parseProperties() { |
22 m_lazyState->countRuleParsed(); | 17 m_lazyState->countRuleParsed(); |
23 return CSSParserImpl::parseDeclarationListForLazyStyle( | 18 return CSSParserImpl::parseDeclarationListForLazyStyle( |
24 m_tokens, m_lazyState->context()); | 19 m_lazyState->sheetText(), m_startOffset, m_lazyState->context()); |
25 } | 20 } |
26 | 21 |
27 } // namespace blink | 22 } // namespace blink |
OLD | NEW |