summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/css/CSSSelector.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-06-08 08:26:01 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-06-08 08:26:01 -0700
commit3742ac093d35d923c81693096ab6671e9b147700 (patch)
treec2add9100f789dad45ef1ec5328bddde02c47a4c /Source/WebCore/css/CSSSelector.cpp
parent901401d90459bc22580842455d4588b9a697514d (diff)
parente5926f4a0d6adc9ad4a75824129f117181953560 (diff)
downloadexternal_webkit-3742ac093d35d923c81693096ab6671e9b147700.zip
external_webkit-3742ac093d35d923c81693096ab6671e9b147700.tar.gz
external_webkit-3742ac093d35d923c81693096ab6671e9b147700.tar.bz2
Merge changes I55c6d71a,Ifb3277d4,Ia1b847a2,I7ba9cf3f,Ida2b2a8a,I1280ec90,I72f818d5,I2e3b588b,I9a4e6289,Ia724c78b,Icd8612c8,Ie31b15d7,Ie125edae,I77941a88,I89dae78b,I3516e5ca,I1a4c17b5,I2c4ecc1a,I9c8e6537,Ifac13115,Ie1f80e09,Ia541ed77,I60ce9d78
* changes: Merge WebKit at r82507: Update ThirdPartyProject.prop Merge WebKit at r82507: Cherry-pick change r88166 to add INSPECTOR guards to ScriptProfiler Merge WebKit at r82507: Work around a V8 bug Merge WebKit at r82507: JNIType renamed to JavaType Merge WebKit at r82507: IconDatabaseClient interface expanded Merge WebKit at r82507: Don't use new loss-free code path in HTMLCanvasElement::toDataURL() Merge WebKit at r82507: IcondDatabaseBase::iconForPageURL() renamed Merge WebKit at r82507: IconDatabaseBase::Open() signature changed Merge WebKit at r82507: Node::isContentEditable() renamed Merge WebKit at r82507: Use icon database through IconDatabaseBase Merge WebKit at r82507: toInputElement() is now a member of Node Merge WebKit at r82507: FrameLoaderClient::objectContentType() signature changed Merge WebKit at r82507: StringImpl::computeHash() removed Merge WebKit at r82507: Stub out FontPlatformData::setOrientation() Merge WebKit at r82507: Path::strokeBoundingRect() is now const Merge WebKit at r82507: Add missing UnusedParam.h include in ApplicationCacheGroup.cpp Merge WebKit at r82507: Continue to use Android's version of FontPlatformData.h Merge WebKit at r82507: Update signature of FontCustomPlatformData::fontPlatformData() Merge WebKit at r82507: Fix conflicts due to JNI refactoring Merge WebKit at r82507: Fix conflicts due to new StorageTracker Merge WebKit at r82507: Fix conflicts Merge WebKit at r82507: Fix makefiles Merge WebKit at r82507: Initial merge by git
Diffstat (limited to 'Source/WebCore/css/CSSSelector.cpp')
-rw-r--r--Source/WebCore/css/CSSSelector.cpp69
1 files changed, 54 insertions, 15 deletions
diff --git a/Source/WebCore/css/CSSSelector.cpp b/Source/WebCore/css/CSSSelector.cpp
index c804697..a87d4f3 100644
--- a/Source/WebCore/css/CSSSelector.cpp
+++ b/Source/WebCore/css/CSSSelector.cpp
@@ -27,6 +27,7 @@
#include "CSSSelector.h"
#include "CSSOMUtils.h"
+#include "CSSSelectorList.h"
#include "HTMLNames.h"
#include <wtf/Assertions.h>
#include <wtf/HashMap.h>
@@ -78,9 +79,12 @@ inline unsigned CSSSelector::specificityForOneSelector() const
case Contain:
case Begin:
case End:
- if (pseudoType() == PseudoNot && simpleSelector())
- s += simpleSelector()->specificityForOneSelector();
- else
+ // FIXME: PsuedoAny should base the specificity on the sub-selectors.
+ // See http://lists.w3.org/Archives/Public/www-style/2010Sep/0530.html
+ if (pseudoType() == PseudoNot) {
+ ASSERT(selectorList());
+ s += selectorList()->first()->specificityForOneSelector();
+ } else
s += 0x100;
case None:
break;
@@ -211,6 +215,7 @@ PseudoId CSSSelector::pseudoId(PseudoType type)
case PseudoNthLastOfType:
case PseudoLink:
case PseudoVisited:
+ case PseudoAny:
case PseudoAnyLink:
case PseudoAutofill:
case PseudoHover:
@@ -265,6 +270,7 @@ static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap(
{
DEFINE_STATIC_LOCAL(AtomicString, active, ("active"));
DEFINE_STATIC_LOCAL(AtomicString, after, ("after"));
+ DEFINE_STATIC_LOCAL(AtomicString, any, ("-webkit-any("));
DEFINE_STATIC_LOCAL(AtomicString, anyLink, ("-webkit-any-link"));
DEFINE_STATIC_LOCAL(AtomicString, autofill, ("-webkit-autofill"));
DEFINE_STATIC_LOCAL(AtomicString, before, ("before"));
@@ -364,6 +370,7 @@ static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap(
nameToPseudoType->set(active.impl(), CSSSelector::PseudoActive);
nameToPseudoType->set(after.impl(), CSSSelector::PseudoAfter);
nameToPseudoType->set(anyLink.impl(), CSSSelector::PseudoAnyLink);
+ nameToPseudoType->set(any.impl(), CSSSelector::PseudoAny);
nameToPseudoType->set(autofill.impl(), CSSSelector::PseudoAutofill);
nameToPseudoType->set(before.impl(), CSSSelector::PseudoBefore);
nameToPseudoType->set(checked.impl(), CSSSelector::PseudoChecked);
@@ -527,6 +534,7 @@ void CSSSelector::extractPseudoType() const
case PseudoNthLastOfType:
case PseudoLink:
case PseudoVisited:
+ case PseudoAny:
case PseudoAnyLink:
case PseudoAutofill:
case PseudoHover:
@@ -638,17 +646,33 @@ String CSSSelector::selectorText() const
} else if (cs->m_match == CSSSelector::PseudoClass || cs->m_match == CSSSelector::PagePseudoClass) {
str += ":";
str += cs->value();
- if (cs->pseudoType() == PseudoNot) {
- if (CSSSelector* subSel = cs->simpleSelector())
- str += subSel->selectorText();
+
+ switch (cs->pseudoType()) {
+ case PseudoNot:
+ ASSERT(cs->selectorList());
+ str += cs->selectorList()->first()->selectorText();
str += ")";
- } else if (cs->pseudoType() == PseudoLang
- || cs->pseudoType() == PseudoNthChild
- || cs->pseudoType() == PseudoNthLastChild
- || cs->pseudoType() == PseudoNthOfType
- || cs->pseudoType() == PseudoNthLastOfType) {
+ break;
+ case PseudoLang:
+ case PseudoNthChild:
+ case PseudoNthLastChild:
+ case PseudoNthOfType:
+ case PseudoNthLastOfType:
str += cs->argument();
str += ")";
+ break;
+ case PseudoAny: {
+ CSSSelector* firstSubSelector = cs->selectorList()->first();
+ for (CSSSelector* subSelector = firstSubSelector; subSelector; subSelector = CSSSelectorList::next(subSelector)) {
+ if (subSelector != firstSubSelector)
+ str += ",";
+ str += subSelector->selectorText();
+ }
+ str += ")";
+ break;
+ }
+ default:
+ break;
}
} else if (cs->m_match == CSSSelector::PseudoElement) {
str += "::";
@@ -736,11 +760,11 @@ void CSSSelector::setArgument(const AtomicString& value)
createRareData();
m_data.m_rareData->m_argument = value;
}
-
-void CSSSelector::setSimpleSelector(PassOwnPtr<CSSSelector> value)
+
+void CSSSelector::setSelectorList(PassOwnPtr<CSSSelectorList> selectorList)
{
createRareData();
- m_data.m_rareData->m_simpleSelector = value;
+ m_data.m_rareData->m_selectorList = selectorList;
}
bool CSSSelector::parseNth()
@@ -761,7 +785,7 @@ bool CSSSelector::matchNth(int count)
bool CSSSelector::isSimple() const
{
- if (simpleSelector() || tagHistory() || matchesPseudoElement())
+ if (selectorList() || tagHistory() || matchesPseudoElement())
return false;
int numConditions = 0;
@@ -784,6 +808,21 @@ bool CSSSelector::isSimple() const
return numConditions <= 1;
}
+CSSSelector::RareData::RareData(PassRefPtr<AtomicStringImpl> value)
+ : m_value(value.leakRef())
+ , m_a(0)
+ , m_b(0)
+ , m_attribute(anyQName())
+ , m_argument(nullAtom)
+{
+}
+
+CSSSelector::RareData::~RareData()
+{
+ if (m_value)
+ m_value->deref();
+}
+
// a helper function for parsing nth-arguments
bool CSSSelector::RareData::parseNth()
{