| Index: third_party/WebKit/Source/core/css/parser/CSSLazyPropertyParserImpl.cpp
|
| diff --git a/third_party/WebKit/Source/core/css/parser/CSSLazyPropertyParserImpl.cpp b/third_party/WebKit/Source/core/css/parser/CSSLazyPropertyParserImpl.cpp
|
| index 7431d1176b3fe0d5ec14f158b6ee2b4f09a2244d..985d69b7b1cc46bf660b55d3272701c049b9f448 100644
|
| --- a/third_party/WebKit/Source/core/css/parser/CSSLazyPropertyParserImpl.cpp
|
| +++ b/third_party/WebKit/Source/core/css/parser/CSSLazyPropertyParserImpl.cpp
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "core/css/parser/CSSLazyParsingState.h"
|
| #include "core/css/parser/CSSParserImpl.h"
|
| +#include "core/css/parser/CSSTokenizer.h"
|
|
|
| namespace blink {
|
|
|
| @@ -16,10 +17,52 @@ CSSLazyPropertyParserImpl::CSSLazyPropertyParserImpl(CSSParserTokenRange block,
|
| size_t length = block.end() - block.begin();
|
| m_tokens.reserveCapacity(length);
|
| m_tokens.append(block.begin(), length);
|
| +
|
| + // TEST:
|
| + discardTokensIfPossible();
|
| +}
|
| +
|
| +CSSLazyPropertyParserImpl::~CSSLazyPropertyParserImpl() {}
|
| +
|
| +// If the first and last tokens have a string backing, generate a StringView
|
| +// from their character offsets. Note that this assumes they share a backing
|
| +// string! Be extremely careful that the first and last token do not point to a
|
| +// string in the escaped string pool!
|
| +void CSSLazyPropertyParserImpl::discardTokensIfPossible() {
|
| + CSSParserToken* begin = m_tokens.begin();
|
| + CSSParserToken* end = m_tokens.end() - 1;
|
| + if (!begin->hasStringBacking() || !end->hasStringBacking())
|
| + return;
|
| +
|
| + StringView beginView = begin->value();
|
| + StringView endView = end->value();
|
| + if (m_lazyState->tokenBackingUsesEscapedString(beginView.bytes()) ||
|
| + m_lazyState->tokenBackingUsesEscapedString(endView.bytes()))
|
| + return;
|
| + if (beginView.is8Bit() && endView.is8Bit()) {
|
| + m_tokenView = StringView(
|
| + beginView.characters8(),
|
| + endView.characters8() - beginView.characters8() + endView.length());
|
| + } else if (!beginView.is8Bit() && !endView.is8Bit()) {
|
| + m_tokenView = StringView(
|
| + beginView.characters16(),
|
| + endView.characters16() - beginView.characters16() + endView.length());
|
| + } else {
|
| + NOTREACHED();
|
| + }
|
| + m_tokens.clear();
|
| +}
|
| +
|
| +StylePropertySet* CSSLazyPropertyParserImpl::retokenizeAndParseProperties() {
|
| + CSSTokenizer tokenizer(m_tokenView.toString());
|
| + return CSSParserImpl::parseDeclarationListForLazyStyle(
|
| + tokenizer.tokenRange(), m_lazyState->context());
|
| }
|
|
|
| StylePropertySet* CSSLazyPropertyParserImpl::parseProperties() {
|
| m_lazyState->countRuleParsed();
|
| + if (m_tokens.isEmpty())
|
| + return retokenizeAndParseProperties();
|
| return CSSParserImpl::parseDeclarationListForLazyStyle(
|
| m_tokens, m_lazyState->context());
|
| }
|
|
|