@@ -26,29 +26,29 @@ namespace Sass {
26
26
}
27
27
28
28
bool Complex_Selector::operator ==(const Complex_Selector& rhs) const {
29
- // TODO: We have to access the tail directly using tail_ since ADD_PROPERTY doesn't provide a const version.
29
+ // TODO: We have to access the tail directly using tail_ since ADD_PROPERTY doesn't provide a const version.
30
30
31
- const Complex_Selector* pOne = this ;
31
+ const Complex_Selector* pOne = this ;
32
32
const Complex_Selector* pTwo = &rhs;
33
33
34
34
// Consume any empty references at the beginning of the Complex_Selector
35
35
if (pOne->combinator () == Complex_Selector::ANCESTOR_OF && pOne->head ()->is_empty_reference ()) {
36
- pOne = pOne->tail_ ;
36
+ pOne = pOne->tail_ ;
37
37
}
38
38
if (pTwo->combinator () == Complex_Selector::ANCESTOR_OF && pTwo->head ()->is_empty_reference ()) {
39
- pTwo = pTwo->tail_ ;
39
+ pTwo = pTwo->tail_ ;
40
40
}
41
41
42
42
while (pOne && pTwo) {
43
- if (pOne->combinator () != pTwo->combinator ()) {
44
- return false ;
43
+ if (pOne->combinator () != pTwo->combinator ()) {
44
+ return false ;
45
45
}
46
46
47
47
if (*(pOne->head ()) != *(pTwo->head ())) {
48
- return false ;
48
+ return false ;
49
49
}
50
50
51
- pOne = pOne->tail_ ;
51
+ pOne = pOne->tail_ ;
52
52
pTwo = pTwo->tail_ ;
53
53
}
54
54
@@ -68,21 +68,21 @@ namespace Sass {
68
68
69
69
bool Simple_Selector::operator ==(const Simple_Selector& rhs) const
70
70
{
71
- // Compare the string representations for equality.
71
+ // Compare the string representations for equality.
72
72
73
- // Cast away const here. To_String should take a const object, but it doesn't.
74
- Simple_Selector* pLHS = const_cast <Simple_Selector*>(this );
73
+ // Cast away const here. To_String should take a const object, but it doesn't.
74
+ Simple_Selector* pLHS = const_cast <Simple_Selector*>(this );
75
75
Simple_Selector* pRHS = const_cast <Simple_Selector*>(&rhs);
76
76
77
77
To_String to_string;
78
78
return pLHS->perform (&to_string) == pRHS->perform (&to_string);
79
79
}
80
80
81
81
bool Simple_Selector::operator <(const Simple_Selector& rhs) const {
82
- // Use the string representation for ordering.
82
+ // Use the string representation for ordering.
83
83
84
- // Cast away const here. To_String should take a const object, but it doesn't.
85
- Simple_Selector* pLHS = const_cast <Simple_Selector*>(this );
84
+ // Cast away const here. To_String should take a const object, but it doesn't.
85
+ Simple_Selector* pLHS = const_cast <Simple_Selector*>(this );
86
86
Simple_Selector* pRHS = const_cast <Simple_Selector*>(&rhs);
87
87
88
88
To_String to_string;
@@ -217,25 +217,25 @@ namespace Sass {
217
217
set<string> lpsuedoset, rpsuedoset;
218
218
for (size_t i = 0 , L = length (); i < L; ++i)
219
219
{
220
- if ((*this )[i]->is_pseudo_element ()) {
221
- string pseudo ((*this )[i]->perform (&to_string));
220
+ if ((*this )[i]->is_pseudo_element ()) {
221
+ string pseudo ((*this )[i]->perform (&to_string));
222
222
pseudo = pseudo.substr (pseudo.find_first_not_of (" :" )); // strip off colons to ensure :after matches ::after since ruby sass is forgiving
223
- lpsuedoset.insert (pseudo);
223
+ lpsuedoset.insert (pseudo);
224
224
}
225
225
}
226
226
for (size_t i = 0 , L = rhs->length (); i < L; ++i)
227
227
{
228
- if ((*rhs)[i]->is_pseudo_element ()) {
229
- string pseudo ((*rhs)[i]->perform (&to_string));
228
+ if ((*rhs)[i]->is_pseudo_element ()) {
229
+ string pseudo ((*rhs)[i]->perform (&to_string));
230
230
pseudo = pseudo.substr (pseudo.find_first_not_of (" :" )); // strip off colons to ensure :after matches ::after since ruby sass is forgiving
231
- rpsuedoset.insert (pseudo);
231
+ rpsuedoset.insert (pseudo);
232
232
}
233
233
}
234
- if (lpsuedoset != rpsuedoset) {
234
+ if (lpsuedoset != rpsuedoset) {
235
235
return false ;
236
236
}
237
237
238
- // Check the Simple_Selectors
238
+ // Check the Simple_Selectors
239
239
240
240
set<string> lset, rset;
241
241
@@ -244,19 +244,17 @@ namespace Sass {
244
244
for (size_t i = 0 , L = length (); i < L; ++i)
245
245
{
246
246
Selector* lhs = (*this )[i];
247
+ // very special case for wrapped matches selector
247
248
if (Wrapped_Selector* wrapped = dynamic_cast <Wrapped_Selector*>(lhs)) {
248
- if (
249
- wrapped->name () == " :matches(" ||
250
- wrapped->name () == " :-moz-any("
251
- ) {
252
- lhs = wrapped->selector ();
253
- if (Selector_List* list = dynamic_cast <Selector_List*>(lhs)) {
254
- if (Compound_Selector* comp = dynamic_cast <Compound_Selector*>(rhs)) {
255
- if (list->is_superselector_of (comp)) return true ;
249
+ if (wrapped->name () == " :matches(" || wrapped->name () == " :-moz-any(" ) {
250
+ if (Selector_List* list = dynamic_cast <Selector_List*>(wrapped->selector ())) {
251
+ if (Compound_Selector* comp = dynamic_cast <Compound_Selector*>(rhs)) {
252
+ if (list->is_superselector_of (comp)) return true ;
253
+ }
256
254
}
257
255
}
258
- }
259
256
}
257
+ // match from here on as strings
260
258
lset.insert (lhs->perform (&to_string));
261
259
}
262
260
for (size_t i = 0 , L = rhs->length (); i < L; ++i)
@@ -290,33 +288,33 @@ namespace Sass {
290
288
set<string> lpsuedoset, rpsuedoset;
291
289
for (size_t i = 0 , L = length (); i < L; ++i)
292
290
{
293
- if ((*this )[i]->is_pseudo_element ()) {
294
- string pseudo ((*this )[i]->perform (&to_string));
291
+ if ((*this )[i]->is_pseudo_element ()) {
292
+ string pseudo ((*this )[i]->perform (&to_string));
295
293
pseudo = pseudo.substr (pseudo.find_first_not_of (" :" )); // strip off colons to ensure :after matches ::after since ruby sass is forgiving
296
- lpsuedoset.insert (pseudo);
294
+ lpsuedoset.insert (pseudo);
297
295
}
298
296
}
299
297
for (size_t i = 0 , L = rhs.length (); i < L; ++i)
300
298
{
301
- if (rhs[i]->is_pseudo_element ()) {
302
- string pseudo (rhs[i]->perform (&to_string));
299
+ if (rhs[i]->is_pseudo_element ()) {
300
+ string pseudo (rhs[i]->perform (&to_string));
303
301
pseudo = pseudo.substr (pseudo.find_first_not_of (" :" )); // strip off colons to ensure :after matches ::after since ruby sass is forgiving
304
- rpsuedoset.insert (pseudo);
302
+ rpsuedoset.insert (pseudo);
305
303
}
306
304
}
307
- if (lpsuedoset != rpsuedoset) {
305
+ if (lpsuedoset != rpsuedoset) {
308
306
return false ;
309
307
}
310
308
311
- // Check the base
309
+ // Check the base
312
310
313
311
const Simple_Selector* const lbase = base ();
314
312
const Simple_Selector* const rbase = rhs.base ();
315
313
316
314
if ((lbase && !rbase) ||
317
- (!lbase && rbase) ||
315
+ (!lbase && rbase) ||
318
316
((lbase && rbase) && (*lbase != *rbase))) {
319
- return false ;
317
+ return false ;
320
318
}
321
319
322
320
@@ -482,7 +480,7 @@ namespace Sass {
482
480
Complex_Selector* cpy = new (ctx.mem ) Complex_Selector (*this );
483
481
484
482
if (head ()) {
485
- cpy->head (head ()->clone (ctx));
483
+ cpy->head (head ()->clone (ctx));
486
484
}
487
485
488
486
if (tail ()) {
0 commit comments