Skip to content

Commit b87f4c7

Browse files
committed
Merge pull request #953 from mgreter/bugfix/issue_947
Implement selector contextualization for keyframe rules
2 parents 4c2a62a + 47dffc5 commit b87f4c7

File tree

6 files changed

+26
-14
lines changed

6 files changed

+26
-14
lines changed

ast.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,10 @@ namespace Sass {
431431
// Keyframe-rules -- the child blocks of "@keyframes" nodes.
432432
///////////////////////////////////////////////////////////////////////
433433
class Keyframe_Rule : public Has_Block {
434-
ADD_PROPERTY(String*, rules);
434+
ADD_PROPERTY(Selector*, selector);
435435
public:
436436
Keyframe_Rule(ParserState pstate, Block* b)
437-
: Has_Block(pstate, b), rules_(0)
437+
: Has_Block(pstate, b), selector_(0)
438438
{ statement_type(KEYFRAMERULE); }
439439
ATTACH_OPERATIONS();
440440
};

cssize.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ namespace Sass {
8787

8888
Keyframe_Rule* rr = new (ctx.mem) Keyframe_Rule(r->pstate(),
8989
r->block()->perform(this)->block());
90-
if (r->rules()) rr->rules(r->rules());
90+
if (r->selector()) rr->selector(r->selector());
9191

9292
return debubble(rr->block(), rr)->block();
9393
}

debugger.hpp

+19-1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
225225
cerr << ind << "Declaration " << block << " " << block->tabs() << endl;
226226
debug_ast(block->property(), ind + " prop: ", env);
227227
debug_ast(block->value(), ind + " value: ", env);
228+
} else if (dynamic_cast<Keyframe_Rule*>(node)) {
229+
Keyframe_Rule* has_block = dynamic_cast<Keyframe_Rule*>(node);
230+
cerr << ind << "Keyframe_Rule " << has_block << " " << has_block->tabs() << endl;
231+
if (has_block->selector()) debug_ast(has_block->selector(), ind + "@");
232+
if (has_block->block()) for(auto i : has_block->block()->elements()) { debug_ast(i, ind + " ", env); }
228233
} else if (dynamic_cast<At_Rule*>(node)) {
229234
At_Rule* block = dynamic_cast<At_Rule*>(node);
230235
cerr << ind << "At_Rule " << block << " [" << block->keyword() << "] " << block->tabs() << endl;
@@ -348,7 +353,20 @@ inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
348353
endl;
349354
} else if (dynamic_cast<Expression*>(node)) {
350355
Expression* expression = dynamic_cast<Expression*>(node);
351-
cerr << ind << "Expression " << expression << " " << expression->concrete_type() << endl;
356+
cerr << ind << "Expression " << expression;
357+
switch (expression->concrete_type()) {
358+
case Expression::Concrete_Type::NONE: cerr << " [NONE]"; break;
359+
case Expression::Concrete_Type::BOOLEAN: cerr << " [BOOLEAN]"; break;
360+
case Expression::Concrete_Type::NUMBER: cerr << " [NUMBER]"; break;
361+
case Expression::Concrete_Type::COLOR: cerr << " [COLOR]"; break;
362+
case Expression::Concrete_Type::STRING: cerr << " [STRING]"; break;
363+
case Expression::Concrete_Type::LIST: cerr << " [LIST]"; break;
364+
case Expression::Concrete_Type::MAP: cerr << " [MAP]"; break;
365+
case Expression::Concrete_Type::SELECTOR: cerr << " [SELECTOR]"; break;
366+
case Expression::Concrete_Type::NULL_VAL: cerr << " [NULL_VAL]"; break;
367+
case Expression::Concrete_Type::NUM_TYPES: cerr << " [NUM_TYPES]"; break;
368+
}
369+
cerr << endl;
352370
} else if (dynamic_cast<Has_Block*>(node)) {
353371
Has_Block* has_block = dynamic_cast<Has_Block*>(node);
354372
cerr << ind << "Has_Block " << has_block << " " << has_block->tabs() << endl;

expand.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ namespace Sass {
4747
if (in_keyframes) {
4848
To_String to_string;
4949
Keyframe_Rule* k = new (ctx.mem) Keyframe_Rule(r->pstate(), r->block()->perform(this)->block());
50-
if (r->selector()) {
51-
string s(r->selector()->perform(eval->with(env, backtrace))->perform(&to_string));
52-
String_Constant* ss = new (ctx.mem) String_Constant(r->selector()->pstate(), s);
53-
k->rules(ss);
54-
}
50+
if (r->selector()) k->selector(r->selector()->perform(contextualize_eval->with(0, env, backtrace)));
5551
in_at_root = old_in_at_root;
5652
old_in_at_root = false;
5753
return k;

inspect.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ namespace Sass {
4444

4545
void Inspect::operator()(Keyframe_Rule* rule)
4646
{
47-
append_indentation();
48-
if (rule->rules()) rule->rules()->perform(this);
49-
rule->block()->perform(this);
47+
if (rule->selector()) rule->selector()->perform(this);
48+
if (rule->block()) rule->block()->perform(this);
5049
}
5150

5251
void Inspect::operator()(Propset* propset)

output.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,10 @@ namespace Sass {
172172

173173
void Output::operator()(Keyframe_Rule* r)
174174
{
175-
String* v = r->rules();
176175
Block* b = r->block();
176+
Selector* v = r->selector();
177177

178178
if (v) {
179-
append_indentation();
180179
v->perform(this);
181180
}
182181

0 commit comments

Comments
 (0)