Skip to content

Commit

Permalink
Clean up white-space in code
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed May 12, 2015
1 parent aa5043d commit f8074a0
Showing 1 changed file with 40 additions and 42 deletions.
82 changes: 40 additions & 42 deletions ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,29 @@ namespace Sass {
}

bool Complex_Selector::operator==(const Complex_Selector& rhs) const {
// TODO: We have to access the tail directly using tail_ since ADD_PROPERTY doesn't provide a const version.
// TODO: We have to access the tail directly using tail_ since ADD_PROPERTY doesn't provide a const version.

const Complex_Selector* pOne = this;
const Complex_Selector* pOne = this;
const Complex_Selector* pTwo = &rhs;

// Consume any empty references at the beginning of the Complex_Selector
if (pOne->combinator() == Complex_Selector::ANCESTOR_OF && pOne->head()->is_empty_reference()) {
pOne = pOne->tail_;
pOne = pOne->tail_;
}
if (pTwo->combinator() == Complex_Selector::ANCESTOR_OF && pTwo->head()->is_empty_reference()) {
pTwo = pTwo->tail_;
pTwo = pTwo->tail_;
}

while (pOne && pTwo) {
if (pOne->combinator() != pTwo->combinator()) {
return false;
if (pOne->combinator() != pTwo->combinator()) {
return false;
}

if (*(pOne->head()) != *(pTwo->head())) {
return false;
return false;
}

pOne = pOne->tail_;
pOne = pOne->tail_;
pTwo = pTwo->tail_;
}

Expand All @@ -68,21 +68,21 @@ namespace Sass {

bool Simple_Selector::operator==(const Simple_Selector& rhs) const
{
// Compare the string representations for equality.
// Compare the string representations for equality.

// Cast away const here. To_String should take a const object, but it doesn't.
Simple_Selector* pLHS = const_cast<Simple_Selector*>(this);
// Cast away const here. To_String should take a const object, but it doesn't.
Simple_Selector* pLHS = const_cast<Simple_Selector*>(this);
Simple_Selector* pRHS = const_cast<Simple_Selector*>(&rhs);

To_String to_string;
return pLHS->perform(&to_string) == pRHS->perform(&to_string);
}

bool Simple_Selector::operator<(const Simple_Selector& rhs) const {
// Use the string representation for ordering.
// Use the string representation for ordering.

// Cast away const here. To_String should take a const object, but it doesn't.
Simple_Selector* pLHS = const_cast<Simple_Selector*>(this);
// Cast away const here. To_String should take a const object, but it doesn't.
Simple_Selector* pLHS = const_cast<Simple_Selector*>(this);
Simple_Selector* pRHS = const_cast<Simple_Selector*>(&rhs);

To_String to_string;
Expand Down Expand Up @@ -217,25 +217,25 @@ namespace Sass {
set<string> lpsuedoset, rpsuedoset;
for (size_t i = 0, L = length(); i < L; ++i)
{
if ((*this)[i]->is_pseudo_element()) {
string pseudo((*this)[i]->perform(&to_string));
if ((*this)[i]->is_pseudo_element()) {
string pseudo((*this)[i]->perform(&to_string));
pseudo = pseudo.substr(pseudo.find_first_not_of(":")); // strip off colons to ensure :after matches ::after since ruby sass is forgiving
lpsuedoset.insert(pseudo);
lpsuedoset.insert(pseudo);
}
}
for (size_t i = 0, L = rhs->length(); i < L; ++i)
{
if ((*rhs)[i]->is_pseudo_element()) {
string pseudo((*rhs)[i]->perform(&to_string));
if ((*rhs)[i]->is_pseudo_element()) {
string pseudo((*rhs)[i]->perform(&to_string));
pseudo = pseudo.substr(pseudo.find_first_not_of(":")); // strip off colons to ensure :after matches ::after since ruby sass is forgiving
rpsuedoset.insert(pseudo);
rpsuedoset.insert(pseudo);
}
}
if (lpsuedoset != rpsuedoset) {
if (lpsuedoset != rpsuedoset) {
return false;
}

// Check the Simple_Selectors
// Check the Simple_Selectors

set<string> lset, rset;

Expand All @@ -244,19 +244,17 @@ namespace Sass {
for (size_t i = 0, L = length(); i < L; ++i)
{
Selector* lhs = (*this)[i];
// very special case for wrapped matches selector
if (Wrapped_Selector* wrapped = dynamic_cast<Wrapped_Selector*>(lhs)) {
if (
wrapped->name() == ":matches(" ||
wrapped->name() == ":-moz-any("
) {
lhs = wrapped->selector();
if (Selector_List* list = dynamic_cast<Selector_List*>(lhs)) {
if (Compound_Selector* comp = dynamic_cast<Compound_Selector*>(rhs)) {
if (list->is_superselector_of(comp)) return true;
if (wrapped->name() == ":matches(" || wrapped->name() == ":-moz-any(") {
if (Selector_List* list = dynamic_cast<Selector_List*>(wrapped->selector())) {
if (Compound_Selector* comp = dynamic_cast<Compound_Selector*>(rhs)) {
if (list->is_superselector_of(comp)) return true;
}
}
}
}
}
// match from here on as strings
lset.insert(lhs->perform(&to_string));
}
for (size_t i = 0, L = rhs->length(); i < L; ++i)
Expand Down Expand Up @@ -290,33 +288,33 @@ namespace Sass {
set<string> lpsuedoset, rpsuedoset;
for (size_t i = 0, L = length(); i < L; ++i)
{
if ((*this)[i]->is_pseudo_element()) {
string pseudo((*this)[i]->perform(&to_string));
if ((*this)[i]->is_pseudo_element()) {
string pseudo((*this)[i]->perform(&to_string));
pseudo = pseudo.substr(pseudo.find_first_not_of(":")); // strip off colons to ensure :after matches ::after since ruby sass is forgiving
lpsuedoset.insert(pseudo);
lpsuedoset.insert(pseudo);
}
}
for (size_t i = 0, L = rhs.length(); i < L; ++i)
{
if (rhs[i]->is_pseudo_element()) {
string pseudo(rhs[i]->perform(&to_string));
if (rhs[i]->is_pseudo_element()) {
string pseudo(rhs[i]->perform(&to_string));
pseudo = pseudo.substr(pseudo.find_first_not_of(":")); // strip off colons to ensure :after matches ::after since ruby sass is forgiving
rpsuedoset.insert(pseudo);
rpsuedoset.insert(pseudo);
}
}
if (lpsuedoset != rpsuedoset) {
if (lpsuedoset != rpsuedoset) {
return false;
}

// Check the base
// Check the base

const Simple_Selector* const lbase = base();
const Simple_Selector* const rbase = rhs.base();

if ((lbase && !rbase) ||
(!lbase && rbase) ||
(!lbase && rbase) ||
((lbase && rbase) && (*lbase != *rbase))) {
return false;
return false;
}


Expand Down Expand Up @@ -482,7 +480,7 @@ namespace Sass {
Complex_Selector* cpy = new (ctx.mem) Complex_Selector(*this);

if (head()) {
cpy->head(head()->clone(ctx));
cpy->head(head()->clone(ctx));
}

if (tail()) {
Expand Down

0 comments on commit f8074a0

Please sign in to comment.