| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/css/parser/CSSLazyParsingState.h" |
| 6 |
| 7 namespace blink { |
| 8 |
| 9 CSSLazyParsingState::CSSLazyParsingState(const CSSParserContext& context, |
| 10 Vector<String> escapedStrings, |
| 11 const String& sheetText) |
| 12 : m_context(context), |
| 13 m_escapedStrings(std::move(escapedStrings)), |
| 14 m_sheetText(sheetText) {} |
| 15 |
| 16 // Disallow lazy parsing for blocks which have |
| 17 // - before/after in their selector list. This ensures we don't cause a |
| 18 // collectFeatures() when we trigger parsing for attr() functions which would |
| 19 // trigger expensive invalidation propagation. |
| 20 // |
| 21 // Note: another optimization might be to disallow lazy parsing for rules which |
| 22 // will end up being empty. This is hard to know without parsing but we may be |
| 23 // able to catch the {}, { } cases. This would be to hit |
| 24 // StyleRule::shouldConsiderForMatchingRules more. |
| 25 bool CSSLazyParsingState::shouldLazilyParseProperties( |
| 26 const CSSSelectorList& selectors) { |
| 27 for (const auto* s = selectors.first(); s; s = CSSSelectorList::next(*s)) { |
| 28 const CSSSelector::PseudoType type(s->getPseudoType()); |
| 29 if (type == CSSSelector::PseudoBefore || type == CSSSelector::PseudoAfter) |
| 30 return false; |
| 31 } |
| 32 return true; |
| 33 } |
| 34 |
| 35 } // namespace blink |
| OLD | NEW |