Commit ce99e9f8 authored by ojan@chromium.org's avatar ojan@chromium.org

2011-03-22 Ojan Vafai <ojan@chromium.org>

        Reviewed by Antti Koivisto.

        move :not over to using selectorList instead of simpleSelector
        https://bugs.webkit.org/show_bug.cgi?id=56894

        Saves memory and simplifies code.

        No new tests since existing tests cover this code.

        * css/CSSGrammar.y:
        Also removed extranenous calls to updateLastSelectorLineAndPosition in
        simple_selector_list. These happened to work, but are only actually
        needed in selector_list.
        * css/CSSParserValues.h:
        * css/CSSSelector.cpp:
        (WebCore::CSSSelector::specificityForOneSelector):
        Removed null-check. The parser null-checks, I don't see why we need to here.
        (WebCore::CSSSelector::selectorText):
        Ditto.
        (WebCore::CSSSelector::setArgument):
        (WebCore::CSSSelector::isSimple):
        * css/CSSSelector.h:
        * css/CSSSelectorList.cpp:
        (WebCore::forEachTagSelector):
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
        (WebCore::collectFeaturesFromSelector):
        (WebCore::collectFeaturesFromList):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@81845 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d7917f7f
2011-03-22 Ojan Vafai <ojan@chromium.org>
Reviewed by Antti Koivisto.
move :not over to using selectorList instead of simpleSelector
https://bugs.webkit.org/show_bug.cgi?id=56894
Saves memory and simplifies code.
No new tests since existing tests cover this code.
* css/CSSGrammar.y:
Also removed extranenous calls to updateLastSelectorLineAndPosition in
simple_selector_list. These happened to work, but are only actually
needed in selector_list.
* css/CSSParserValues.h:
* css/CSSSelector.cpp:
(WebCore::CSSSelector::specificityForOneSelector):
Removed null-check. The parser null-checks, I don't see why we need to here.
(WebCore::CSSSelector::selectorText):
Ditto.
(WebCore::CSSSelector::setArgument):
(WebCore::CSSSelector::isSimple):
* css/CSSSelector.h:
* css/CSSSelectorList.cpp:
(WebCore::forEachTagSelector):
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
(WebCore::collectFeaturesFromSelector):
(WebCore::collectFeaturesFromList):
2011-03-23 Carol Szabo <carol.szabo@nokia.com>
Reviewed by David Hyatt.
......@@ -928,9 +928,7 @@ simple_selector_list:
if ($1) {
CSSParser* p = static_cast<CSSParser*>(parser);
$$ = p->createFloatingSelectorVector();
$$->shrink(0);
$$->append(p->sinkFloatingSelector($1));
p->updateLastSelectorLineAndPosition();
} else
$$ = 0
}
......@@ -939,7 +937,6 @@ simple_selector_list:
CSSParser* p = static_cast<CSSParser*>(parser);
$$ = $1;
$$->append(p->sinkFloatingSelector($5));
p->updateLastSelectorLineAndPosition();
} else
$$ = 0;
}
......@@ -1197,7 +1194,11 @@ pseudo:
CSSParser* p = static_cast<CSSParser*>(parser);
$$ = p->createFloatingSelector();
$$->setMatch(CSSSelector::PseudoClass);
$$->setSimpleSelector(p->sinkFloatingSelector($4)->releaseSelector());
Vector<OwnPtr<CSSParserSelector> > selectorVector;
selectorVector.append(p->sinkFloatingSelector($4));
$$->adoptSelectorVector(selectorVector);
$2.lower();
$$->setValue($2);
}
......
......@@ -105,7 +105,6 @@ public:
void setValue(const AtomicString& value) { m_selector->setValue(value); }
void setAttribute(const QualifiedName& value) { m_selector->setAttribute(value); }
void setArgument(const AtomicString& value) { m_selector->setArgument(value); }
void setSimpleSelector(PassOwnPtr<CSSSelector> value) { m_selector->setSimpleSelector(value); }
void setMatch(CSSSelector::Match value) { m_selector->m_match = value; }
void setRelation(CSSSelector::Relation value) { m_selector->m_relation = value; }
void setForPage() { m_selector->setForPage(); }
......
......@@ -81,9 +81,10 @@ inline unsigned CSSSelector::specificityForOneSelector() const
case End:
// 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 && simpleSelector())
s += simpleSelector()->specificityForOneSelector();
else
if (pseudoType() == PseudoNot) {
ASSERT(selectorList());
s += selectorList()->first()->specificityForOneSelector();
} else
s += 0x100;
case None:
break;
......@@ -648,8 +649,8 @@ String CSSSelector::selectorText() const
switch (cs->pseudoType()) {
case PseudoNot:
if (CSSSelector* subSel = cs->simpleSelector())
str += subSel->selectorText();
ASSERT(cs->selectorList());
str += cs->selectorList()->first()->selectorText();
str += ")";
break;
case PseudoLang:
......@@ -759,12 +760,6 @@ void CSSSelector::setArgument(const AtomicString& value)
createRareData();
m_data.m_rareData->m_argument = value;
}
void CSSSelector::setSimpleSelector(PassOwnPtr<CSSSelector> value)
{
createRareData();
m_data.m_rareData->m_simpleSelector = value;
}
void CSSSelector::setSelectorList(PassOwnPtr<CSSSelectorList> selectorList)
{
......@@ -790,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;
......
......@@ -249,14 +249,12 @@ namespace WebCore {
const AtomicString& value() const { return *reinterpret_cast<const AtomicString*>(m_hasRareData ? &m_data.m_rareData->m_value : &m_data.m_value); }
const QualifiedName& attribute() const;
const AtomicString& argument() const { return m_hasRareData ? m_data.m_rareData->m_argument : nullAtom; }
CSSSelector* simpleSelector() const { return m_hasRareData ? m_data.m_rareData->m_simpleSelector.get() : 0; }
CSSSelectorList* selectorList() const { return m_hasRareData ? m_data.m_rareData->m_selectorList.get() : 0; }
void setTag(const QualifiedName& value) { m_tag = value; }
void setValue(const AtomicString&);
void setAttribute(const QualifiedName&);
void setArgument(const AtomicString&);
void setSimpleSelector(PassOwnPtr<CSSSelector>);
void setSelectorList(PassOwnPtr<CSSSelectorList>);
bool parseNth();
......@@ -307,12 +305,9 @@ namespace WebCore {
AtomicStringImpl* m_value; // Plain pointer to keep things uniform with the union.
int m_a; // Used for :nth-*
int m_b; // Used for :nth-*
// Used for :not.
// FIXME: m_selectorList instead to save memory.
OwnPtr<CSSSelector> m_simpleSelector;
QualifiedName m_attribute; // used for attribute selector
AtomicString m_argument; // Used for :contains, :lang and :nth-*
OwnPtr<CSSSelectorList> m_selectorList; // Used for :-webkit-any
OwnPtr<CSSSelectorList> m_selectorList; // Used for :-webkit-any and :not
};
void createRareData();
......
......@@ -122,10 +122,6 @@ static bool forEachTagSelector(Functor& functor, CSSSelector* selector)
do {
if (functor(selector))
return true;
if (CSSSelector* simpleSelector = selector->simpleSelector()) {
if (forEachTagSelector(functor, simpleSelector))
return true;
}
if (CSSSelectorList* selectorList = selector->selectorList()) {
for (CSSSelector* subSelector = selectorList->first(); subSelector; subSelector = CSSSelectorList::next(subSelector)) {
if (forEachTagSelector(functor, subSelector))
......
......@@ -2529,12 +2529,12 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme
if (sel->m_match == CSSSelector::PseudoClass) {
// Handle :not up front.
if (sel->pseudoType() == CSSSelector::PseudoNot) {
// check the simple selector
for (CSSSelector* subSel = sel->simpleSelector(); subSel; subSel = subSel->tagHistory()) {
ASSERT(sel->selectorList());
for (CSSSelector* subSel = sel->selectorList()->first(); subSel; subSel = subSel->tagHistory()) {
// :not cannot nest. I don't really know why this is a
// restriction in CSS3, but it is, so let's honor it.
// the parser enforces that this never occurs
ASSERT(!subSel->simpleSelector());
ASSERT(subSel->pseudoType() != CSSSelector::PseudoNot);
if (!checkOneSelector(subSel, e, selectorAttrs, dynamicPseudo, true, elementStyle, elementParentStyle))
return true;
......@@ -3309,10 +3309,6 @@ static inline void collectFeaturesFromSelector(CSSStyleSelector::Features& featu
case CSSSelector::PseudoVisited:
features.usesLinkRules = true;
break;
case CSSSelector::PseudoAny:
for (CSSSelector* subSelector = selector->selectorList()->first(); subSelector; subSelector = CSSSelectorList::next(subSelector))
collectFeaturesFromSelector(features, subSelector);
return;
default:
break;
}
......@@ -3326,8 +3322,14 @@ static void collectFeaturesFromList(CSSStyleSelector::Features& features, const
bool foundSiblingSelector = false;
for (CSSSelector* selector = ruleData.selector(); selector; selector = selector->tagHistory()) {
collectFeaturesFromSelector(features, selector);
if (CSSSelector* simpleSelector = selector->simpleSelector())
collectFeaturesFromSelector(features, simpleSelector);
if (CSSSelectorList* selectorList = selector->selectorList()) {
for (CSSSelector* subSelector = selectorList->first(); subSelector; subSelector = CSSSelectorList::next(subSelector)) {
ASSERT(!subSelector->isSiblingSelector());
collectFeaturesFromSelector(features, subSelector);
}
}
if (selector->isSiblingSelector())
foundSiblingSelector = true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment