| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/css/parser/CSSSelectorParser.h" | 6 #include "core/css/parser/CSSSelectorParser.h" |
| 7 | 7 |
| 8 #include "core/css/CSSSelectorList.h" | 8 #include "core/css/CSSSelectorList.h" |
| 9 #include "core/css/StyleSheetContents.h" | 9 #include "core/css/StyleSheetContents.h" |
| 10 #include "platform/RuntimeEnabledFeatures.h" | 10 #include "platform/RuntimeEnabledFeatures.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 return; | 44 return; |
| 45 selectorList.append(selector.release()); | 45 selectorList.append(selector.release()); |
| 46 } | 46 } |
| 47 | 47 |
| 48 if (!m_failedParsing) | 48 if (!m_failedParsing) |
| 49 output.adoptSelectorVector(selectorList); | 49 output.adoptSelectorVector(selectorList); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void CSSSelectorParser::consumeCompoundSelectorList(CSSParserTokenRange& range,
CSSSelectorList& output) | 52 void CSSSelectorParser::consumeCompoundSelectorList(CSSParserTokenRange& range,
CSSSelectorList& output) |
| 53 { | 53 { |
| 54 Vector<OwnPtr<CSSParserSelector> > selectorList; | 54 Vector<OwnPtr<CSSParserSelector>> selectorList; |
| 55 OwnPtr<CSSParserSelector> selector = consumeCompoundSelector(range); | 55 OwnPtr<CSSParserSelector> selector = consumeCompoundSelector(range); |
| 56 range.consumeWhitespaceAndComments(); | 56 range.consumeWhitespaceAndComments(); |
| 57 if (!selector) | 57 if (!selector) |
| 58 return; | 58 return; |
| 59 selectorList.append(selector.release()); | 59 selectorList.append(selector.release()); |
| 60 while (!range.atEnd() && range.peek().type() == CommaToken) { | 60 while (!range.atEnd() && range.peek().type() == CommaToken) { |
| 61 // FIXME: This differs from the spec grammar: | 61 // FIXME: This differs from the spec grammar: |
| 62 // Spec: compound_selector S* [ COMMA S* compound_selector ]* S* | 62 // Spec: compound_selector S* [ COMMA S* compound_selector ]* S* |
| 63 // Impl: compound_selector S* [ COMMA S* compound_selector S* ]* | 63 // Impl: compound_selector S* [ COMMA S* compound_selector S* ]* |
| 64 range.consumeIncludingWhitespaceAndComments(); | 64 range.consumeIncludingWhitespaceAndComments(); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 selector->setSelectorList(adoptPtr(selectorList)); | 305 selector->setSelectorList(adoptPtr(selectorList)); |
| 306 selector->pseudoType(); // FIXME: Do we need to force the pseudo type to
be cached? | 306 selector->pseudoType(); // FIXME: Do we need to force the pseudo type to
be cached? |
| 307 ASSERT(selector->pseudoType() != CSSSelector::PseudoUnknown); | 307 ASSERT(selector->pseudoType() != CSSSelector::PseudoUnknown); |
| 308 return selector.release(); | 308 return selector.release(); |
| 309 } | 309 } |
| 310 | 310 |
| 311 if (colons == 1 && equalIgnoringCase(token.value(), "not")) { | 311 if (colons == 1 && equalIgnoringCase(token.value(), "not")) { |
| 312 OwnPtr<CSSParserSelector> innerSelector = consumeCompoundSelector(block)
; | 312 OwnPtr<CSSParserSelector> innerSelector = consumeCompoundSelector(block)
; |
| 313 if (!innerSelector || !innerSelector->isSimple() || !block.atEnd()) | 313 if (!innerSelector || !innerSelector->isSimple() || !block.atEnd()) |
| 314 return nullptr; | 314 return nullptr; |
| 315 Vector<OwnPtr<CSSParserSelector> > selectorVector; | 315 Vector<OwnPtr<CSSParserSelector>> selectorVector; |
| 316 selectorVector.append(innerSelector.release()); | 316 selectorVector.append(innerSelector.release()); |
| 317 selector->adoptSelectorVector(selectorVector); | 317 selector->adoptSelectorVector(selectorVector); |
| 318 return selector.release(); | 318 return selector.release(); |
| 319 } | 319 } |
| 320 | 320 |
| 321 if (colons == 1 && equalIgnoringCase(token.value(), "lang")) { | 321 if (colons == 1 && equalIgnoringCase(token.value(), "lang")) { |
| 322 // FIXME: CSS Selectors Level 4 allows :lang(*-foo) | 322 // FIXME: CSS Selectors Level 4 allows :lang(*-foo) |
| 323 const CSSParserToken& ident = block.consumeIncludingWhitespaceAndComment
s(); | 323 const CSSParserToken& ident = block.consumeIncludingWhitespaceAndComment
s(); |
| 324 if (ident.type() != IdentToken || !block.atEnd()) | 324 if (ident.type() != IdentToken || !block.atEnd()) |
| 325 return nullptr; | 325 return nullptr; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 } | 608 } |
| 609 if (specifiers->isContentPseudoElement()) { | 609 if (specifiers->isContentPseudoElement()) { |
| 610 specifiers->insertTagHistory(CSSSelector::SubSelector, newSpecifier, CSS
Selector::SubSelector); | 610 specifiers->insertTagHistory(CSSSelector::SubSelector, newSpecifier, CSS
Selector::SubSelector); |
| 611 return specifiers; | 611 return specifiers; |
| 612 } | 612 } |
| 613 specifiers->appendTagHistory(CSSSelector::SubSelector, newSpecifier); | 613 specifiers->appendTagHistory(CSSSelector::SubSelector, newSpecifier); |
| 614 return specifiers; | 614 return specifiers; |
| 615 } | 615 } |
| 616 | 616 |
| 617 } // namespace blink | 617 } // namespace blink |
| OLD | NEW |