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 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1892 | 1892 |
1893 QualifiedName BisonCSSParser::determineNameInNamespace(const AtomicString& prefi
x, const AtomicString& localName) | 1893 QualifiedName BisonCSSParser::determineNameInNamespace(const AtomicString& prefi
x, const AtomicString& localName) |
1894 { | 1894 { |
1895 if (!m_styleSheet) | 1895 if (!m_styleSheet) |
1896 return QualifiedName(prefix, localName, m_defaultNamespace); | 1896 return QualifiedName(prefix, localName, m_defaultNamespace); |
1897 return QualifiedName(prefix, localName, m_styleSheet->determineNamespace(pre
fix)); | 1897 return QualifiedName(prefix, localName, m_styleSheet->determineNamespace(pre
fix)); |
1898 } | 1898 } |
1899 | 1899 |
1900 CSSParserSelector* BisonCSSParser::rewriteSpecifiersWithNamespaceIfNeeded(CSSPar
serSelector* specifiers) | 1900 CSSParserSelector* BisonCSSParser::rewriteSpecifiersWithNamespaceIfNeeded(CSSPar
serSelector* specifiers) |
1901 { | 1901 { |
1902 if (m_defaultNamespace != starAtom || specifiers->needsCrossingTreeScopeBoun
dary()) | 1902 if (m_defaultNamespace != starAtom || specifiers->crossesTreeScopes()) |
1903 return rewriteSpecifiersWithElementName(nullAtom, starAtom, specifiers,
/*tagIsForNamespaceRule*/true); | 1903 return rewriteSpecifiersWithElementName(nullAtom, starAtom, specifiers,
/*tagIsForNamespaceRule*/true); |
1904 return specifiers; | 1904 return specifiers; |
1905 } | 1905 } |
1906 | 1906 |
1907 CSSParserSelector* BisonCSSParser::rewriteSpecifiersWithElementName(const Atomic
String& namespacePrefix, const AtomicString& elementName, CSSParserSelector* spe
cifiers, bool tagIsForNamespaceRule) | 1907 CSSParserSelector* BisonCSSParser::rewriteSpecifiersWithElementName(const Atomic
String& namespacePrefix, const AtomicString& elementName, CSSParserSelector* spe
cifiers, bool tagIsForNamespaceRule) |
1908 { | 1908 { |
1909 AtomicString determinedNamespace = namespacePrefix != nullAtom && m_styleShe
et ? m_styleSheet->determineNamespace(namespacePrefix) : m_defaultNamespace; | 1909 AtomicString determinedNamespace = namespacePrefix != nullAtom && m_styleShe
et ? m_styleSheet->determineNamespace(namespacePrefix) : m_defaultNamespace; |
1910 QualifiedName tag(namespacePrefix, elementName, determinedNamespace); | 1910 QualifiedName tag(namespacePrefix, elementName, determinedNamespace); |
1911 | 1911 |
1912 if (specifiers->needsCrossingTreeScopeBoundary()) | 1912 if (specifiers->crossesTreeScopes()) |
1913 return rewriteSpecifiersWithElementNameForCustomPseudoElement(tag, eleme
ntName, specifiers, tagIsForNamespaceRule); | 1913 return rewriteSpecifiersWithElementNameForCustomPseudoElement(tag, eleme
ntName, specifiers, tagIsForNamespaceRule); |
1914 | 1914 |
1915 if (specifiers->isContentPseudoElement()) | 1915 if (specifiers->isContentPseudoElement()) |
1916 return rewriteSpecifiersWithElementNameForContentPseudoElement(tag, elem
entName, specifiers, tagIsForNamespaceRule); | 1916 return rewriteSpecifiersWithElementNameForContentPseudoElement(tag, elem
entName, specifiers, tagIsForNamespaceRule); |
1917 | 1917 |
1918 // *:host never matches, so we can't discard the * otherwise we can't tell t
he | 1918 // *:host never matches, so we can't discard the * otherwise we can't tell t
he |
1919 // difference between *:host and just :host. | 1919 // difference between *:host and just :host. |
1920 if (tag == anyQName() && !specifiers->hasHostPseudoSelector()) | 1920 if (tag == anyQName() && !specifiers->hasHostPseudoSelector()) |
1921 return specifiers; | 1921 return specifiers; |
1922 if (specifiers->pseudoType() != CSSSelector::PseudoCue) | 1922 if (specifiers->pseudoType() != CSSSelector::PseudoCue) |
1923 specifiers->prependTagSelector(tag, tagIsForNamespaceRule); | 1923 specifiers->prependTagSelector(tag, tagIsForNamespaceRule); |
1924 return specifiers; | 1924 return specifiers; |
1925 } | 1925 } |
1926 | 1926 |
1927 CSSParserSelector* BisonCSSParser::rewriteSpecifiersWithElementNameForCustomPseu
doElement(const QualifiedName& tag, const AtomicString& elementName, CSSParserSe
lector* specifiers, bool tagIsForNamespaceRule) | 1927 CSSParserSelector* BisonCSSParser::rewriteSpecifiersWithElementNameForCustomPseu
doElement(const QualifiedName& tag, const AtomicString& elementName, CSSParserSe
lector* specifiers, bool tagIsForNamespaceRule) |
1928 { | 1928 { |
1929 if (m_context.useCounter() && specifiers->pseudoType() == CSSSelector::Pseud
oUserAgentCustomElement) | 1929 if (m_context.useCounter() && specifiers->pseudoType() == CSSSelector::Pseud
oUserAgentCustomElement) |
1930 m_context.useCounter()->count(UseCounter::CSSPseudoElementUserAgentCusto
mPseudo); | 1930 m_context.useCounter()->count(UseCounter::CSSPseudoElementUserAgentCusto
mPseudo); |
1931 | 1931 |
1932 CSSParserSelector* lastShadowPseudo = specifiers; | 1932 CSSParserSelector* lastShadowPseudo = specifiers; |
1933 CSSParserSelector* history = specifiers; | 1933 CSSParserSelector* history = specifiers; |
1934 while (history->tagHistory()) { | 1934 while (history->tagHistory()) { |
1935 history = history->tagHistory(); | 1935 history = history->tagHistory(); |
1936 if (history->needsCrossingTreeScopeBoundary() || history->hasShadowPseud
o()) | 1936 if (history->crossesTreeScopes() || history->hasShadowPseudo()) |
1937 lastShadowPseudo = history; | 1937 lastShadowPseudo = history; |
1938 } | 1938 } |
1939 | 1939 |
1940 if (lastShadowPseudo->tagHistory()) { | 1940 if (lastShadowPseudo->tagHistory()) { |
1941 if (tag != anyQName()) | 1941 if (tag != anyQName()) |
1942 lastShadowPseudo->tagHistory()->prependTagSelector(tag, tagIsForName
spaceRule); | 1942 lastShadowPseudo->tagHistory()->prependTagSelector(tag, tagIsForName
spaceRule); |
1943 return specifiers; | 1943 return specifiers; |
1944 } | 1944 } |
1945 | 1945 |
1946 // For shadow-ID pseudo-elements to be correctly matched, the ShadowPseudo c
ombinator has to be used. | 1946 // For shadow-ID pseudo-elements to be correctly matched, the ShadowPseudo c
ombinator has to be used. |
(...skipping 23 matching lines...) Expand all Loading... |
1970 // For shadow-ID pseudo-elements to be correctly matched, the ShadowPseudo c
ombinator has to be used. | 1970 // For shadow-ID pseudo-elements to be correctly matched, the ShadowPseudo c
ombinator has to be used. |
1971 // We therefore create a new Selector with that combinator here in any case,
even if matching any (host) element in any namespace (i.e. '*'). | 1971 // We therefore create a new Selector with that combinator here in any case,
even if matching any (host) element in any namespace (i.e. '*'). |
1972 OwnPtr<CSSParserSelector> elementNameSelector = adoptPtr(new CSSParserSelect
or(tag)); | 1972 OwnPtr<CSSParserSelector> elementNameSelector = adoptPtr(new CSSParserSelect
or(tag)); |
1973 last->setTagHistory(elementNameSelector.release()); | 1973 last->setTagHistory(elementNameSelector.release()); |
1974 last->setRelation(CSSSelector::SubSelector); | 1974 last->setRelation(CSSSelector::SubSelector); |
1975 return specifiers; | 1975 return specifiers; |
1976 } | 1976 } |
1977 | 1977 |
1978 CSSParserSelector* BisonCSSParser::rewriteSpecifiers(CSSParserSelector* specifie
rs, CSSParserSelector* newSpecifier) | 1978 CSSParserSelector* BisonCSSParser::rewriteSpecifiers(CSSParserSelector* specifie
rs, CSSParserSelector* newSpecifier) |
1979 { | 1979 { |
1980 if (newSpecifier->needsCrossingTreeScopeBoundary()) { | 1980 if (newSpecifier->crossesTreeScopes()) { |
1981 // Unknown pseudo element always goes at the top of selector chain. | 1981 // Unknown pseudo element always goes at the top of selector chain. |
1982 newSpecifier->appendTagHistory(CSSSelector::ShadowPseudo, sinkFloatingSe
lector(specifiers)); | 1982 newSpecifier->appendTagHistory(CSSSelector::ShadowPseudo, sinkFloatingSe
lector(specifiers)); |
1983 return newSpecifier; | 1983 return newSpecifier; |
1984 } | 1984 } |
1985 if (newSpecifier->isContentPseudoElement()) { | 1985 if (newSpecifier->isContentPseudoElement()) { |
1986 newSpecifier->appendTagHistory(CSSSelector::SubSelector, sinkFloatingSel
ector(specifiers)); | 1986 newSpecifier->appendTagHistory(CSSSelector::SubSelector, sinkFloatingSel
ector(specifiers)); |
1987 return newSpecifier; | 1987 return newSpecifier; |
1988 } | 1988 } |
1989 if (specifiers->needsCrossingTreeScopeBoundary()) { | 1989 if (specifiers->crossesTreeScopes()) { |
1990 // Specifiers for unknown pseudo element go right behind it in the chain
. | 1990 // Specifiers for unknown pseudo element go right behind it in the chain
. |
1991 specifiers->insertTagHistory(CSSSelector::SubSelector, sinkFloatingSelec
tor(newSpecifier), CSSSelector::ShadowPseudo); | 1991 specifiers->insertTagHistory(CSSSelector::SubSelector, sinkFloatingSelec
tor(newSpecifier), CSSSelector::ShadowPseudo); |
1992 return specifiers; | 1992 return specifiers; |
1993 } | 1993 } |
1994 if (specifiers->isContentPseudoElement()) { | 1994 if (specifiers->isContentPseudoElement()) { |
1995 specifiers->insertTagHistory(CSSSelector::SubSelector, sinkFloatingSelec
tor(newSpecifier), CSSSelector::SubSelector); | 1995 specifiers->insertTagHistory(CSSSelector::SubSelector, sinkFloatingSelec
tor(newSpecifier), CSSSelector::SubSelector); |
1996 return specifiers; | 1996 return specifiers; |
1997 } | 1997 } |
1998 specifiers->appendTagHistory(CSSSelector::SubSelector, sinkFloatingSelector(
newSpecifier)); | 1998 specifiers->appendTagHistory(CSSSelector::SubSelector, sinkFloatingSelector(
newSpecifier)); |
1999 return specifiers; | 1999 return specifiers; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2168 rule->setProperties(createStylePropertySet()); | 2168 rule->setProperties(createStylePropertySet()); |
2169 clearProperties(); | 2169 clearProperties(); |
2170 | 2170 |
2171 StyleRuleViewport* result = rule.get(); | 2171 StyleRuleViewport* result = rule.get(); |
2172 m_parsedRules.append(rule.release()); | 2172 m_parsedRules.append(rule.release()); |
2173 | 2173 |
2174 return result; | 2174 return result; |
2175 } | 2175 } |
2176 | 2176 |
2177 } | 2177 } |
OLD | NEW |