OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
10 * | 10 * |
(...skipping 1887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1898 { | 1898 { |
1899 if (!m_styleSheet) | 1899 if (!m_styleSheet) |
1900 return QualifiedName(prefix, localName, m_defaultNamespace); | 1900 return QualifiedName(prefix, localName, m_defaultNamespace); |
1901 return QualifiedName(prefix, localName, m_styleSheet->determineNamespace(pre
fix)); | 1901 return QualifiedName(prefix, localName, m_styleSheet->determineNamespace(pre
fix)); |
1902 } | 1902 } |
1903 | 1903 |
1904 CSSParserSelector* BisonCSSParser::rewriteSpecifiersWithNamespaceIfNeeded(CSSPar
serSelector* specifiers) | 1904 CSSParserSelector* BisonCSSParser::rewriteSpecifiersWithNamespaceIfNeeded(CSSPar
serSelector* specifiers) |
1905 { | 1905 { |
1906 if (m_defaultNamespace != starAtom || specifiers->needsCrossingTreeScopeBoun
dary()) | 1906 if (m_defaultNamespace != starAtom || specifiers->needsCrossingTreeScopeBoun
dary()) |
1907 return rewriteSpecifiersWithElementName(nullAtom, starAtom, specifiers,
/*tagIsForNamespaceRule*/true); | 1907 return rewriteSpecifiersWithElementName(nullAtom, starAtom, specifiers,
/*tagIsForNamespaceRule*/true); |
1908 if (CSSParserSelector* distributedPseudoElementSelector = specifiers->findDi
stributedPseudoElementSelector()) { | |
1909 specifiers->prependTagSelector(QualifiedName(nullAtom, starAtom, m_defau
ltNamespace), /*tagIsForNamespaceRule*/true); | |
1910 return rewriteSpecifiersForShadowDistributed(specifiers, distributedPseu
doElementSelector); | |
1911 } | |
1912 return specifiers; | 1908 return specifiers; |
1913 } | 1909 } |
1914 | 1910 |
1915 CSSParserSelector* BisonCSSParser::rewriteSpecifiersWithElementName(const Atomic
String& namespacePrefix, const AtomicString& elementName, CSSParserSelector* spe
cifiers, bool tagIsForNamespaceRule) | 1911 CSSParserSelector* BisonCSSParser::rewriteSpecifiersWithElementName(const Atomic
String& namespacePrefix, const AtomicString& elementName, CSSParserSelector* spe
cifiers, bool tagIsForNamespaceRule) |
1916 { | 1912 { |
1917 AtomicString determinedNamespace = namespacePrefix != nullAtom && m_styleShe
et ? m_styleSheet->determineNamespace(namespacePrefix) : m_defaultNamespace; | 1913 AtomicString determinedNamespace = namespacePrefix != nullAtom && m_styleShe
et ? m_styleSheet->determineNamespace(namespacePrefix) : m_defaultNamespace; |
1918 QualifiedName tag(namespacePrefix, elementName, determinedNamespace); | 1914 QualifiedName tag(namespacePrefix, elementName, determinedNamespace); |
1919 | 1915 |
1920 if (CSSParserSelector* distributedPseudoElementSelector = specifiers->findDi
stributedPseudoElementSelector()) { | |
1921 specifiers->prependTagSelector(tag, tagIsForNamespaceRule); | |
1922 return rewriteSpecifiersForShadowDistributed(specifiers, distributedPseu
doElementSelector); | |
1923 } | |
1924 | |
1925 if (specifiers->needsCrossingTreeScopeBoundary()) | 1916 if (specifiers->needsCrossingTreeScopeBoundary()) |
1926 return rewriteSpecifiersWithElementNameForCustomPseudoElement(tag, eleme
ntName, specifiers, tagIsForNamespaceRule); | 1917 return rewriteSpecifiersWithElementNameForCustomPseudoElement(tag, eleme
ntName, specifiers, tagIsForNamespaceRule); |
1927 | 1918 |
1928 if (specifiers->isContentPseudoElement()) | 1919 if (specifiers->isContentPseudoElement()) |
1929 return rewriteSpecifiersWithElementNameForContentPseudoElement(tag, elem
entName, specifiers, tagIsForNamespaceRule); | 1920 return rewriteSpecifiersWithElementNameForContentPseudoElement(tag, elem
entName, specifiers, tagIsForNamespaceRule); |
1930 | 1921 |
1931 // *:host never matches, so we can't discard the * otherwise we can't tell t
he | 1922 // *:host never matches, so we can't discard the * otherwise we can't tell t
he |
1932 // difference between *:host and just :host. | 1923 // difference between *:host and just :host. |
1933 if (tag == anyQName() && !specifiers->hasHostPseudoSelector()) | 1924 if (tag == anyQName() && !specifiers->hasHostPseudoSelector()) |
1934 return specifiers; | 1925 return specifiers; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1981 } | 1972 } |
1982 | 1973 |
1983 // For shadow-ID pseudo-elements to be correctly matched, the ShadowPseudo c
ombinator has to be used. | 1974 // For shadow-ID pseudo-elements to be correctly matched, the ShadowPseudo c
ombinator has to be used. |
1984 // We therefore create a new Selector with that combinator here in any case,
even if matching any (host) element in any namespace (i.e. '*'). | 1975 // We therefore create a new Selector with that combinator here in any case,
even if matching any (host) element in any namespace (i.e. '*'). |
1985 OwnPtr<CSSParserSelector> elementNameSelector = adoptPtr(new CSSParserSelect
or(tag)); | 1976 OwnPtr<CSSParserSelector> elementNameSelector = adoptPtr(new CSSParserSelect
or(tag)); |
1986 last->setTagHistory(elementNameSelector.release()); | 1977 last->setTagHistory(elementNameSelector.release()); |
1987 last->setRelation(CSSSelector::SubSelector); | 1978 last->setRelation(CSSSelector::SubSelector); |
1988 return specifiers; | 1979 return specifiers; |
1989 } | 1980 } |
1990 | 1981 |
1991 CSSParserSelector* BisonCSSParser::rewriteSpecifiersForShadowDistributed(CSSPars
erSelector* specifiers, CSSParserSelector* distributedPseudoElementSelector) | |
1992 { | |
1993 if (m_context.useCounter()) | |
1994 m_context.useCounter()->count(UseCounter::CSSPseudoElementPrefixedDistri
buted); | |
1995 CSSParserSelector* argumentSelector = distributedPseudoElementSelector->func
tionArgumentSelector(); | |
1996 ASSERT(argumentSelector); | |
1997 ASSERT(!specifiers->isDistributedPseudoElement()); | |
1998 for (CSSParserSelector* end = specifiers; end->tagHistory(); end = end->tagH
istory()) { | |
1999 if (end->tagHistory()->isDistributedPseudoElement()) { | |
2000 end->clearTagHistory(); | |
2001 break; | |
2002 } | |
2003 } | |
2004 CSSParserSelector* end = argumentSelector; | |
2005 while (end->tagHistory()) | |
2006 end = end->tagHistory(); | |
2007 | |
2008 switch (end->relation()) { | |
2009 case CSSSelector::Child: | |
2010 case CSSSelector::Descendant: | |
2011 end->setTagHistory(sinkFloatingSelector(specifiers)); | |
2012 end->setRelationIsAffectedByPseudoContent(); | |
2013 return argumentSelector; | |
2014 default: | |
2015 return 0; | |
2016 } | |
2017 } | |
2018 | |
2019 CSSParserSelector* BisonCSSParser::rewriteSpecifiers(CSSParserSelector* specifie
rs, CSSParserSelector* newSpecifier) | 1982 CSSParserSelector* BisonCSSParser::rewriteSpecifiers(CSSParserSelector* specifie
rs, CSSParserSelector* newSpecifier) |
2020 { | 1983 { |
2021 if (newSpecifier->needsCrossingTreeScopeBoundary()) { | 1984 if (newSpecifier->needsCrossingTreeScopeBoundary()) { |
2022 // Unknown pseudo element always goes at the top of selector chain. | 1985 // Unknown pseudo element always goes at the top of selector chain. |
2023 newSpecifier->appendTagHistory(CSSSelector::ShadowPseudo, sinkFloatingSe
lector(specifiers)); | 1986 newSpecifier->appendTagHistory(CSSSelector::ShadowPseudo, sinkFloatingSe
lector(specifiers)); |
2024 return newSpecifier; | 1987 return newSpecifier; |
2025 } | 1988 } |
2026 if (newSpecifier->isContentPseudoElement()) { | 1989 if (newSpecifier->isContentPseudoElement()) { |
2027 newSpecifier->appendTagHistory(CSSSelector::SubSelector, sinkFloatingSel
ector(specifiers)); | 1990 newSpecifier->appendTagHistory(CSSSelector::SubSelector, sinkFloatingSel
ector(specifiers)); |
2028 return newSpecifier; | 1991 return newSpecifier; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2209 rule->setProperties(createStylePropertySet()); | 2172 rule->setProperties(createStylePropertySet()); |
2210 clearProperties(); | 2173 clearProperties(); |
2211 | 2174 |
2212 StyleRuleViewport* result = rule.get(); | 2175 StyleRuleViewport* result = rule.get(); |
2213 m_parsedRules.append(rule.release()); | 2176 m_parsedRules.append(rule.release()); |
2214 | 2177 |
2215 return result; | 2178 return result; |
2216 } | 2179 } |
2217 | 2180 |
2218 } | 2181 } |
OLD | NEW |