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 "core/css/parser/CSSSelectorParser.h" | 5 #include "core/css/parser/CSSSelectorParser.h" |
6 | 6 |
7 #include "core/css/CSSSelectorList.h" | 7 #include "core/css/CSSSelectorList.h" |
8 #include "core/css/StyleSheetContents.h" | 8 #include "core/css/StyleSheetContents.h" |
9 #include "core/frame/UseCounter.h" | 9 #include "core/frame/UseCounter.h" |
10 #include "platform/RuntimeEnabledFeatures.h" | 10 #include "platform/RuntimeEnabledFeatures.h" |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 | 696 |
697 const AtomicString& CSSSelectorParser::defaultNamespace() const | 697 const AtomicString& CSSSelectorParser::defaultNamespace() const |
698 { | 698 { |
699 if (!m_styleSheet) | 699 if (!m_styleSheet) |
700 return starAtom; | 700 return starAtom; |
701 return m_styleSheet->defaultNamespace(); | 701 return m_styleSheet->defaultNamespace(); |
702 } | 702 } |
703 | 703 |
704 const AtomicString& CSSSelectorParser::determineNamespace(const AtomicString& pr
efix) | 704 const AtomicString& CSSSelectorParser::determineNamespace(const AtomicString& pr
efix) |
705 { | 705 { |
| 706 if (prefix.isNull()) |
| 707 return defaultNamespace(); |
| 708 if (prefix.isEmpty()) |
| 709 return emptyAtom; // No namespace. If an element/attribute has a namespa
ce, we won't match it. |
| 710 if (prefix == starAtom) |
| 711 return starAtom; // We'll match any namespace. |
706 if (!m_styleSheet) | 712 if (!m_styleSheet) |
707 return defaultNamespace(); | 713 return nullAtom; // Cannot resolve prefix to namespace without a stylesh
eet, syntax error. |
708 return m_styleSheet->determineNamespace(prefix); | 714 return m_styleSheet->namespaceURIFromPrefix(prefix); |
709 } | 715 } |
710 | 716 |
711 void CSSSelectorParser::prependTypeSelectorIfNeeded(const AtomicString& namespac
ePrefix, const AtomicString& elementName, CSSParserSelector* compoundSelector) | 717 void CSSSelectorParser::prependTypeSelectorIfNeeded(const AtomicString& namespac
ePrefix, const AtomicString& elementName, CSSParserSelector* compoundSelector) |
712 { | 718 { |
713 if (elementName.isNull() && defaultNamespace() == starAtom && !compoundSelec
tor->needsImplicitShadowCombinatorForMatching()) | 719 if (elementName.isNull() && defaultNamespace() == starAtom && !compoundSelec
tor->needsImplicitShadowCombinatorForMatching()) |
714 return; | 720 return; |
715 | 721 |
716 AtomicString determinedElementName = elementName.isNull() ? starAtom : eleme
ntName; | 722 AtomicString determinedElementName = elementName.isNull() ? starAtom : eleme
ntName; |
717 AtomicString namespaceURI = determineNamespace(namespacePrefix); | 723 AtomicString namespaceURI = determineNamespace(namespacePrefix); |
718 if (namespaceURI.isNull()) { | 724 if (namespaceURI.isNull()) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 | 771 |
766 if (!splitAfter || !splitAfter->tagHistory()) | 772 if (!splitAfter || !splitAfter->tagHistory()) |
767 return compoundSelector; | 773 return compoundSelector; |
768 | 774 |
769 OwnPtr<CSSParserSelector> secondCompound = splitAfter->releaseTagHistory(); | 775 OwnPtr<CSSParserSelector> secondCompound = splitAfter->releaseTagHistory(); |
770 secondCompound->appendTagHistory(secondCompound->pseudoType() == CSSSelector
::PseudoSlotted ? CSSSelector::ShadowSlot : CSSSelector::ShadowPseudo, compoundS
elector); | 776 secondCompound->appendTagHistory(secondCompound->pseudoType() == CSSSelector
::PseudoSlotted ? CSSSelector::ShadowSlot : CSSSelector::ShadowPseudo, compoundS
elector); |
771 return secondCompound.release(); | 777 return secondCompound.release(); |
772 } | 778 } |
773 | 779 |
774 } // namespace blink | 780 } // namespace blink |
OLD | NEW |