|
2 | 2 | #include "ast.hpp" |
3 | 3 | #include "context.hpp" |
4 | 4 | #include "node.hpp" |
| 5 | +#include "eval.hpp" |
5 | 6 | #include "extend.hpp" |
6 | 7 | #include "emitter.hpp" |
7 | 8 | #include "color_maps.hpp" |
@@ -126,29 +127,29 @@ namespace Sass { |
126 | 127 | return length() < rhs.length(); |
127 | 128 | } |
128 | 129 |
|
129 | | - bool Compound_Selector::has_parent_ref() |
| 130 | + bool Compound_Selector::has_parent_ref() const |
130 | 131 | { |
131 | 132 | for (Simple_Selector_Obj s : *this) { |
132 | 133 | if (s && s->has_parent_ref()) return true; |
133 | 134 | } |
134 | 135 | return false; |
135 | 136 | } |
136 | 137 |
|
137 | | - bool Compound_Selector::has_real_parent_ref() |
| 138 | + bool Compound_Selector::has_real_parent_ref() const |
138 | 139 | { |
139 | 140 | for (Simple_Selector_Obj s : *this) { |
140 | 141 | if (s && s->has_real_parent_ref()) return true; |
141 | 142 | } |
142 | 143 | return false; |
143 | 144 | } |
144 | 145 |
|
145 | | - bool Complex_Selector::has_parent_ref() |
| 146 | + bool Complex_Selector::has_parent_ref() const |
146 | 147 | { |
147 | 148 | return (head() && head()->has_parent_ref()) || |
148 | 149 | (tail() && tail()->has_parent_ref()); |
149 | 150 | } |
150 | 151 |
|
151 | | - bool Complex_Selector::has_real_parent_ref() |
| 152 | + bool Complex_Selector::has_real_parent_ref() const |
152 | 153 | { |
153 | 154 | return (head() && head()->has_real_parent_ref()) || |
154 | 155 | (tail() && tail()->has_real_parent_ref()); |
@@ -1185,7 +1186,14 @@ namespace Sass { |
1185 | 1186 | } |
1186 | 1187 | } |
1187 | 1188 |
|
| 1189 | + } |
1188 | 1190 |
|
| 1191 | + Selector_List_Obj Selector_List::eval(Eval& eval) |
| 1192 | + { |
| 1193 | + Selector_List_Obj list = schema() ? |
| 1194 | + eval(schema()) : eval(this); |
| 1195 | + list->schema(schema()); |
| 1196 | + return list; |
1189 | 1197 | } |
1190 | 1198 |
|
1191 | 1199 | Selector_List_Ptr Selector_List::resolve_parent_refs(Context& ctx, std::vector<Selector_List_Obj>& pstack, bool implicit_parent) |
@@ -1472,31 +1480,55 @@ namespace Sass { |
1472 | 1480 | } |
1473 | 1481 | } |
1474 | 1482 |
|
1475 | | - bool Selector_List::has_parent_ref() |
| 1483 | + size_t Wrapped_Selector::hash() |
| 1484 | + { |
| 1485 | + if (hash_ == 0) { |
| 1486 | + hash_combine(hash_, Simple_Selector::hash()); |
| 1487 | + if (selector_) hash_combine(hash_, selector_->hash()); |
| 1488 | + } |
| 1489 | + return hash_; |
| 1490 | + } |
| 1491 | + bool Wrapped_Selector::has_parent_ref() const { |
| 1492 | + // if (has_reference()) return true; |
| 1493 | + if (!selector()) return false; |
| 1494 | + return selector()->has_parent_ref(); |
| 1495 | + } |
| 1496 | + bool Wrapped_Selector::has_real_parent_ref() const { |
| 1497 | + // if (has_reference()) return true; |
| 1498 | + if (!selector()) return false; |
| 1499 | + return selector()->has_real_parent_ref(); |
| 1500 | + } |
| 1501 | + unsigned long Wrapped_Selector::specificity() const |
| 1502 | + { |
| 1503 | + return selector_ ? selector_->specificity() : 0; |
| 1504 | + } |
| 1505 | + |
| 1506 | + |
| 1507 | + bool Selector_List::has_parent_ref() const |
1476 | 1508 | { |
1477 | 1509 | for (Complex_Selector_Obj s : elements()) { |
1478 | 1510 | if (s && s->has_parent_ref()) return true; |
1479 | 1511 | } |
1480 | 1512 | return false; |
1481 | 1513 | } |
1482 | 1514 |
|
1483 | | - bool Selector_List::has_real_parent_ref() |
| 1515 | + bool Selector_List::has_real_parent_ref() const |
1484 | 1516 | { |
1485 | 1517 | for (Complex_Selector_Obj s : elements()) { |
1486 | 1518 | if (s && s->has_real_parent_ref()) return true; |
1487 | 1519 | } |
1488 | 1520 | return false; |
1489 | 1521 | } |
1490 | 1522 |
|
1491 | | - bool Selector_Schema::has_parent_ref() |
| 1523 | + bool Selector_Schema::has_parent_ref() const |
1492 | 1524 | { |
1493 | 1525 | if (String_Schema_Obj schema = Cast<String_Schema>(contents())) { |
1494 | 1526 | return schema->length() > 0 && Cast<Parent_Selector>(schema->at(0)) != NULL; |
1495 | 1527 | } |
1496 | 1528 | return false; |
1497 | 1529 | } |
1498 | 1530 |
|
1499 | | - bool Selector_Schema::has_real_parent_ref() |
| 1531 | + bool Selector_Schema::has_real_parent_ref() const |
1500 | 1532 | { |
1501 | 1533 | if (String_Schema_Obj schema = Cast<String_Schema>(contents())) { |
1502 | 1534 | Parent_Selector_Obj p = Cast<Parent_Selector>(schema->at(0)); |
|
0 commit comments