CSS-Sass
view release on metacpan or search on metacpan
libsass/ast.hpp view on Meta::CPAN
virtual Block* block() { return 0; }
};
inline Statement::~Statement() { }
////////////////////////
// Blocks of statements.
////////////////////////
class Block : public Statement, public Vectorized<Statement*> {
ADD_PROPERTY(bool, is_root);
// needed for properly formatted CSS emission
ADD_PROPERTY(bool, has_hoistable);
ADD_PROPERTY(bool, has_non_hoistable);
protected:
void adjust_after_pushing(Statement* s)
{
if (s->is_hoistable()) has_hoistable_ = true;
else has_non_hoistable_ = true;
};
public:
Block(ParserState pstate, size_t s = 0, bool r = false)
: Statement(pstate),
Vectorized<Statement*>(s),
is_root_(r), has_hoistable_(false), has_non_hoistable_(false)
{ }
Block* block() { return this; }
ATTACH_OPERATIONS();
};
////////////////////////////////////////////////////////////////////////
// Abstract base class for statements that contain blocks of statements.
////////////////////////////////////////////////////////////////////////
class Has_Block : public Statement {
ADD_PROPERTY(Block*, block);
public:
Has_Block(ParserState pstate, Block* b)
: Statement(pstate), block_(b)
{ }
virtual ~Has_Block() = 0;
};
inline Has_Block::~Has_Block() { }
/////////////////////////////////////////////////////////////////////////////
// Rulesets (i.e., sets of styles headed by a selector and containing a block
// of style declarations.
/////////////////////////////////////////////////////////////////////////////
class Ruleset : public Has_Block {
ADD_PROPERTY(Selector*, selector);
public:
Ruleset(ParserState pstate, Selector* s, Block* b)
: Has_Block(pstate, b), selector_(s)
{ statement_type(RULESET); }
bool is_invisible();
// nested rulesets need to be hoisted out of their enclosing blocks
bool is_hoistable() { return true; }
ATTACH_OPERATIONS();
};
/////////////////////////////////////////////////////////
// Nested declaration sets (i.e., namespaced properties).
/////////////////////////////////////////////////////////
class Propset : public Has_Block {
ADD_PROPERTY(String*, property_fragment);
public:
Propset(ParserState pstate, String* pf, Block* b = 0)
: Has_Block(pstate, b), property_fragment_(pf)
{ }
ATTACH_OPERATIONS();
};
/////////////////
// Bubble.
/////////////////
class Bubble : public Statement {
ADD_PROPERTY(Statement*, node);
ADD_PROPERTY(bool, group_end);
public:
Bubble(ParserState pstate, Statement* n, Statement* g = 0, size_t t = 0)
: Statement(pstate, Statement::BUBBLE, t), node_(n), group_end_(g == 0)
{ }
bool bubbles() { return true; }
ATTACH_OPERATIONS();
};
/////////////////
// Media queries.
/////////////////
class Media_Block : public Has_Block {
ADD_PROPERTY(List*, media_queries);
ADD_PROPERTY(Selector*, selector);
public:
Media_Block(ParserState pstate, List* mqs, Block* b)
: Has_Block(pstate, b), media_queries_(mqs), selector_(0)
{ statement_type(MEDIA); }
Media_Block(ParserState pstate, List* mqs, Block* b, Selector* s)
: Has_Block(pstate, b), media_queries_(mqs), selector_(s)
{ statement_type(MEDIA); }
bool bubbles() { return true; }
bool is_hoistable() { return true; }
bool is_invisible() {
bool is_invisible = true;
for (size_t i = 0, L = block()->length(); i < L && is_invisible; i++)
is_invisible &= (*block())[i]->is_invisible();
return is_invisible;
}
ATTACH_OPERATIONS();
};
///////////////////
// Feature queries.
///////////////////
class Feature_Block : public Has_Block {
ADD_PROPERTY(Feature_Query*, feature_queries);
ADD_PROPERTY(Selector*, selector);
public:
Feature_Block(ParserState pstate, Feature_Query* fqs, Block* b)
: Has_Block(pstate, b), feature_queries_(fqs), selector_(0)
{ statement_type(FEATURE); }
bool is_hoistable() { return true; }
bool bubbles() { return true; }
ATTACH_OPERATIONS();
};
///////////////////////////////////////////////////////////////////////
// At-rules -- arbitrary directives beginning with "@" that may have an
( run in 0.527 second using v1.01-cache-2.11-cpan-71847e10f99 )